Java Code Examples for javafx.scene.shape.Line#setVisible()
The following examples show how to use
javafx.scene.shape.Line#setVisible() .
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: TrackerSnapConstraint.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** @param toolkit * @param group Group where snap lines are added */ public TrackerSnapConstraint(final JFXRepresentation toolkit, final Group group) { this.toolkit = toolkit; horiz_guide = new Line(); horiz_guide.getStyleClass().add("guide_line"); horiz_guide.setVisible(false); horiz_guide.setManaged(false); vert_guide = new Line(); vert_guide.getStyleClass().add("guide_line"); vert_guide.setVisible(false); vert_guide.setManaged(false); group.getChildren().addAll(horiz_guide, vert_guide); }
Example 2
Source File: MultipleAxesLineChart.java From chart-fx with Apache License 2.0 | 5 votes |
private void bindMouseEvents(final LineChart<?, ?> baseChart, final Double strokeWidth) { getChildren().add(detailsWindow); detailsWindow.prefHeightProperty().bind(heightProperty()); detailsWindow.prefWidthProperty().bind(widthProperty()); detailsWindow.setMouseTransparent(true); setOnMouseMoved(null); setMouseTransparent(false); final Axis<?> xAxis = baseChart.getXAxis(); final Axis<?> yAxis = baseChart.getYAxis(); final Line xLine = new Line(); final Line yLine = new Line(); yLine.setFill(Color.GRAY); xLine.setFill(Color.GRAY); yLine.setStrokeWidth(strokeWidth / 2); xLine.setStrokeWidth(strokeWidth / 2); xLine.setVisible(false); yLine.setVisible(false); final Node chartBackground = baseChart.lookup(".chart-plot-background"); for (final Node n : chartBackground.getParent().getChildrenUnmodifiable()) { if ((n != chartBackground) && (n != xAxis) && (n != yAxis)) { n.setMouseTransparent(true); } } }
Example 3
Source File: SnappingFeedbackPart.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override protected Line doCreateVisual() { Line line = new Line(); line.setStroke(Color.RED); line.setStrokeWidth(1); line.setStrokeType(StrokeType.CENTERED); line.setStrokeLineCap(StrokeLineCap.BUTT); line.setVisible(false); return line; }
Example 4
Source File: GridRenderer.java From chart-fx with Apache License 2.0 | 4 votes |
public GridRenderer() { super(); getStylesheets().add(GridRenderer.CHART_CSS); getStyleClass().setAll(GridRenderer.STYLE_CLASS_GRID_RENDERER); horMajorGridStyleNode = new Line(); horMajorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MAJOR_GRID_LINE); horMajorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MAJOR_GRID_LINE_H); verMajorGridStyleNode = new Line(); verMajorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MAJOR_GRID_LINE); verMajorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MAJOR_GRID_LINE_V); horMinorGridStyleNode = new Line(); horMinorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MINOR_GRID_LINE); horMinorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MINOR_GRID_LINE_H); horMinorGridStyleNode.setVisible(false); verMinorGridStyleNode = new Line(); verMinorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MINOR_GRID_LINE); verMinorGridStyleNode.getStyleClass().add(GridRenderer.STYLE_CLASS_MINOR_GRID_LINE_V); verMinorGridStyleNode.setVisible(false); drawGridOnTopNode = new Line(); drawGridOnTopNode.getStyleClass().add(GridRenderer.STYLE_CLASS_GRID_ON_TOP); drawGridOnTopNode.getStyleClass().add(GridRenderer.STYLE_CLASS_GRID_ON_TOP); drawGridOnTopNode.setVisible(true); gridStyleNodes.getChildren().addAll(horMajorGridStyleNode, verMajorGridStyleNode, horMinorGridStyleNode, verMinorGridStyleNode, drawGridOnTopNode); getChildren().add(gridStyleNodes); final Scene scene = new Scene(this); scene.getStylesheets().add(GridRenderer.CHART_CSS); gridStyleNodes.applyCss(); final SetChangeListener<? super PseudoClass> listener = evt -> gridStyleNodes.applyCss(); horMajorGridStyleNode.getPseudoClassStates().addListener(listener); verMajorGridStyleNode.getPseudoClassStates().addListener(listener); horMinorGridStyleNode.getPseudoClassStates().addListener(listener); verMinorGridStyleNode.getPseudoClassStates().addListener(listener); drawGridOnTopNode.getPseudoClassStates().addListener(listener); ChangeListener<? super Boolean> change = (ob, o, n) -> { horMajorGridStyleNode.pseudoClassStateChanged(GridRenderer.SELECTED_PSEUDO_CLASS, horMinorGridStyleNode.isVisible()); verMajorGridStyleNode.pseudoClassStateChanged(GridRenderer.SELECTED_PSEUDO_CLASS, verMinorGridStyleNode.isVisible()); drawGridOnTopNode.pseudoClassStateChanged(GridRenderer.SELECTED_PSEUDO_CLASS, drawGridOnTopNode.isVisible()); }; horizontalGridLinesVisibleProperty().addListener(change); verticalGridLinesVisibleProperty().addListener(change); drawOnTopProperty().addListener(change); }
Example 5
Source File: StockTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); averagingListener = o -> handleEvents("AVERAGING_PERIOD"); timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale()); state = State.CONSTANT; if (tile.isAutoScale()) tile.calcAutoScale(); low = tile.getMaxValue(); high = tile.getMinValue(); movingAverage = tile.getMovingAverage(); noOfDatapoints = tile.getAveragingPeriod(); dataList = new LinkedList<>(); // To get smooth lines in the chart we need at least 4 values if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3."); graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getValue())); valueText.setBoundsType(TextBoundsType.VISUAL); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); valueUnitFlow = new TextFlow(valueText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); highText = new Text(); highText.setTextOrigin(VPos.BOTTOM); highText.setFill(tile.getValueColor()); lowText = new Text(); lowText.setTextOrigin(VPos.TOP); lowText.setFill(tile.getValueColor()); text = new Text(tile.getText()); text.setTextOrigin(VPos.TOP); text.setFill(tile.getTextColor()); timeSpanText = new Text(""); timeSpanText.setTextOrigin(VPos.TOP); timeSpanText.setFill(tile.getTextColor()); Helper.enableNode(timeSpanText, !tile.isTextVisible()); referenceLine = new Line(); referenceLine.getStrokeDashArray().addAll(3d, 3d); referenceLine.setVisible(false); pathElements = new ArrayList<>(noOfDatapoints); pathElements.add(0, new MoveTo()); for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); } sparkLine = new Path(); sparkLine.getElements().addAll(pathElements); sparkLine.setFill(null); sparkLine.setStroke(tile.getBarColor()); sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075); sparkLine.setStrokeLineCap(StrokeLineCap.ROUND); sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND); dot = new Circle(); dot.setFill(tile.getBarColor()); dot.setVisible(false); triangle = new Path(); triangle.setStroke(null); triangle.setFill(state.color); indicatorPane = new StackPane(triangle); changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue()))); changeText.setTextFill(state.color); changeText.setAlignment(Pos.CENTER_RIGHT); changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append("\u0025").toString()); changePercentageText.setFill(state.color); changePercentageFlow = new TextFlow(indicatorPane, changePercentageText); changePercentageFlow.setTextAlignment(TextAlignment.RIGHT); getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow); }
Example 6
Source File: StockTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); averagingListener = o -> handleEvents("AVERAGING_PERIOD"); timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale()); state = State.CONSTANT; if (tile.isAutoScale()) tile.calcAutoScale(); low = tile.getMaxValue(); high = tile.getMinValue(); movingAverage = tile.getMovingAverage(); noOfDatapoints = tile.getAveragingPeriod(); dataList = new LinkedList<>(); // To get smooth lines in the chart we need at least 4 values if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3."); graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getValue())); valueText.setBoundsType(TextBoundsType.VISUAL); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); valueUnitFlow = new TextFlow(valueText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); highText = new Text(); highText.setTextOrigin(VPos.BOTTOM); highText.setFill(tile.getValueColor()); lowText = new Text(); lowText.setTextOrigin(VPos.TOP); lowText.setFill(tile.getValueColor()); text = new Text(tile.getText()); text.setTextOrigin(VPos.TOP); text.setFill(tile.getTextColor()); timeSpanText = new Text(""); timeSpanText.setTextOrigin(VPos.TOP); timeSpanText.setFill(tile.getTextColor()); Helper.enableNode(timeSpanText, !tile.isTextVisible()); referenceLine = new Line(); referenceLine.getStrokeDashArray().addAll(3d, 3d); referenceLine.setVisible(false); pathElements = new ArrayList<>(noOfDatapoints); pathElements.add(0, new MoveTo()); for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); } sparkLine = new Path(); sparkLine.getElements().addAll(pathElements); sparkLine.setFill(null); sparkLine.setStroke(tile.getBarColor()); sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075); sparkLine.setStrokeLineCap(StrokeLineCap.ROUND); sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND); dot = new Circle(); dot.setFill(tile.getBarColor()); dot.setVisible(false); triangle = new Path(); triangle.setStroke(null); triangle.setFill(state.color); indicatorPane = new StackPane(triangle); changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue()))); changeText.setTextFill(state.color); changeText.setAlignment(Pos.CENTER_RIGHT); changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append(Helper.PERCENTAGE).toString()); changePercentageText.setFill(state.color); changePercentageFlow = new TextFlow(indicatorPane, changePercentageText); changePercentageFlow.setTextAlignment(TextAlignment.RIGHT); getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow); }
Example 7
Source File: JFXCheckBoxOldSkin.java From JFoenix with Apache License 2.0 | 4 votes |
public JFXCheckBoxOldSkin(JFXCheckBox control) { super(control); box.setMinSize(20, 20); box.setPrefSize(20, 20); box.setMaxSize(20, 20); box.setBorder(new Border(new BorderStroke(control.getUnCheckedColor(), BorderStrokeStyle.SOLID, new CornerRadii(0), new BorderWidths(lineThick)))); // StackPane boxContainer = new StackPane(); boxContainer.getChildren().add(box); boxContainer.setPadding(new Insets(padding)); rippler = new JFXRippler(boxContainer, RipplerMask.CIRCLE); rippler.setRipplerFill(getSkinnable().isSelected() ? control.getUnCheckedColor() : control.getCheckedColor()); rightLine = new Line(); leftLine = new Line(); rightLine.setStroke(control.getCheckedColor()); rightLine.setStrokeWidth(lineThick); leftLine.setStroke(control.getCheckedColor()); leftLine.setStrokeWidth(lineThick); rightLine.setVisible(false); leftLine.setVisible(false); container.getChildren().add(rightLine); container.getChildren().add(leftLine); container.getChildren().add(rippler); AnchorPane.setRightAnchor(rippler, labelOffset); // add listeners getSkinnable().selectedProperty().addListener((o, oldVal, newVal) -> { rippler.setRipplerFill(newVal ? control.getUnCheckedColor() : control.getCheckedColor()); transition.setRate(newVal ? 1 : -1); transition.play(); }); updateChildren(); }