Java Code Examples for javafx.scene.Node

The following are top voted examples for showing how to use javafx.scene.Node. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: ComponentsTest.java   Source Code and License 8 votes vote down vote up
@Test public void loadFX() throws Exception {
    final CountDownLatch cdl = new CountDownLatch(1);
    final CountDownLatch done = new CountDownLatch(1);
    final JFXPanel p = new JFXPanel();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Node wv = TestPages.getFX(10, cdl);
            Scene s = new Scene(new Group(wv));
            p.setScene(s);
            done.countDown();
        }
    });
    done.await();
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.pack();
    f.setVisible(true);
    cdl.await();
}
 
Example 2
Project: marathonv5   File: JavaFXElementPropertyAccessor.java   Source Code and License 6 votes vote down vote up
private void findFields(Node current, Node container, List<String> fieldNames) {
    Field[] declaredFields = container.getClass().getDeclaredFields();
    for (Field field : declaredFields) {
        boolean accessible = field.isAccessible();
        try {
            field.setAccessible(true);
            Object o = field.get(container);
            if (o == current) {
                fieldNames.add(field.getName());
            }
        } catch (Throwable t) {
        } finally {
            field.setAccessible(accessible);
        }
    }
}
 
Example 3
Project: vars-annotation   File: FilterableTreeItemDemo.java   Source Code and License 6 votes vote down vote up
private Node createFilteredTree() {
    FilterableTreeItem<Actor> root = getTreeModel();
    root.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (filterField.getText() == null || filterField.getText().isEmpty())
            return null;
        return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
    }, filterField.textProperty()));

    TreeView<Actor> treeView = new TreeView<>(root);
    treeView.setShowRoot(false);

    TitledPane pane = new TitledPane("Filtered TreeView", treeView);
    pane.setCollapsible(false);
    pane.setMaxHeight(Double.MAX_VALUE);
    return pane;
}
 
Example 4
Project: FYS_T3   File: contactController.java   Source Code and License 6 votes vote down vote up
@FXML
public void openHome(ActionEvent event) throws IOException {
    MyJDBC.createTestDatabase("shabo");
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
    stage.centerOnScreen();

    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode() + " Made by ShaMaster");
                stage.setScene(hScene);
            }
        }
    });
}
 
Example 5
Project: CalendarFX   File: IntroPaneSkin.java   Source Code and License 6 votes vote down vote up
private void updateView() {
    getChildren().clear();

    getSkinnable().setVisible(false);
    final Scene scene = getSkinnable().getScene();
    if (scene == null) {
        return;
    }

    for (IntroPane.IntroTarget target : getSkinnable().getTargets()) {
        Set<Node> nodes = target.getParent().lookupAll(target.getId());
        if (nodes != null) {
            nodes.forEach(node -> snapshotNode(scene, node));
        }
    }

    getSkinnable().setVisible(true);
    getSkinnable().requestLayout();
}
 
Example 6
Project: Conan   File: ProofView.java   Source Code and License 6 votes vote down vote up
public void rowAdded() {
    RowPane rp;
    if (curBoxDepth.isEmpty()) {
    	System.out.println("rowAdded! curBoxDepth.isEmpty");
        rp = new RowPane(false, 0);
        rList.add(rp);
        rp.init(this, rList);
        rows.getChildren().add(rp);
    } else {
    	System.out.println("rowAdded!");
        VBox box = curBoxDepth.peek();
        List<Node> children = box.getChildren();
        boolean isFirstRowInBox = (children.isEmpty()) ? true : false;
        rp = new RowPane(isFirstRowInBox, 0);
        rList.add(rp);
        rp.init(this, rList);
        children.add(rp);
    }
    lineNo.getChildren().add(createLabel());
    updateLabelPaddings(rList.size());
    scroll = true;
}
 
Example 7
Project: CalendarFX   File: AllDayViewSkin.java   Source Code and License 6 votes vote down vote up
private int findIndex(Entry<?> entry) {
    int childrenSize = getChildren().size();

    for (int i = 0; i < childrenSize; i++) {
        Node node = getChildren().get(i);
        if (node instanceof AllDayEntryView) {
            AllDayEntryView view = (AllDayEntryView) node;
            Entry<?> viewEntry = view.getEntry();
            if (viewEntry.getStartAsZonedDateTime().isAfter(entry.getStartAsZonedDateTime())) {
                return i;
            }
        }
    }

    return childrenSize;
}
 
