Java Code Examples for javafx.scene.shape.Line#setStrokeLineCap()

The following examples show how to use javafx.scene.shape.Line#setStrokeLineCap() . 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: LinearSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeParts() {
  value = new Text(0, ARTBOARD_HEIGHT * 0.5, String.format(FORMAT, getSkinnable().getValue()));
  value.getStyleClass().add("value");
  value.setTextOrigin(VPos.CENTER);
  value.setTextAlignment(TextAlignment.CENTER);
  value.setMouseTransparent(true);
  value.setWrappingWidth(ARTBOARD_HEIGHT);
  value.setBoundsType(TextBoundsType.VISUAL);

  thumb = new Circle(ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5);
  thumb.getStyleClass().add("thumb");

  thumbGroup = new Group(thumb, value);

  valueBar = new Line();
  valueBar.getStyleClass().add("valueBar");
  valueBar.setStrokeLineCap(StrokeLineCap.ROUND);
  applyCss(valueBar);
  strokeWidthFromCSS = valueBar.getStrokeWidth();

  scale = new Line();
  scale.getStyleClass().add("scale");
  scale.setStrokeLineCap(StrokeLineCap.ROUND);

  // always needed
  drawingPane = new Pane();
}
 
Example 2
Source File: SlimSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private void initializeParts() {
  double cx = ARTBOARD_WIDTH * 0.5;

  separator = new Line(25, 15, 225, 15);
  separator.getStyleClass().add("separator");
  separator.setStrokeLineCap(StrokeLineCap.ROUND);

  titleLabel = createCenteredText(cx, 19, "title");
  titleLabel.setTextOrigin(VPos.TOP);

  valueLabel = createCenteredText(cx, 150, "value");

  unitLabel = createCenteredText(cx, 188, "unit");
  unitLabel.setTextOrigin(VPos.TOP);

  barBackground = new Circle(CIRCLE_CENTER_X, CIRCLE_CENTER_Y, RADIUS);
  barBackground.getStyleClass().add("barBackground");

  bar = new Arc(CIRCLE_CENTER_X, CIRCLE_CENTER_Y, RADIUS, RADIUS, START_ANGLE, 0);
  bar.getStyleClass().add("bar");
  bar.setType(ArcType.OPEN);

  thumb = new Circle(7);
  thumb.getStyleClass().add("thumb");

  // always needed
  drawingPane = new Pane();
  drawingPane.setMaxSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setMinSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setPrefSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
}
 
Example 3
Source File: SnappingFeedbackPart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@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: ViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private Line createLine(final Point p1, final Point p2) {
	final Line line = new Line();
	line.startXProperty().bind(p1.xProperty());
	line.startYProperty().bind(p1.yProperty());
	line.endXProperty().bind(p2.xProperty());
	line.endYProperty().bind(p2.yProperty());
	line.strokeWidthProperty().bind(Bindings.createDoubleBinding(() -> model.getFullThickness() / 2d, model.thicknessProperty(),
		model.dbleBordSepProperty(), model.dbleBordProperty()));
	line.strokeProperty().bind(Bindings.createObjectBinding(() -> model.getLineColour().toJFX(), model.lineColourProperty()));
	line.setStrokeLineCap(StrokeLineCap.BUTT);
	line.getStrokeDashArray().clear();
	line.getStrokeDashArray().addAll(model.getDashSepBlack(), model.getDashSepWhite());
	return line;
}
 
Example 5
Source File: BarGaugeTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    if (tile.isAutoScale()) tile.calcAutoScale();

    gradientLookup       = new GradientLookup(tile.getGradientStops());
    noOfGradientStops    = tile.getGradientStops().size();
    sectionsVisible      = tile.getSectionsVisible();
    colorGradientEnabled = tile.isStrokeWithGradient();

    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.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

    upperUnitText = new Text("");
    upperUnitText.setFill(tile.getUnitColor());
    Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty());

    fractionLine = new Line();

    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());

    unitFlow = new VBox(upperUnitText, unitText);
    unitFlow.setAlignment(Pos.CENTER_RIGHT);

    valueUnitFlow = new HBox(valueText, unitFlow);
    valueUnitFlow.setAlignment(Pos.CENTER);
    valueUnitFlow.setMouseTransparent(true);

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, 0, ANGLE_RANGE);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(tile.getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.125);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, 270, 0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(tile.getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.125);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);

    lowerThreshold = new Line();
    lowerThreshold.setStroke(tile.getLowerThresholdColor());
    lowerThreshold.setStrokeLineCap(StrokeLineCap.BUTT);
    Helper.enableNode(lowerThreshold, tile.isLowerThresholdVisible());

    lowerThresholdText = new Text(String.format(locale, formatString, tile.getLowerThreshold()));
    Helper.enableNode(lowerThresholdText, tile.isLowerThresholdVisible());
    
    threshold = new Line();
    threshold.setStroke(tile.getThresholdColor());
    threshold.setStrokeLineCap(StrokeLineCap.BUTT);
    Helper.enableNode(threshold, tile.isThresholdVisible());
    
    thresholdText = new Text(String.format(locale, formatString, tile.getThreshold()));
    Helper.enableNode(thresholdText, tile.isThresholdVisible());
    
    minValueText = new Text();
    maxValueText = new Text();

    getPane().getChildren().addAll(barBackground, bar, lowerThreshold, lowerThresholdText, threshold, thresholdText, minValueText, maxValueText, titleText, valueUnitFlow, fractionLine, text);
}
 
