javafx.beans.property.ReadOnlyDoubleProperty Java Examples

The following examples show how to use javafx.beans.property.ReadOnlyDoubleProperty. 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: SeriesController.java    From houdoku with MIT License 6 votes vote down vote up
/**
 * Creates a Callback of a standard cell factory for a table cell.
 * 
 * <p>The cell factory represents the String content as a JavaFX Text object using the
 * "tableText" style class. The cell is given a click handler from newCellClickHandler().
 *
 * @param widthProperty the widthProperty of this cell's column
 * @param contextMenu   the context menu shown when right clicking
 * @return a Callback of a standard cell factory for a table cell
 */
private Callback<TableColumn<Chapter, String>, TableCell<Chapter, String>> newStringCellFactory(
        ReadOnlyDoubleProperty widthProperty, ContextMenu contextMenu) {
    return tc -> {
        TableCell<Chapter, String> cell = new TableCell<>();
        cell.getStyleClass().add("tableCell");
        Text text = new Text();
        text.getStyleClass().add("tableText");
        text.setTextAlignment(TextAlignment.LEFT);
        cell.setGraphic(text);
        text.wrappingWidthProperty().bind(widthProperty);
        text.textProperty().bind(cell.itemProperty());
        cell.setOnMouseClicked(newCellClickHandler(contextMenu));
        return cell;
    };
}
 
Example #2
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 vote down vote up
@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 Rectangle resizeHandleSW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleSW.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSW, mouseLocation, Cursor.SW_RESIZE);

	resizeHandleSW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSW;
}
 
Example #4
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 #5
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 Rectangle resizeHandleSE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleSE.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSE, mouseLocation, Cursor.SE_RESIZE);

	resizeHandleSE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSE;
}
 
Example #6
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 Rectangle resizeHandleNE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleNE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleNE.yProperty().bind(yProperty.subtract(handleRadius / 2));

	setUpDragging(resizeHandleNE, mouseLocation, Cursor.NE_RESIZE);

	resizeHandleNE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragNorth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleNE;
}
 
Example #8
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 #9
Source File: ChatView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addListenersOnSessionChange(ReadOnlyDoubleProperty widthProperty) {
    if (tableGroupHeadline != null) {
        tableGroupHeadline.prefWidthProperty().bind(widthProperty);
        messageListView.prefWidthProperty().bind(widthProperty);
        this.prefWidthProperty().bind(widthProperty);
        chatMessages.addListener(disputeDirectMessageListListener);
        inputTextAreaTextSubscription = EasyBind.subscribe(inputTextArea.textProperty(), t -> sendButton.setDisable(t.isEmpty()));
    }
}
 
Example #10
Source File: TableItemTask.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * constructor
 *
 * @param doc
 * @param cNames
 * @param classificationName
 * @param tableView
 */
public TableItemTask(Document doc, String[] cNames, String classificationName, Set<Integer> classIds, TableView<TableItem> tableView, FloatProperty maxBitScore, FloatProperty maxNormalizedBitScore, IntegerProperty maxReadLength, ReadOnlyDoubleProperty layoutWidth) {
    this.doc = doc;
    this.cNames = cNames;
    this.classificationName = classificationName;
    this.classIds = classIds;
    this.tableView = tableView;
    this.maxBitScore = maxBitScore;
    this.maxNormalizedBitScore = maxNormalizedBitScore;
    this.maxReadLength = maxReadLength;
    this.layoutWidth = layoutWidth;
}
 
Example #11
Source File: LRInspectorController.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create a horizontal axis
 *
 * @param maxReadLength
 * @return axis
 */
private static Pane createAxis(final ReadOnlyIntegerProperty maxReadLength, final ReadOnlyDoubleProperty widthProperty) {
    final Pane pane = new Pane();
    pane.prefWidthProperty().bind(widthProperty);

    final NumberAxis axis = new NumberAxis();
    axis.setSide(Side.TOP);
    axis.setAutoRanging(false);
    axis.setLowerBound(0);
    axis.prefHeightProperty().set(20);
    axis.prefWidthProperty().bind(widthProperty.subtract(60));
    axis.setTickLabelFont(Font.font("Arial", 10));

    final ChangeListener<Number> changeListener = (observable, oldValue, newValue) -> {
        int minX = Math.round(maxReadLength.get() / 2000.0f); // at most 2000 major ticks
        for (int x = 10; x < 10000000; x *= 10) {
            if (x >= minX && widthProperty.doubleValue() * x >= 50 * maxReadLength.doubleValue()) {
                axis.setUpperBound(maxReadLength.get());
                axis.setTickUnit(x);
                return;
            }
        }
        axis.setTickUnit(maxReadLength.get());
        axis.setUpperBound(maxReadLength.get());
    };

    maxReadLength.addListener(changeListener);
    widthProperty.addListener(changeListener);

    pane.getChildren().add(axis);
    return pane;
}
 
