Java Code Examples for javafx.beans.property.SimpleDoubleProperty

The following examples show how to use javafx.beans.property.SimpleDoubleProperty. These examples are extracted from open source projects. 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 Project: fxgraph   Source File: Edge.java    License: Do What The F*ck You Want To Public License 7 votes vote down vote up
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 Project: mzmine3   Source File: TestDatatypes.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void simpleSumBinding() {
  DoubleProperty a = new SimpleDoubleProperty();
  DoubleProperty b = new SimpleDoubleProperty();
  DoubleProperty sum = new SimpleDoubleProperty();

  sum.bind(a.add(b));
  sum.add(b);
  logger.info("Sum=" + sum.get() + "   " + sum.getValue());
  a.set(10);
  logger.info("Sum=" + sum.get() + "   " + sum.getValue());
  b.set(5);
  logger.info("Sum=" + sum.get() + "   " + sum.getValue());
}
 
Example 3
Source Project: marathonv5   Source File: DataAppPreloader.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) throws Exception {
    preloaderStage = stage;
    preloaderStage.setScene(preloaderScene);
    preloaderStage.show();
    
    if (DEMO_MODE) {
        final DoubleProperty prog = new SimpleDoubleProperty(0){
            @Override protected void invalidated() {
                handleProgressNotification(new ProgressNotification(get()));
            }
        };
        Timeline t = new Timeline();
        t.getKeyFrames().add(new KeyFrame(Duration.seconds(20), new KeyValue(prog, 1)));
        t.play();
    }
}
 
Example 4
Source Project: Recaf   Source File: UiUtil.java    License: MIT License 6 votes vote down vote up
private static void animate(Node node, long millis, int r, int g, int b) {
	DoubleProperty dblProp = new SimpleDoubleProperty(1);
	dblProp.addListener((ob, o, n) -> {
		InnerShadow innerShadow = new InnerShadow();
		innerShadow.setBlurType(BlurType.ONE_PASS_BOX);
		innerShadow.setChoke(1);
		innerShadow.setRadius(5);
		innerShadow.setColor(Color.rgb(r, g, b, n.doubleValue()));
		node.setEffect(innerShadow);
	});
	Timeline timeline = new Timeline();
	KeyValue kv = new KeyValue(dblProp, 0);
	KeyFrame kf = new KeyFrame(Duration.millis(millis), kv);
	timeline.getKeyFrames().add(kf);
	timeline.play();
}
 
Example 5
Source Project: latexdraw   Source File: GridImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a grid with a predefined point.
 * @param pt The position.
 */
GridImpl(final Point pt) {
	super(pt);
	xLabelSouth = new SimpleBooleanProperty(true);
	yLabelWest = new SimpleBooleanProperty(true);
	gridDots = new SimpleIntegerProperty(PSTricksConstants.DEFAULT_GRIDDOTS);
	gridLabelsColour = new SimpleObjectProperty<>(PSTricksConstants.DEFAULT_LABELGRIDCOLOR);
	labelSize.set((int) PSTricksConstants.DEFAULT_GRID_LABEL);
	gridWidth = new SimpleDoubleProperty(PSTricksConstants.DEFAULT_GRID_WIDTH * PPC);
	subGridColour = new SimpleObjectProperty<>(PSTricksConstants.DEFAULT_SUB_GRID_COLOR);
	subGridDiv = new SimpleIntegerProperty(PSTricksConstants.DEFAULT_SUBGRIDDIV);
	subGridDots = new SimpleIntegerProperty(PSTricksConstants.DEFAULT_SUBGRIDDOTS);
	subGridWidth = new SimpleDoubleProperty(PSTricksConstants.DEFAULT_SUB_GRID_WIDTH * PPC);
	unit = new SimpleDoubleProperty(PSTricksConstants.DEFAULT_UNIT);
}
 
Example 6
Source Project: JavaFX   Source File: Minimal.java    License: MIT License 5 votes vote down vote up
private void nextPane(Service<Rectangle> recBuilder) {
	loading[counter].textProperty().bind(recBuilder.messageProperty());
	indicators[counter].visibleProperty().bind(
			recBuilder.progressProperty().isNotEqualTo(
					new SimpleDoubleProperty(
							ProgressBar.INDETERMINATE_PROGRESS)));
	recBuilder.restart();
}
 
Example 7
Source Project: latexdraw   Source File: GridBase.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an abstract grid.
 * @param pt The position
 */