Example 8
Project: marathonv5   File: GeneralSiblingSelector.java   Source Code and License 6 votes vote down vote up
protected List<IJavaFXElement> found(List<IJavaFXElement> pElements, IJavaFXAgent driver) {
    List<IJavaFXElement> r = new ArrayList<IJavaFXElement>();
    for (IJavaFXElement je : pElements) {
        Node component = je.getComponent();
        if (!(component instanceof Parent)) {
            continue;
        }
        int index = getIndexOfComponentInParent(component);
        if (index < 0) {
            continue;
        }
        Parent parent = component.getParent();
        JFXWindow topContainer = driver.switchTo().getTopContainer();
        ObservableList<Node> children = parent.getChildrenUnmodifiable();
        for (int i = index + 1; i < children.size(); i++) {
            Node c = children.get(i);
            IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
            if (sibling.matchesSelector(je2).size() > 0) {
                IJavaFXElement e = topContainer.addElement(JavaFXElementFactory.createElement(c, driver, topContainer));
                if (!r.contains(e)) {
                    r.add(e);
                }
            }
        }
    }
    return r;
}
 
Example 9
Project: MultiAxisCharts   File: MultiAxisAreaChart.java   Source Code and License 6 votes vote down vote up
private void updateDefaultColorIndex(final MultiAxisChart.Series<X, Y> series) {
	int clearIndex = seriesColorMap.get(series);
	Path seriesLine = (Path) ((Group) series.getNode()).getChildren().get(1);
	Path fillPath = (Path) ((Group) series.getNode()).getChildren().get(0);
	if (seriesLine != null) {
		seriesLine.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
	}
	if (fillPath != null) {
		fillPath.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
	}
	for (int j = 0; j < series.getData().size(); j++) {
		final Node node = series.getData().get(j).getNode();
		if (node != null) {
			node.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
		}
	}
}
 
Example 10
Project: marathonv5   File: VBoxSample.java   Source Code and License 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    VBox vbox = new VBox(3);
    vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(5, 5, 5, 5));

    Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
    Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));

    vbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, vbox);
    return new Group(sp);
}
 
Example 11
Project: IDBuilderFX   File: ViewSingleParsedController.java   Source Code and License 6 votes vote down vote up
public void clicknext(ActionEvent event) throws IOException {
	if(edit.getText().equalsIgnoreCase("Edit"))
	{
	Stage stage = new Stage();
	Parent root = FXMLLoader.load(getClass().getResource("/template/TemplateFXML.fxml"));
	Scene scene = new Scene(root);
	scene.getStylesheets().add(getClass().getResource("/template/TemplateCSS.css").toExternalForm());
	stage.setTitle("IDBuilderFX - Select Template");
	Stage currstage = (Stage) ((Node) event.getSource()).getScene().getWindow();
	currstage.close();
	stage.setScene(scene);
	stage.resizableProperty().setValue(Boolean.FALSE);
	stage.show();
	}
	else
		warnLabel.setText("Please Save First....");
}
 
Example 12
Project: hygene   File: GenomeMappingController.java   Source Code and License 6 votes vote down vote up
/**
 * The action to fire when the user clicks the "Ok" button.
 * <p>
 * Sets the mapped genome in {@link GraphAnnotation} to the value in the genome choice textfield.
 *
 * @param actionEvent the {@link ActionEvent}
 */
@FXML
void okAction(final ActionEvent actionEvent) {
    if (genomeChoice.getText().isEmpty()) {
        (new WarningDialogue("Please select a mapping.")).show();
        return;
    }

    try {
        graphAnnotation.setMappedGenome(genomeChoice.getText());
    } catch (final IOException e) {
        LOGGER.error("Unable to build an index for genome " + genomeChoice.getText() + ".", e);
        new ErrorDialogue(e).show();
    }

    final Node source = (Node) actionEvent.getSource();
    source.getScene().getWindow().hide();

    actionEvent.consume();

    LOGGER.info("Genome " + gffGenome.getText() + " from GFF will be mapped onto " + genomeChoice.getText() + ".");
}
 