Example #12
Source File: LogView.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
@MustCallOnJavaFXThread
public LogView( BindableValue<Font> fontValue,
                ReadOnlyDoubleProperty widthProperty,
                HighlightOptions highlightOptions,
                FileContentReader fileContentReader,
                TaskRunner taskRunner ) {
    this.highlightOptions = highlightOptions;
    this.fileContentReader = fileContentReader;
    this.taskRunner = taskRunner;
    this.selectionHandler = new SelectionHandler( this );
    this.file = fileContentReader.getFile();

    final LogLineColors logLineColors = highlightOptions.logLineColorsFor( "" );
    final NumberBinding width = Bindings.max( widthProperty(), widthProperty );

    logLineFactory = () -> new LogLine( fontValue, width,
            logLineColors.getBackground(), logLineColors.getFill() );

    for ( int i = 0; i < MAX_LINES; i++ ) {
        getChildren().add( logLineFactory.get() );
    }

    this.expressionsChangeListener = ( Observable o ) -> immediateOnFileChange();

    highlightOptions.getObservableExpressions().addListener( expressionsChangeListener );
    highlightOptions.getStandardLogColors().addListener( expressionsChangeListener );
    highlightOptions.filterEnabled().addListener( expressionsChangeListener );

    tailingFile.addListener( event -> {
        if ( tailingFile.get() ) {
            onFileChange();
        }
    } );

    this.fileChangeWatcher = new FileChangeWatcher( file, taskRunner, this::onFileChange );
}
 
Example #13
Source File: Workbench.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #14
Source File: AbstractFormLayoutRegion.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public ReadOnlyDoubleProperty minEditorWidthProperty() {
    return minEditorWidth.getReadOnlyProperty();
}
 
Example #15
Source File: BitcoinUIModel.java    From thundernetwork with GNU Affero General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty syncProgressProperty () {
    return syncProgress;
}
 
Example #16
Source File: BaseMap.java    From maps with GNU General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty zoom() {
    return zoom.getReadOnlyProperty();
}
 
Example #17
Source File: AbstractFormLayoutRegion.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public ReadOnlyDoubleProperty prefTitleWidthProperty() {
    return prefTitleWidth.getReadOnlyProperty();
}
 
Example #18
Source File: AbstractFormLayoutRegion.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public ReadOnlyDoubleProperty minTitleWidthProperty() {
    return minTitleWidth.getReadOnlyProperty();
}
 
Example #19
Source File: Lcd.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final ReadOnlyDoubleProperty formerValueProperty() {
    return formerValue;
}
 
Example #20
Source File: AbstractFormLayoutRegion.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public ReadOnlyDoubleProperty maxTitleWidthProperty() {
    return maxTitleWidth.getReadOnlyProperty();
}
 
Example #21
Source File: ChatView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public void display(SupportSession supportSession, ReadOnlyDoubleProperty widthProperty) {
    display(supportSession, null, widthProperty);
}
 
Example #22
Source File: MutableOfferDataModel.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
ReadOnlyDoubleProperty getBuyerSecurityDeposit() {
    return buyerSecurityDeposit;
}
 
Example #23
Source File: WalletsSetup.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty downloadPercentageProperty() {
    return downloadListener.percentageProperty();
}
 
Example #24
Source File: WalletsSetup.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty percentageProperty() {
    return percentage;
}
 
Example #25
Source File: Lcd.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final ReadOnlyDoubleProperty currentValueProperty() {
    return currentValue;
}
 
Example #26
Source File: RectangleItem.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
@Override
public ReadOnlyDoubleProperty getMinXProperty() {
   return xProperty();
}
 
Example #27
Source File: AbstractFormLayoutRegion.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public ReadOnlyDoubleProperty maxEditorWidthProperty() {
    return maxEditorWidth.getReadOnlyProperty();
}
 
Example #28
Source File: BaseMap.java    From maps with GNU General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty centerLat() {
    return centerLat.getReadOnlyProperty();
}
 
Example #29
Source File: BaseMap.java    From maps with GNU General Public License v3.0 4 votes vote down vote up
public ReadOnlyDoubleProperty centerLon() {
    return centerLon.getReadOnlyProperty();
}
 
Example #30
Source File: Catalog.java    From xltsearch with Apache License 2.0 4 votes vote down vote up
ReadOnlyDoubleProperty indexProgressProperty() {
    return indexProgress.getReadOnlyProperty();
}