Java Examples for javafx.scene.Node
The following java examples will help you to understand the usage of javafx.scene.Node. These source code samples are taken from different open source projects.
Example 1
| Project: JXTN-master File: ParentMaker.java View source code |
/**
* å¢žåŠ é›†å?ˆå±¬æ€§{@link Parent#getChildrenUnmodifiable}的內容。
*
* @param value 新的集�內容
* @return 目�的建構器(this)
*/
@SafeVarargs
@SuppressWarnings("unchecked")
public final B childrenUnmodifiableAdd(javafx.scene.Node... value) {
java.util.Objects.requireNonNull(value);
this.hasChildrenUnmodifiable = true;
if (this.valChildrenUnmodifiable == null)
this.valChildrenUnmodifiable = new java.util.ArrayList<>(value.length);
this.valChildrenUnmodifiable.addAll(java.util.Arrays.asList(value));
return (B) this;
}Example 2
| Project: downlords-faf-client-master File: ModVaultControllerTest.java View source code |
@Test
public void testShowModDetail() throws Exception {
Node pane = new Pane();
pane.setVisible(false);
when(modDetailController.getRoot()).thenReturn(pane);
ModInfoBean modInfoBean = ModInfoBeanBuilder.create().defaultValues().get();
instance.onShowModDetail(modInfoBean);
verify(modDetailController).setMod(modInfoBean);
assertThat(pane.isVisible(), is(true));
}Example 3
| Project: e-fx-clipse-master File: ToolItemRenderer.java View source code |
private void selectButton(ButtonBase button) {
for (Node n : button.getParent().getChildrenUnmodifiable()) {
if (n instanceof RadioButton) {
if (n != button) {
((MToolItem) n.getUserData()).setSelected(false);
}
}
}
System.err.println("Add selection");
((MToolItem) button.getUserData()).setSelected(true);
}Example 4
| Project: gef-master File: HiddenNeighborsFeedbackPart.java View source code |
@Override
protected void doRefreshVisual(Group visual) {
Set<IVisualPart<? extends Node>> keySet = getAnchoragesUnmodifiable().keySet();
if (keySet.isEmpty()) {
return;
}
IVisualPart<? extends Node> anchorage = keySet.iterator().next();
if (((NodePart) anchorage).getContent() == null) {
return;
}
// update position
Bounds anchorageLayoutBoundsInLocal = getVisual().sceneToLocal(anchorage.getVisual().localToScene(anchorage.getVisual().getLayoutBounds()));
double x = anchorageLayoutBoundsInLocal.getMaxX();
double y = anchorageLayoutBoundsInLocal.getMaxY();
circle.setCenterX(x);
circle.setCenterY(y);
// update text
HidingModel hidingModel = getViewer().getAdapter(HidingModel.class);
int count = hidingModel.getHiddenNeighbors(((NodePart) anchorage).getContent()).size();
text.setText(Integer.toString(count));
Bounds textLayoutBounds = text.getLayoutBounds();
// update circle size
double size = textLayoutBounds.getWidth();
if (textLayoutBounds.getHeight() > size) {
size = textLayoutBounds.getHeight();
}
circle.setRadius(size / 2);
// update text position
text.relocate(x - textLayoutBounds.getWidth() / 2, y - textLayoutBounds.getHeight() / 2);
}Example 5
| Project: mytime-master File: SortingStrategyLastName.java View source code |
@Override public List<Node> sort(List<Node> listToSort) { List<Node> newList = listToSort; Collections.sort(newList, new Comparator<Node>() { @Override public int compare(Node s1, Node s2) { Volunteer v1 = (Volunteer) s1.getUserData(); Volunteer v2 = (Volunteer) s2.getUserData(); return v1.getLastName().get().compareTo(v2.getLastName().get()); } }); return newList; }
Example 6
| Project: FXForm2-master File: CustomFactoryForm.java View source code |
@Override
public Node getPanel(Stage stage) {
Pane root = new Pane();
FXForm form = new FXFormBuilder<>().includeAndReorder("firstName", "lastName", "age", "hobby").resourceBundle(Utils.SAMPLE).build();
UserWithCustomFactory userWithCustomFactory = new UserWithCustomFactory();
// another way to register a custom factory using the DefaultFactoryProvider
DefaultFactoryProvider factoryProvider = new DefaultFactoryProvider();
factoryProvider.addFactory( element -> true, new ListChoiceBoxFactory<>(new SimpleListProperty<>(FXCollections.observableArrayList("Robert", "Jon", "Catelyn"))));
form.setEditorFactoryProvider(factoryProvider);
form.setSource(userWithCustomFactory);
root.getChildren().add(form);
return root;
}Example 7
| Project: graph-editor-master File: ColorAnimationUtils.java View source code |
/**
* Adds animated color properties to the given node that can be accessed from CSS.
*
* @param node the node to be styled with animated colors
* @param data a {@link AnimatedColor} object storing the animation parameters
*/
public static void animateColor(final Node node, final AnimatedColor data) {
removeAnimation(node);
final ObjectProperty<Color> baseColor = new SimpleObjectProperty<>();
final KeyValue firstkeyValue = new KeyValue(baseColor, data.getFirstColor());
final KeyValue secondKeyValue = new KeyValue(baseColor, data.getSecondColor());
final KeyFrame firstKeyFrame = new KeyFrame(Duration.ZERO, firstkeyValue);
final KeyFrame secondKeyFrame = new KeyFrame(data.getInterval(), secondKeyValue);
final Timeline timeline = new Timeline(firstKeyFrame, secondKeyFrame);
baseColor.addListener(( v, o, n) -> {
final int redValue = (int) (n.getRed() * 255);
final int greenValue = (int) (n.getGreen() * 255);
final int blueValue = (int) (n.getBlue() * 255);
final String format = data.getProperty() + ": " + COLOR_FORMAT + ";";
node.setStyle(String.format(format, redValue, greenValue, blueValue));
});
node.getProperties().put(TIMELINE_KEY, timeline);
timeline.setAutoReverse(true);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}Example 8
| Project: jointry-master File: MultiKeyPopup.java View source code |
public void show(Node node, Side side, double d, double d1) {
if (node == null) {
return;
}
Event.fireEvent(this, new Event(Menu.ON_SHOWING));
if (buttonPane.getChildren().size() == 0) {
return;
} else {
HPos hpos = side != Side.LEFT ? side != Side.RIGHT ? HPos.CENTER : HPos.RIGHT : HPos.LEFT;
VPos vpos = side != Side.TOP ? side != Side.BOTTOM ? VPos.CENTER : VPos.BOTTOM : VPos.TOP;
// Point2D point2d = Utils.pointRelativeTo(node,
// computePrefWidth(-1D), computePrefHeight(-1D), hpos, vpos, d,
// d1, true);
Point2D point2d = Utils.pointRelativeTo(node, buttonPane.getPrefWidth(), buttonPane.getPrefHeight(), hpos, vpos, d, d1, true);
super.show(node, point2d.getX(), point2d.getY());
return;
}
}Example 9
| Project: jubula.core-master File: NodeBounds.java View source code |
/**
* Must be called from FX Thread.
*
* Checks if the given point with coordinates relative to the scene is in
* the given Node.
*
* @param point
* the Point
* @param n
* the Node
* @return true if the Point is in the Node, false if not.
*/
public static boolean checkIfContains(Point2D point, Node n) throws IllegalStateException {
EventThreadQueuerJavaFXImpl.checkEventThread();
if (n.getScene() == null) {
return false;
}
Point2D nodePos = n.localToScreen(0, 0);
// (non-existent) bounds cannot contain the given point.
if (nodePos == null) {
return false;
}
return n.contains(n.screenToLocal(point.getX(), point.getY()));
}Example 10
| Project: MiscellaneousStudy-master File: AddPanelController.java View source code |
@Override
public void initialize(URL location, ResourceBundle resources) {
// add ボタンクリックã?§ Text 追åŠ
add.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
System.out.println("Fire add event.");
Text t = new Text();
t.setText(String.format("Added %d.", count++));
target.getChildren().add(t);
}
});
// delete ボタンクリックã?§ Text 追åŠ
delete.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
System.out.println("Fire delete event.");
ObservableList<Node> targetChild = target.getChildren();
{
int size = targetChild.size();
if (size > 0) {
targetChild.remove(size - 1);
}
}
}
});
}Example 11
| Project: pieShare-master File: TwoColumnListViewEntry.java View source code |
@Override
public void updateItem(ITwoColumnListViewItem entry, boolean empty) {
super.updateItem(entry, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
setText(null);
// DO NOT CREATE INSTANCES IN THIS METHOD, THIS IS BAD!
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(4);
// grid.setPadding(new Insets(0, 5, 0, 5));
int i = 0;
Node icon = entry.getFirstColumn();
if (icon != null) {
icon.getStyleClass().add("cache-list-icon");
//, 1, 2);
grid.add(//, 1, 2);
icon, //, 1, 2);
i, //, 1, 2);
0);
i++;
}
Node name = entry.getSecondColumn();
if (name != null) {
grid.add(name, i, 0);
}
setGraphic(grid);
}
}Example 12
| Project: Starbound-Mod-Manager-master File: FXHelper.java View source code |
public static void setColor(final Node image, final double r, final double g, final double b) {
Image src = ((ImageView) image).getImage();
PixelReader reader = src.getPixelReader();
int width = (int) src.getWidth();
int height = (int) src.getHeight();
WritableImage dest = new WritableImage(width, height);
PixelWriter writer = dest.getPixelWriter();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
Color c = new Color(r, g, b, reader.getColor(x, y).getOpacity());
writer.setColor(x, y, c);
}
}
((ImageView) image).setImage(dest);
}Example 13
| Project: teamearth-master File: StartGameButtonOnClickListener.java View source code |
@Override
public void handle(ActionEvent event) {
// Clear the buttons from the main screen to set up the game field.
border.getChildren().clear();
List<GameObject> allObjects = gameWorldInitializer.getGameObjectManager().getAllObjects();
for (GameObject currentObject : allObjects) {
Node node = currentObject.getNode();
Point2D position = currentObject.getPosition();
if (position != null) {
node.setTranslateX(position.getX());
node.setTranslateY(position.getY());
}
node.setVisible(true);
}
}Example 14
| Project: wikokit-master File: TranslationCell.java View source code |
// Text text;
/*public TranslationCell(final ListView<wiwordik.word_card.TranslationEntryItem> list) {
//label = new Label();
//setNode(label);
}*/
@Override
public void updateItem(wiwordik.word_card.TranslationEntryItem item, boolean empty) {
super.updateItem(item, empty);
// text = new Text("the very temp");
if (null != item) {
setText(item.getLangCodeTranslation());
//Node n = item.hbox;
//System.out.println("TranslationCell.updateItem(): lang_name="+item.lang_name+
// "; lang_code=" + item.lang_code +
// "; text="+item.text);
//setGraphic(n);
//setNode(n);
}
//setGraphic(item.hbox);
//setNode(item.hbox);
}Example 15
| Project: AsciidocFX-master File: PieChartBuilderService.java View source code |
@Override
public void chartBuild(String chartContent, String imagesDir, String imageTarget, Map<String, String> optMap) throws Exception {
try {
super.chartBuild(chartContent, imagesDir, imageTarget, optMap);
} catch (InterruptedException e) {
throw e;
}
String[] split = chartContent.split("\\r?\\n");
List<String> lines = Arrays.asList(split);
ObservableList<PieChart.Data> datas = FXCollections.observableArrayList();
ObservableList<String> colors = FXCollections.observableArrayList();
for (String line : lines) {
String[] parts = line.split(",");
if (parts.length < 2)
continue;
String name = null;
Double value = null;
String color = null;
try {
name = parts[0];
value = Double.valueOf(parts[1]);
color = parts[2];
} catch (Exception e) {
}
colors.add(color);
datas.add(new PieChart.Data(name, value));
}
PieChart pieChart = new PieChart(datas);
pieChart.getStyleClass().add("chart-extension");
int scale = extensionConfigBean.getDefaultImageScale();
pieChart.setScaleX(scale);
pieChart.setScaleY(scale);
pieChart.setScaleZ(scale);
for (int i = 0; i < datas.size(); i++) {
PieChart.Data data = datas.get(i);
String color = colors.get(i);
if (Objects.nonNull(color))
data.getNode().setStyle("-fx-pie-color:" + color + ";");
}
if (Objects.nonNull(optMap.get("clockwise")))
pieChart.setClockwise(Boolean.valueOf(optMap.get("clockwise")));
if (Objects.nonNull(optMap.get("labels-visible")))
pieChart.setLabelsVisible(Boolean.valueOf(optMap.get("labels-visible")));
if (Objects.nonNull(optMap.get("line-length")))
pieChart.setLabelLineLength(Double.parseDouble(optMap.get("line-length")));
if (Objects.nonNull(optMap.get("start-angle")))
pieChart.setStartAngle(Double.parseDouble(optMap.get("start-angle")));
if (Objects.nonNull(optMap.get("legend"))) {
try {
pieChart.setLegendSide(Side.valueOf(optMap.get("legend").toUpperCase()));
} catch (RuntimeException e) {
pieChart.setLegendVisible(false);
}
}
if (Objects.nonNull(optMap.get("title")))
pieChart.setTitle(optMap.get("title"));
if (Objects.nonNull(optMap.get("title-side")))
pieChart.setTitleSide(Side.valueOf(optMap.get("title-side").toUpperCase()));
Set<Node> nodes = pieChart.lookupAll(".chart-title");
for (Node node : nodes) {
String titleColor = Objects.isNull(optMap.get("title-color")) ? "#000" : optMap.get("title-color");
String titleSize = Objects.isNull(optMap.get("title-size")) ? "1.6em" : optMap.get("title-size");
node.setStyle(String.format("-fx-text-fill: %s; -fx-font-size: %s;", titleColor, titleSize));
}
pieChart.setLayoutX(-19000);
pieChart.setLayoutY(-19000);
threadService.runActionLater(() -> {
controller.getRootAnchor().getChildren().add(pieChart);
WritableImage writableImage = pieChart.snapshot(new SnapshotParameters(), null);
controller.getRootAnchor().getChildren().remove(pieChart);
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(writableImage, null);
IOHelper.createDirectories(currentRoot.resolve(imagesDir));
IOHelper.imageWrite(bufferedImage, "png", imagePath.toFile());
controller.clearImageCache(imagePath);
});
}Example 16
| Project: Cachoeira-master File: StartWindowView.java View source code |
private Node createTable() {
recentProjectsTable.setPrefWidth(TABLE_WIDTH);
TableColumn<File, String> recentProjectsPathColumn = new TableColumn<>("Recent Projects");
recentProjectsPathColumn.setCellValueFactory( cellData -> new ReadOnlyStringWrapper(cellData.getValue().getPath()));
recentProjectsTable.getColumns().add(recentProjectsPathColumn);
recentProjectsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
return recentProjectsTable;
}Example 17
| Project: chvote-1-0-master File: AdditionalTableViewMatchers.java View source code |
@Factory public static <T> Matcher<Node> hasTableCell(final Matcher<T> contentsMatcher) { return new TypeSafeMatcher<Node>(TableView.class) { @Override protected boolean matchesSafely(Node item) { NodeFinder nodeFinder = FxAssert.assertContext().getNodeFinder(); NodeQuery nodeQuery = nodeFinder.from(item); Optional<Node> result = nodeQuery.lookup(".table-cell").match(cellWithValue(contentsMatcher)).tryQuery(); return result.isPresent(); } @Override public void describeTo(Description description) { description.appendText(TableView.class.getSimpleName()).appendText(" containing ").appendDescriptionOf(contentsMatcher); } @Override protected void describeMismatchSafely(Node item, Description mismatchDescription) { mismatchDescription.appendText("was ").appendValue(item); } }; }
Example 18
| Project: closurefx-builder-master File: TooltipManager.java View source code |
private void disappear(final Node node) {
FadeTransition ft = new FadeTransition(Duration.millis(500), node);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (parent != null) {
parent.getChildren().remove(node);
}
}
});
}Example 19
| Project: db-preservation-toolkit-master File: CustomChooser.java View source code |
@FXML
public void btnCancelAction(ActionEvent event) throws Exception {
Node node = (Node) event.getSource();
Stage stage = (Stage) node.getScene().getWindow();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setResources(ResourceBundle.getBundle(App.bundle));
Parent root = (Parent) fxmlLoader.load(getClass().getResource("Main.fxml").openStream());
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
stage.setScene(scene);
stage.show();
}Example 20
| Project: desktopgap-master File: Draggable.java View source code |
// ------------------------------------------------------------------------
// p r i v a t e
// ------------------------------------------------------------------------
private void addDraggableNode(final Node node) {
if (null == node) {
return;
}
node.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(final MouseEvent me) {
node.setCursor(DRAGGABLE);
}
});
node.setOnMouseReleased(new EventHandler<MouseEvent>() {
@Override
public void handle(final MouseEvent me) {
node.setCursor(DRAGGABLE);
}
});
node.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(final MouseEvent me) {
try {
if (me.getButton() != MouseButton.MIDDLE) {
node.setCursor(DRAGGING);
initialX = me.getSceneX();
initialY = me.getSceneY();
}
} catch (Throwable ignored) {
}
}
});
node.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override
public void handle(final MouseEvent me) {
try {
if (me.getButton() != MouseButton.MIDDLE) {
node.getScene().getWindow().setX(me.getScreenX() - initialX);
node.getScene().getWindow().setY(me.getScreenY() - initialY);
node.setCursor(DRAGGING);
}
} catch (Throwable ignored) {
}
}
});
}Example 21
| Project: emfdatabinding-tutorial-master File: SashRenderer.java View source code |
@Override
public void processContents(final MElementContainer<MUIElement> container) {
if (!(((MUIElement) container) instanceof MPartSashContainer)) {
return;
}
super.processContents(container);
final SplitPane splitPane = (SplitPane) container.getWidget();
for (MUIElement e : container.getChildren()) {
if (e.getWidget() != null) {
splitPane.getItems().add((Node) e.getWidget());
}
}
int i = 0;
for (MUIElement e : container.getChildren()) {
String data = e.getContainerData();
if (data != null) {
try {
double d = Double.parseDouble(data);
splitPane.setDividerPosition(i++, d);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
for (Divider d : splitPane.getDividers()) {
d.positionProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) {
int i = 0;
for (double d : splitPane.getDividersPositions()) {
container.getChildren().get(i++).setContainerData(Double.toString(d));
}
}
});
}
}Example 22
| Project: Enzo-master File: DemoSimpleGauge.java View source code |
// ******************** Misc ********************************************** private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); for (Node n : tempChildren) { calcNoOfNodes(n); //System.out.println(n.getStyleClass().toString()); } } } }
Example 23
| Project: FxProjects-master File: ModalConfirmExample.java View source code |
@Override
public void start(final Stage primaryStage) {
// initialize the stage
primaryStage.setTitle("Modal Confirm Example");
final WebView webView = new WebView();
webView.getEngine().load("http://docs.oracle.com/javafx/");
primaryStage.setScene(new Scene(webView));
primaryStage.show();
// initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.TRANSPARENT);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.initOwner(primaryStage);
dialog.setScene(new Scene(HBoxBuilder.create().styleClass("modal-dialog").children(LabelBuilder.create().text("Will you like this page?").build(), ButtonBuilder.create().text("Yes").defaultButton(true).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
// take action and close the dialog.
System.out.println("Liked: " + webView.getEngine().getTitle());
primaryStage.getScene().getRoot().setEffect(null);
dialog.close();
}
}).build(), ButtonBuilder.create().text("No").cancelButton(true).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
// abort action and close the dialog.
System.out.println("Disliked: " + webView.getEngine().getTitle());
primaryStage.getScene().getRoot().setEffect(null);
dialog.close();
}
}).build()).build(), Color.TRANSPARENT));
dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm());
// allow the dialog to be dragged around.
final Node root = dialog.getScene().getRoot();
final Delta dragDelta = new Delta();
root.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
// record a delta distance for the drag and drop operation.
dragDelta.x = dialog.getX() - mouseEvent.getScreenX();
dragDelta.y = dialog.getY() - mouseEvent.getScreenY();
}
});
root.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
dialog.setX(mouseEvent.getScreenX() + dragDelta.x);
dialog.setY(mouseEvent.getScreenY() + dragDelta.y);
}
});
// show the confirmation dialog each time a new page is loaded.
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State state, Worker.State newState) {
if (newState.equals(Worker.State.SUCCEEDED)) {
primaryStage.getScene().getRoot().setEffect(new BoxBlur());
dialog.show();
}
}
});
}Example 24
| Project: geotoolkit-master File: FXOptionDialog.java View source code |
public static boolean showOkCancel(Object owner, Node content, String title, boolean modal) { final Dialog dia = new Dialog(); final DialogPane pane = new DialogPane(); pane.getButtonTypes().add(ButtonType.OK); pane.getButtonTypes().add(ButtonType.CANCEL); pane.setContent(content); dia.setTitle(title); if (owner instanceof Node) { final Window window = ((Node) owner).getScene().getWindow(); dia.initOwner(window); } dia.setDialogPane(pane); final Optional<ButtonType> result = dia.showAndWait(); return result.isPresent() && result.get() == ButtonType.OK; // if(result.isPresent() && result.get() == ButtonType.OK){ // if(layerVisible){ // return chooser.getSelectedLayers(); // }else{ // final Client store = chooser.getStore(); // if(store == null){ // return Collections.EMPTY_LIST; // }else{ // return Collections.singletonList(store); // } // } // }else{ // return Collections.EMPTY_LIST; // } // // final Dialog dialog = new Dialog(); // dialog.setContent(content); // dialog.setIconifiable(false); // final AtomicBoolean state = new AtomicBoolean(false); // dialog.getActions().addAll(new OkAction(dialog, state), new CancelAction(dialog, state)); // // dialog.show(); // return state.get(); }
Example 25
| Project: griffon-master File: AbstractJavaFXGriffonView.java View source code |
@Nullable
protected Node loadFromFXML(@Nonnull String baseName) {
requireNonBlank(baseName, "Argument 'baseName' must not be blank");
if (baseName.endsWith(FXML_SUFFIX)) {
baseName = stripFilenameExtension(baseName);
}
baseName = baseName.replace('.', '/');
String viewName = baseName + FXML_SUFFIX;
String styleName = baseName + ".css";
URL viewResource = getResourceAsURL(viewName);
if (viewResource == null) {
return null;
}
FXMLLoader fxmlLoader = new FXMLLoader(viewResource);
fxmlLoader.setResources(getApplication().getMessageSource().asResourceBundle());
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory(getApplication().getApplicationClassLoader().get()));
fxmlLoader.setClassLoader(getApplication().getApplicationClassLoader().get());
fxmlLoader.setControllerFactory( klass -> getMvcGroup().getView());
try {
fxmlLoader.load();
} catch (IOException e) {
throw new GriffonException(e);
}
Parent node = fxmlLoader.getRoot();
URL cssResource = getResourceAsURL(styleName);
if (cssResource != null) {
String uriToCss = cssResource.toExternalForm();
node.getStylesheets().add(uriToCss);
}
return node;
}Example 26
| Project: Icew1nd-master File: Utils.java View source code |
public static void fitFont(ObservableList<Node> children, Pane pane) { for (Node obj : recurse(children)) { if (obj instanceof Labeled && !obj.getStyleClass().contains("noresize")) { Labeled element = (Labeled) obj; double s = element.getFont().getSize(); DoubleBinding fontSize = pane.widthProperty().multiply(0.75).add(pane.heightProperty()).divide(1200).multiply(s); obj.styleProperty().bind(Bindings.concat("-fx-font-size: ").concat(fontSize.asString()).concat(";")); } else { //:I } } }
Example 27
| Project: idnadrev-master File: TagContainerTest.java View source code |
@Test
public void testAddRemove() throws Exception {
TagContainer container = activityController.getControllerInstance(TagContainer.class);
FXPlatform.invokeLater(() -> container.addTag("bla"));
Thread.sleep(100);
activityController.waitForTasks();
FXPlatform.waitForFX();
assertEquals(1, container.tagPane.getChildren().size());
assertEquals(1, container.getCurrentTags().size());
FXPlatform.invokeLater(() -> container.removeTag("bla"));
assertEquals(0, container.tagPane.getChildren().size());
assertEquals(0, container.getCurrentTags().size());
addTag(container, "tag1");
FXPlatform.invokeLater(() -> {
Node node = container.tagPane.getChildren().get(0);
Button lookup = (Button) node.lookup("#remove");
lookup.getOnAction().handle(null);
});
assertEquals(0, container.tagPane.getChildren().size());
assertEquals(0, container.getCurrentTags().size());
}Example 28
| Project: javafx-minesweeper-master File: Draggable.java View source code |
public static void makeDraggable(Node node) {
node.setCache(true);
node.setCacheHint(CacheHint.SPEED);
final MouseHandler handler = new MouseHandler(node);
node.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
handler.mouseOn(event);
}
});
node.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
handler.mouseDragged(event);
}
});
}Example 29
| Project: JFoenix-master File: JFXDepthManager.java View source code |
/**
* this method will generate a new container node that prevent
* control transformation to be applied to the shadow effect
* (which makes it looks as a real shadow)
*/
public static Node createMaterialNode(Node control, int level) {
Node container = new Pane(control);
container.getStyleClass().add("depth-container");
level = level < 0 ? 0 : level;
level = level > 5 ? 5 : level;
container.setEffect(new DropShadow(BlurType.GAUSSIAN, depth[level].getColor(), depth[level].getRadius(), depth[level].getSpread(), depth[level].getOffsetX(), depth[level].getOffsetY()));
return container;
}Example 30
| Project: JFX8CustomControls-master File: Demo.java View source code |
// ******************** Misc ********************************************** private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); for (Node n : tempChildren) { calcNoOfNodes(n); //System.out.println(n.getStyleClass().toString()); } } } }
Example 31
| Project: jfxtras-master File: CategorySelectionGridPane.java View source code |
private void setupMouseOverAsBusy(final Node node) {
// play with the mouse pointer to show something can be done here
node.setOnMouseEntered(( mouseEvent) -> {
if (!mouseEvent.isPrimaryButtonDown()) {
node.setCursor(Cursor.HAND);
mouseEvent.consume();
}
});
node.setOnMouseExited(( mouseEvent) -> {
if (!mouseEvent.isPrimaryButtonDown()) {
node.setCursor(Cursor.DEFAULT);
mouseEvent.consume();
}
});
}Example 32
| Project: JRebirth-master File: FadeTransitionCommand.java View source code |
/**
* {@inheritDoc}
*/
@Override
protected void perform(final Wave wave) {
// The old node is the one that exists into the parent container (or null if none)
Node oldNode = getWaveBean(wave).hideModel() == null ? null : getWaveBean(wave).hideModel().getRootNode();
if (oldNode == null) {
final ObservableList<Node> parentContainer = getWaveBean(wave).childrenPlaceHolder();
oldNode = parentContainer.size() > 1 ? parentContainer.get(getWaveBean(wave).childrenPlaceHolder().size() - 1) : null;
}
// The new node is the one create by PrepareModelCommand
final Node newNode = getWaveBean(wave).showModel() == null ? null : getWaveBean(wave).showModel().getRootNode();
if (oldNode != null || newNode != null) {
final ParallelTransition animation = ParallelTransitionBuilder.create().build();
if (oldNode != null) {
animation.getChildren().add(FadeTransitionBuilder.create().duration(Duration.millis(600)).node(oldNode).fromValue(1.0).toValue(0.0).build());
}
if (newNode != null) {
animation.getChildren().add(FadeTransitionBuilder.create().duration(Duration.millis(600)).node(newNode).fromValue(0.0).toValue(1.0).build());
}
final Node oldNodeLink = oldNode;
// When animation is finished remove the hidden node from the stack to let only one node at the same time
animation.setOnFinished(new EventHandler<ActionEvent>() {
/**
* {@inheritDoc}
*/
@Override
public void handle(final ActionEvent arg0) {
if (oldNodeLink != null) {
// remove the old nod from the stack to hide it
getWaveBean(wave).childrenPlaceHolder().remove(oldNodeLink);
LOGGER.info("Remove " + oldNodeLink.toString() + " from stack container");
}
// FIXME do it in the right way
getWaveBean(wave).showModel().doShowView(wave);
}
});
animation.playFromStart();
}
}Example 33
| Project: latexdraw-master File: TestLatexdrawGUI.java View source code |
@Override
public void start(Stage aStage) {
stage = aStage;
try {
final Injector injector = Guice.createInjector(createModule());
guiceFactory = injector::getInstance;
final Parent root = FXMLLoader.load(LaTeXDraw.class.getResource(getFXMLPathFromLatexdraw()), LangTool.INSTANCE.getBundle(), new LatexdrawBuilderFactory(injector), guiceFactory);
Parent parent = root;
// So, need to add a fictive pane to contain the widgets.
if (root instanceof Pane) {
parent = root;
} else {
// TitledPane leads to flaky tests with TestFX. So, replacing the TitlePane with a classical pane.
if (parent instanceof TitledPane) {
titledPane = (TitledPane) parent;
final Node content = ((TitledPane) parent).getContent();
if (content instanceof Parent) {
parent = (Parent) content;
} else {
final BorderPane pane = new BorderPane();
pane.setCenter(content);
parent = pane;
}
}
}
final Scene scene = new Scene(parent);
aStage.setScene(scene);
aStage.show();
aStage.toFront();
if (root instanceof Region) {
aStage.minHeightProperty().bind(((Region) root).heightProperty());
aStage.minWidthProperty().bind(((Region) root).widthProperty());
}
aStage.sizeToScene();
} catch (final IOException ex) {
ex.printStackTrace();
}
}Example 34
| Project: lightfish-master File: SnapshotTable.java View source code |
public Node createTable() {
TableView tableView = new TableView();
ObservableList columns = tableView.getColumns();
columns.add(createColumn("monitoringTime", "Monitoring Time"));
columns.add(createColumn("usedHeapSizeInMB", "Heap Size"));
columns.add(createColumn("threadCount", "Thread Count"));
columns.add(createColumn("peakThreadCount", "Peak Thread Count"));
columns.add(createColumn("totalErrors", "Total Errors"));
columns.add(createColumn("currentThreadBusy", "Busy Threads"));
columns.add(createColumn("committedTX", "Commits"));
columns.add(createColumn("rolledBackTX", "Rollbacks"));
columns.add(createColumn("queuedConnections", "Queued Connections"));
columns.add(createColumn("totalErrors", "Total Errors"));
columns.add(createColumn("activeSessions", "Active Sessions"));
columns.add(createColumn("expiredSessions", "Expired Sessions"));
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
tableView.setItems(this.snapshots);
return tableView;
}Example 35
| Project: many-ql-master File: PaginationSample.java View source code |
@Override
public void start(final Stage stage) throws Exception {
fonts = Font.getFamilies().toArray(fonts);
pagination = new Pagination(fonts.length / itemsPerPage(), 0);
pagination.setStyle("-fx-border-color:red;");
pagination.setPageFactory(new Callback<Integer, Node>() {
@Override
public Node call(Integer pageIndex) {
return createPage(pageIndex);
}
});
AnchorPane anchor = new AnchorPane();
AnchorPane.setTopAnchor(pagination, 10.0);
AnchorPane.setRightAnchor(pagination, 10.0);
AnchorPane.setBottomAnchor(pagination, 10.0);
AnchorPane.setLeftAnchor(pagination, 10.0);
anchor.getChildren().addAll(pagination);
Scene scene = new Scene(anchor, 400, 450);
stage.setScene(scene);
stage.setTitle("PaginationSample");
stage.show();
}Example 36
| Project: mephisto_iii-master File: StreamStatusBox.java View source code |
//---------- Helper -------------------------------------------------------
private Node createStatusBox() {
VBox status = new VBox(3);
status.setPadding(new Insets(3, 3, 3, 8));
nameLabel = ComponentUtil.createCustomLabel("", "player-name-label", status);
nameLabel.getStyleClass().remove("label");
titleLabel = ComponentUtil.createCustomLabel("", "player-title-label", status);
titleLabel.getStyleClass().remove("label");
return status;
}Example 37
| Project: metastone-master File: DigitFactory.java View source code |
private static Node getCachedDigitImage(int number, Color color) {
String numberString = String.valueOf(number);
if (numberString.length() == 1) {
char digitToChar = Character.forDigit(number, 10);
ImageView image = new ImageView(digits.get(digitToChar));
applyFontColor(image, color);
return image;
}
HBox layoutPane = new HBox(-4);
for (int i = 0; i < numberString.length(); i++) {
char digitToChar = numberString.charAt(i);
ImageView image = new ImageView(digits.get(digitToChar));
applyFontColor(image, color);
layoutPane.getChildren().add(image);
}
return layoutPane;
}Example 38
| Project: NoticEditor-master File: WebImportController.java View source code |
@Override
public void initialize(URL location, ResourceBundle resources) {
importer = new WebImporter();
importMode = HtmlImportMode.ORIGINAL;
ObservableList<Node> nodes = modesBox.getChildren();
nodes.clear();
final ToggleGroup modesGroup = new ToggleGroup();
for (HtmlImportMode value : HtmlImportMode.values()) {
RadioButton radio = new RadioButton(resources.getString(value.getName()));
if (value == importMode)
radio.setSelected(true);
radio.setOnAction( e -> onModeChanged(value));
radio.setToggleGroup(modesGroup);
nodes.add(radio);
}
pagePreview.getEngine().loadContent(resources.getString("preview"), "text/html");
}Example 39
| Project: OCRaptor-master File: DoughnutChart.java View source code |
private void addInnerCircleIfNotPresent() {
if (getData().size() > 0) {
Node pie = getData().get(0).getNode();
if (pie.getParent() instanceof Pane) {
Pane parent = (Pane) pie.getParent();
if (!parent.getChildren().contains(innerCircle)) {
parent.getChildren().add(innerCircle);
}
}
}
}Example 40
| Project: Offene-Pflege.de-master File: FXTools.java View source code |
/**
* https://community.oracle.com/message/11145722#11145722
*
* @return
*/
public static TitledPane createTitledPane(Pane root, String text, Image icon, Node content, Node... buttons) {
// final VBox root = new VBox();
final TitledPane titledPane = new TitledPane();
titledPane.setText(text);
final HBox buttonBox = new HBox(5);
buttonBox.getChildren().addAll(buttons);
final Label label = new Label();
label.textProperty().bind(titledPane.textProperty());
final AnchorPane title = new AnchorPane();
AnchorPane.setLeftAnchor(label, 0.0);
AnchorPane.setRightAnchor(buttonBox, 0.0);
title.getChildren().addAll(label, buttonBox);
titledPane.setGraphic(title);
titledPane.setContent(content);
titledPane.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
titledPane.setExpanded(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
final Region arrow = (Region) titledPane.lookup(".arrow-button");
title.prefWidthProperty().bind(new DoubleBinding() {
{
super.bind(arrow.widthProperty(), root.widthProperty());
}
@Override
protected double computeValue() {
double breathingSpace = 20;
double value = root.getWidth() - arrow.getWidth() - breathingSpace;
return value;
}
});
}
});
return titledPane;
}Example 41
| Project: sea-master File: Main.java View source code |
private void addDragListeners(final Node n, Stage primaryStage) {
n.setOnMousePressed(( mouseEvent) -> {
this.x = n.getScene().getWindow().getX() - mouseEvent.getScreenX();
this.y = n.getScene().getWindow().getY() - mouseEvent.getScreenY();
});
n.setOnMouseDragged(( mouseEvent) -> {
primaryStage.setX(mouseEvent.getScreenX() + this.x);
primaryStage.setY(mouseEvent.getScreenY() + this.y);
});
}Example 42
| Project: skadi-master File: JavaFXUtil.java View source code |
public static ScrollBar getVerticalScrollbar(final TableView<?> table) {
ScrollBar result = null;
for (final Node n : table.lookupAll(".scroll-bar")) {
if (n instanceof ScrollBar) {
final ScrollBar bar = (ScrollBar) n;
if (bar.getOrientation().equals(Orientation.VERTICAL)) {
result = bar;
}
}
}
return result;
}Example 43
| Project: spring-framework-issues-master File: FormattedTableCellFactory.java View source code |
@Override
protected void updateItem(T item, boolean empty) {
if (item == getItem()) {
return;
}
super.updateItem((T) item, empty);
if (item == null) {
super.setText(null);
super.setGraphic(null);
} else if (format != null) {
super.setText(format.format(item));
} else if (item instanceof Node) {
super.setText(null);
super.setGraphic((Node) item);
} else {
super.setText(item.toString());
super.setGraphic(null);
}
}Example 44
| Project: SyncNotes-master File: RegisterController.java View source code |
@FXML
protected void button_start(ActionEvent event) {
Node source = (Node) event.getSource();
Stage stage = (Stage) source.getScene().getWindow();
setStatus("Loading...");
ParseQuery<ParseObject> query = ParseQuery.getQuery("_Installation");
query.whereEqualTo("installationId", textfield_uuid.getText());
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> arg0, ParseException arg1) {
if (arg0 == null) {
setStatus("Error: UUID not found!");
} else {
setStatus("Success! Working...");
// Save UUID
new FileHandler().add(textfield_uuid.getText());
// Load note data
final ParseQuery<Note> query = ParseQuery.getQuery("Note");
query.whereEqualTo("ownerID", textfield_uuid.getText());
query.findInBackground(new FindCallback<Note>() {
@Override
public void done(List<Note> arg0, ParseException arg1) {
for (Note note : arg0) {
Database database = new Database();
if (database.contains(note.getID())) {
database.update(note, 0, 0, false);
} else {
database.addNote(note);
}
}
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
stage.close();
new NotesList().start(new Stage());
new AutoUpdater().start();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
});
}
}
});
}Example 45
| Project: Topsoil-master File: JavaFXDisplayable.java View source code |
@Override
protected Void call() throws Exception {
Node node = displayAsNode();
Parent parent;
// cast/wrap node as appropriate
if (node instanceof Parent) {
parent = (Parent) node;
} else {
parent = new VBox(node);
}
Scene scene = new Scene(parent);
jfxPanel.setScene(scene);
return null;
}Example 46
| Project: CausticSDK-master File: ViewStackController.java View source code |
protected void setToggleBar(Parent value) {
toggleBar = value;
// stop double selections
for (Node child : toggleBar.getChildrenUnmodifiable()) {
final ToggleButton button = (ToggleButton) child;
button.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
public void handle(final MouseEvent e) {
if (button.isSelected()) {
e.consume();
}
}
});
button.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
public void handle(final KeyEvent e) {
if (button.isSelected() && e.getCode() == KeyCode.SPACE) {
e.consume();
}
}
});
}
}Example 47
| Project: CloudTrailViewer-master File: XYChartController.java View source code |
public void finishedLoading(boolean reload) {
if (reload) {
chart.getData().clear();
}
xAxis.setLabel(widget.getSeriesField());
yAxis.setLabel("Count");
List<Map.Entry<String, Integer>> topEvents = getTopEvents();
if (topEvents != null) {
categories.clear();
for (Map.Entry<String, Integer> entry : topEvents) {
String seriesName = entry.getKey();
categories.add(seriesName);
XYChart.Series<String, Number> series = new XYChart.Series<>();
series.setName(seriesName);
series.getData().add(new XYChart.Data<>(seriesName, entry.getValue()));
chart.getData().add(series);
}
for (XYChart.Series<String, Number> serie : chart.getData()) {
for (XYChart.Data<String, Number> item : serie.getData()) {
item.getNode().setOnMousePressed((MouseEvent event) -> eventTableService.setTableEvents(singleSeries.get(serie.getName())));
Node node = item.getNode();
Tooltip t = new Tooltip(serie.getName() + " : " + item.getYValue());
Tooltip.install(node, t);
}
}
}
xAxis.setCategories(FXCollections.observableArrayList(categories));
}Example 48
| Project: code-of-gotham-master File: LayoutManager.java View source code |
public void moveCityChildrenBackToCity(AbstractElement element) {
ObservableList<Node> children = element.getChildren();
for (Node child : children) {
if (child instanceof AbstractElement) {
AbstractElement item = (AbstractElement) child;
double xOffset = item.getWidth() / 2;
double zOffset = item.getWidth() / 2;
item.getShape().setTranslateX(-xOffset);
item.getShape().setTranslateZ(-zOffset);
moveCityChildrenBackToCity(item);
}
}
}Example 49
| Project: ColloidUI-master File: FightTree.java View source code |
protected void init(Comparator<Actor> comparator) {
ArrayList<Actor> fightActors = new ArrayList<Actor>(fight.getActors());
Collections.sort(fightActors, comparator);
Iterator<Actor> iterActor = fightActors.iterator();
while (iterActor.hasNext()) {
Actor actor = iterActor.next();
String vps = "";
Date endTime = fight.getFinish();
if (endTime == null) {
endTime = new Date();
}
long duration = endTime.getTime() - fight.getStart().getTime();
if (duration > 100) {
vps = Util.valuePerSecond(valueDone(actor, fight), duration);
double valueDone = valueDone(actor, fight);
String info = String.format("%s: %s(%s)", actor.getName(), valueDone, vps);
TreeItem<String> itemActor = new TreeItem<String>(info);
ArrayList<Ability> actorAbilities = getAbilities(actor);
Collections.sort(actorAbilities, getAbilityComparator(actor));
Iterator<Ability> iterAbility = actorAbilities.iterator();
while (iterAbility.hasNext()) {
Ability ability = iterAbility.next();
if (ability.name() != null) {
//final Node abilityIcon = new ImageView(new Image(getClass().getResourceAsStream("/img/small/dark_field.jpg")));
itemActor.getChildren().add(new TreeItem<String>(abilityInfo(ability, valueDone), ability.getIcon()));
}
}
item.getChildren().add(itemActor);
}
}
}Example 50
| Project: e4-rendering-master File: TrimBarRenderer.java View source code |
@Override
public void processContents(MElementContainer<MUIElement> container) {
System.out.println("TrimBarRenderer.processContents(): " + container.getElementId());
IPresentationEngine renderer = (IPresentationEngine) context.get(IPresentationEngine.class.getName());
ToolBar toolbar = (ToolBar) container.getWidget();
boolean isFirst = true;
toolbar.getItems().removeAll(toolbar.getItems());
for (MUIElement element : container.getChildren()) {
Node node = (Node) element.getWidget();
if (node != null) {
if (!isFirst) {
toolbar.getItems().add(new Separator());
}
try {
toolbar.getItems().add(node);
} catch (Exception e) {
e.printStackTrace();
}
isFirst = false;
}
}
}Example 51
| Project: grantmaster-master File: ProjectListTabController.java View source code |
public void handleOpenButtonAction(ActionEvent event) throws IOException {
Node sourceButton = (Node) event.getSource();
EditButtonTableCell sourceCell = (EditButtonTableCell) sourceButton.getProperties().get("tableCell");
ProjectWrapper sourceProjectWrapper = (ProjectWrapper) sourceCell.getEntityWrapper();
if (sourceProjectWrapper.getState() != RowEditState.SAVED) {
return;
}
parent.addTab(createProjectTab(sourceProjectWrapper.getEntity()));
}Example 52
| Project: itol-master File: AttachmentsContextMenu.java View source code |
@Override
public void show(Node anchor, double screenX, double screenY) {
this.node = anchor;
if (screenX < 0 || screenY < 0) {
Bounds bounds = node.getBoundsInLocal();
Bounds screenBounds = node.localToScreen(bounds);
int x = (int) screenBounds.getMinX();
int y = (int) screenBounds.getMinY();
int width = (int) screenBounds.getWidth();
int height = (int) screenBounds.getHeight();
screenX = x + width / 2;
screenY = y + height / 2;
}
menuPaste.setDisable(true);
for (DataFlavor flavor : acceptedClipboardDataFlavors) {
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (transferable.isDataFlavorSupported(flavor)) {
menuPaste.setDisable(false);
break;
}
}
super.show(anchor, screenX, screenY);
}Example 53
| Project: jabref-master File: RecursiveTreeItem.java View source code |
private boolean showNode(T t) {
if (filter.get() == null) {
return true;
}
if (filter.get().test(t)) {
// Node is directly matched -> so show it
return true;
}
// Are there children (or children of children...) that are matched? If yes we also need to show this node
return childrenFactory.call(t).stream().anyMatch(this::showNode);
}Example 54
| Project: javafx-ws-client-master File: TabSettingsController.java View source code |
/**
* Save current settings state action
*/
@FXML
private void saveSettings() {
// Enable loader
mainController.setProgressVisible(true);
// Save new settings in database
boolean status = dataBase.setSettings(new Settings(((Number) fontSlider.getValue()).intValue(), chWrap.isSelected(), cbAutoScroll.isSelected(), cbWsSslValidate.isSelected()));
if (status) {
Settings settings = dataBase.getSettings();
// Set font size for all messages
for (Tab tab : mainController.getTabPane().getTabs()) {
if (tab instanceof WsMessageTab) {
Node tabNode = tab.getContent();
if (tabNode instanceof GridPane) {
for (Node node : ((GridPane) tabNode).getChildren()) {
if (node instanceof TextArea || node instanceof ListView) {
node.setStyle(String.format(FONT_SIZE_FORMAT, settings.getFontSize()));
node.applyCss();
}
}
}
}
}
// Show successful dialog
new Dialogs().getInfoDialog("Settings save successful");
} else {
new Dialogs().getWarningDialog("Error save settings. See log.");
}
// Disable loader
mainController.setProgressVisible(false);
}Example 55
| Project: JFXMaterial-master File: Card.java View source code |
public void changeContent(Node n) {
Circle circle = new Circle();
if (!isSecondAnimRunning) {
double minRad;
if (getPrefHeight() > getPrefWidth()) {
minRad = getPrefWidth();
} else {
minRad = getPrefHeight();
}
circle.setRadius(minRad / 3);
anim_var2 = (int) (minRad / 3);
incrementAmount = (int) (minRad / 60);
circle.setCenterX(getPrefWidth() / 2);
circle.setCenterY(getPrefHeight() / 2);
getChildren().add(n);
n.setClip(circle);
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(10), e -> {
isSecondAnimRunning = true;
anim_var2 += incrementAmount;
circle.setRadius(anim_var2);
}));
timeline.setCycleCount((int) ((minRad * 2.0 / 3.0) / incrementAmount));
timeline.setAutoReverse(false);
timeline.setOnFinished( e -> {
n.setClip(null);
isSecondAnimRunning = false;
if (getChildren().size() != 1) {
getChildren().remove(0, getChildren().size() - 1);
}
});
timeline.play();
}
}Example 56
| Project: LibFX-master File: SceneGraphNavigator.java View source code |
@Override
public OptionalInt getChildIndex(Node node) {
Objects.requireNonNull(node, "The argument 'node' must not be null.");
Parent parent = node.getParent();
if (parent == null)
return OptionalInt.empty();
int childIndex = parent.getChildrenUnmodifiable().indexOf(node);
if (childIndex == -1)
return OptionalInt.empty();
return OptionalInt.of(childIndex);
}Example 57
| Project: opencards-master File: SwingFXWebView.java View source code |
@Override
public void run() {
Stage stage;
WebView browser;
stage = new Stage();
stage.setTitle("Hello Java FX");
stage.setResizable(true);
Group root = new Group();
Scene scene = new Scene(root, 80, 20);
stage.setScene(scene);
// Set up the embedded browser:
browser = new WebView();
webEngine = browser.getEngine();
// webEngine.load("http://heise.de");
// ScrollPane scrollPane = new ScrollPane();
// scrollPane.setContent(browser);
webEngine.loadContent("<b>asdf</b>");
// root.getChildren().addAll(scrollPane);
// scene.setRoot(root);
// stage.setScene(scene);
ObservableList<Node> children = root.getChildren();
children.add(browser);
jfxPanel.setScene(scene);
}Example 58
| Project: PhysLayout-master File: PhysicalVBox.java View source code |
@Override
protected void layoutChildren() {
simulation.stopSimulation();
List<Node> managedChildren = getManagedChildren();
int n = managedChildren.size();
// Store the old positions.
Point2D[] positions = new Point2D[n];
for (int i = 0; i < n; i++) {
Node child = managedChildren.get(i);
positions[i] = child.localToParent(Point2D.ZERO);
}
// Perform the layout.
super.layoutChildren();
// Determine the new positions, and translate the nodes to their old positions.
for (int i = 0; i < n; i++) {
Node child = managedChildren.get(i);
Point2D newPosition = new Point2D(child.getLayoutX(), child.getLayoutY());
child.setTranslateX(positions[i].getX() - newPosition.getX());
child.setTranslateY(positions[i].getY() - newPosition.getY());
positions[i] = newPosition;
}
// Reconnect the nodes.
layout.clearAllConnections();
layout.clearAllTethers();
for (int i = 0; i < n; i++) {
layout.addTether(managedChildren.get(i), new Tether(0, strength, positions[i]));
for (int j = 0; j < i; j++) {
double distance = positions[i].distance(positions[j]);
layout.addConnection(managedChildren.get(i), managedChildren.get(j), new Spring(distance, strength));
}
}
simulation.startSimulation();
}Example 59
| Project: RegexGolf2-master File: RequirementCellUI.java View source code |
//TODO move all the images into a different directory
private void initLayout() {
_editLabel.editIconAppearsProperty().bind(this.hoverProperty());
Node editLabelNode = _editLabel.getUINode();
AnchorPane.setLeftAnchor(editLabelNode, 0.0);
AnchorPane.setTopAnchor(editLabelNode, 0.0);
AnchorPane.setBottomAnchor(editLabelNode, 0.0);
_imageView.setFitHeight(25);
_imageView.setFitWidth(25);
AnchorPane.setTopAnchor(_imageView, 0.0);
AnchorPane.setRightAnchor(_imageView, 0.0);
_rootNode.getChildren().add(editLabelNode);
_rootNode.getChildren().add(_imageView);
//Setup correct scaling
this.setPrefWidth(0);
_rootNode.prefWidthProperty().bind(this.widthProperty());
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}Example 60
| Project: ResponsiveFX-master File: ResponsiveHandler.java View source code |
private static void updateManagedProperty(Node n, DeviceType type) {
// first time we've set this invisible => store the preset
if (!n.getProperties().containsKey(PROP_MANAGED_STATE)) {
n.getProperties().put(PROP_MANAGED_STATE, n.isManaged());
}
// don't track changes through this
n.managedProperty().removeListener(MANAGED_LISTENER);
// If it's visible we use the stored value for "managed" property
n.setManaged(n.isVisible() ? (Boolean) n.getProperties().get(PROP_MANAGED_STATE) : false);
// need to track changes through API
n.managedProperty().addListener(MANAGED_LISTENER);
}Example 61
| Project: SlideshowFX-master File: SnippetContentExtensionController.java View source code |
@Override
public void initialize(URL location, ResourceBundle resources) {
OSGiManager.getInstance().getInstalledServices(ISnippetExecutor.class).stream().sorted(( snippet1, snippet2) -> snippet1.getCode().compareTo(snippet2.getCode())).forEach( ref -> this.language.getItems().add(ref));
this.language.setCellFactory((ListView<ISnippetExecutor> param) -> {
final ListCell<ISnippetExecutor> cell = new SnippetExecutorListCell();
return cell;
});
this.language.setButtonCell(new SnippetExecutorListCell());
this.language.valueProperty().addListener(( languageValue, oldLanguage, newLanguage) -> {
// Clear the code snippet for the new language
this.codeSnippet.getProperties().clear();
this.codeSnippet.setCode(null);
if (newLanguage == null)
this.advancedOptions.setContent(null);
else {
final Node codeSnippetUI = newLanguage.getUI(codeSnippet);
if (codeSnippetUI == null)
this.advancedOptions.setContent(null);
else {
final TitledPane titledPane = new TitledPane("Advanced options", codeSnippetUI);
titledPane.setPrefWidth(250);
titledPane.setPadding(new Insets(0, 5, 0, 0));
titledPane.setExpanded(true);
titledPane.setCollapsible(false);
this.advancedOptions.setContent(titledPane);
}
}
});
// Each time the code in the ZoomTextArea changes, reflect it to the CodeSnippet
this.code.textProperty().addListener(( textValue, oldText, newText) -> {
if (newText == null || newText.isEmpty())
this.codeSnippet.setCode(null);
else
this.codeSnippet.setCode(newText);
});
}Example 62
| Project: socius-master File: LoginController.java View source code |
@FXML
public void cadastro(ActionEvent e) {
try {
Node source = (Node) e.getSource();
Stage stage = (Stage) source.getScene().getWindow();
stage.close();
redirect = new ClientBoot();
redirect.telaCadastro();
redirect.start(new Stage());
} catch (Exception ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
}
}Example 63
| Project: speedment-master File: PropertyLayout.java View source code |
/**
* Adds a new editor item to the layout. New items are added at the
* bottom.
*
* @param item the item
*/
void addItem(PropertyEditor.Item item) {
final Node label = item.createLabel();
label.getStyleClass().add("property-label");
GridPane.setValignment(label, VPos.TOP);
final Node editor = item.createEditor();
editor.getStyleClass().add("property-editor");
GridPane.setValignment(editor, VPos.CENTER);
addRow(index.getAndIncrement(), label, editor);
items.add(item);
}Example 64
| Project: svg2fx-master File: TreeBuilderAttributeVisitorFactory.java View source code |
public static StylePropertyBuilder createBuilder(Node node, DefsBuilder defs) {
if (node instanceof Group) {
return new GroupStylePropertyBuilder(node, defs);
} else if (node instanceof Path) {
return new PathStylePropertyBuilder(node, defs);
} else if (node instanceof Line) {
return new LineStylePropertyBuilder(node, defs);
} else if (node instanceof Rectangle) {
return new RectangleStylePropertyBuilder(node, defs);
} else if (node instanceof Circle) {
return new CircleStylePropertyBuilder(node, defs);
} else if (node instanceof Ellipse) {
return new EllipseStylePropertyBuilder(node, defs);
} else if (node instanceof Polyline) {
return new PolylineStylePropertyBuilder(node, defs);
} else {
throw new java.lang.IllegalArgumentException("Unsupportet node type.");
}
}Example 65
| Project: xapi-master File: UiElementJavaFx.java View source code |
@Override
public void insertAdjacent(ElementPosition pos, UiElementJavaFx child) {
final Node node = element();
final ObservableList<Node> children;
switch(pos) {
// Thus, we must be attached to a parent, and insert into it's children nodes
case BEFORE_BEGIN:
case AFTER_END:
final UiElementJavaFx parent = getParent();
children = parent.getInsertionPoint();
final int myPos = children.indexOf(node);
assert myPos != -1 : "Trying to insert a child adjacent to a node that is not in its parent's insertion point";
if (pos == ElementPosition.BEFORE_BEGIN) {
children.add(myPos, child.element());
} else {
children.add(myPos + 1, child.element());
}
child.setParent(parent);
break;
case AFTER_BEGIN:
case BEFORE_END:
children = getInsertionPoint();
if (pos == ElementPosition.AFTER_BEGIN) {
children.add(0, child.element());
} else {
children.add(children.size(), child.element());
}
child.setParent(ui());
break;
default:
throw new IllegalStateException("Unhandled injection position " + pos + " in " + this);
}
}Example 66
| Project: XR3Player-master File: TransitioningTabPane.java View source code |
@Override
public void start(Stage primaryStage) {
TabPane tabPane = new TabPane();
Tab tab1 = new Tab("Tab 1");
Tab tab2 = new Tab("Tab 2");
Tab tab3 = new Tab("Tab 1");
Tab tab4 = new Tab("Tab 2");
Tab tab5 = new Tab("Tab 1");
Tab tab6 = new Tab("Tab 2");
tabPane.getTabs().addAll(tab1, tab2, tab3, tab4, tab5, tab6);
List<String> list = new ArrayList<String>();
Map<Tab, Node> tabContent = new HashMap<>();
tabContent.put(tab1, createTab1Content());
tabContent.put(tab2, createTab2Content());
tabContent.put(tab3, createTab1Content());
tabContent.put(tab4, createTab2Content());
tabContent.put(tab5, createTab1Content());
tabContent.put(tab6, createTab2Content());
// Initial state:
tab1.setContent(tabContent.get(tab1));
tab2.setContent(tabContent.get(tab2));
tab3.setContent(tabContent.get(tab3));
tab4.setContent(tabContent.get(tab4));
tab5.setContent(tabContent.get(tab5));
tab6.setContent(tabContent.get(tab6));
tabPane.getSelectionModel().select(tab1);
// State change manager:
tabPane.getSelectionModel().selectedItemProperty().addListener(( obs, oldTab, newTab) -> {
// oldTab.setContent(null);
Node oldContent = tabContent.get(oldTab);
Node newContent = tabContent.get(newTab);
newTab.setContent(oldContent);
ScaleTransition fadeOut = new ScaleTransition(Duration.seconds(0.1), oldContent);
fadeOut.setFromX(1);
fadeOut.setFromY(1);
fadeOut.setToX(0);
fadeOut.setToY(0);
ScaleTransition fadeIn = new ScaleTransition(Duration.seconds(0.2), newContent);
fadeIn.setFromX(0);
fadeIn.setFromY(0);
fadeIn.setToX(1);
fadeIn.setToY(1);
fadeOut.setOnFinished( event -> newTab.setContent(newContent));
SequentialTransition crossFade = new SequentialTransition(fadeOut, fadeIn);
crossFade.play();
});
BorderPane root = new BorderPane(tabPane);
Scene scene = new Scene(root, 600, 600);
primaryStage.setScene(scene);
primaryStage.show();
}Example 67
| Project: aima-java-master File: SimulationPaneBuilder.java View source code |
/**
* Adds a toolbar, a state view, and a status label to the provided pane and returns
* a controller class instance. The toolbar contains combo boxes to control parameter settings
* and buttons for simulation control. The controller class instance handles user events and provides
* access to user settings (parameter settings, simulation speed, status text, ...).
*/
public SimulationPaneCtrl getResultFor(BorderPane pane) {
List<ComboBox<String>> combos = new ArrayList<>();
parameters.add(createSimSpeedParam());
for (Parameter param : parameters) {
ComboBox<String> combo = new ComboBox<>();
combo.setId(param.getName());
combo.getItems().addAll(param.getValueNames());
combo.getSelectionModel().select(param.getDefaultValueIndex());
combos.add(combo);
}
Button simBtn = new Button();
Node[] tools = new Node[combos.size() + 2];
for (int i = 0; i < combos.size() - 1; i++) tools[i] = combos.get(i);
tools[combos.size() - 1] = new Separator();
tools[combos.size() + 0] = combos.get(combos.size() - 1);
tools[combos.size() + 1] = simBtn;
ToolBar toolBar = new ToolBar(tools);
Label statusLabel = new Label();
statusLabel.setMaxWidth(Double.MAX_VALUE);
statusLabel.setAlignment(Pos.CENTER);
statusLabel.setFont(Font.font(16));
pane.setTop(toolBar);
if (stateView.isPresent()) {
if (stateView.get() instanceof Canvas) {
// make canvas resizable
Canvas canvas = (Canvas) stateView.get();
Pane canvasPane = new Pane();
canvasPane.getChildren().add(canvas);
canvas.widthProperty().bind(canvasPane.widthProperty());
canvas.heightProperty().bind(canvasPane.heightProperty());
pane.setCenter(canvasPane);
pane.setStyle("-fx-background-color: white");
} else
pane.setCenter(stateView.get());
}
pane.setBottom(statusLabel);
if (!initMethod.isPresent())
throw new IllegalStateException("No initialization method defined.");
if (!simMethod.isPresent())
throw new IllegalStateException("No simulation method defined.");
return new SimulationPaneCtrl(parameters, combos, initMethod.get(), simMethod.get(), simBtn, statusLabel);
}Example 68
| Project: aima-master File: SimulationPaneBuilder.java View source code |
/**
* Adds a toolbar, a state view, and a status label to the provided pane and returns
* a controller class instance. The toolbar contains combo boxes to control parameter settings
* and buttons for simulation control. The controller class instance handles user events and provides
* access to user settings (parameter settings, simulation speed, status text, ...).
*/
public SimulationPaneCtrl getResultFor(BorderPane pane) {
List<ComboBox<String>> combos = new ArrayList<>();
parameters.add(createSimSpeedParam());
for (Parameter param : parameters) {
ComboBox<String> combo = new ComboBox<>();
combo.setId(param.getName());
combo.getItems().addAll(param.getValueNames());
combo.getSelectionModel().select(param.getDefaultValueIndex());
combos.add(combo);
}
Button simBtn = new Button();
Node[] tools = new Node[combos.size() + 2];
for (int i = 0; i < combos.size() - 1; i++) tools[i] = combos.get(i);
tools[combos.size() - 1] = new Separator();
tools[combos.size() + 0] = combos.get(combos.size() - 1);
tools[combos.size() + 1] = simBtn;
ToolBar toolBar = new ToolBar(tools);
Label statusLabel = new Label();
statusLabel.setMaxWidth(Double.MAX_VALUE);
statusLabel.setAlignment(Pos.CENTER);
statusLabel.setFont(Font.font(16));
pane.setTop(toolBar);
if (stateView.isPresent()) {
if (stateView.get() instanceof Canvas) {
// make canvas resizable
Canvas canvas = (Canvas) stateView.get();
Pane canvasPane = new Pane();
canvasPane.getChildren().add(canvas);
canvas.widthProperty().bind(canvasPane.widthProperty());
canvas.heightProperty().bind(canvasPane.heightProperty());
pane.setCenter(canvasPane);
pane.setStyle("-fx-background-color: white");
} else
pane.setCenter(stateView.get());
}
pane.setBottom(statusLabel);
if (!initMethod.isPresent())
throw new IllegalStateException("No initialization method defined.");
if (!simMethod.isPresent())
throw new IllegalStateException("No simulation method defined.");
return new SimulationPaneCtrl(parameters, combos, initMethod.get(), simMethod.get(), simBtn, statusLabel);
}Example 69
| Project: bikingFX-master File: GalleryPictureTableCell.java View source code |
void displayImage(final Image image) {
final Node currentContent = this.container.getChildren().get(0);
if (!(currentContent instanceof ProgressIndicator)) {
final ImageView imageView = (ImageView) currentContent;
imageView.setImage(image);
} else {
final ImageView imageView = new ImageView(image);
imageView.fitWidthProperty().bind(this.container.widthProperty());
imageView.setPreserveRatio(true);
imageView.setCache(true);
this.container.getChildren().set(0, imageView);
}
}Example 70
| Project: bitcoinj-watcher-service-master File: GuiUtils.java View source code |
public static void blurOut(Node node) {
GaussianBlur blur = new GaussianBlur(0.0);
node.setEffect(blur);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
}Example 71
| Project: blackmarket-master File: BlackmarketTextField.java View source code |
private void setupClearButtonField(TextField inputField, ObjectProperty<Node> rightProperty) {
//$NON-NLS-1$
inputField.getStyleClass().add("clearable-field");
Region clearButton = new Region();
//$NON-NLS-1$
clearButton.getStyleClass().addAll("graphic");
StackPane clearButtonPane = new StackPane(clearButton);
//$NON-NLS-1$
clearButtonPane.getStyleClass().addAll("clear-button");
clearButtonPane.setOpacity(0.0);
clearButtonPane.setCursor(Cursor.DEFAULT);
clearButtonPane.setOnMouseReleased( e -> inputField.clear());
clearButtonPane.managedProperty().bind(inputField.editableProperty());
clearButtonPane.visibleProperty().bind(inputField.editableProperty());
rightProperty.set(clearButtonPane);
final FadeTransition fader = new FadeTransition(FADE_DURATION, clearButtonPane);
fader.setCycleCount(1);
inputField.textProperty().addListener(new InvalidationListener() {
@Override
public void invalidated(Observable arg0) {
String text = inputField.getText();
boolean isTextEmpty = text == null || text.isEmpty();
boolean isButtonVisible = fader.getNode().getOpacity() > 0;
if (isTextEmpty && isButtonVisible) {
setButtonVisible(false);
} else if (!isTextEmpty && !isButtonVisible) {
setButtonVisible(true);
}
}
private void setButtonVisible(boolean visible) {
fader.setFromValue(visible ? 0.0 : 1.0);
fader.setToValue(visible ? 1.0 : 0.0);
fader.play();
}
});
}Example 72
| Project: Cardshifter-master File: ZoneView.java View source code |
//This causes a Null Pointer Exception, don't know why
public void highlightCard(int cardId) {
Pane pane = this.getPane(cardId).getRootPane();
List<Node> children = pane.getChildren();
for (Node node : children) {
if (node.getId().equals("backgroundRectangle")) {
Rectangle rectangle = (Rectangle) node;
rectangle.setFill(Color.YELLOW);
}
}
}Example 73
| Project: cirqwizard-master File: PopOverController.java View source code |
protected Node createCloseIcon() {
Group group = new Group();
//$NON-NLS-1$
group.getStyleClass().add("graphics");
Circle circle = new Circle();
//$NON-NLS-1$
circle.getStyleClass().add("circle");
circle.setRadius(6);
circle.setCenterX(6);
circle.setCenterY(6);
circle.setFill(Color.GRAY);
circle.setEffect(new InnerShadow(BlurType.GAUSSIAN, Color.color(0, 0, 0, 0.2), 3, 0.5, 1.0, 1.0));
group.getChildren().add(circle);
Line line1 = new Line();
//$NON-NLS-1$
line1.getStyleClass().add("line");
line1.setStartX(4);
line1.setStartY(4);
line1.setEndX(8);
line1.setEndY(8);
line1.setStroke(Color.WHITE);
line1.setStrokeWidth(2);
group.getChildren().add(line1);
Line line2 = new Line();
//$NON-NLS-1$
line2.getStyleClass().add("line");
line2.setStartX(8);
line2.setStartY(4);
line2.setEndX(4);
line2.setEndY(8);
line2.setStroke(Color.WHITE);
line2.setStrokeWidth(2);
group.getChildren().add(line2);
return group;
}Example 74
| Project: cssfx-master File: CSSFXTesterApp.java View source code |
private Node createButtonBar() {
FlowPane fp = new FlowPane();
fp.getStyleClass().addAll("button-bar", "bottom");
fp.getChildren().addAll(new Button("Action"), new Button("Action"));
String buttonBarCSSUri = getClass().getResource("bottom.css").toExternalForm();
fp.getStylesheets().add(buttonBarCSSUri);
return fp;
}Example 75
| Project: Cymric-master File: Commons.java View source code |
/**
* Create a new custom pane from FXML data. <br>
* Restraints: Name and package of FXML file should be the same as
* <code>resourceClass</code>. <code>resourceClass</code> should extend
* <code>BorderPane</code> or one of its descendents.
*
* @param resourceClass Pane class in which data to be loaded.
* @return Pane type object containing loaded node.
*/
public static Pane loadPaneFromFXML(Class resourceClass) throws IOException {
//init loader
FXMLLoader loader = new FXMLLoader();
loader.setLocation(resourceClass.getResource(resourceClass.getSimpleName() + ".fxml"));
//load fxml
Node node = (Node) loader.load();
BorderPane control = (BorderPane) loader.getController();
BorderPane.setAlignment(node, Pos.CENTER);
control.setCenter(node);
return control;
}Example 76
| Project: darkcoinj-master File: GuiUtils.java View source code |
public static void blurOut(Node node) {
GaussianBlur blur = new GaussianBlur(0.0);
node.setEffect(blur);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
}Example 77
| Project: EclipseDay-Presentation-master File: HelloToulouse.java View source code |
/**
* {@inheritDoc}
*
* @throws IOException
*/
@Override
public void start(final Stage primaryStage) throws IOException {
// Build the root node
// StackPaneBuilder.create().build();
final StackPane parent = new StackPane();
// Build the scene
final Scene scene = SceneBuilder.create().root(parent).width(400).height(300).fill(Color.CORAL).build();
// Build the hello label
final Label label = LabelBuilder.create().text("Hello Toulouse").textFill(// .style("-fx-font-size:24px")
Color.ANTIQUEWHITE).build();
// Manage stylesheet
label.getStyleClass().add("icon");
scene.getStylesheets().add("style.css");
// Add an fxml node
final Node fxmlNode = (Node) FXMLLoader.load(Thread.currentThread().getContextClassLoader().getResource("powered.fxml"));
final String content = "Lorem ipsum sin dolor amut";
final Text text = new Text(10, 20, "");
final Animation animation = new Transition() {
{
setCycleDuration(Duration.millis(2000));
}
@Override
protected void interpolate(final double frac) {
final int length = content.length();
final int n = Math.round(length * (float) frac);
text.setText(content.substring(0, n));
}
};
// Add visual components to the root node
parent.getChildren().addAll(label, fxmlNode, text);
// Manage layout constraints
StackPane.setAlignment(parent.getChildren().get(0), Pos.CENTER);
StackPane.setAlignment(parent.getChildren().get(1), Pos.BOTTOM_RIGHT);
// Display the default window
primaryStage.setTitle("JavaFX Demo");
primaryStage.setScene(scene);
primaryStage.show();
scene.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() {
@Override
public void handle(final KeyEvent arg0) {
System.out.println("filter1");
}
});
scene.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() {
@Override
public void handle(final KeyEvent arg0) {
System.out.println("filter2");
}
});
scene.addEventHandler(KeyEvent.ANY, new EventHandler<KeyEvent>() {
@Override
public void handle(final KeyEvent arg0) {
System.out.println("handler");
}
});
animation.play();
}Example 78
| Project: FXGL-master File: CustomMenuBackgroundSample.java View source code |
@NotNull
@Override
public FXGLMenu newMainMenu(@NotNull GameApplication app) {
return new FXGLDefaultMenu(app, MenuType.MAIN_MENU) {
@Override
protected Node createBackground(double width, double height) {
return FXGL.getAssetLoader().loadTexture("custom_bg.png");
}
@Override
protected Node createTitleView(String title) {
return new Text("");
}
};
}Example 79
| Project: FXyz-master File: Cones.java View source code |
@Override
protected Node buildControlPanel() {
NumberSliderControl divsSlider = ControlFactory.buildNumberSlider(null, .01D, 200D);
divsSlider.getSlider().setMinorTickCount(10);
divsSlider.getSlider().setMajorTickUnit(0.5);
divsSlider.getSlider().setBlockIncrement(0.01d);
NumberSliderControl heightSlider = ControlFactory.buildNumberSlider(null, .01D, 200D);
heightSlider.getSlider().setMinorTickCount(10);
heightSlider.getSlider().setMajorTickUnit(0.5);
heightSlider.getSlider().setBlockIncrement(0.01d);
NumberSliderControl radSlider = ControlFactory.buildNumberSlider(null, .01D, 200D);
radSlider.getSlider().setMinorTickCount(10);
radSlider.getSlider().setMajorTickUnit(0.5);
radSlider.getSlider().setBlockIncrement(0.01d);
ControlCategory geomControls = ControlFactory.buildCategory("Geometry");
//geomControls.addControls(widthSlider,heightSlider,depthSlider,levelSlider);
this.controlPanel = ControlFactory.buildControlPanel(ControlFactory.buildMeshViewCategory(this.drawMode, this.culling), geomControls, ControlFactory.buildTextureMeshCategory(this.textureType, this.colors, null, this.textureImage, this.useBumpMap, this.bumpScale, this.bumpFineScale, this.invert, this.patterns, this.pattScale, this.specColor, this.specularPower, this.dens, this.func));
return this.controlPanel;
}Example 80
| Project: igv-master File: Cravat.java View source code |
private static void initFX(JFXPanel fxPanel, JsonObject jsonObject) {
GridPane gridPane = new GridPane();
gridPane.setHgap(5);
gridPane.setVgap(5);
ScrollPane scrollPane = new ScrollPane(gridPane);
Scene scene = new Scene(scrollPane);
int row = 1;
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
String key = entry.getKey();
String value = entry.getValue().getAsString();
final Label keyLabel = new Label(key);
Node valueLabel;
if ("dbSNP".equals(key)) {
String link = "https://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?searchType=adhoc_search&type=rs&rs=" + value;
valueLabel = new Hyperlink(value);
((Hyperlink) valueLabel).setOnAction( event -> {
try {
BrowserLauncher.openURL(link);
} catch (IOException e) {
e.printStackTrace();
}
});
} else {
valueLabel = new Label(value);
}
StackPane keyPane = new StackPane(keyLabel);
keyPane.setAlignment(Pos.CENTER_LEFT);
StackPane valuePane = new StackPane(valueLabel);
valuePane.setAlignment(Pos.CENTER_LEFT);
if (row % 2 == 0) {
keyPane.setStyle("-fx-background-color: #FFFFFF;");
valuePane.setStyle("-fx-background-color: #FFFFFF;");
}
gridPane.add(keyPane, 1, row);
gridPane.add(valuePane, 2, row);
row++;
}
fxPanel.setScene(scene);
}Example 81
| Project: JacpFX-demos-master File: ChatWindowComponent.java View source code |
@Override public Node postHandle(final Node arg0, final Message<Event, Object> message) { // runs in FX application thread if (message.isMessageBodyTypeOf(ChatMessage.class)) { ChatMessage chatMessage = message.getTypedMessageBody(ChatMessage.class); main.getChildren().add(new ChatMessageRight(chatMessage.getSourceName(), chatMessage.getMessage())); } else if (message.isMessageBodyTypeOf(User.class)) { current = message.getTypedMessageBody(User.class); } else if (message.isMessageBodyTypeOf(LoginMessage.class)) { myUser = message.getTypedMessageBody(LoginMessage.class).getUser(); } return null; }
Example 82
| Project: JacpFX-misc-master File: ComponentLeft.java View source code |
/**
* create the UI on first call
*
* @return
*/
private Node createUI() {
final VBox main = new VBox();
main.setSpacing(10);
main.setPadding(new Insets(0, 20, 10, 20));
final ManagedFragmentHandler<DialogFragment> handler = context.getManagedFragmentHandler(DialogFragment.class);
final DialogFragment controller = handler.getController();
controller.init();
main.getChildren().addAll(handler.getFragmentNode());
return main;
}Example 83
| Project: javamoney-examples-master File: MainScreen.java View source code |
private void addButton(VBox box, String title, final Class<? extends Node> type) {
Hyperlink button = new Hyperlink(title);
button.setPrefWidth(200d);
button.setAlignment(Pos.CENTER_LEFT);
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent arg0) {
openSample(type);
}
});
box.getChildren().add(button);
}Example 84
| Project: jfxvnc-master File: PointerEventHandler.java View source code |
public void register(Node node) {
node.addEventFilter(ScrollEvent.SCROLL, scrollEventHandler);
node.addEventFilter(MouseEvent.MOUSE_PRESSED, mouseEventHandler);
node.addEventFilter(MouseEvent.MOUSE_MOVED, mouseEventHandler);
node.addEventFilter(MouseEvent.MOUSE_DRAGGED, mouseEventHandler);
node.addEventFilter(MouseEvent.MOUSE_RELEASED, mouseEventHandler);
}Example 85
| Project: megacoinj-master File: GuiUtils.java View source code |
public static void blurOut(Node node) {
GaussianBlur blur = new GaussianBlur(0.0);
node.setEffect(blur);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
}Example 86
| Project: openpnp-master File: UiUtils.java View source code |
// From http://stackoverflow.com/questions/26854301/control-javafx-tooltip-delay
public static void bindTooltip(final Node node, final Tooltip tooltip) {
node.setOnMouseMoved(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// +15 moves the tooltip 15 pixels below the mouse cursor;
// if you don't change the y coordinate of the tooltip, you
// will see constant screen flicker
tooltip.show(node, event.getScreenX(), event.getScreenY() + 15);
}
});
node.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
tooltip.hide();
}
});
}Example 87
| Project: orson-charts-master File: LineChart3DFXDemo1.java View source code |
public static Node createDemoNode() {
CategoryDataset3D dataset = LineChart3D1.createDataset();
Chart3D chart = LineChart3D1.createChart(dataset);
Chart3DViewer viewer = new Chart3DViewer(chart);
Platform.runLater(() -> {
Chart3DCanvas c = viewer.getCanvas();
if (c != null) {
c.zoomToFit(viewer.getWidth(), viewer.getHeight());
}
});
return viewer;
}Example 88
| Project: PeerWasp-master File: ActivityItemCell.java View source code |
private Node getIconByType(ActivityType type) { Node ico = null; switch(type) { case INFORMATION: ico = fontAwesome.create(FontAwesome.Glyph.INFO_CIRCLE); break; case WARNING: ico = fontAwesome.create(FontAwesome.Glyph.WARNING); break; default: break; } return ico; }
Example 89
| Project: POL-POM-5-master File: StepRepresentationBrowse.java View source code |
private Node dragPane() {
final Text textLabel = new Text(textToShow);
final Text dragLabel = new Text("Please click here, or drag a file to me.");
textLabel.getStyleClass().add("boldLabel");
dragLabel.getStyleClass().addAll("normalLabel");
final VBox dragTarget = new VBox();
dragTarget.getChildren().addAll(textLabel, dragLabel);
dragTarget.setOnDragOver( event -> {
if (event.getGestureSource() != dragTarget && event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
event.consume();
});
dragTarget.setOnDragDropped( event -> {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
this.selectFile(db.getFiles().get(0));
success = true;
}
event.setDropCompleted(success);
event.consume();
});
dragTarget.setPrefSize(660, 308);
dragTarget.getStyleClass().addAll("dragAndDropBox");
dragTarget.setOnMouseClicked( event -> {
final FileChooser fileChooser = new FileChooser();
if (extensions != null) {
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(translate("Allowed files"), extensions));
}
fileChooser.setInitialDirectory(browseDirectory);
File dialogResult = fileChooser.showOpenDialog(null);
if (dialogResult != null) {
selectFile(dialogResult);
}
});
return dragTarget;
}Example 90
| Project: spdx-edit-master File: PackagePropertyEditor.java View source code |
public void initialize(TitledPane parentContainer) {
AnchorPane control = new AnchorPane();
parentContainer.setContent(control);
int top = 40;
VBox vbox = new VBox();
control.getChildren().addAll(vbox);
AnchorPane.setBottomAnchor(vbox, 0D);
AnchorPane.setTopAnchor(vbox, 0D);
AnchorPane.setLeftAnchor(vbox, 0D);
AnchorPane.setRightAnchor(vbox, 0D);
vbox.setPadding(new Insets(20));
vbox.setSpacing(11);
List<Pane> rows = ImmutableList.<Pane>builder().add(createTextBoxEditor("Version Info:", spdxPackage.getVersionInfo(), spdxPackage::setVersionInfo, top += rowHeight), createTextAreaEditor("Description:", spdxPackage.getDescription(), spdxPackage::setDescription, top += rowHeight), createTextBoxEditor("Summary:", spdxPackage.getSummary(), spdxPackage::setSummary, top += rowHeight), createTextBoxEditor("Download Location:", spdxPackage.getDownloadLocation(), spdxPackage::setDownloadLocation, top += rowHeight), createTextBoxEditor("Source Info:", spdxPackage.getSourceInfo(), spdxPackage::setSourceInfo, top += rowHeight), createTextBoxEditor("Copyright Text:", spdxPackage.getCopyrightText(), spdxPackage::setCopyrightText, top += rowHeight), createTextBoxEditor("Package File Name:", spdxPackage.getPackageFileName(), spdxPackage::setPackageFileName, top += rowHeight), createTextBoxEditor("Homepage:", spdxPackage.getHomepage(), spdxPackage::setHomepage, top += rowHeight), createTextBoxEditor("Originator:", spdxPackage.getOriginator(), spdxPackage::setOriginator, top += rowHeight), createTextBoxEditor("Supplier:", spdxPackage.getSupplier(), spdxPackage::setSupplier, top += rowHeight)).build();
vbox.getChildren().addAll(rows);
rows.stream().map(Pane::getChildren).flatMap(List::stream).filter( n -> n instanceof TextField).forEach(Node::autosize);
rows.forEach(Node::autosize);
}Example 91
| Project: svarog-master File: SignalChart.java View source code |
private static XYChart.Series<Number, Number> createDataSeries(ObservableList<XYChart.Data<Number, Number>> data, final String style) {
XYChart.Series<Number, Number> serie = new XYChart.Series<Number, Number>(data);
serie.nodeProperty().addListener(new ChangeListener<Node>() {
@Override
public void changed(ObservableValue<? extends Node> observable, Node oldValue, Node newValue) {
if (newValue != null) {
newValue.setStyle(style);
}
}
});
return serie;
}Example 92
| Project: Time4J-master File: CalendarContent.java View source code |
private static Node createLabel(CalendarControl<?> control) {
Label label = new Label();
label.textProperty().bind(control.navigationInfoProperty());
HBox bottom = new HBox();
bottom.getChildren().add(label);
bottom.setAlignment(Pos.CENTER);
HBox.setHgrow(label, Priority.ALWAYS);
label.getStyleClass().add(CSS_CALENDAR_NAVIGATION_INFO);
return bottom;
}Example 93
| Project: TwitDuke-master File: HierarchyChangeObserver.java View source code |
@Override
public void onChanged(final ListChangeListener.Change c) {
while (c.next()) {
c.getRemoved().parallelStream().filter( child -> child instanceof Node).forEach( child -> onRemovedCallbackLList.invoke((Node) child));
c.getAddedSubList().parallelStream().filter( child -> child instanceof Node).forEach( child -> onAddedCallbackList.invoke((Node) child));
c.getAddedSubList().parallelStream().filter( child -> child instanceof Parent).forEach( child -> this.mark((Parent) child));
}
}Example 94
| Project: TwoFactorBtcWallet-master File: GuiUtils.java View source code |
public static void blurOut(Node node) {
GaussianBlur blur = new GaussianBlur(0.0);
node.setEffect(blur);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
}Example 95
| Project: AndroidDevToolbox-master File: MainController.java View source code |
public void updateContentScreen(MouseEvent mouseEvent) {
statusBarLabel.setText("");
ToggleButton button = (ToggleButton) mouseEvent.getSource();
Screen screen = getScreenForButton(button);
selectButton(button);
if (this.currentScreen == screen) {
return;
}
setScreen(screen);
this.contentPane.getChildren().clear();
try {
FXMLLoader fxmlLoader = new FXMLLoader(FileHelper.getFxmlUrl(getClass(), getFxmlNameForButton(button)), resourceBundle);
this.contentPane.getChildren().add((Node) fxmlLoader.load());
BaseController controller = fxmlLoader.getController();
controller.setStatusBarLabel(statusBarLabel);
controller.setBackgroundTaskExecutionListener(taskExecutionListener);
} catch (Exception e) {
e.printStackTrace();
}
}Example 96
| Project: autopsy-master File: Category.java View source code |
public synchronized Node getGraphic() {
if (snapshot == null) {
Region region = new Region();
region.setBackground(new Background(new BackgroundFill(getColor(), CORNER_RADII_4, Insets.EMPTY)));
region.setPrefSize(16, 16);
region.setBorder(new Border(new BorderStroke(getColor().darker(), BorderStrokeStyle.SOLID, CORNER_RADII_4, BORDER_WIDTHS_2)));
Scene scene = new Scene(region, 16, 16, Color.TRANSPARENT);
snapshot = region.snapshot(null, null);
}
return new ImageView(snapshot);
}Example 97
| Project: behaviorsearch-master File: RunOptionDialogController.java View source code |
public void updateOptions(ActionEvent event) {
runOptions.outputStem = outputPathTextField.getText();
runOptions.numSearches = (Integer) searchesNumSpinner.getValue();
runOptions.firstSearchNumber = (Integer) startingSearchIDSpinner.getValue();
runOptions.numThreads = (Integer) threadNumSpinner.getValue();
runOptions.randomSeed = (Integer) iniRanSeedSpinner.getValue();
runOptions.briefOutput = briefOutputCheckBox.isSelected();
// trying to open progress from here
Node source = (Node) event.getSource();
Stage thisStage = (Stage) source.getScene().getWindow();
thisStage.close();
main.displayProgressDialog();
}Example 98
| Project: bgfinancas-master File: Animacao.java View source code |
private static FadeTransition fadeIn(Node node, Boolean invisivel, Boolean play) {
FadeTransition fadeIn = new FadeTransition(Duration.millis(DURACAO), node);
if (invisivel) {
fadeIn.setFromValue(INVISIVEL);
} else {
fadeIn.setFromValue(TRANSPARENTE);
}
fadeIn.setToValue(VISIVEL);
if (play) {
fadeIn.play();
}
return fadeIn;
}Example 99
| Project: bitcoin-exchange-master File: Transitions.java View source code |
public void fadeOutAndRemove(Node node, int duration, EventHandler<ActionEvent> handler) {
FadeTransition fade = fadeOut(node, getDuration(duration));
fade.setInterpolator(Interpolator.EASE_IN);
fade.setOnFinished( actionEvent -> {
((Pane) (node.getParent())).getChildren().remove(node);
if (handler != null)
handler.handle(actionEvent);
});
}Example 100
| Project: bitsquare-master File: Transitions.java View source code |
public void fadeOutAndRemove(Node node, int duration, EventHandler<ActionEvent> handler) {
FadeTransition fade = fadeOut(node, getDuration(duration));
fade.setInterpolator(Interpolator.EASE_IN);
fade.setOnFinished( actionEvent -> {
((Pane) (node.getParent())).getChildren().remove(node);
if (handler != null)
handler.handle(actionEvent);
});
}Example 101
| Project: CCAutotyper-master File: FXGuiUtils.java View source code |
public static Alert buildLongAlert(String context, String longMessage, Node... additional) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setHeaderText(context);
Label label = new Label("Details: ");
TextArea textArea = new TextArea(longMessage);
textArea.setEditable(false);
textArea.setWrapText(false);
textArea.setMaxHeight(Double.MAX_VALUE);
textArea.setMaxWidth(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expanded = new GridPane();
expanded.setMaxWidth(Double.MAX_VALUE);
expanded.add(label, 0, 0);
expanded.add(textArea, 0, 1);
for (int i = 0; i < additional.length; i++) expanded.add(additional[i], 0, 2 + i);
alert.getDialogPane().setContent(expanded);
alert.getDialogPane().setPrefWidth(700);
alert.getDialogPane().setPrefHeight(400);
return alert;
}