private void clearSmallPolygons(Path... paths){ validPaths = new ArrayList<>(); Point2D p0 = Point2D.ZERO; for (Path path : paths) { for (PathElement elem : path.getElements()) { if (elem instanceof MoveTo) { elements = new ArrayList<>(); elements.add(elem); listPoints = new ArrayList<>(); p0 = new Point2D(((MoveTo)elem).getX(), ((MoveTo)elem).getY()); listPoints.add(p0); } else if (elem instanceof CubicCurveTo) { elements.add(elem); Point2D ini = listPoints.size() > 0 ? listPoints.get(listPoints.size() - 1) : p0; listPoints.addAll(evalCubicCurve((CubicCurveTo) elem, ini, POINTS_CURVE)); } else if (elem instanceof ClosePath) { elements.add(elem); listPoints.add(p0); if (Math.abs(calculateArea()) > MINIMUM_AREA) { validPaths.add(new Path(elements)); } } } } }
private String pathsToSVGPath() { final StringBuilder sb = new StringBuilder(); for (Path path : validPaths) { for (PathElement element : path.getElements()) { if (element instanceof MoveTo) { sb.append("M ").append(((MoveTo) element).getX()).append(" ") .append(((MoveTo) element).getY()); } else if (element instanceof CubicCurveTo) { CubicCurveTo curve = (CubicCurveTo) element; sb.append(" C ") .append(curve.getControlX1()).append(" ").append(curve.getControlY1()).append(" ") .append(curve.getControlX2()).append(" ").append(curve.getControlY2()).append(" ") .append(curve.getX()).append(" ").append(curve.getY()); } else if (element instanceof ClosePath) { sb.append(" Z "); } } } return sb.toString(); }
private void createNeedle() { double needleWidth = size * 0.04; double needleHeight = size * 0.4675; needle.getElements().clear(); needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight, 0.4375 * needleWidth, 0.0, 0.5 * needleWidth, 0.0)); needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0, 0.6875 * needleWidth, 0.005319148936170213 * needleHeight, 0.6875 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight, needleWidth, 0.9946808510638298 * needleHeight, needleWidth, 0.9946808510638298 * needleHeight)); needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight, 0.3125 * needleWidth, 0.015957446808510637 * needleHeight, 0.3125 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new ClosePath()); needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0, needle.getLayoutBounds().getMaxX(), 0, false, CycleMethod.NO_CYCLE, new Stop(0.0, gauge.getNeedleColor().darker()), new Stop(0.5, gauge.getNeedleColor()), new Stop(1.0, gauge.getNeedleColor().darker()))); }
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) { final Path PATH = new Path(); PATH.setFillRule(FillRule.EVEN_ODD); while (!PATH_LIST.isEmpty()) { if ("M".equals(READER.read())) { PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY())); } else if ("C".equals(READER.read())) { PATH.getElements().add(new CubicCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("Q".equals(READER.read())) { PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("H".equals(READER.read())) { PATH.getElements().add(new HLineTo(READER.nextX())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new VLineTo(READER.nextY())); } else if ("A".equals(READER.read())) { PATH.getElements().add(new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false)); } else if ("Z".equals(READER.read())) { PATH.getElements().add(new ClosePath()); } } return PATH; }
MySVGShortHandCubicCurveTo(PathElement lastElement, float lastX, float lastY, float x2, float y2, float x, float y, Point2D lastPoint) { super( 0f, 0f, x2, y2, x, y); float x1 = lastX; float y1 = lastY; if (lastElement instanceof CubicCurveTo){ x1 = 2 * lastX - (float)((CubicCurveTo)lastElement).getControlX2(); y1 = 2 * lastY - (float)((CubicCurveTo)lastElement).getControlY2(); } this.setControlX1(x1); this.setControlY1(y1); this.lastPoint = new Point2D(lastPoint.getX(), lastPoint.getY()); pStartControl = new Point2D(x1, y1); pEndControl = new Point2D(x2, y2); pTo = new Point2D(x, y); }
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400,260)); Rectangle rect = new Rectangle (0, 0, 40, 40); rect.setArcHeight(10); rect.setArcWidth(10); rect.setFill(Color.ORANGE); root.getChildren().add(rect); Path path = PathBuilder.create() .elements( new MoveTo(20,20), new CubicCurveTo(380, 0, 380, 120, 200, 120), new CubicCurveTo(0, 120, 0, 240, 380, 240) ) .build(); path.setStroke(Color.DODGERBLUE); path.getStrokeDashArray().setAll(5d,5d); root.getChildren().add(path); pathTransition = PathTransitionBuilder.create() .duration(Duration.seconds(4)) .path(path) .node(rect) .orientation(OrientationType.ORTHOGONAL_TO_TANGENT) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
public PathSample() { super(180,90); // Create path shape - square Path path1 = new Path(); path1.getElements().addAll( new MoveTo(25, 25), new HLineTo(65), new VLineTo(65), new LineTo(25, 65), new ClosePath() ); path1.setFill(null); path1.setStroke(Color.RED); path1.setStrokeWidth(2); // Create path shape - curves Path path2 = new Path(); path2.getElements().addAll( new MoveTo(100, 45), new CubicCurveTo(120, 20, 130, 80, 140, 45), new QuadCurveTo(150, 0, 160, 45), new ArcTo(20, 40, 0, 180, 45, true, true) ); path2.setFill(null); path2.setStroke(Color.DODGERBLUE); path2.setStrokeWidth(2); // show the path shapes; getChildren().add(new Group(path1, path2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()), new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty()) ); // END REMOVE ME }
private void drawTriangle() { MoveTo moveTo = new MoveTo(0.056 * size, 0.032 * size); CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size, 0.028 * size, 0.064 * size, 0.028 * size, 0.068 * size, 0.032 * size); CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size, 0.032 * size, 0.120 * size, 0.080 * size, 0.12 * size, 0.080 * size); CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size, 0.088 * size, 0.124 * size, 0.096 * size, 0.112 * size, 0.096 * size); CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size, 0.096 * size, 0.012 * size, 0.096 * size, 0.012 * size, 0.096 * size); CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size, -0.004 * size, 0.088 * size, 0.004 * size, 0.080 * size); CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size, 0.080 * size, 0.056 * size, 0.032 * size, 0.056 * size, 0.032 * size); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath); }
private void drawTriangle() { MoveTo moveTo = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath); }
public static final Path smoothPath(final ObservableList<PathElement> ELEMENTS, final boolean FILLED) { if (ELEMENTS.isEmpty()) { return new Path(); } final Point[] dataPoints = new Point[ELEMENTS.size()]; for (int i = 0; i < ELEMENTS.size(); i++) { final PathElement element = ELEMENTS.get(i); if (element instanceof MoveTo) { MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { LineTo line = (LineTo) element; dataPoints[i] = new Point(line.getX(), line.getY()); } } double zeroY = ((MoveTo) ELEMENTS.get(0)).getY(); List<PathElement> smoothedElements = new ArrayList<>(); Pair<Point[], Point[]> result = calcCurveControlPoints(dataPoints); Point[] firstControlPoints = result.getKey(); Point[] secondControlPoints = result.getValue(); // Start path dependent on filled or not if (FILLED) { smoothedElements.add(new MoveTo(dataPoints[0].getX(), zeroY)); smoothedElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY())); } else { smoothedElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY())); } // Add curves for (int i = 2; i < dataPoints.length; i++) { final int ci = i - 1; smoothedElements.add(new CubicCurveTo( firstControlPoints[ci].getX(), firstControlPoints[ci].getY(), secondControlPoints[ci].getX(), secondControlPoints[ci].getY(), dataPoints[i].getX(), dataPoints[i].getY())); } // Close the path if filled if (FILLED) { smoothedElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY)); smoothedElements.add(new ClosePath()); } return new Path(smoothedElements); }
private List<Point2D> evalCubicCurve(CubicCurveTo c, Point2D ini, int size){ List<Point2D> list = new ArrayList<>(); for (int i = 0; i < size; i++) { double t = (double) i / (double) size; final double t3 = Math.pow(t, 3); final double t2 = Math.pow(t, 2); final double ct3 = Math.pow(1 - t, 3); final double ct2 = Math.pow(1 - t, 2); list.add(new Point2D(ct3 * ini.getX() + 3 * t * ct2 * c.getControlX1() + 3 * (1 - t) * t2 * c.getControlX2() + t3 * c.getX(), ct3 * ini.getY() + 3 * t * ct2 * c.getControlY1() + 3 * (1 - t) * t2 * c.getControlY2() + t3 * c.getY())); } return list; }
private Path generateRandomPath(Pane layer) { Random randGen = new Random(); int dimensionX = (int) layer.getPrefWidth(); // TODO: Have this not use prefWidth / Height int dimensionY = (int) layer.getPrefHeight(); int pathPointNum = randGen.nextInt(50) + randGen.nextInt(20) + 5; Path particlePath = new Path(); particlePath.getElements().add(new MoveTo(randGen.nextInt(dimensionX), randGen.nextInt(dimensionY))); for (int i = pathPointNum; i > 0; i--) { particlePath.getElements().add(new CubicCurveTo(randGen.nextInt(500), randGen.nextInt(500), randGen.nextInt(500), randGen.nextInt(500), randGen.nextInt(dimensionX), randGen.nextInt(dimensionY))); } return particlePath; }
public void smooth(final List<Double> DATA_LIST) { int size = DATA_LIST.size(); double[] x = new double[size]; double[] y = new double[size]; low = Statistics.getMin(DATA_LIST); high = Statistics.getMax(DATA_LIST); if (Double.compare(low, high) == 0) { low = minValue; high = maxValue; } range = high - low; double minX = graphBounds.getX(); double maxX = minX + graphBounds.getWidth(); double minY = graphBounds.getY(); double maxY = minY + graphBounds.getHeight(); double stepX = graphBounds.getWidth() / (noOfDatapoints - 1); double stepY = graphBounds.getHeight() / range; for (int i = 0 ; i < size ; i++) { x[i] = minX + i * stepX; y[i] = maxY - Math.abs(low - DATA_LIST.get(i)) * stepY; } Pair<Double[], Double[]> px = computeControlPoints(x); Pair<Double[], Double[]> py = computeControlPoints(y); sparkLine.getElements().clear(); for (int i = 0 ; i < size - 1 ; i++) { sparkLine.getElements().add(new MoveTo(x[i], y[i])); sparkLine.getElements().add(new CubicCurveTo(px.getKey()[i], py.getKey()[i], px.getValue()[i], py.getValue()[i], x[i + 1], y[i + 1])); } dot.setCenterX(maxX); dot.setCenterY(y[size - 1]); }
private void createHourPointer() { double width = size * 0.09733333; double height = size * 0.42066667; hour.setCache(false); hour.getElements().clear(); hour.getElements().add(new MoveTo(0.0, 0.0)); hour.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.884310618066561 * height, 0.0, 0.884310618066561 * height)); hour.getElements().add(new CubicCurveTo(0.0, 0.9477020602218701 * height, 0.22602739726027396 * width, height, 0.5 * width, height)); hour.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9477020602218701 * height, width, 0.884310618066561 * height)); hour.getElements().add(new CubicCurveTo(width, 0.884310618066561 * height, width, 0.0, width, 0.0)); hour.getElements().add(new LineTo(0.0, 0.0)); hour.getElements().add(new ClosePath()); hour.setCache(true); hour.setCacheHint(CacheHint.ROTATE); }
private void createMinutePointer() { double width = size * 0.09733333; double height = size * 0.548; minute.setCache(false); minute.getElements().clear(); minute.getElements().add(new MoveTo(0.0, 0.0)); minute.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.9111922141119222 * height, 0.0, 0.9111922141119222 * height)); minute.getElements().add(new CubicCurveTo(0.0, 0.9598540145985401 * height, 0.22602739726027396 * width, height, 0.5 * width, height)); minute.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9598540145985401 * height, width, 0.9111922141119222 * height)); minute.getElements().add(new CubicCurveTo(width, 0.9111922141119222 * height, width, 0.0, width, 0.0)); minute.getElements().add(new LineTo(0.0, 0.0)); minute.getElements().add(new ClosePath()); minute.setCache(true); minute.setCacheHint(CacheHint.ROTATE); }
private Path createVerticalBattery(final Path PATH) { PATH.getElements().clear(); PATH.getElements().add(new MoveTo(0.25 * size, 0.175 * size)); PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.175 * size, 0.25 * size, 0.925 * size, 0.25 * size, 0.925 * size)); PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.96875 * size, 0.28125 * size, size, 0.325 * size, size)); PATH.getElements().add(new CubicCurveTo(0.325 * size, size, 0.675 * size, size, 0.675 * size, size)); PATH.getElements().add(new CubicCurveTo(0.71875 * size, size, 0.75 * size, 0.96875 * size, 0.75 * size, 0.925 * size)); PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.925 * size, 0.75 * size, 0.175 * size, 0.75 * size, 0.175 * size)); PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.13125 * size, 0.71875 * size, 0.1 * size, 0.675 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.675 * size, 0.1 * size, 0.6 * size, 0.1 * size, 0.6 * size, 0.1 * size)); PATH.getElements().add(new LineTo(0.6 * size, 0.0)); PATH.getElements().add(new LineTo(0.4 * size, 0.0)); PATH.getElements().add(new LineTo(0.4 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.4 * size, 0.1 * size, 0.325 * size, 0.1 * size, 0.325 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.28125 * size, 0.1 * size, 0.25 * size, 0.13125 * size, 0.25 * size, 0.175 * size)); PATH.getElements().add(new ClosePath()); return PATH; }
private Path createHorizontalBattery(final Path PATH) { PATH.getElements().clear(); PATH.getElements().add(new MoveTo(0.825 * size, 0.25 * size)); PATH.getElements().add(new CubicCurveTo(0.825 * size, 0.25 * size, 0.075 * size, 0.25 * size, 0.075 * size, 0.25 * size)); PATH.getElements().add(new CubicCurveTo(0.03125 * size, 0.25 * size, 0.0, 0.28125 * size, 0.0, 0.325 * size)); PATH.getElements().add(new CubicCurveTo(0.0, 0.325 * size, 0.0, 0.675 * size, 0.0, 0.675 * size)); PATH.getElements().add(new CubicCurveTo(0.0, 0.71875 * size, 0.03125 * size, 0.75 * size, 0.075 * size, 0.75 * size)); PATH.getElements().add(new CubicCurveTo(0.075 * size, 0.75 * size, 0.825 * size, 0.75 * size, 0.825 * size, 0.75 * size)); PATH.getElements().add(new CubicCurveTo(0.86875 * size, 0.75 * size, 0.9 * size, 0.71875 * size, 0.9 * size, 0.675 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.675 * size, 0.9 * size, 0.6 * size, 0.9 * size, 0.6 * size)); PATH.getElements().add(new LineTo(size, 0.6 * size)); PATH.getElements().add(new LineTo(size, 0.4 * size)); PATH.getElements().add(new LineTo(0.9 * size, 0.4 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.4 * size, 0.9 * size, 0.325 * size, 0.9 * size, 0.325 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.28125 * size, 0.86875 * size, 0.25 * size, 0.825 * size, 0.25 * size)); PATH.getElements().add(new ClosePath()); return PATH; }
private void drawNeedle() { double needleWidth = size * 0.064; double needleHeight = size * 0.44; needle.setCache(false); needle.getElements().clear(); needle.getElements().add(new MoveTo(0.1875 * needleWidth, 0.0)); needle.getElements().add(new CubicCurveTo(0.1875 * needleWidth, 0.0, 0.1875 * needleWidth, 0.8727272727272727 * needleHeight, 0.1875 * needleWidth, 0.8727272727272727 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0625 * needleWidth, 0.8818181818181818 * needleHeight, 0.0, 0.9 * needleHeight, 0.0, 0.9272727272727272 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0, 0.9636363636363636 * needleHeight, 0.25 * needleWidth, needleHeight, 0.5 * needleWidth, needleHeight)); needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, needleHeight, needleWidth, 0.9636363636363636 * needleHeight, needleWidth, 0.9272727272727272 * needleHeight)); needle.getElements().add(new CubicCurveTo(needleWidth, 0.9 * needleHeight, 0.9375 * needleWidth, 0.8818181818181818 * needleHeight, 0.8125 * needleWidth, 0.8727272727272727 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.8125 * needleWidth, 0.8727272727272727 * needleHeight, 0.8125 * needleWidth, 0.0, 0.8125 * needleWidth, 0.0)); needle.getElements().add(new LineTo(0.1875 * needleWidth, 0.0)); needle.getElements().add(new ClosePath()); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); }
/** * Create a transition * * @param sourceElements * the source elements * @param targetElements * the target elements * @param duation * the duration * @param pathNode * the path not the morph is done on */ public PathMorphTransition(List<PathElement> sourceElements, List<PathElement> targetElements, Duration duation, Path pathNode) { this.pathNode = pathNode; setCycleDuration(duation); if (sourceElements.size() != targetElements.size()) { throw new IllegalArgumentException("Only equal paths are allowed"); //$NON-NLS-1$ } for (int i = 0; i < sourceElements.size(); i++) { PathElement sourceElement = sourceElements.get(i); PathElement targetElement = targetElements.get(i); if (sourceElement.getClass() != targetElement.getClass()) { throw new IllegalArgumentException("Only equal paths are allowed"); //$NON-NLS-1$ } if (sourceElement instanceof ArcTo) { this.interpolateList.add(new ArcToInterpolatable((ArcTo) sourceElement)); } else if (sourceElement instanceof CubicCurveTo) { this.interpolateList.add(new CubicCurveToInterpolatable((CubicCurveTo) sourceElement)); } else if (sourceElement instanceof HLineTo) { this.interpolateList.add(new HLineToInterpolatable((HLineTo) sourceElement)); } else if (sourceElement instanceof LineTo) { this.interpolateList.add(new LineToInterpolatable((LineTo) sourceElement)); } else if (sourceElement instanceof MoveTo) { this.interpolateList.add(new MoveToInterpolatable((MoveTo) sourceElement)); } else if (sourceElement instanceof QuadCurveTo) { this.interpolateList.add(new QuadCurveToInterpolatable((QuadCurveTo) sourceElement)); } else if (sourceElement instanceof VLineTo) { this.interpolateList.add(new VLineToInterpolatable((VLineTo) sourceElement)); } } this.sourceElements = sourceElements; this.targetElements = targetElements; }
@Override public CubicCurveTo interpolate(CubicCurveTo endValue, double t) { CubicCurveTo rv = new CubicCurveTo(this.source.getControlX1() + (endValue.getControlX1() - this.source.getControlX1()) * t, this.source.getControlY1() + (endValue.getControlY1() - this.source.getControlY1()) * t, this.source.getControlX2() + (endValue.getControlX2() - this.source.getControlX2()) * t, this.source.getControlY2() + (endValue.getControlY2() - this.source.getControlY2()) * t, this.source.getX() + (endValue.getX() - this.source.getX()) * t, this.source.getY() + (endValue.getY() - this.source.getY()) * t); rv.setAbsolute(this.source.isAbsolute()); return rv; }
public static void setPath(Path p, Path2D p2d) { p.getElements().clear(); PathIterator pi = p2d.getPathIterator(null); double[] coords = new double[6]; while (!pi.isDone()) { switch (pi.currentSegment(coords)) { case PathIterator.SEG_MOVETO: p.getElements().add(new MoveTo(coords[0], coords[1])); break; case PathIterator.SEG_LINETO: p.getElements().add(new LineTo(coords[0], coords[1])); break; case PathIterator.SEG_QUADTO: p.getElements().add(new QuadCurveTo(coords[0], coords[1], coords[2], coords[3])); break; case PathIterator.SEG_CUBICTO: p.getElements().add(new CubicCurveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5])); break; case PathIterator.SEG_CLOSE: p.getElements().add(new ClosePath()); break; default: throw new InternalError("unexpected segment type"); } pi.next(); } p.getElements().add(new ClosePath()); }
/** * Generate Path upon which animation will occur. * * @return Generated path. */ private Path generateCurvyPath() { final Path path = new Path(); path.getElements().add(new MoveTo(70,20)); path.getElements().add(new CubicCurveTo(430, 0, 430, 120, 250, 120)); path.getElements().add(new CubicCurveTo(50, 120, 50, 240, 430, 240)); path.setOpacity(0.0); return path; }
private Point3D evalCubicBezier(CubicCurveTo c, Point3D ini, double t){ Point3D p=new Point3D((float)(Math.pow(1-t,3)*ini.x+ 3*t*Math.pow(1-t,2)*c.getControlX1()+ 3*(1-t)*t*t*c.getControlX2()+ Math.pow(t, 3)*c.getX()), (float)(Math.pow(1-t,3)*ini.y+ 3*t*Math.pow(1-t, 2)*c.getControlY1()+ 3*(1-t)*t*t*c.getControlY2()+ Math.pow(t, 3)*c.getY()), 0f); return p; }
public void setPathToBefore(Path path) { path.getElements().clear(); path.getElements().add(new MoveTo(before.start.x, before.start.y)); path.getElements().add(new CubicCurveTo(before.handle1.x, before.handle1.y, before.handle2.x, before.handle2.y, before.end.x, before.end.y)); }
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) { final Path PATH = new Path(); PATH.setFillRule(FillRule.EVEN_ODD); while (!PATH_LIST.isEmpty()) { if ("M".equals(READER.read())) { PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY())); } else if ("C".equals(READER.read())) { PATH.getElements().add(new CubicCurveTo( READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("Q".equals(READER.read())) { PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("H".equals(READER.read())) { PATH.getElements().add(new HLineTo(READER.nextX())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new VLineTo(READER.nextY())); } else if ("A".equals(READER.read())) { PATH.getElements().add( new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false)); } else if ("Z".equals(READER.read())) { PATH.getElements().add(new ClosePath()); } } return PATH; }
@Override public void curvetoCubicAbs(float x1, float y1, float x2, float y2, float x, float y) throws ParseException { lastX = x; lastY = y; CubicCurveTo c = new CubicCurveTo(x1,y1,x2,y2,x,y); c.setAbsolute(true); path.getElements().add(c); }
@Override public void curvetoCubicRel(float x1, float y1, float x2, float y2, float x, float y) throws ParseException { lastX = x; lastY = y; CubicCurveTo c = new CubicCurveTo(x1,y1,x2,y2,x,y); c.setAbsolute(false); path.getElements().add(c); }
private void drawNeedle() { double needleWidth = size * 0.05; double needleHeight = size * 0.3325; needle.setCache(false); needle.getElements().clear(); needle.getElements().add(new MoveTo(0.25 * needleWidth, 0.924812030075188 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.25 * needleWidth, 0.9022556390977443 * needleHeight, 0.35 * needleWidth, 0.8872180451127819 * needleHeight, 0.5 * needleWidth, 0.8872180451127819 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.8872180451127819 * needleHeight, 0.75 * needleWidth, 0.9022556390977443 * needleHeight, 0.75 * needleWidth, 0.924812030075188 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, 0.9473684210526315 * needleHeight, 0.65 * needleWidth, 0.9624060150375939 * needleHeight, 0.5 * needleWidth, 0.9624060150375939 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.9624060150375939 * needleHeight, 0.25 * needleWidth, 0.9473684210526315 * needleHeight, 0.25 * needleWidth, 0.924812030075188 * needleHeight)); needle.getElements().add(new ClosePath()); needle.getElements().add(new MoveTo(0.0, 0.924812030075188 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0, 0.9699248120300752 * needleHeight, 0.2 * needleWidth, needleHeight, 0.5 * needleWidth, needleHeight)); needle.getElements().add(new CubicCurveTo(0.8 * needleWidth, needleHeight, needleWidth, 0.9699248120300752 * needleHeight, needleWidth, 0.924812030075188 * needleHeight)); needle.getElements().add(new CubicCurveTo(needleWidth, 0.8947368421052632 * needleHeight, 0.85 * needleWidth, 0.8646616541353384 * needleHeight, 0.65 * needleWidth, 0.849624060150376 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.849624060150376 * needleHeight, 0.65 * needleWidth, 0.022556390977443608 * needleHeight, 0.65 * needleWidth, 0.022556390977443608 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.007518796992481203 * needleHeight, 0.6 * needleWidth, 0.0, 0.5 * needleWidth, 0.0)); needle.getElements().add(new CubicCurveTo(0.4 * needleWidth, 0.0, 0.35 * needleWidth, 0.007518796992481203 * needleHeight, 0.35 * needleWidth, 0.022556390977443608 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.022556390977443608 * needleHeight, 0.35 * needleWidth, 0.849624060150376 * needleHeight, 0.35 * needleWidth, 0.849624060150376 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.15 * needleWidth, 0.8646616541353384 * needleHeight, 0.0, 0.8947368421052632 * needleHeight, 0.0, 0.924812030075188 * needleHeight)); needle.getElements().add(new ClosePath()); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); }
private void drawAlertIcon() { alertIcon.setCache(false); double iconWidth = size * 0.155; double iconHeight = size * 0.135; alertIcon.getElements().clear(); alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.3 * iconHeight, 0.4684873949579832 * iconWidth, 0.2714285714285714 * iconHeight, 0.5 * iconWidth, 0.2714285714285714 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.2714285714285714 * iconHeight, 0.5588235294117647 * iconWidth, 0.3 * iconHeight, 0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight, 0.5588235294117647 * iconWidth, 0.6 * iconHeight, 0.5588235294117647 * iconWidth, 0.6 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.6357142857142857 * iconHeight, 0.5315126050420168 * iconWidth, 0.6666666666666666 * iconHeight, 0.5 * iconWidth, 0.6666666666666666 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.6666666666666666 * iconHeight, 0.4411764705882353 * iconWidth, 0.6357142857142857 * iconHeight, 0.4411764705882353 * iconWidth, 0.6 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.6 * iconHeight, 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight, 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight)); alertIcon.getElements().add(new ClosePath()); alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.8 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.7642857142857142 * iconHeight, 0.4684873949579832 * iconWidth, 0.7333333333333333 * iconHeight, 0.5 * iconWidth, 0.7333333333333333 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.7333333333333333 * iconHeight, 0.5588235294117647 * iconWidth, 0.7642857142857142 * iconHeight, 0.5588235294117647 * iconWidth, 0.8 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.8380952380952381 * iconHeight, 0.5315126050420168 * iconWidth, 0.8666666666666667 * iconHeight, 0.5 * iconWidth, 0.8666666666666667 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.8666666666666667 * iconHeight, 0.4411764705882353 * iconWidth, 0.8380952380952381 * iconHeight, 0.4411764705882353 * iconWidth, 0.8 * iconHeight)); alertIcon.getElements().add(new ClosePath()); alertIcon.getElements().add(new MoveTo(0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.523109243697479 * iconWidth, -0.011904761904761904 * iconHeight, 0.47689075630252103 * iconWidth, -0.011904761904761904 * iconHeight, 0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight, 0.012605042016806723 * iconWidth, 0.9 * iconHeight, 0.012605042016806723 * iconWidth, 0.9 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(-0.014705882352941176 * iconWidth, 0.9547619047619048 * iconHeight, 0.0063025210084033615 * iconWidth, iconHeight, 0.06302521008403361 * iconWidth, iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.06302521008403361 * iconWidth, iconHeight, 0.9369747899159664 * iconWidth, iconHeight, 0.9369747899159664 * iconWidth, iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.9936974789915967 * iconWidth, iconHeight, 1.0147058823529411 * iconWidth, 0.9547619047619048 * iconHeight, 0.9873949579831933 * iconWidth, 0.9 * iconHeight)); alertIcon.getElements().add(new CubicCurveTo(0.9873949579831933 * iconWidth, 0.9 * iconHeight, 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight, 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight)); alertIcon.getElements().add(new ClosePath()); alertIcon.setCache(true); alertIcon.setCacheHint(CacheHint.SPEED); }
private void createSecondPointer() { double width = size * 0.11866667; double height = size * 0.46266667; second.setCache(false); second.getElements().clear(); second.getElements().add(new MoveTo(0.1348314606741573 * width, 0.4365994236311239 * height)); second.getElements().add(new CubicCurveTo(0.1348314606741573 * width, 0.38328530259365995 * height, 0.29775280898876405 * width, 0.3414985590778098 * height, 0.5 * width, 0.3414985590778098 * height)); second.getElements().add(new CubicCurveTo(0.702247191011236 * width, 0.3414985590778098 * height, 0.8651685393258427 * width, 0.38328530259365995 * height, 0.8651685393258427 * width, 0.4365994236311239 * height)); second.getElements().add(new CubicCurveTo(0.8651685393258427 * width, 0.4884726224783862 * height, 0.702247191011236 * width, 0.5302593659942363 * height, 0.5 * width, 0.5302593659942363 * height)); second.getElements().add(new CubicCurveTo(0.29775280898876405 * width, 0.5302593659942363 * height, 0.1348314606741573 * width, 0.4884726224783862 * height, 0.1348314606741573 * width, 0.4365994236311239 * height)); second.getElements().add(new ClosePath()); second.getElements().add(new MoveTo(0.0, 0.4365994236311239 * height)); second.getElements().add(new CubicCurveTo(0.0, 0.5 * height, 0.1853932584269663 * width, 0.553314121037464 * height, 0.42134831460674155 * width, 0.5634005763688761 * height)); second.getElements().add(new CubicCurveTo(0.42134831460674155 * width, 0.5634005763688761 * height, 0.398876404494382 * width, height, 0.398876404494382 * width, height)); second.getElements().add(new LineTo(0.601123595505618 * width, height)); second.getElements().add(new CubicCurveTo(0.601123595505618 * width, height, 0.5786516853932584 * width, 0.5634005763688761 * height, 0.5786516853932584 * width, 0.5634005763688761 * height)); second.getElements().add(new CubicCurveTo(0.8146067415730337 * width, 0.553314121037464 * height, width, 0.5 * height, width, 0.4365994236311239 * height)); second.getElements().add(new CubicCurveTo(width, 0.3703170028818444 * height, 0.8089887640449438 * width, 0.3170028818443804 * height, 0.5617977528089888 * width, 0.30835734870317005 * height)); second.getElements().add(new CubicCurveTo(0.5617977528089888 * width, 0.30835734870317005 * height, 0.5449438202247191 * width, 0.0, 0.5449438202247191 * width, 0.0)); second.getElements().add(new LineTo(0.4550561797752809 * width, 0.0)); second.getElements().add(new CubicCurveTo(0.4550561797752809 * width, 0.0, 0.43820224719101125 * width, 0.30835734870317005 * height, 0.43820224719101125 * width, 0.30835734870317005 * height)); second.getElements().add(new CubicCurveTo(0.19101123595505617 * width, 0.3170028818443804 * height, 0.0, 0.3703170028818444 * height, 0.0, 0.4365994236311239 * height)); second.getElements().add(new ClosePath()); second.setCache(true); second.setCacheHint(CacheHint.ROTATE); }
@Override protected void resize() { double width = gauge.getWidth() - gauge.getInsets().getLeft() - gauge.getInsets().getRight(); double height = gauge.getHeight() - gauge.getInsets().getTop() - gauge.getInsets().getBottom(); size = width < height ? width : height; if (size > 0) { pane.setMaxSize(size, size); pane.relocate((gauge.getWidth() - size) * 0.5, (gauge.getHeight() - size) * 0.5); ring.getElements().clear(); ring.getElements().add(new MoveTo(0.5 * size, 0.03 * size)); ring.getElements().add(new CubicCurveTo(0.76 * size, 0.03 * size, 0.97 * size, 0.24 * size, 0.97 * size, 0.5 * size)); ring.getElements().add(new CubicCurveTo(0.97 * size, 0.76 * size, 0.76 * size, 0.97 * size, 0.5 * size, 0.97 * size)); ring.getElements().add(new CubicCurveTo(0.24 * size, 0.97 * size, 0.03 * size, 0.76 * size, 0.03 * size, 0.5 * size)); ring.getElements().add(new CubicCurveTo(0.03 * size, 0.24 * size, 0.24 * size, 0.03 * size, 0.5 * size, 0.03 * size)); ring.getElements().add(new ClosePath()); ring.getElements().add(new MoveTo(0.5 * size, 0.2125 * size)); ring.getElements().add(new CubicCurveTo(0.6575 * size, 0.2125 * size, 0.7875 * size, 0.3425 * size, 0.7875 * size, 0.5 * size)); ring.getElements().add(new CubicCurveTo(0.7875 * size, 0.6575 * size, 0.6575 * size, 0.7875 * size, 0.5 * size, 0.7875 * size)); ring.getElements().add(new CubicCurveTo(0.3425 * size, 0.7875 * size, 0.2125 * size, 0.6575 * size, 0.2125 * size, 0.5 * size)); ring.getElements().add(new CubicCurveTo(0.2125 * size, 0.3425 * size, 0.3425 * size, 0.2125 * size, 0.5 * size, 0.2125 * size)); ring.getElements().add(new ClosePath()); sectionsCanvas.setCache(false); sectionsCanvas.setWidth(size); sectionsCanvas.setHeight(size); drawSections(); sectionsCanvas.setCache(true); sectionsCanvas.setCacheHint(CacheHint.QUALITY); mask.setCenterX(size * 0.5); mask.setCenterY(size * 0.5); mask.setRadius(size * 0.2855); knob.setCenterX(size * 0.5); knob.setCenterY(size * 0.5); knob.setRadius(size * 0.10375); needle.setCache(false); createNeedle(); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); needle.relocate((size - needle.getLayoutBounds().getWidth()) * 0.5, (size * 0.5) - needle.getLayoutBounds().getHeight()); needleRotate.setPivotX(needle.getLayoutBounds().getWidth() * 0.5); needleRotate.setPivotY(needle.getLayoutBounds().getMaxY()); double currentValue = (needleRotate.getAngle() + START_ANGLE - 180) / angleStep + gauge.getMinValue(); valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()) + gauge.getUnit()); valueText.setVisible(gauge.isValueVisible()); titleText.setText(gauge.getTitle()); resizeText(); } }
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); }
private void createHourPointer() { double width = size * 0.04533333; double height = size * 0.292; hour.setCache(false); hour.getElements().clear(); hour.getElements().add(new MoveTo(0.3235294117647059 * width, 0.9223744292237442 * height)); hour.getElements().add(new CubicCurveTo(0.3235294117647059 * width, 0.906392694063927 * height, 0.39705882352941174 * width, 0.8949771689497716 * height, 0.5 * width, 0.8949771689497716 * height)); hour.getElements().add(new CubicCurveTo(0.6029411764705882 * width, 0.8949771689497716 * height, 0.6764705882352942 * width, 0.906392694063927 * height, 0.6764705882352942 * width, 0.9223744292237442 * height)); hour.getElements().add(new CubicCurveTo(0.6764705882352942 * width, 0.9383561643835616 * height, 0.6029411764705882 * width, 0.9497716894977168 * height, 0.5 * width, 0.9497716894977168 * height)); hour.getElements().add(new CubicCurveTo(0.39705882352941174 * width, 0.9497716894977168 * height, 0.3235294117647059 * width, 0.9383561643835616 * height, 0.3235294117647059 * width, 0.9223744292237442 * height)); hour.getElements().add(new ClosePath()); hour.getElements().add(new MoveTo(0.22058823529411764 * width, 0.0639269406392694 * height)); hour.getElements().add(new CubicCurveTo(0.22058823529411764 * width, 0.03881278538812785 * height, 0.3382352941176471 * width, 0.02054794520547945 * height, 0.5 * width, 0.02054794520547945 * height)); hour.getElements().add(new CubicCurveTo(0.6617647058823529 * width, 0.02054794520547945 * height, 0.7794117647058824 * width, 0.03881278538812785 * height, 0.7794117647058824 * width, 0.0639269406392694 * height)); hour.getElements().add(new CubicCurveTo(0.7794117647058824 * width, 0.0639269406392694 * height, 0.7794117647058824 * width, 0.6484018264840182 * height, 0.7794117647058824 * width, 0.6484018264840182 * height)); hour.getElements().add(new CubicCurveTo(0.7794117647058824 * width, 0.6735159817351598 * height, 0.6617647058823529 * width, 0.6917808219178082 * height, 0.5 * width, 0.6917808219178082 * height)); hour.getElements().add(new CubicCurveTo(0.3382352941176471 * width, 0.6917808219178082 * height, 0.22058823529411764 * width, 0.6735159817351598 * height, 0.22058823529411764 * width, 0.6484018264840182 * height)); hour.getElements().add(new CubicCurveTo(0.22058823529411764 * width, 0.6484018264840182 * height, 0.22058823529411764 * width, 0.0639269406392694 * height, 0.22058823529411764 * width, 0.0639269406392694 * height)); hour.getElements().add(new ClosePath()); hour.getElements().add(new MoveTo(0.0, 0.9223744292237442 * height)); hour.getElements().add(new CubicCurveTo(0.0, 0.9657534246575342 * height, 0.22058823529411764 * width, height, 0.5 * width, height)); hour.getElements().add(new CubicCurveTo(0.7794117647058824 * width, height, width, 0.9657534246575342 * height, width, 0.9223744292237442 * height)); hour.getElements().add(new CubicCurveTo(width, 0.8881278538812786 * height, 0.8529411764705882 * width, 0.8584474885844748 * height, 0.6617647058823529 * width, 0.8493150684931506 * height)); hour.getElements().add(new CubicCurveTo(0.6617647058823529 * width, 0.8493150684931506 * height, 0.6617647058823529 * width, 0.7077625570776256 * height, 0.6617647058823529 * width, 0.7077625570776256 * height)); hour.getElements().add(new CubicCurveTo(0.8088235294117647 * width, 0.6986301369863014 * height, 0.9117647058823529 * width, 0.6757990867579908 * height, 0.9117647058823529 * width, 0.6484018264840182 * height)); hour.getElements().add(new CubicCurveTo(0.9117647058823529 * width, 0.6484018264840182 * height, 0.9117647058823529 * width, 0.0639269406392694 * height, 0.9117647058823529 * width, 0.0639269406392694 * height)); hour.getElements().add(new CubicCurveTo(0.9117647058823529 * width, 0.0273972602739726 * height, 0.7352941176470589 * width, 0.0, 0.5 * width, 0.0)); hour.getElements().add(new CubicCurveTo(0.2647058823529412 * width, 0.0, 0.08823529411764706 * width, 0.0273972602739726 * height, 0.08823529411764706 * width, 0.0639269406392694 * height)); hour.getElements().add(new CubicCurveTo(0.08823529411764706 * width, 0.0639269406392694 * height, 0.08823529411764706 * width, 0.6484018264840182 * height, 0.08823529411764706 * width, 0.6484018264840182 * height)); hour.getElements().add(new CubicCurveTo(0.08823529411764706 * width, 0.6757990867579908 * height, 0.19117647058823528 * width, 0.6986301369863014 * height, 0.3382352941176471 * width, 0.7077625570776256 * height)); hour.getElements().add(new CubicCurveTo(0.3382352941176471 * width, 0.7077625570776256 * height, 0.3382352941176471 * width, 0.8493150684931506 * height, 0.3382352941176471 * width, 0.8493150684931506 * height)); hour.getElements().add(new CubicCurveTo(0.14705882352941177 * width, 0.8584474885844748 * height, 0.0, 0.8881278538812786 * height, 0.0, 0.9223744292237442 * height)); hour.getElements().add(new ClosePath()); hour.setCache(true); hour.setCacheHint(CacheHint.ROTATE); }
private void createMinutePointer() { double width = size * 0.04533333; double height = size * 0.488; minute.setCache(false); minute.getElements().clear(); minute.getElements().add(new MoveTo(0.3235294117647059 * width, 0.953551912568306 * height)); minute.getElements().add(new CubicCurveTo(0.3235294117647059 * width, 0.9439890710382514 * height, 0.39705882352941174 * width, 0.9371584699453552 * height, 0.5 * width, 0.9371584699453552 * height)); minute.getElements().add(new CubicCurveTo(0.6029411764705882 * width, 0.9371584699453552 * height, 0.6764705882352942 * width, 0.9439890710382514 * height, 0.6764705882352942 * width, 0.953551912568306 * height)); minute.getElements().add(new CubicCurveTo(0.6764705882352942 * width, 0.9631147540983607 * height, 0.6029411764705882 * width, 0.9699453551912568 * height, 0.5 * width, 0.9699453551912568 * height)); minute.getElements().add(new CubicCurveTo(0.39705882352941174 * width, 0.9699453551912568 * height, 0.3235294117647059 * width, 0.9631147540983607 * height, 0.3235294117647059 * width, 0.953551912568306 * height)); minute.getElements().add(new ClosePath()); minute.getElements().add(new MoveTo(0.22058823529411764 * width, 0.03825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.22058823529411764 * width, 0.02459016393442623 * height, 0.35294117647058826 * width, 0.012295081967213115 * height, 0.5 * width, 0.012295081967213115 * height)); minute.getElements().add(new CubicCurveTo(0.6470588235294118 * width, 0.012295081967213115 * height, 0.7794117647058824 * width, 0.02459016393442623 * height, 0.7794117647058824 * width, 0.03825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.7794117647058824 * width, 0.03825136612021858 * height, 0.7794117647058824 * width, 0.7896174863387978 * height, 0.7794117647058824 * width, 0.7896174863387978 * height)); minute.getElements().add(new CubicCurveTo(0.7794117647058824 * width, 0.8032786885245902 * height, 0.6470588235294118 * width, 0.8155737704918032 * height, 0.5 * width, 0.8155737704918032 * height)); minute.getElements().add(new CubicCurveTo(0.35294117647058826 * width, 0.8155737704918032 * height, 0.22058823529411764 * width, 0.8032786885245902 * height, 0.22058823529411764 * width, 0.7896174863387978 * height)); minute.getElements().add(new CubicCurveTo(0.22058823529411764 * width, 0.7896174863387978 * height, 0.22058823529411764 * width, 0.03825136612021858 * height, 0.22058823529411764 * width, 0.03825136612021858 * height)); minute.getElements().add(new ClosePath()); minute.getElements().add(new MoveTo(0.0, 0.953551912568306 * height)); minute.getElements().add(new CubicCurveTo(0.0, 0.9795081967213115 * height, 0.22058823529411764 * width, height, 0.5 * width, height)); minute.getElements().add(new CubicCurveTo(0.7794117647058824 * width, height, width, 0.9795081967213115 * height, width, 0.953551912568306 * height)); minute.getElements().add(new CubicCurveTo(width, 0.9330601092896175 * height, 0.8529411764705882 * width, 0.9153005464480874 * height, 0.6617647058823529 * width, 0.9098360655737705 * height)); minute.getElements().add(new CubicCurveTo(0.6617647058823529 * width, 0.9098360655737705 * height, 0.6617647058823529 * width, 0.825136612021858 * height, 0.6617647058823529 * width, 0.825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.8088235294117647 * width, 0.8183060109289617 * height, 0.9117647058823529 * width, 0.8060109289617486 * height, 0.9117647058823529 * width, 0.7896174863387978 * height)); minute.getElements().add(new CubicCurveTo(0.9117647058823529 * width, 0.7896174863387978 * height, 0.9117647058823529 * width, 0.03825136612021858 * height, 0.9117647058823529 * width, 0.03825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.9117647058823529 * width, 0.017759562841530054 * height, 0.7205882352941176 * width, 0.0, 0.5 * width, 0.0)); minute.getElements().add(new CubicCurveTo(0.27941176470588236 * width, 0.0, 0.08823529411764706 * width, 0.017759562841530054 * height, 0.08823529411764706 * width, 0.03825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.08823529411764706 * width, 0.03825136612021858 * height, 0.08823529411764706 * width, 0.7896174863387978 * height, 0.08823529411764706 * width, 0.7896174863387978 * height)); minute.getElements().add(new CubicCurveTo(0.08823529411764706 * width, 0.8060109289617486 * height, 0.19117647058823528 * width, 0.8183060109289617 * height, 0.3382352941176471 * width, 0.825136612021858 * height)); minute.getElements().add(new CubicCurveTo(0.3382352941176471 * width, 0.825136612021858 * height, 0.3382352941176471 * width, 0.9098360655737705 * height, 0.3382352941176471 * width, 0.9098360655737705 * height)); minute.getElements().add(new CubicCurveTo(0.14705882352941177 * width, 0.9153005464480874 * height, 0.0, 0.9330601092896175 * height, 0.0, 0.953551912568306 * height)); minute.getElements().add(new ClosePath()); minute.setCache(true); minute.setCacheHint(CacheHint.ROTATE); }