Example 13
Project: hygene   File: GraphNavigationController.java   Source Code and License 6 votes vote down vote up
/**
 * Add an event handler to a node will trigger continuously trigger at a given interval while the button is
 * being pressed.
 *
 * @param node     the {@link Node}
 * @param holdTime interval time
 * @param handler  the handler
 */
private void addContinuousPressHandler(final Node node, final Duration holdTime,
                                       final EventHandler<MouseEvent> handler) {
    final Wrapper<MouseEvent> eventWrapper = new Wrapper<>();

    final PauseTransition holdTimer = new PauseTransition(holdTime);
    holdTimer.setOnFinished(event -> {
        handler.handle(eventWrapper.content);
        holdTimer.playFromStart();
    });

    node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    });
    node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
    node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
 
Example 14
Project: ChatRoom-JavaFX   File: EmojiDisplayer.java   Source Code and License 6 votes vote down vote up
/**
 * 创建emoji图片节点
 *
 * @param emoji
 *            emoji
 * @param size
 *            图片显示大小
 * @param pad
 *            图片间距
 * @param isCursor
 *            是否需要图片光标及鼠标处理事件
 * @return
 */
public static Node createEmojiNode(Emoji emoji, int size, int pad) {
	// 将表情放到stackpane中
	StackPane stackPane = new StackPane();
	stackPane.setMaxSize(size, size);
	stackPane.setPrefSize(size, size);
	stackPane.setMinSize(size, size);
	stackPane.setPadding(new Insets(pad));
	ImageView imageView = new ImageView();
	imageView.setFitWidth(size);
	imageView.setFitHeight(size);
	imageView.setImage(ImageCache.getInstance().getImage(getEmojiImagePath(emoji.getHex())));
	stackPane.getChildren().add(imageView);

	return stackPane;
}
 
Example 15
Project: javafx-3d-surface-chart   File: Mesh3DChartPanel.java   Source Code and License 6 votes vote down vote up
private void calculateAndRotatoNodes(List<Node> nodes, double alp, double bet, double gam) {
    double A11 = Math.cos(alp) * Math.cos(gam);
    double A12 = Math.cos(bet) * Math.sin(alp) + Math.cos(alp) * Math.sin(bet) * Math.sin(gam);
    double A13 = Math.sin(alp) * Math.sin(bet) - Math.cos(alp) * Math.cos(bet) * Math.sin(gam);
    double A21 = -Math.cos(gam) * Math.sin(alp);
    double A22 = Math.cos(alp) * Math.cos(bet) - Math.sin(alp) * Math.sin(bet) * Math.sin(gam);
    double A23 = Math.cos(alp) * Math.sin(bet) + Math.cos(bet) * Math.sin(alp) * Math.sin(gam);
    double A31 = Math.sin(gam);
    double A32 = -Math.cos(gam) * Math.sin(bet);
    double A33 = Math.cos(bet) * Math.cos(gam);

    double d = Math.acos((A11 + A22 + A33 - 1d) / 2d);
    if (!ObjectUtils.equalsDoublePrecision(d, 0.0)) {
        double den = 2d * Math.sin(d);
        Point3D p = new Point3D((A32 - A23) / den, (A13 - A31) / den, (A21 - A12) / den);
        for (Node node : nodes) {
            node.setRotationAxis(p);
            node.setRotate(Math.toDegrees(d));
        }
    }
}
 
Example 16
Project: fxexperience2   File: FadeOutRightTransition.java   Source Code and License 6 votes vote down vote up
/**
 * Create new FadeOutRightTransition
 * 
 * @param node The node to affect
 */