Example 6
Source File: DashboardSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    unitText = new Text(gauge.getUnit());
    unitText.setTextOrigin(VPos.CENTER);
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setTextOrigin(VPos.CENTER);
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    minValue = gauge.getMinValue();
    minText  = new Text(String.format(locale, otherFormatString, minValue));
    minText.setTextOrigin(VPos.CENTER);
    minText.setFill(gauge.getValueColor());

    maxText = new Text(String.format(locale, otherFormatString, gauge.getMaxValue()));
    maxText.setTextOrigin(VPos.CENTER);
    maxText.setFill(gauge.getValueColor());

    boolean tickLabelsVisible = gauge.getTickLabelsVisible();
    Helper.enableNode(minText, tickLabelsVisible);
    Helper.enableNode(maxText, tickLabelsVisible);

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.3), 30.0, 0.0, 0.0, 10.0);

    barBackgroundStart          = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    barBackgroundOuterArc       = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, true, true);
    barBackgroundLineToInnerArc = new LineTo(0.72222 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    barBackgroundInnerArc       = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, false, false);

    barBackground = new Path();
    barBackground.setFillRule(FillRule.EVEN_ODD);
    barBackground.getElements().add(barBackgroundStart);
    barBackground.getElements().add(barBackgroundOuterArc);
    barBackground.getElements().add(barBackgroundLineToInnerArc);
    barBackground.getElements().add(barBackgroundInnerArc);
    barBackground.getElements().add(new ClosePath());
    barBackground.setFill(gauge.getBarBackgroundColor());
    barBackground.setStroke(gauge.getBorderPaint());
    barBackground.setEffect(gauge.isShadowsEnabled() ? innerShadow : null);

    dataBarStart          = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    dataBarOuterArc       = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, 0, 0, false, true);
    dataBarLineToInnerArc = new LineTo(0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    dataBarInnerArc       = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0, 0, false, false);

    dataBar = new Path();
    dataBar.setFillRule(FillRule.EVEN_ODD);
    dataBar.getElements().add(dataBarStart);
    dataBar.getElements().add(dataBarOuterArc);
    dataBar.getElements().add(dataBarLineToInnerArc);
    dataBar.getElements().add(dataBarInnerArc);
    dataBar.getElements().add(new ClosePath());
    dataBar.setFill(gauge.getBarColor());
    dataBar.setStroke(gauge.getBorderPaint());
    dataBar.setEffect(gauge.isShadowsEnabled() ? innerShadow : null);

    threshold = new Line();
    threshold.setStrokeLineCap(StrokeLineCap.BUTT);
    Helper.enableNode(threshold, gauge.isThresholdVisible());

    thresholdText = new Text(String.format(locale, formatString, gauge.getThreshold()));
    Helper.enableNode(thresholdText, gauge.isThresholdVisible());

    pane = new Pane(unitText, titleText, valueText, minText, maxText, barBackground, dataBar, threshold, thresholdText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 7
Source File: SymbolRepresentation.java    From phoebus with Eclipse Public License 1.0 3 votes vote down vote up
DefaultSymbolNode() {

            setManaged(true);

            int w = 100;
            int h = 100;

            r = new Rectangle(0, 0, w, h);

            r.setFill(null);
            r.setArcHeight(0);
            r.setArcWidth(0);
            r.setStroke(Color.BLACK);
            r.setStrokeType(StrokeType.INSIDE);

            l1 = new Line(0.5, 0.5, w - 0.5, h - 0.5);

            l1.setStroke(Color.BLACK);
            l1.setStrokeLineCap(StrokeLineCap.BUTT);

            l2 = new Line(0.5, h - 0.5, w - 0.5, 0.5);

            l2.setStroke(Color.BLACK);
            l2.setStrokeLineCap(StrokeLineCap.BUTT);

            getChildren().add(r);
            getChildren().add(l1);
            getChildren().add(l2);

        }