GridBase(final Point pt) {
	super(pt);
	originx = new SimpleDoubleProperty(0d);
	originy = new SimpleDoubleProperty(0d);
	gridStartx = new SimpleDoubleProperty(0d);
	gridStarty = new SimpleDoubleProperty(0d);
	gridEndx = new SimpleDoubleProperty(2d);
	gridEndy = new SimpleDoubleProperty(2d);
	labelSize = new SimpleIntegerProperty(10);
}
 
Example 8
Source Project: JFX8CustomControls   Source File: LedBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B translateX(final double TRANSLATE_X) {
    properties.put("translateX", new SimpleDoubleProperty(TRANSLATE_X));
    return (B)this;
}
 
Example 9
Source Project: latexdraw   Source File: Canvas.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates the canvas.
 */
@Inject
public Canvas(final PreferencesService prefs, final ViewFactory viewFactory) {
	super();
	this.viewFactory = Objects.requireNonNull(viewFactory);
	modified = false;
	drawing = ShapeFactory.INST.createDrawing();
	zoom = new SimpleDoubleProperty(1d);
	tempView = Optional.empty();
	page = new PageView(prefs, getOrigin());
	magneticGrid = new MagneticGrid(this, prefs);
	disposables = new ArrayList<>();

	widgetsPane = new Group();
	shapesPane = new Group();
	shapesToViewMap = new HashMap<>();
	selectionBorder = new Rectangle();
	ongoingSelectionBorder = new Rectangle();

	widgetsPane.setFocusTraversable(false);
	ongoingSelectionBorder.setFocusTraversable(false);
	ongoingSelectionBorder.setMouseTransparent(true);
	ongoingSelectionBorder.setFill(null);
	ongoingSelectionBorder.setStroke(Color.GRAY);
	ongoingSelectionBorder.setStrokeLineCap(StrokeLineCap.BUTT);
	ongoingSelectionBorder.getStrokeDashArray().addAll(7d, 7d);

	getChildren().add(page);
	getChildren().add(magneticGrid);
	getChildren().add(shapesPane);
	getChildren().add(widgetsPane);
	widgetsPane.getChildren().add(selectionBorder);
	widgetsPane.getChildren().add(ongoingSelectionBorder);
	widgetsPane.relocate(ORIGIN.getX(), ORIGIN.getY());
	shapesPane.relocate(ORIGIN.getX(), ORIGIN.getY());

	defineShapeListToViewBinding();

	selectionBorder.setFocusTraversable(false);
	selectionBorder.setVisible(false);
	selectionBorder.setFill(null);
	selectionBorder.setStroke(Color.GRAY);
	selectionBorder.setStrokeLineCap(StrokeLineCap.BUTT);
	selectionBorder.getStrokeDashArray().addAll(7d, 7d);

	// Bloody key shortcuts. To work the canvas must grab the focus
	// Must be a MOUSE_CLICKED, not a MOUSE_PRESSED, do not know why...
	io.github.interacto.jfx.binding.Bindings
		.anonCmdBinder(() -> requestFocus())
		.usingInteraction(Click::new)
		.on(this)
		.bind();

	// Instead of triggering the update on each change, wait for 20 ms
	disposables.add(JavaFxObservable.<ObservableList<Shape>>changesOf(drawing.getSelection().getShapes())
		.throttleLast(20, TimeUnit.MILLISECONDS)
		.observeOn(JavaFxScheduler.platform())
		.subscribe(next -> updateSelectionBorders(), ex -> BadaboomCollector.INSTANCE.add(ex)));

	disposables.add(CommandsRegistry.getInstance().commands()
		.filter(c -> c instanceof Modifying || c instanceof Undo || c instanceof Redo)
		.subscribe(c -> update()));

	shapesPane.setFocusTraversable(false);

	prefWidthProperty().bind(Bindings.createDoubleBinding(() -> margins * 2d + prefs.getPage().getWidth() * Shape.PPC, prefs.pageProperty()));
	prefHeightProperty().bind(Bindings.createDoubleBinding(() -> margins * 2d + prefs.getPage().getHeight() * Shape.PPC, prefs.pageProperty()));
}
 
Example 10
Source Project: Enzo   Source File: PushButtonBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B minHeight(final double MIN_HEIGHT) {
    properties.put("minHeight", new SimpleDoubleProperty(MIN_HEIGHT));
    return (B)this;
}
 
Example 11
Source Project: Enzo   Source File: SimpleGaugeBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final SimpleGaugeBuilder minValue(final double MIN_VALUE) {
    properties.put("minValue", new SimpleDoubleProperty(MIN_VALUE));
    return this;
}
 