public FadeOutRightTransition(final Node node) {
    super(
        node,
        new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 20, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
 
Example 17
Project: Cluster   File: Cluster.java   Source Code and License 5 votes vote down vote up
private void moveCentroid() {
    Node centre = borderPane.getCenter();
    borderPane.getChildren().remove(centre);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    controller.moveCentroids();
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    updateCost();
}
 
Example 18
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void selectRadiobuttonSelectedNotSelected() {
    Set<Node> radioButtonNodes = getPrimaryStage().getScene().getRoot().lookupAll(".radio-button");
    List<Node> nodes = new ArrayList<>(radioButtonNodes);
    RadioButton radioButtonNode = (RadioButton) nodes.get(1);
    AssertJUnit.assertEquals(true, radioButtonNode.isSelected());
    radioButton.marathon_select("false");
    new Wait("Waiting for the radio button deselect.") {
        @Override public boolean until() {
            return radioButtonNode.isSelected();
        }
    };
}
 
Example 19
Project: CalendarFX   File: HelloWeekView.java   Source Code and License 5 votes vote down vote up
@Override
public Node getPanel(Stage stage) {
    Calendar dirk = new Calendar("Dirk");
    Calendar katja = new Calendar("Katja");
    Calendar philip = new Calendar("Philip");
    Calendar jule = new Calendar("Jule");
    Calendar armin = new Calendar("Armin");

    dirk.setStyle(Style.STYLE1);
    katja.setStyle(Style.STYLE2);
    philip.setStyle(Style.STYLE3);
    jule.setStyle(Style.STYLE4);
    armin.setStyle(Style.STYLE5);

    CalendarSource calendarSource = new CalendarSource();
    calendarSource.getCalendars().add(dirk);
    calendarSource.getCalendars().add(katja);
    calendarSource.getCalendars().add(philip);
    calendarSource.getCalendars().add(jule);
    calendarSource.getCalendars().add(armin);

    weekView.getCalendarSources().setAll(calendarSource);

    DayViewScrollPane scroll = new DayViewScrollPane(weekView, new ScrollBar());
    scroll.setStyle("-fx-background-color: white;");
    return scroll;
}
 
Example 20
Project: marathonv5   File: BorderPaneSample.java   Source Code and License 5 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    BorderPane borderPane = new BorderPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    borderPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
 
    Rectangle recTop = new Rectangle(62, 5, Color.web("#349b00"));
    recTop.setStroke(Color.BLACK);
    Rectangle recBottom = new Rectangle(62, 14, Color.web("#349b00"));
    recBottom.setStroke(Color.BLACK);
    Rectangle recLeft = new Rectangle(20, 41, Color.TRANSPARENT);
    recLeft.setStroke(Color.BLACK);
    Rectangle recRight = new Rectangle(20, 41, Color.TRANSPARENT);
    recRight.setStroke(Color.BLACK);
    Rectangle centerRight = new Rectangle(20, 41, Color.TRANSPARENT);
    centerRight.setStroke(Color.BLACK);
    borderPane.setRight(recRight);
    borderPane.setTop(recTop);
    borderPane.setLeft(recLeft);
    borderPane.setBottom(recBottom);
    borderPane.setCenter(centerRight);
 
    sp.getChildren().addAll(rectangle, borderPane);
    return new Group(sp);
}
 
Example 21
Project: JavaFX-EX   File: DragSupport.java   Source Code and License 5 votes vote down vote up
@Override
public void press(MouseEvent e) {
  Node node = get();
  if (isEnable() && e.isConsumed() == false && node != null) {
    Bounds boundsInLocal = node.getBoundsInLocal();
    if (canDrag(node.screenToLocal(e.getScreenX(), e.getScreenY()), boundsInLocal.getMaxX(), boundsInLocal.getMaxY())) {
      startX = e.getScreenX() - node.getLayoutX();
      startY = e.getScreenY() - node.getLayoutY();
      e.consume();
      pressed = true;
    }
  }
}
 
Example 22
Project: java-ml-projects   File: App.java   Source Code and License 5 votes vote down vote up
private Node buildCenterPane() {
	Canvas canvas = new Canvas(CANVAS_WIDTH, CANVAS_HEIGHT);
	ScrollPane spCanvas = new ScrollPane(canvas);
	gc = canvas.getGraphicsContext2D();
	gc.setFill(Color.LIGHTGOLDENRODYELLOW);
	gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
	return spCanvas;
}
 
Example 23
Project: marathonv5   File: CompositeLayout.java   Source Code and License 5 votes vote down vote up
private void updateTabPane() {
    optionTabpane.getTabs().clear();
    layouts = getLauncherLayouts();
    for (ISubPropertiesLayout p : layouts) {
        Node content = p.getContent();
        if (Boolean.getBoolean("marathon.show.id")) {
            parent.addToolTips(content);
        }
        String name = p.getName();
        Tab tab = new Tab(name, content);
        tab.setId(name);
        tab.setGraphic(p.getIcon());
        optionTabpane.getTabs().add(tab);
    }
}
 
Example 24
Project: MultiAxisCharts   File: MultiAxisBarChart.java   Source Code and License 5 votes vote down vote up
@Override
protected void seriesAdded(Series<X, Y> series, int seriesIndex) {
	// handle any data already in series
	// create entry in the map
	Map<String, Data<X, Y>> categoryMap = new HashMap<String, Data<X, Y>>();
	for (int j = 0; j < series.getData().size(); j++) {
		Data<X, Y> item = series.getData().get(j);
		Node bar = createBar(series, seriesIndex, item, j);
		String category;
		if (orientation == Orientation.VERTICAL) {
			category = (String) item.getXValue();
		} else {
			category = (String) item.getYValue();
		}
		categoryMap.put(category, item);
		if (shouldAnimate()) {
			animateDataAdd(item, bar);
		} else {
			// RT-21164 check if bar value is negative to add NEGATIVE_STYLE style class
			double barVal = (orientation == Orientation.VERTICAL) ? ((Number) item.getYValue()).doubleValue()
					: ((Number) item.getXValue()).doubleValue();
			if (barVal < 0) {
				bar.getStyleClass().add(NEGATIVE_STYLE);
			}
			getPlotChildren().add(bar);
		}
	}
	if (categoryMap.size() > 0)
		seriesCategoryMap.put(series, categoryMap);
}
 
Example 25
Project: fx-animation-editor   File: KeyFrameDragAnimator.java   Source Code and License 5 votes vote down vote up
private void onReleased(Node dragged, MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && dragActive) {
        dragActive = false;

        container.setMinWidth(minWidthBackup);
        container.setPrefWidth(prefWidthBackup);
        container.setMaxWidth(maxWidthBackup);

        int draggedIndex = translates.get(dragged).initialIndex;
        int dropIndex = translates.values().stream()
                .filter(t -> t.forward.get())
                .map(t -> t.initialIndex)
                .map(i -> i < draggedIndex ? i : i - 1)
                .min(Comparator.naturalOrder())
                .orElse(container.getChildren().size() - 1);

        // Reset dragged node to original index.
        for (int i = draggedIndex; i < container.getChildren().size() - 1; i++) {
            container.getChildren().get(draggedIndex).toFront();
        }

        moveableChildren().forEach(child -> child.setManaged(true));
        moveableChildren().forEach(child -> child.setTranslateX(0));
        translates.values().forEach(animation -> {
            if (animation.translate != null) {
                animation.translate.stop();
                animation.translate.setNode(null);
            }
        });
        translates = null;

        if (repositionHandler != null && draggedIndex != dropIndex) {
            repositionHandler.accept(draggedIndex, dropIndex);
        }
    }
}
 
