public CycleView(final List<Node> nodes, final int cycleIndex, final double hueInterval) { Paint p = Color.hsb(cycleIndex * hueInterval, 0.75, 0.70, 0.25); setFill(p); setStroke(p); setStrokeWidth(20); setStrokeLineJoin(StrokeLineJoin.ROUND); setStrokeType(StrokeType.OUTSIDE); updateHull(nodes, HULL_ALGORITHM); final ChangeListener<Number> listener = (_0, _1, _2) -> { updateHull(nodes, HULL_ALGORITHM); }; for (Node n : nodes) { n.translateXProperty().addListener(listener); n.translateYProperty().addListener(listener); } }
/** @param color Color to display */ public void setColor(final WidgetColor color) { final GraphicsContext gc = blob.getGraphicsContext2D(); gc.setFill(JFXUtil.convert(color)); gc.fillRect(0, 0, 16, 16); gc.setLineCap(StrokeLineCap.SQUARE); gc.setLineJoin(StrokeLineJoin.MITER); gc.setLineWidth(1.75); gc.setStroke(Color.BLACK); gc.strokeRect(0, 0, 16, 16); button.setText(String.valueOf(color)); }
/** * Sets the stroke line join with a JavaFx stroke line join * @param javaFxStrokeLineJoin */ public void setStrokeLineJoin(StrokeLineJoin javaFxStrokeLineJoin) { switch (javaFxStrokeLineJoin) { case MITER: setStrokeLineJoin(SvgStrokeLineJoin.MITER); break; case ROUND: setStrokeLineJoin(SvgStrokeLineJoin.ROUND); break; case BEVEL: setStrokeLineJoin(SvgStrokeLineJoin.BEVEL); break; default: String message = "The line join " + javaFxStrokeLineJoin + " is not known."; throw new IllegalArgumentException(message); } }
@Override public void draw(ZoomableGraphicsContext gc, MapPolyline element) { definePath(gc, element); final Color color = gc.rgb(getDrawingColor(element)); gc.setFill(null); gc.setStroke(color); if (element.isWidePolyline()) { gc.setLineWidthInMeters(element.getWidth()); } else { gc.setLineWidthInPixels(1); } gc.setLineCap(StrokeLineCap.ROUND); gc.setLineJoin(StrokeLineJoin.ROUND); gc.stroke(); }
@Override public void draw(ZoomableGraphicsContext gc, RoadPolyline element) { definePath(gc, element); gc.setFill(null); gc.setLineCap(StrokeLineCap.ROUND); gc.setLineJoin(StrokeLineJoin.ROUND); switch (gc.getState()) { case RoadNetworkDrawerConstants.DRAWING_STATE_ROAD_BORDERS: setupRoadBorders(gc, element); break; case RoadNetworkDrawerConstants.DRAWING_STATE_ROAD_INTERIOR: setupRoadInterior(gc, element); break; case RoadNetworkDrawerConstants.DRAWING_STATE_ROAD_DETAILS: setupRoadDetails(gc, element); break; default: } gc.stroke(); }
private void initialize(double width, double height){ this.setScaleY(-1); this.interval = 1; this.currentX = 0; this.setMaxWidth(width); this.setMaxHeight(height); this.setWidth(width); this.setHeight(height); this.setMinWidth(width); this.setMinHeight(height); this.points = new ArrayList<>(); this.isRendered = false; this.isNormalized = false; this.isManualEntry = false; //Unique identification this.setId(UUID.randomUUID().toString()); //Layers this.graphPath = new SVGPath(); this.pointLines = new SVGPath(); this.pointDots = new Pane(); //Styling values this.smoothing = 0.2; this.circleStyle = new Circle(); this.close = true; graphPath.setStrokeWidth(1); graphPath.setStroke(BLACK); graphPath.setFill(TRANSPARENT); graphPath.setStrokeLineJoin(StrokeLineJoin.ROUND); pointLines.setStrokeWidth(0.5); pointLines.setStroke(BLACK); circleStyle.setRadius(2); circleStyle.setFill(BLACK); }
@Override protected void seriesAdded(Series<X, Y> series, int seriesIndex) { // create new path for series Path seriesLine = new Path(); seriesLine.setStrokeLineJoin(StrokeLineJoin.BEVEL); series.setNode(seriesLine); // create series Y multiplier DoubleProperty seriesYAnimMultiplier = new SimpleDoubleProperty(this, "seriesYMultiplier"); seriesYMultiplierMap.put(series, seriesYAnimMultiplier); // handle any data already in series if (shouldAnimate()) { seriesLine.setOpacity(0); seriesYAnimMultiplier.setValue(0d); } else { seriesYAnimMultiplier.setValue(1d); } getPlotChildren().add(seriesLine); List<KeyFrame> keyFrames = new ArrayList<KeyFrame>(); if (shouldAnimate()) { // animate in new series keyFrames.add(new KeyFrame(Duration.ZERO, new KeyValue(seriesLine.opacityProperty(), 0), new KeyValue(seriesYAnimMultiplier, 0))); keyFrames.add(new KeyFrame(Duration.millis(200), new KeyValue(seriesLine.opacityProperty(), 1))); keyFrames.add(new KeyFrame(Duration.millis(500), new KeyValue(seriesYAnimMultiplier, 1))); } for (int j = 0; j < series.getData().size(); j++) { Data<X, Y> item = series.getData().get(j); final Node symbol = createSymbol(series, seriesIndex, item, j); if (symbol != null) { if (shouldAnimate()) symbol.setOpacity(0); getPlotChildren().add(symbol); if (shouldAnimate()) { // fade in new symbol keyFrames.add(new KeyFrame(Duration.ZERO, new KeyValue(symbol.opacityProperty(), 0))); keyFrames.add(new KeyFrame(Duration.millis(200), new KeyValue(symbol.opacityProperty(), 1))); } } } if (shouldAnimate()) animate(keyFrames.toArray(new KeyFrame[keyFrames.size()])); }
/** * Maps a line join code from AWT to the corresponding JavaFX * StrokeLineJoin enum value. * * @param c the line join code. * * @return A JavaFX line join value. */ private StrokeLineJoin awtToJavaFXLineJoin(int j) { if (j == BasicStroke.JOIN_BEVEL) { return StrokeLineJoin.BEVEL; } else if (j == BasicStroke.JOIN_MITER) { return StrokeLineJoin.MITER; } else if (j == BasicStroke.JOIN_ROUND) { return StrokeLineJoin.ROUND; } else { throw new IllegalArgumentException("Unrecognised join code: " + j); } }
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); } } graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45); titleText = new Text(gauge.getTitle()); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, gauge.getValue())); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(gauge.getUnit()); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); averageText = new Text(String.format(locale, formatString, gauge.getAverage())); averageText.setFill(gauge.getAverageColor()); Helper.enableNode(averageText, gauge.isAverageVisible()); highText = new Text(); highText.setTextOrigin(VPos.BOTTOM); highText.setFill(gauge.getValueColor()); lowText = new Text(); lowText.setTextOrigin(VPos.TOP); lowText.setFill(gauge.getValueColor()); subTitleText = new Text(gauge.getSubTitle()); subTitleText.setTextOrigin(VPos.TOP); subTitleText.setFill(gauge.getSubTitleColor()); stdDeviationArea = new Rectangle(); Helper.enableNode(stdDeviationArea, gauge.isAverageVisible()); averageLine = new Line(); averageLine.setStroke(gauge.getAverageColor()); averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005); Helper.enableNode(averageLine, gauge.isAverageVisible()); 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(gauge.getBarColor()); sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075); sparkLine.setStrokeLineCap(StrokeLineCap.ROUND); sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND); dot = new Circle(); dot.setFill(gauge.getBarColor()); pane = new Pane(titleText, valueText, unitText, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, subTitleText); pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY))); getChildren().setAll(pane); }
@Override public void start(final Stage stage) throws Exception { poly.setStroke(Color.BLUE); poly.setStrokeWidth(4); poly.setStrokeLineCap(StrokeLineCap.ROUND); poly.setStrokeLineJoin(StrokeLineJoin.ROUND); poly.setFill(Color.CORNSILK); final Group root = new Group(); root.getChildren().add(poly); final Scene scene = new Scene(root, 400, 400); stage.setScene(scene); stage.show(); EditorUtil.setSceneStyle(scene); editor = new PointsEditor(root, points, new PointsEditorListener() { @Override public void pointsChanged(final Points points) { updatePoly(); } @Override public void done() { editor.dispose(); } }); updatePoly(); }
@Override public Group createJFXNode() throws Exception { final Polyline polyline = new Polyline(); polyline.setStrokeLineJoin(StrokeLineJoin.MITER); polyline.setStrokeLineCap(StrokeLineCap.BUTT); return new Group(polyline, new Arrow(), new Arrow()); }
@Override public Polygon createJFXNode() throws Exception { final Polygon polygon = new Polygon(); polygon.setStrokeLineJoin(StrokeLineJoin.ROUND); polygon.setStrokeLineCap(StrokeLineCap.BUTT); return polygon; }
public MapPolyline() { getStyleClass().add("map-polyline"); setFill(null); setStrokeLineJoin(StrokeLineJoin.ROUND); locationsProperty.addListener((ListChangeListener.Change<? extends Location> c) -> updatePoints()); }
public MapPolygon() { getStyleClass().add("map-polygon"); setFill(null); setStrokeLineJoin(StrokeLineJoin.ROUND); locationsProperty.addListener((ListChangeListener.Change<? extends Location> c) -> updatePoints()); }
private static void addStrokeDataFromShape(SvgNodeProperties properties, Shape shape) { //color Paint stroke = shape.getStroke(); String strokeColor = paintToColorString(stroke); properties.setStroke(strokeColor); //width Double strokeWidth = shape.getStrokeWidth(); properties.setStrokeWidth(strokeWidth); //line cap StrokeLineCap strokeLineCap = shape.getStrokeLineCap(); properties.setStrokeLineCap(strokeLineCap); //dash array List<Double> strokeDashArrayList = shape.getStrokeDashArray(); String strokeDashArray = doubleArrayToStrokeDashArrayString(strokeDashArrayList); properties.setStrokeDashArray(strokeDashArray); //dash offset Double strokeDashOffset = shape.getStrokeDashOffset(); properties.setStrokeDashOffset(strokeDashOffset); //line join StrokeLineJoin strokeLineJoin = shape.getStrokeLineJoin(); properties.setStrokeLineJoin(strokeLineJoin); //miter limit Double strokeMiterLimit = shape.getStrokeMiterLimit(); properties.setStrokeMiterLimit(strokeMiterLimit); //alignment StrokeType strokeType = shape.getStrokeType(); properties.setStrokeAlignment(strokeType); }
protected void startLine(double x, double y) { // Create the new line and set it's properties. line = new Line(); line.setStartX(x); line.setStartY(y); line.setStroke(Properties.getForeColor()); line.setStrokeWidth(Properties.getWidth()); line.setStrokeLineCap(StrokeLineCap.ROUND); line.setStrokeLineJoin(StrokeLineJoin.BEVEL); }
/** * Maps a line join code from AWT to the corresponding JavaFX * StrokeLineJoin enum value. * * @param j the line join code. * * @return A JavaFX line join value. */ private StrokeLineJoin awtToJavaFXLineJoin(int j) { if (j == BasicStroke.JOIN_BEVEL) { return StrokeLineJoin.BEVEL; } else if (j == BasicStroke.JOIN_MITER) { return StrokeLineJoin.MITER; } else if (j == BasicStroke.JOIN_ROUND) { return StrokeLineJoin.ROUND; } else { throw new IllegalArgumentException("Unrecognised join code: " + j); } }
/** * Maps a line join code from AWT to the corresponding JavaFX * StrokeLineJoin enum value. * * @param c the line join code. * @return A JavaFX line join value. */ private StrokeLineJoin awtToJavaFXLineJoin(int j) { if (j == BasicStroke.JOIN_BEVEL) { return StrokeLineJoin.BEVEL; } else if (j == BasicStroke.JOIN_MITER) { return StrokeLineJoin.MITER; } else if (j == BasicStroke.JOIN_ROUND) { return StrokeLineJoin.ROUND; } else { throw new IllegalArgumentException("Unrecognised join code: " + j); } }
public PropertyTimeline<String> strokeLineJoinProperty() { return strokeLineJoin.setIfEmptyThenGet(enumToString(StrokeLineJoin.class, shape.strokeLineJoinProperty())); }
@Override protected void seriesAdded(MultiAxisChart.Series<X, Y> series, int seriesIndex) { // create new paths for series Path seriesLine = new Path(); Path fillPath = new Path(); seriesLine.setStrokeLineJoin(StrokeLineJoin.BEVEL); Group areaGroup = new Group(fillPath, seriesLine); series.setNode(areaGroup); // create series Y multiplier DoubleProperty seriesYAnimMultiplier = new SimpleDoubleProperty(this, "seriesYMultiplier"); seriesYMultiplierMap.put(series, seriesYAnimMultiplier); // handle any data already in series if (shouldAnimate()) { seriesYAnimMultiplier.setValue(0d); } else { seriesYAnimMultiplier.setValue(1d); } getPlotChildren().add(areaGroup); List<KeyFrame> keyFrames = new ArrayList<KeyFrame>(); if (shouldAnimate()) { // animate in new series keyFrames.add(new KeyFrame(Duration.ZERO, new KeyValue(areaGroup.opacityProperty(), 0), new KeyValue(seriesYAnimMultiplier, 0))); keyFrames.add(new KeyFrame(Duration.millis(200), new KeyValue(areaGroup.opacityProperty(), 1))); keyFrames.add(new KeyFrame(Duration.millis(500), new KeyValue(seriesYAnimMultiplier, 1))); } for (int j = 0; j < series.getData().size(); j++) { Data<X, Y> item = series.getData().get(j); final Node symbol = createSymbol(series, seriesIndex, item, j); if (symbol != null) { if (shouldAnimate()) { symbol.setOpacity(0); getPlotChildren().add(symbol); // fade in new symbol keyFrames.add(new KeyFrame(Duration.ZERO, new KeyValue(symbol.opacityProperty(), 0))); keyFrames.add(new KeyFrame(Duration.millis(200), new KeyValue(symbol.opacityProperty(), 1))); } else { getPlotChildren().add(symbol); } } } if (shouldAnimate()) animate(keyFrames.toArray(new KeyFrame[keyFrames.size()])); }
public void setStrokeLineJoin(StrokeLineJoin x) { lineJoin = x; }
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); } } sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsCtx = sectionsCanvas.getGraphicsContext2D(); needleRotate = new Rotate(180 - START_ANGLE); angleStep = ANGLE_RANGE / (gauge.getRange()); double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep; needleRotate.setAngle(Helper.clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle)); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleLineTo5 = new LineTo(); needleLineTo6 = new LineTo(); needleCubicCurveTo7 = new CubicCurveTo(); needleClosePath8 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleLineTo6, needleCubicCurveTo7, needleClosePath8); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(gauge.getNeedleColor()); needle.setStroke(gauge.getBorderPaint()); needle.setStrokeLineCap(StrokeLineCap.ROUND); needle.setStrokeLineJoin(StrokeLineJoin.BEVEL); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit()); valueText.setMouseTransparent(true); valueText.setTextOrigin(VPos.CENTER); valueText.setFill(gauge.getValueColor()); enableNode(valueText, gauge.isValueVisible()); titleText = new Text(gauge.getTitle()); titleText.setTextOrigin(VPos.CENTER); titleText.setFill(gauge.getTitleColor()); enableNode(titleText, !gauge.getTitle().isEmpty()); subTitleText = new Text(gauge.getSubTitle()); subTitleText.setTextOrigin(VPos.CENTER); subTitleText.setFill(gauge.getSubTitleColor()); enableNode(subTitleText, !gauge.getSubTitle().isEmpty()); // Add all nodes pane = new Pane(sectionsCanvas, needle, valueText, titleText, subTitleText); getChildren().setAll(pane); }
public void set(PrimitiveProperties p) { super.set(p); this.lineJoin = StrokeLineJoin.valueOf(p.getString("lineJoin", "ROUND").toUpperCase()); }
private void drawForeground() { ctxFg.clearRect(0, 0, width, height); ctxFg.setStroke(getSkinnable().getSeriesStroke()); ctxFg.setLineCap(StrokeLineCap.ROUND); ctxFg.setLineJoin(StrokeLineJoin.ROUND); ctxFg.setLineWidth(0.025 * height); ctxFg.save(); ctxFg.translate(0, sectionMinimum * heightFactor); widthFactor = width / (getSkinnable().getSeries().getData().size()); int noOfDataPoints = getSkinnable().getSeries().getData().size(); if (noOfDataPoints > 2) { for (int i = 0 ; i < noOfDataPoints - 1 ; i++) { XYChart.Data p1 = (XYChart.Data) getSkinnable().getSeries().getData().get(i); XYChart.Data p2 = (XYChart.Data) getSkinnable().getSeries().getData().get(i + 1); ctxFg.strokeLine(widthFactor / 2 + i * widthFactor, height - (Double) p1.getYValue() * heightFactor, widthFactor / 2 + (i + 1) * widthFactor, height - (Double) p2.getYValue() * heightFactor); drawBullet(ctxFg, widthFactor / 2 + i * widthFactor, height - (Double) p1.getYValue() * heightFactor, getSkinnable().getBulletFill()); } drawBullet(ctxFg, widthFactor / 2 + (noOfDataPoints - 1) * widthFactor, height - (Double) (getSkinnable().getSeries().getData().get(noOfDataPoints - 1)).getYValue() * heightFactor, getSkinnable().getBulletFill()); } ctxFg.save(); ctxFg.applyEffect(new DropShadow(0.025 * height, 0, 0.025 * height, Color.rgb(0, 0, 0, 0.65))); ctxFg.restore(); // draw from and to text ctxFg.setFill(Color.WHITE); ctxFg.setFont(Font.font("Open Sans", height * 0.1)); ctxFg.setTextBaseline(VPos.BOTTOM); ctxFg.setTextAlign(TextAlignment.LEFT); ctxFg.fillText(getSkinnable().getFrom(), 2, height - 2); ctxFg.setTextAlign(TextAlignment.RIGHT); ctxFg.fillText(getSkinnable().getTo(), width - 2, height -2); // draw title text if (getSkinnable().isTitleVisible()) { ctxFg.setTextBaseline(VPos.TOP); ctxFg.setTextAlign(TextAlignment.CENTER); ctxFg.fillText(getSkinnable().getSeries().getName(), width * 0.5, 2); } ctxFg.restore(); }
@Override public void Draw(Pane canvas) { try { double xGridSize = canvas.getWidth() / MaximumX; double yGridSize = canvas.getHeight() / MaximumY; double x = GetDoubleAttribute("X"); double y = GetDoubleAttribute("Y"); Vector finalCenterPoint = new Vector(x * xGridSize, y * yGridSize); double scaleFactor = ScaleFactor(canvas.getWidth(), canvas.getHeight()); SVGPath path = new SVGPath(); path.setContent(_path); path.setFill(GetColorAttribute("Color")); path.setStroke(GetColorAttribute("StrokeColor")); path.setStrokeWidth(StrokeThickness(canvas.getWidth(), canvas.getHeight())); path.setStrokeLineJoin(GetBooleanAttribute("StrokeCurved") ? StrokeLineJoin.ROUND : StrokeLineJoin.MITER); Rotate rotate = new Rotate(); rotate.setAngle(GetDoubleAttribute("Rotation") / MaximumX * 360); rotate.setPivotX(0); rotate.setPivotY(0); Translate translate = new Translate(); translate.setX(finalCenterPoint.X); translate.setY(finalCenterPoint.Y); Scale scale = new Scale(); scale.setX(scaleFactor); scale.setY(scaleFactor); scale.setPivotX(0); scale.setPivotY(0); path.getTransforms().add(translate); path.getTransforms().add(scale); path.getTransforms().add(rotate); canvas.getChildren().add(path); } catch (Exception e) { // Show alert } }
/** * Sets the current stroke line join. * The default value is {@link StrokeLineJoin#MITER}. * The line join is a stroke attribute * used for any of the stroke methods as specified in the * Rendering Attributes Table of {@link GraphicsContext}. * A {@code null} value will be ignored and the current value will remain unchanged. * * @param join {@code StrokeLineJoin} with a value of Miter, Bevel, or Round or null. */ public void setLineJoin(StrokeLineJoin join) { this.gc.setLineJoin(join); }
/** * Gets the current stroke line join. * The default value is {@link StrokeLineJoin#MITER}. * The line join is a stroke attribute * used for any of the stroke methods as specified in the * Rendering Attributes Table of {@link GraphicsContext}. * * @return {@code StrokeLineJoin} with a value of Miter, Bevel, or Round. */ public StrokeLineJoin getLineJoin() { return this.gc.getLineJoin(); }