Example 12
Source Project: Enzo   Source File: SquareMatrixSegmentBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B minWidth(final double MIN_WIDTH) {
    properties.put("minWidth", new SimpleDoubleProperty(MIN_WIDTH));
    return (B)this;
}
 
Example 13
Source Project: tilesfx   Source File: TileBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B scaleX(final double SCALE_X) {
    properties.put("scaleX", new SimpleDoubleProperty(SCALE_X));
    return (B)this;
}
 
Example 14
Source Project: charts   Source File: CircularPlotBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B prefWidth(final double PREF_WIDTH) {
    properties.put("prefWidth", new SimpleDoubleProperty(PREF_WIDTH));
    return (B)this;
}
 
Example 15
Source Project: worldfx   Source File: LocationBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B longitude(final double LONGITUDE) {
    properties.put("longitude", new SimpleDoubleProperty(LONGITUDE));
    return (B)this;
}
 
Example 16
Source Project: Enzo   Source File: IconSwitchBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B maxHeight(final double MAX_HEIGHT) {
    properties.put("maxHeight", new SimpleDoubleProperty(MAX_HEIGHT));
    return (B)this;
}
 
Example 17
Source Project: charts   Source File: ParallelCoordinatesChartBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B maxHeight(final double MAX_HEIGHT) {
    properties.put("maxHeight", new SimpleDoubleProperty(MAX_HEIGHT));
    return (B) this;
}
 
Example 18
Source Project: Enzo   Source File: LcdBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B prefHeight(final double PREF_HEIGHT) {
    properties.put("prefHeight", new SimpleDoubleProperty(PREF_HEIGHT));
    return (B)this;
}
 
Example 19
Source Project: Enzo   Source File: PushButtonBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B translateY(final double TRANSLATE_Y) {
    properties.put("translateY", new SimpleDoubleProperty(TRANSLATE_Y));
    return (B)this;
}
 
Example 20
Source Project: regulators   Source File: FeedbackRegulatorBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B maxValue(final double VALUE) {
    properties.put("maxValue", new SimpleDoubleProperty(VALUE));
    return (B)this;
}
 
Example 21
Source Project: charts   Source File: ParallelCoordinatesChartBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B minWidth(final double MIN_WIDTH) {
    properties.put("minWidth", new SimpleDoubleProperty(MIN_WIDTH));
    return (B) this;
}
 
Example 22
Source Project: OEE-Designer   Source File: PixelMatrixBuilder.java    License: MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public final B prefHeight(final double PREF_HEIGHT) {
       properties.put("prefHeight", new SimpleDoubleProperty(PREF_HEIGHT));
       return (B)this;
   }
 
Example 23
Source Project: charts   Source File: XYZSeriesBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B strokeWidth(final double WIDTH) {
    properties.put("strokeWidth", new SimpleDoubleProperty(WIDTH));
    return (B)this;
}
 
Example 24
Source Project: Enzo   Source File: SimpleGaugeBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final SimpleGaugeBuilder animationDuration(final double ANIMATION_DURATION) {
    properties.put("animationDuration", new SimpleDoubleProperty(ANIMATION_DURATION));
    return this;
}
 
Example 25
Source Project: Enzo   Source File: SignalTowerBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B prefWidth(final double PREF_WIDTH) {
    properties.put("prefWidth", new SimpleDoubleProperty(PREF_WIDTH));
    return (B)this;
}
 
Example 26
Source Project: charts   Source File: SankeyPlotBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B prefWidth(final double PREF_WIDTH) {
    properties.put("prefWidth", new SimpleDoubleProperty(PREF_WIDTH));
    return (B)this;
}
 
Example 27
Source Project: Medusa   Source File: GaugeBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B prefWidth(final double PREF_WIDTH) {
    properties.put("prefWidth", new SimpleDoubleProperty(PREF_WIDTH));
    return (B)this;
}
 
Example 28
Source Project: Enzo   Source File: LcdBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B translateX(final double TRANSLATE_X) {
    properties.put("translateX", new SimpleDoubleProperty(TRANSLATE_X));
    return (B)this;
}
 
Example 29
Source Project: tilesfx   Source File: TileBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B startAngle(final double ANGLE) {
    properties.put("startAngle", new SimpleDoubleProperty(ANGLE));
    return (B)this;
}
 
Example 30
Source Project: Enzo   Source File: PushButtonBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public final B maxHeight(final double MAX_HEIGHT) {
    properties.put("maxHeight", new SimpleDoubleProperty(MAX_HEIGHT));
    return (B)this;
}