Example 26
Project: GameAuthoringEnvironment   File: ProfileCellView.java   Source Code and License 5 votes vote down vote up
/**
 * Helper to get a the correct image from the sprite
 *
 * @return
 */
protected Image getSpriteImage () {
    Node node =
            getProfilable().getProfile().getImage()
                    .getVisualRepresentation(new UnscaledFactory());

    return new BasicUIFactory().getImageFromNode(node);
}
 
Example 27
Project: marathonv5   File: RunHistoryStage.java   Source Code and License 5 votes vote down vote up
private Node getIcon(State state) {
    Node icon = null;
    if (state == State.ERROR) {
        icon = FXUIUtils.getIcon("testerror");
    } else if (state == State.FAILURE) {
        icon = FXUIUtils.getIcon("testfail");
    } else if (state == State.SUCCESS) {
        icon = FXUIUtils.getIcon("tsuiteok");
    }
    return icon;
}
 
Example 28
Project: CalendarFX   File: HelloSourceView.java   Source Code and License 5 votes vote down vote up
@Override
protected Node createControl() {
    sourceView = new SourceView();

    Calendar meetings = new Calendar("Meetings");
    Calendar training = new Calendar("Training");
    Calendar customers = new Calendar("Customers");
    Calendar holidays = new Calendar("Holidays");

    meetings.setStyle(Style.STYLE2);
    training.setStyle(Style.STYLE3);
    customers.setStyle(Style.STYLE4);
    holidays.setStyle(Style.STYLE5);

    workCalendarSource = new CalendarSource("Work");
    workCalendarSource.getCalendars().addAll(meetings, training, customers,
            holidays);

    Calendar birthdays = new Calendar("Birthdays");
    Calendar katja = new Calendar("Katja");
    Calendar dirk = new Calendar("Dirk");
    Calendar philip = new Calendar("Philip");
    Calendar jule = new Calendar("Jule");
    Calendar armin = new Calendar("Armin");

    familyCalendarSource = new CalendarSource("Family");
    familyCalendarSource.getCalendars().addAll(birthdays, katja, dirk,
            philip, jule, armin);

    sourceView.getCalendarSources().addAll(workCalendarSource,
            familyCalendarSource);

    return sourceView;
}
 
