javafx.beans.binding.DoubleBinding Java Examples
The following examples show how to use
javafx.beans.binding.DoubleBinding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Edge.java From fxgraph with Do What The F*ck You Want To Public License | 7 votes |
public EdgeGraphic(Graph graph, Edge edge, StringProperty textProperty) { group = new Group(); line = new Line(); final DoubleBinding sourceX = edge.getSource().getXAnchor(graph, edge); final DoubleBinding sourceY = edge.getSource().getYAnchor(graph, edge); final DoubleBinding targetX = edge.getTarget().getXAnchor(graph, edge); final DoubleBinding targetY = edge.getTarget().getYAnchor(graph, edge); line.startXProperty().bind(sourceX); line.startYProperty().bind(sourceY); line.endXProperty().bind(targetX); line.endYProperty().bind(targetY); group.getChildren().add(line); final DoubleProperty textWidth = new SimpleDoubleProperty(); final DoubleProperty textHeight = new SimpleDoubleProperty(); text = new Text(); text.textProperty().bind(textProperty); text.getStyleClass().add("edge-text"); text.xProperty().bind(line.startXProperty().add(line.endXProperty()).divide(2).subtract(textWidth.divide(2))); text.yProperty().bind(line.startYProperty().add(line.endYProperty()).divide(2).subtract(textHeight.divide(2))); final Runnable recalculateWidth = () -> { textWidth.set(text.getLayoutBounds().getWidth()); textHeight.set(text.getLayoutBounds().getHeight()); }; text.parentProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run()); text.textProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run()); group.getChildren().add(text); getChildren().add(group); }
Example #2
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Node apply(Region region, Wrapper<Point2D> mouseLocation) { final DoubleProperty xProperty = region.layoutXProperty(); final DoubleProperty yProperty = region.layoutYProperty(); final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty(); final DoubleBinding halfHeightProperty = heightProperty.divide(2); final Rectangle resizeHandleW = new Rectangle(handleRadius, handleRadius, Color.BLACK); resizeHandleW.xProperty().bind(xProperty.subtract(handleRadius / 2)); resizeHandleW.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2)); setUpDragging(resizeHandleW, mouseLocation, Cursor.W_RESIZE); resizeHandleW.setOnMouseDragged(event -> { if(mouseLocation.value != null) { dragWest(event, mouseLocation, region, handleRadius); mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY()); } }); return resizeHandleW; }
Example #3
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Node apply(Region region, Wrapper<Point2D> mouseLocation) { final DoubleProperty xProperty = region.layoutXProperty(); final DoubleProperty yProperty = region.layoutYProperty(); final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty(); final DoubleBinding halfWidthProperty = widthProperty.divide(2); final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty(); final Rectangle resizeHandleS = new Rectangle(handleRadius, handleRadius, Color.BLACK); resizeHandleS.xProperty().bind(xProperty.add(halfWidthProperty).subtract(handleRadius / 2)); resizeHandleS.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2)); setUpDragging(resizeHandleS, mouseLocation, Cursor.S_RESIZE); resizeHandleS.setOnMouseDragged(event -> { if(mouseLocation.value != null) { dragSouth(event, mouseLocation, region, handleRadius); mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY()); } }); return resizeHandleS; }
Example #4
Source File: PointingHeroIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 6 votes |
public PointingHeroIcon(ObservableEntity oe) { super(oe); shape = new Polygon( 0, -200, -120, 200, 120, 200 ); shape.fillProperty().bind(getPlayerColor()); ObjectBinding<Vector> angRotVector = oe.getPropertyBinding(Vector.class, "CBodyComponent.m_angRotation", null); DoubleBinding angRot = Bindings.createDoubleBinding(() -> (double) angRotVector.get().getElement(1), angRotVector); IntegerBinding angDiff = Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "m_anglediff", 0)); shape.translateXProperty().bind(getMapX()); shape.translateYProperty().bind(getMapY()); shape.rotateProperty().bind(getBaseAngle().add(angRot).add(angDiff)); }
Example #5
Source File: Pin.java From BlockMap with MIT License | 6 votes |
/** * Wrap a given Node (e.g. a Pin button) in a {@link StackPane} to be placed on to the map. Applies a scaling function (used to scales it * relative to the current zoom factor) and translations (to keep it at a given world space position and centered). */ static StackPane wrapGui(Node node, Vector2dc position, DoubleBinding scale, DisplayViewport viewport) { StackPane stack = new StackPane(node); Translate center = new Translate(); center.xProperty().bind(stack.widthProperty().multiply(-0.5)); center.yProperty().bind(stack.heightProperty().multiply(-0.5)); if (position != null) stack.getTransforms().add(new Translate(position.x(), position.y())); if (scale != null) { Scale scaleTransform = new Scale(); scaleTransform.xProperty().bind(scale); scaleTransform.yProperty().bind(scale); stack.getTransforms().add(scaleTransform); } stack.getTransforms().add(center); stack.setVisible(false); stack.setPickOnBounds(false); stack.setOpacity(0.0); return stack; }
Example #6
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Node apply(Region region, Wrapper<Point2D> mouseLocation) { final DoubleProperty xProperty = region.layoutXProperty(); final DoubleProperty yProperty = region.layoutYProperty(); final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty(); final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty(); final DoubleBinding halfHeightProperty = heightProperty.divide(2); final Rectangle resizeHandleE = new Rectangle(handleRadius, handleRadius, Color.BLACK); resizeHandleE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2)); resizeHandleE.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2)); setUpDragging(resizeHandleE, mouseLocation, Cursor.E_RESIZE); resizeHandleE.setOnMouseDragged(event -> { if(mouseLocation.value != null) { dragEast(event, mouseLocation, region, handleRadius); mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY()); } }); return resizeHandleE; }
Example #7
Source File: BoardCell.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Collection<Shape> createSymbol(BoardCell cell) { final DoubleBinding padding = cell.widthProperty().multiply(.15); Line l1 = new Line(20, 20, cell.getWidth() - 20, cell.getHeight() - 20); l1.setMouseTransparent(true); l1.getStyleClass().add("board-symbol"); l1.endXProperty().bind(cell.widthProperty().subtract(padding)); l1.endYProperty().bind(cell.heightProperty().subtract(padding)); Line l2 = new Line(20, cell.getHeight() - 20, cell.getWidth() - 20, 20); l2.setMouseTransparent(true); l2.getStyleClass().add("board-symbol"); l2.endXProperty().bind(cell.widthProperty().subtract(padding)); l2.startYProperty().bind(cell.heightProperty().subtract(padding)); return Arrays.asList(l1,l2); }
Example #8
Source File: Board.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Board() { super(GAP, GAP); getStyleClass().add("board"); build(); sceneProperty().addListener((o, os, ns) -> { DoubleBinding tileSize = getScene().widthProperty().subtract(GAP * 4).divide(SIZE); prefTileHeightProperty().bind(tileSize); prefTileWidthProperty().bind(tileSize); }); setTileAlignment(Pos.CENTER); setPrefColumns(Board.SIZE); setAlignment(Pos.CENTER); }
Example #9
Source File: ConnectionClickableAreaBehavior.java From gef with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected void doActivate() { clickableAreaBinding = new DoubleBinding() { @Override protected double computeValue() { double localClickableWidth = ABSOLUTE_CLICKABLE_WIDTH / ((InfiniteCanvasViewer) getHost().getRoot().getViewer()).getCanvas() .getContentTransform().getMxx(); return Math.min(localClickableWidth, ABSOLUTE_CLICKABLE_WIDTH); } }; // TODO: bind to the curve property of the connection and update the // binding in case the curve node is changed ((GeometryNode<ICurve>) getHost().getVisual().getCurve()) .clickableAreaWidthProperty().bind(clickableAreaBinding); ((InfiniteCanvasViewer) getHost().getRoot().getViewer()).getCanvas() .getContentTransform().mxxProperty() .addListener(scaleXListener); }
Example #10
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Node apply(Region region, Wrapper<Point2D> mouseLocation) { final DoubleProperty xProperty = region.layoutXProperty(); final DoubleProperty yProperty = region.layoutYProperty(); final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty(); final DoubleBinding halfWidthProperty = widthProperty.divide(2); final Rectangle resizeHandleN = new Rectangle(handleRadius, handleRadius, Color.BLACK); resizeHandleN.xProperty().bind(xProperty.add(halfWidthProperty).subtract(handleRadius / 2)); resizeHandleN.yProperty().bind(yProperty.subtract(handleRadius / 2)); setUpDragging(resizeHandleN, mouseLocation, Cursor.N_RESIZE); resizeHandleN.setOnMouseDragged(event -> { if(mouseLocation.value != null) { dragNorth(event, mouseLocation, region, handleRadius); mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY()); } }); return resizeHandleN; }
Example #11
Source File: FXStockField.java From Rails with GNU General Public License v2.0 | 5 votes |
/** * Create the token objects based on the model of this stock field * * @return A list containing all tokens */ private List<FXStockToken> createTokens() { List<FXStockToken> tokens = new ArrayList<>(); if (model.hasTokens()) { List<PublicCompany> publicCompanies = Lists.reverse(model.getTokens()); for (int companyIndex = 0; companyIndex < publicCompanies.size(); companyIndex++) { PublicCompany publicCompany = publicCompanies.get(companyIndex); FXStockToken token = new FXStockToken( ColorUtils.toColor(publicCompany.getFgColour()), ColorUtils.toColor(publicCompany.getBgColour()), publicCompany.getId() ); DoubleBinding diameter = Bindings.multiply(Bindings.min(widthProperty(), heightProperty()), 0.5); token.minWidthProperty().bind(diameter); token.prefWidthProperty().bind(diameter); token.maxWidthProperty().bind(diameter); token.minHeightProperty().bind(diameter); token.prefHeightProperty().bind(diameter); token.maxHeightProperty().bind(diameter); StackPane.setAlignment(token, Pos.TOP_RIGHT); StackPane.setMargin(token, new Insets(5 + (companyIndex * 5), 5, 5, 5)); tokens.add(token); } } return tokens; }
Example #12
Source File: TagBase.java From OpenLabeler with Apache License 2.0 | 5 votes |
private DoubleBinding getNameTranslateYProperty(Rotate rotate) { DoubleBinding anchor = shapeItem.getMinYProperty().add(0); switch ((int)rotate.getAngle()) { case -270: case 90: case 180: case -180: anchor = shapeItem.getMaxYProperty().add(0); break; } return translate.yProperty().add(anchor.multiply(scale.yProperty())); }
Example #13
Source File: SettingsDialog.java From mdict-java with GNU General Public License v3.0 | 5 votes |
static HBox make_2_simple_switcher(ResourceBundle bundle, ChangeListener<? super Boolean> listener, String message1, boolean enabled1, String message2, boolean enabled2) { HBox vb1 = new HBox( make_simple_switcher(bundle, listener, message1, enabled1), make_simple_switcher(bundle, listener, message2, enabled2) ); DoubleBinding bindTarget = vb1.widthProperty().divide(2); for(Node nI:vb1.getChildren()){ ((Region)nI).prefWidthProperty().bind(bindTarget); } return vb1; }
Example #14
Source File: SettingsDialog.java From mdict-java with GNU General Public License v3.0 | 5 votes |
static HBox make_3_simple_switcher(ResourceBundle bundle, ChangeListener<? super Boolean> listener, String message1, boolean enabled1, String message2, boolean enabled2, String message3, boolean enabled3) { HBox vb1 = new HBox( make_simple_switcher(bundle, listener, message1, enabled1), make_simple_switcher(bundle, listener, message2, enabled2), make_simple_switcher(bundle, listener, message3, enabled3) ); DoubleBinding bindTarget = vb1.widthProperty().divide(3); for(Node nI:vb1.getChildren()){ ((Region)nI).prefWidthProperty().bind(bindTarget); } return vb1; }
Example #15
Source File: TextureLayerSettings.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@FxThread private @NotNull ListCell<TextureLayer> newCell() { final DoubleBinding width = widthProperty().subtract(4D); final TextureLayerCell cell = new TextureLayerCell(width, width); cells.add(cell); return cell; }
Example #16
Source File: TextureLayerCell.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Instantiates a new Texture layer cell. * @param prefWidth the pref width * @param maxWidth the max width */ public TextureLayerCell(final DoubleBinding prefWidth, final DoubleBinding maxWidth) { settingContainer = new GridPane(); settingContainer.prefWidthProperty().bind(prefWidth); settingContainer.maxWidthProperty().bind(maxWidth); layerField = new Label(); layerField.prefWidthProperty().bind(settingContainer.widthProperty()); diffuseTextureControl = new NamedChooseTextureControl("Diffuse"); diffuseTextureControl.setChangeHandler(this::updateDiffuse); diffuseTextureControl.setControlWidthPercent(PropertyControl.CONTROL_WIDTH_PERCENT_2); normalTextureControl = new NamedChooseTextureControl("Normal"); normalTextureControl.setChangeHandler(this::updateNormal); normalTextureControl.setControlWidthPercent(PropertyControl.CONTROL_WIDTH_PERCENT_2); final Label scaleLabel = new Label(Messages.MODEL_PROPERTY_SCALE + ":"); scaleLabel.prefWidthProperty().bind(settingContainer.widthProperty().multiply(LABEL_PERCENT)); scaleField = new FloatTextField(); scaleField.setMinMax(0.0001F, Integer.MAX_VALUE); scaleField.setScrollPower(3F); scaleField.addChangeListener((observable, oldValue, newValue) -> updateScale(newValue)); scaleField.prefWidthProperty().bind(settingContainer.widthProperty().multiply(FIELD_PERCENT)); settingContainer.add(layerField, 0, 0, 2, 1); settingContainer.add(diffuseTextureControl, 0, 1, 2, 1); settingContainer.add(normalTextureControl, 0, 2, 2, 1); settingContainer.add(scaleLabel, 0, 3); settingContainer.add(scaleField, 1, 3); FXUtils.addClassTo(settingContainer, CssClasses.DEF_GRID_PANE); FXUtils.addClassTo(layerField, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME); FXUtils.addClassTo(scaleLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); FXUtils.addClassTo(scaleField, CssClasses.PROPERTY_CONTROL_COMBO_BOX); FXUtils.addClassTo(this, CssClasses.PROCESSING_COMPONENT_TERRAIN_EDITOR_TEXTURE_LAYER); }
Example #17
Source File: BoardCell.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Collection<Shape> createSymbol(BoardCell cell) { Circle c = new Circle(); c.setMouseTransparent(true); c.getStyleClass().add("board-symbol"); final DoubleBinding padding = cell.widthProperty().multiply(.15); c.radiusProperty().bind(cell.widthProperty().divide(2).subtract(padding)); return Arrays.asList(c); }
Example #18
Source File: PointingHeroIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 5 votes |
private DoubleBinding getBaseAngle() { long modelHandle = getModelHandle().get(); DoubleBinding binding = BASE_ANGLES.get(modelHandle); if (binding != null) { return binding; } return new DoubleBinding() { @Override protected double computeValue() { return 0.0; } }; }
Example #19
Source File: VirtualizedScrollPane.java From Flowless with BSD 2-Clause "Simplified" License | 5 votes |
private static void setupUnitIncrement(ScrollBar bar) { bar.unitIncrementProperty().bind(new DoubleBinding() { { bind(bar.maxProperty(), bar.visibleAmountProperty()); } @Override protected double computeValue() { double max = bar.getMax(); double visible = bar.getVisibleAmount(); return max > visible ? 16 / (max - visible) * max : 0; } }); }
Example #20
Source File: AuthenticateController.java From Cryogen with GNU General Public License v2.0 | 5 votes |
@Override public void initialize(URL url, ResourceBundle rb) { DoubleBinding fontSize = pane.widthProperty().multiply(0.75).add(pane.heightProperty()).divide(50); Email.styleProperty().bind(Bindings.concat("-fx-font-size: ").concat(fontSize.asString()).concat(";")); Pass.styleProperty().bind(Email.styleProperty()); Incorrect.styleProperty().bind(Email.styleProperty()); AuthBubble.widthProperty().bind(pane.widthProperty().multiply(0.7).subtract(5)); AuthBubble.heightProperty().bind(pane.heightProperty().multiply(0.575).subtract(5)); }
Example #21
Source File: Utils.java From Cryogen with GNU General Public License v2.0 | 5 votes |
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 #22
Source File: TagBase.java From OpenLabeler with Apache License 2.0 | 5 votes |
private DoubleBinding getNameTranslateXProperty(Rotate rotate) { DoubleBinding anchor = shapeItem.getMinXProperty().add(0); switch ((int)rotate.getAngle()) { case 180: case -180: anchor = shapeItem.getMaxXProperty().subtract(name.heightProperty()); break; case -90: case 270: anchor = shapeItem.getMaxXProperty().add(0); break; } return translate.xProperty().add(anchor.multiply(scale.xProperty())); }
Example #23
Source File: DynamicWidthChoicebox.java From pmd-designer with BSD 2-Clause "Simplified" License | 5 votes |
public DynamicWidthChoicebox() { ControlUtil.subscribeOnSkin( this, skin -> { Label label = (Label) skin.getNode().lookup(".label"); StackPane arrow = (StackPane) skin.getNode().lookup(".open-button"); boolean showArrow = !getStyleClass().contains("no-arrow"); label.setAlignment(showArrow ? Pos.CENTER_LEFT : Pos.CENTER); DoubleBinding widthBinding = Bindings.createDoubleBinding( () -> { Insets myInsets = getInsets(); double arrowWidth = showArrow ? arrow.prefWidth(-1) : 0; return myInsets.getLeft() + label.prefWidth(-1) + arrowWidth + myInsets.getRight(); }, label.widthProperty(), this.getSelectionModel().selectedItemProperty(), this.insetsProperty() ); return rewire(this.prefWidthProperty(), widthBinding); } ); }
Example #24
Source File: SequenceDiagram.java From fxgraph with Do What The F*ck You Want To Public License | 5 votes |
@Override public Region getGraphic(Graph graph) { Group group = new Group(); Arrow arrow = new Arrow(); arrow.getStyleClass().add("arrow"); final DoubleBinding sourceX = getSource().getXAnchor(graph, this); final DoubleBinding sourceY = getSource().getYAnchor(graph, this).add(yOffsetProperty); final DoubleBinding targetX = getTarget().getXAnchor(graph, this); final DoubleBinding targetY = getTarget().getYAnchor(graph, this).add(yOffsetProperty); arrow.startXProperty().bind(sourceX); arrow.startYProperty().bind(sourceY); arrow.endXProperty().bind(targetX); arrow.endYProperty().bind(targetY); group.getChildren().add(arrow); final DoubleProperty textWidth = new SimpleDoubleProperty(); final DoubleProperty textHeight = new SimpleDoubleProperty(); Text text = new Text(name); text.getStyleClass().add("edge-text"); text.xProperty().bind(arrow.startXProperty().add(arrow.endXProperty()).divide(2).subtract(textWidth.divide(2))); text.yProperty().bind(arrow.startYProperty().add(arrow.endYProperty()).divide(2).subtract(textHeight.divide(2))); final Runnable recalculateWidth = () -> { textWidth.set(text.getLayoutBounds().getWidth()); textHeight.set(text.getLayoutBounds().getHeight()); }; text.parentProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run()); text.textProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run()); group.getChildren().add(text); Pane pane = new Pane(group); pane.getStyleClass().add("message-edge"); return pane; }
Example #25
Source File: Workbench.java From WorkbenchFX with Apache License 2.0 | 5 votes |
/** * Handles the initial animation of an overlay. * * <p>An overlay will have a default size of {@code 0}, when it is <b>first being shown</b> by * {@link WorkbenchPresenter#showOverlay(Region, boolean)}, because it has not been added to the * scene graph or a layout pass has not been performed yet. This means the animation won't be * played by {@link WorkbenchPresenter#showOverlay(Region, boolean)} as well.<br> * For this reason, we wait for the {@link WorkbenchOverlay} to be initialized and then initially * set the coordinates of the overlay to be outside of the {@link Scene}, followed by playing the * initial starting animation.<br> * Any subsequent calls which show this {@code workbenchOverlay} again will <b>not</b> cause this * to trigger again, as the {@link Event} of {@link WorkbenchOverlay#onInitializedProperty()} * will only be fired once, since calling {@link Workbench#hideOverlay(Region)} only makes the * overlays not visible, which means the nodes remain with their size already initialized in the * scene graph. * * @param workbenchOverlay for which to prepare the initial animation handler for * @param side from which the sliding animation should originate */ private void addInitialAnimationHandler(WorkbenchOverlay workbenchOverlay, Side side) { Region overlay = workbenchOverlay.getOverlay(); // prepare values for setting the listener ReadOnlyDoubleProperty size = side.isVertical() ? overlay.widthProperty() : overlay.heightProperty(); // LEFT or RIGHT side TOP or BOTTOM side // make sure this code only gets run the first time the overlay has been shown and // rendered in the scene graph, to ensure the overlay has a size for the calculations workbenchOverlay.setOnInitialized(event -> { // prepare variables TranslateTransition start = workbenchOverlay.getAnimationStart(); TranslateTransition end = workbenchOverlay.getAnimationEnd(); DoubleExpression hiddenCoordinate = DoubleBinding.doubleExpression(size); if (Side.LEFT.equals(side) || Side.TOP.equals(side)) { hiddenCoordinate = hiddenCoordinate.negate(); // make coordinates in hidden state negative } if (side.isVertical()) { // LEFT or RIGHT => X overlay.setTranslateX(hiddenCoordinate.get()); // initial position start.setToX(0); if (!end.toXProperty().isBound()) { end.toXProperty().bind(hiddenCoordinate); } } if (side.isHorizontal()) { // TOP or BOTTOM => Y overlay.setTranslateY(hiddenCoordinate.get()); // initial position start.setToY(0); if (!end.toYProperty().isBound()) { end.toYProperty().bind(hiddenCoordinate); } } start.play(); }); }
Example #26
Source File: EntityIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected DoubleBinding getVecX() { return Bindings.selectDouble(oe.getPropertyBinding(Double.class, "CBodyComponent.m_vecX", 0.0)); }
Example #27
Source File: GenericViewArrow.java From latexdraw with GNU General Public License v3.0 | 4 votes |
default DoubleBinding createFullThickBinding() { return Bindings.createDoubleBinding(() -> getArrow().getShape().getFullThickness(), getArrow().getShape().thicknessProperty(), getArrow().getShape().dbleBordSepProperty(), getArrow().getShape().dbleBordProperty()); }
Example #28
Source File: Pin.java From BlockMap with MIT License | 4 votes |
@Override protected Node initTopGui() { /* If there are to many different pins, merge some */ Map<PinType, Long> pinCount = new HashMap<>(this.pinCount); /* * Merge the village pins not based on their count, but based on the current zoom factor. */ if (minHeight > 50) { // if (minHeight > 50 || // (pinCount.size() > 4 && (PinType.VILLAGE_MAPPING.values().stream().filter(x -> pinCount.getOrDefault(x, 0L) > 0).count() > 1))) { /* Merge village pins to one */ List<PinType> villageObjects = PinType.VILLAGE.children.stream().filter(this.pinCount::containsKey).collect(Collectors.toList()); if (!villageObjects.isEmpty()) { pinCount.keySet().removeAll(villageObjects); pinCount.put(PinType.VILLAGE, villageObjects.stream().mapToLong(this.pinCount::get).sum()); } } if (pinCount.size() > 4) { /* Merge all structures */ List<PinType> structures = PinType.STRUCTURE.children.stream().filter(this.pinCount::containsKey).collect(Collectors.toList()); if (!structures.isEmpty()) { pinCount.keySet().removeAll(structures); pinCount.put(PinType.STRUCTURE, structures.stream().mapToLong(this.pinCount::get).sum()); } } if (pinCount.size() > 4 && pinCount.getOrDefault(PinType.MAP_POSITION, 0L) > 0 && pinCount.getOrDefault(PinType.MAP_BANNER, 0L) > 0) { /* Merge map with banners */ pinCount.put(PinType.MAP_POSITION, pinCount.get(PinType.MAP_POSITION) + pinCount.get(PinType.MAP_BANNER)); pinCount.remove(PinType.MAP_BANNER); } if (pinCount.size() > 4 && pinCount.getOrDefault(PinType.PLAYER_POSITION, 0L) > 0 && pinCount.getOrDefault(PinType.PLAYER_SPAWN, 0L) > 0) { /* Just remove them, showing more players than there are may be confusing */ pinCount.remove(PinType.PLAYER_SPAWN); } int columns = (int) Math.floor(Math.sqrt(pinCount.size())); GridPane box = new GridPane(); box.getStyleClass().add("mergedpin-box"); /* Image for the pin's button */ StreamUtils.zipWithIndex(pinCount.entrySet().stream()).forEach(e -> { ImageView img = new ImageView(e.getValue().getKey().image); img.setSmooth(false); img.setPreserveRatio(true); Label label = new Label(String.format("%dx", e.getValue().getValue()), img); img.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> label.getFont().getSize() * 1.5, label.fontProperty())); box.add(label, (int) e.getIndex() % columns, (int) e.getIndex() / columns); }); button = new Button(null, box); button.getStyleClass().add("pin"); button.setOnAction(mouseEvent -> getInfo().show(button)); DoubleBinding scale = Bindings.createDoubleBinding( () -> 1.0 * Math.min(1 / viewport.scaleProperty.get(), 4) * Math.pow(pinCount.size(), -0.3), viewport.scaleProperty); return wrapGui(button, position, scale, viewport); }
Example #29
Source File: EntityIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected DoubleBinding getMapY() { return getWorldY().subtract(16384.0).subtract(MapControl.MIN_Y); }
Example #30
Source File: EntityIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected DoubleBinding getMapX() { return getWorldX().subtract(16384.0).subtract(MapControl.MIN_X); }