Example 29
Project: marathonv5   File: AdjacentSiblingSelector.java   Source Code and License 5 votes vote down vote up
private int getIndexOfComponentInParent(Node component) {
    Parent parent = component.getParent();
    if (parent == null) {
        return -1;
    }
    ObservableList<Node> components = parent.getChildrenUnmodifiable();
    for (int i = 0; i < components.size(); i++) {
        if (components.get(i) == component) {
            return i;
        }
    }
    return -1;
}
 
Example 30
Project: lttng-scope   File: StateRectangle.java   Source Code and License 5 votes vote down vote up
public void addTooltipRow(Object... objects) {
    Node[] labels = Arrays.stream(objects)
            .map(Object::toString)
            .map(Text::new)
            .peek(text -> {
                text.fontProperty().bind(fOpts.toolTipFont);
                text.fillProperty().bind(fOpts.toolTipFontFill);
            })
            .toArray(Node[]::new);
    appendRow(labels);
}
 
Example 31
Project: marathonv5   File: FXUIUtils.java   Source Code and License 5 votes vote down vote up
public static MenuItem createMenuItem(String name, String commandName, String mnemonic) {
    MenuItem menuItem = new MenuItem();
    menuItem.setId(name + "MenuItem");
    Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
    if (enabledIcon != null) {
        menuItem.setGraphic(enabledIcon);
    }
    menuItem.setText(commandName);
    if (!"".equals(mnemonic)) {
        menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
    }

    return menuItem;
}
 
Example 32
Project: marathonv5   File: JavaFXTreeTableViewCellElement.java   Source Code and License 5 votes vote down vote up
private Node getTextObj(TreeTableCell<?, ?> cell) {
    for (Node child : cell.getChildrenUnmodifiable()) {
        if (child instanceof Text) {
            return child;
        }
    }
    return cell;
}
 
Example 33
Project: CalendarFX   File: HelloPrintView.java   Source Code and License 5 votes vote down vote up
@Override
protected Node createControl() {
    Calendar meetings = new Calendar("Meetings");
    Calendar training = new Calendar("Training");
    Calendar customers = new Calendar("Customers");
    Calendar holidays = new Calendar("Holidays");

    meetings.setStyle(Style.STYLE2);
    training.setStyle(Style.STYLE3);
    customers.setStyle(Style.STYLE4);
    holidays.setStyle(Style.STYLE5);

    CalendarSource workCalendarSource = new CalendarSource("Work");
    workCalendarSource.getCalendars().addAll(meetings, training, customers, holidays);

    Calendar birthdays = new Calendar("Birthdays");
    Calendar katja = new Calendar("Katja");
    Calendar dirk = new Calendar("Dirk");
    Calendar philip = new Calendar("Philip");

    CalendarSource familyCalendarSource = new CalendarSource("Family");
    familyCalendarSource.getCalendars().addAll(birthdays, katja, dirk, philip);

    Entry<String> meetings1 = new Entry<>("Meetings 1");
    meetings1.setCalendar(meetings);

    PrintView printView = new PrintView();
    printView.setPrefWidth(1200);
    printView.setPrefHeight(950);
    printView.getCalendarSources().addAll(workCalendarSource, familyCalendarSource);

    return printView;
}
 
Example 34
Project: lttng-scope   File: ExampleMouseDrag2.java   Source Code and License 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {

    if( !enabled) {
        return;
    }

    // all in selection
    for( Node node: selectionModel.selection) {
        node.setTranslateX( dragContext.x + event.getSceneX());
        node.setTranslateY( dragContext.y + event.getSceneY());
    }

}
 
Example 35
Project: FastisFX   File: TimeIndicator.java   Source Code and License 5 votes vote down vote up
public TimeIndicator(DayPane dayPane, Node indicator) {
    AnchorPane.setLeftAnchor(dayPane, 0.0);
    AnchorPane.setTopAnchor(dayPane, 0.0);
    AnchorPane.setRightAnchor(dayPane, 0.0);
    AnchorPane.setBottomAnchor(dayPane, 0.0);
    this.getChildren().add(dayPane);

    this.startTime = dayPane.dayStartTimeProperty();
    this.endTime = dayPane.dayEndTimeProperty();
    this.date = dayPane.getDayDate();

    this.indicator = indicator;
    AnchorPane.setLeftAnchor(indicator, 0.0);
    AnchorPane.setRightAnchor(indicator, 0.0);

    // update position if the DayPane's time window changes
    startTime.addListener(observable -> setIndicatorPosition(indicator));
    endTime.addListener(observable -> setIndicatorPosition(indicator));

    // updates the position every minute
    Timeline indicatorupdate = new Timeline(new KeyFrame(javafx.util.Duration.minutes(1), actionEvent -> setIndicatorPosition(indicator)));
    indicatorupdate.setCycleCount(Animation.INDEFINITE);
    indicatorupdate.play();

    // initial position
    setIndicatorPosition(indicator);
}
 
Example 36
Project: uPMT   File: TypeClassRepresentationController.java   Source Code and License 5 votes vote down vote up
public static void RemoveTypeClassRepFromList(ObservableList<Node> children, TypeClassRepresentationController t) {
	for (Object object : children) {
		TypeClassRepresentationController tmp = (TypeClassRepresentationController) object;
		
		if(tmp.getClasse().equals(t.getClasse())) {
			children.remove(tmp);
			break;
		}
	} 
}
 
Example 37
Project: drd   File: RootController.java   Source Code and License 5 votes vote down vote up
@Override
public void setChildNode(Node node) {
    containerContent.clear();
    AnchorPane.setTopAnchor(node, 0.0);
    AnchorPane.setLeftAnchor(node, 0.0);
    AnchorPane.setRightAnchor(node, 0.0);
    AnchorPane.setBottomAnchor(node, 0.0);
    containerContent.setAll(node);
}
 
Example 38
Project: marathonv5   File: JavaFXElementPropertyAccessor.java   Source Code and License 5 votes vote down vote up
public String _getText() {
    Node c = node;
    if (this instanceof IPseudoElement) {
        c = ((IPseudoElement) this).getPseudoComponent();
    }
    Object attributeObject = getAttributeObject(c, "text");
    if (attributeObject == null) {
        return null;
    }
    return attributeObject.toString();
}
 
Example 39
Project: creacoinj   File: GuiUtils.java   Source Code and License 5 votes vote down vote up
public static Animation fadeOut(Node ui) {
    FadeTransition ft = new FadeTransition(Duration.millis(UI_ANIMATION_TIME_MSEC), ui);
    ft.setFromValue(ui.getOpacity());
    ft.setToValue(0.0);
    ft.play();
    return ft;
}
 
Example 40
Project: marathonv5   File: ImagePropertiesSample.java   Source Code and License 5 votes vote down vote up
public static Node createIconContent() {
    //TODO better icon?
    ImageView iv = new ImageView(BRIDGE);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(0, 85, 330, 330));
    return iv;
}