类javafx.scene.shape.MoveTo源码实例Demo

下面列出了怎么用javafx.scene.shape.MoveTo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: latexdraw   文件: ViewTriangle.java
private final void setupPath(final Path path) {
	final MoveTo moveTo = pathProducer.createMoveTo(0d, 0d);

	moveTo.xProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getX() + model.getWidth() / 2d,
		model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty()));
	moveTo.yProperty().bind(model.getPtAt(0).yProperty());
	path.getElements().add(moveTo);

	LineTo lineTo = pathProducer.createLineTo(0d, 0d);
	lineTo.xProperty().bind(model.getPtAt(2).xProperty());
	lineTo.yProperty().bind(model.getPtAt(2).yProperty());
	path.getElements().add(lineTo);

	lineTo = pathProducer.createLineTo(0d, 0d);
	lineTo.xProperty().bind(model.getPtAt(3).xProperty());
	lineTo.yProperty().bind(model.getPtAt(3).yProperty());
	path.getElements().add(lineTo);

	path.getElements().add(pathProducer.createClosePath());
}
 
源代码2 项目: OEE-Designer   文件: SmoothAreaChartTileSkin.java
private void drawChart(final List<Point> POINTS) {
    if (POINTS.isEmpty()) return;
    Point[] points = smoothing ? Helper.subdividePoints(POINTS.toArray(new Point[0]), 8) : POINTS.toArray(new Point[0]);

    fillPath.getElements().clear();
    fillPath.getElements().add(new MoveTo(0, height));

    strokePath.getElements().clear();
    strokePath.getElements().add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point p : points) {
        fillPath.getElements().add(new LineTo(p.getX(), p.getY()));
        strokePath.getElements().add(new LineTo(p.getX(), p.getY()));
    }

    fillPath.getElements().add(new LineTo(width, height));
    fillPath.getElements().add(new LineTo(0, height));
    fillPath.getElements().add(new ClosePath());

    if (dataPointsVisible) { drawDataPoints(POINTS, tile.isFillWithGradient() ? tile.getGradientStops().get(0).getColor() : tile.getBarColor()); }
}
 
源代码3 项目: OEE-Designer   文件: StockTileSkin.java
@Override protected void handleEvents(final String EVENT_TYPE) {
    super.handleEvents(EVENT_TYPE);

    if ("VISIBILITY".equals(EVENT_TYPE)) {
        Helper.enableNode(titleText, !tile.getTitle().isEmpty());
        Helper.enableNode(valueText, tile.isValueVisible());
        Helper.enableNode(timeSpanText, !tile.isTextVisible());
        redraw();
    } else if ("VALUE".equals(EVENT_TYPE)) {
        if(tile.isAnimated()) { tile.setAnimated(false); }
        if (!tile.isAveragingEnabled()) { tile.setAveragingEnabled(true); }
        double value = clamp(minValue, maxValue, tile.getValue());
        addData(value);
        handleCurrentValue(value);
    } else if ("AVERAGING".equals(EVENT_TYPE)) {
        noOfDatapoints = tile.getAveragingPeriod();
        // 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.");
        for (int i = 0; i < noOfDatapoints; i++) { dataList.add(minValue); }
        pathElements.clear();
        pathElements.add(0, new MoveTo());
        for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }
        sparkLine.getElements().setAll(pathElements);
        redraw();
    }
}
 
源代码4 项目: RichTextFX   文件: TextFlowExt.java
/**
 * @param from The index of the first character.
 * @param to The index of the last character.
 * @return An array with the PathElement objects which define an
 *         underline from the first to the last character.
 */
PathElement[] getUnderlineShape(int from, int to) {
    // get a Path for the text underline
    PathElement[] shape = textLayout().getRange(from, to, TextLayout.TYPE_UNDERLINE, 0, 0);

    // The shape is returned as a closed Path (a thin rectangle).
    // If we use the Path as it is, this causes rendering issues.
    // Hence we only use the MoveTo and the succeeding LineTo elements for the result
    // so that simple line segments instead of rectangles are returned.
    List<PathElement> result = new ArrayList<>();

    boolean collect = false;
    for (PathElement elem : shape) {
        if (elem instanceof MoveTo) {   // There seems to be no API to get the type of the PathElement
            result.add(elem);
            collect = true;
        } else if (elem instanceof LineTo) {
            if (collect) {
                result.add(elem);
                collect = false;
            }
        }
    }

   return result.toArray(new PathElement[0]);
}
 
源代码5 项目: paintera   文件: RenderBoxHelperFX.java
public void renderCanvas(final Interval targetInterval, final Path canvas)
{
	final double tX0 = targetInterval.min(0);
	final double tX1 = targetInterval.max(0);
	final double tY0 = targetInterval.min(1);
	final double tY1 = targetInterval.max(1);

	final double[] c000 = new double[] {tX0, tY0, 0};
	final double[] c100 = new double[] {tX1, tY0, 0};
	final double[] c010 = new double[] {tX0, tY1, 0};
	final double[] c110 = new double[] {tX1, tY1, 0};

	canvas.getElements().add(new MoveTo(perspectiveX(c000), perspectiveY(c000)));
	canvas.getElements().add(new LineTo(perspectiveX(c100), perspectiveY(c100)));
	canvas.getElements().add(new LineTo(perspectiveX(c110), perspectiveY(c110)));
	canvas.getElements().add(new LineTo(perspectiveX(c010), perspectiveY(c010)));
	canvas.getElements().add(new ClosePath());
}
 
源代码6 项目: tilesfx   文件: Gauge2TileSkin.java
private void drawNeedle() {
    double needleWidth  = size * 0.04536638;
    double needleHeight = size * 0.23706897;
    needle.setCache(false);
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.754441805225653, needleHeight *0.0743545454545455, needleWidth *0.788052256532067, needleHeight * 0, needleWidth * 0.499643705463183, needleHeight * 0));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.211235154394299, needleHeight *0, needleWidth *0.248907363420428, needleHeight * 0.0741090909090909, needleWidth * 0.186104513064133, needleHeight * 0.227272727272727));
    needle.getElements().add(new LineTo(needleWidth * 0.000831353919239905, needleHeight * 0.886363636363636));
    needle.getElements().add(new CubicCurveTo(needleWidth * -0.0155581947743468, needleHeight *0.978604545454545, needleWidth *0.211235154394299, needleHeight * 1, needleWidth * 0.499643705463183, needleHeight * 1));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.788052256532067, needleHeight *1, needleWidth *1.0253919239905, needleHeight * 0.976459090909091, needleWidth * 0.998456057007126, needleHeight * 0.886363636363636));
    needle.getElements().add(new LineTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
    needle.getElements().add(new ClosePath());
    needle.getElements().add(new MoveTo(needleWidth * 0.552826603325416, needleHeight *0.854286363636364));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.536223277909739, needleHeight *0.852981818181818, needleWidth *0.518313539192399, needleHeight * 0.852272727272727, needleWidth * 0.499643705463183, needleHeight * 0.852272727272727));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.480237529691211, needleHeight *0.852272727272727, needleWidth *0.46166270783848, needleHeight * 0.853040909090909, needleWidth * 0.444513064133017, needleHeight * 0.854445454545455));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.37313539192399, needleHeight *0.858890909090909, needleWidth *0.321496437054632, needleHeight * 0.871736363636364, needleWidth * 0.321496437054632, needleHeight * 0.886868181818182));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.321496437054632, needleHeight *0.905681818181818, needleWidth *0.401330166270784, needleHeight * 0.920959090909091, needleWidth * 0.499643705463183, needleHeight * 0.920959090909091));
    needle.getElements().add(new LineTo(needleWidth * 0.500285035629454, needleHeight *0.920959090909091));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.598598574821853, needleHeight *0.920959090909091, needleWidth *0.678432304038005, needleHeight * 0.905681818181818, needleWidth * 0.678432304038005, needleHeight * 0.886868181818182));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.678432304038005, needleHeight *0.871554545454545, needleWidth *0.625534441805226, needleHeight * 0.858581818181818, needleWidth * 0.552826603325416, needleHeight * 0.854286363636364));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
 
源代码7 项目: tilesfx   文件: SparkLineTileSkin.java
private void smooth(final List<Double> DATA_LIST) {
    Task<Point[]> smoothTask = new Task<Point[]>() {
        @Override protected Point[] call() {
            return Helper.smoothSparkLine(DATA_LIST, minValue, maxValue, graphBounds, noOfDatapoints);
        }
    };
    smoothTask.setOnSucceeded(t -> {
        Point[] smoothedPoints = smoothTask.getValue();
        int lengthMinusOne = smoothedPoints.length - 1;
        sparkLine.getElements().clear();
        sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY()));
        for (int i = 1 ; i < lengthMinusOne ; i++) {
            sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY()));
        }
        dot.setCenterX(smoothedPoints[lengthMinusOne].getX());
        dot.setCenterY(smoothedPoints[lengthMinusOne].getY());
    });
    Thread smoothThread = new Thread(smoothTask);
    smoothThread.setDaemon(true);
    smoothThread.start();
}
 
源代码8 项目: tilesfx   文件: GaugeSparkLineTileSkin.java
private void smooth(final List<Double> DATA_LIST) {
    Task<Point[]> smoothTask = new Task<Point[]>() {
        @Override protected Point[] call() {
            return Helper.smoothSparkLine(DATA_LIST, minValue, maxValue, graphBounds, noOfDatapoints);
        }
    };
    smoothTask.setOnSucceeded(t -> {
        Point[] smoothedPoints = smoothTask.getValue();
        int lengthMinusOne = smoothedPoints.length - 1;
        sparkLine.getElements().clear();
        sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY()));
        for (int i = 1 ; i < lengthMinusOne ; i++) {
            sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY()));
        }
        dot.setCenterX(smoothedPoints[lengthMinusOne].getX());
        dot.setCenterY(smoothedPoints[lengthMinusOne].getY());
    });
    Thread smoothThread = new Thread(smoothTask);
    smoothThread.setDaemon(true);
    smoothThread.start();
}
 
源代码9 项目: JetUML   文件: ObjectReferenceEdgeViewer.java
private Path getSShape(Line pConnectionPoints)
{
	final int x1 = pConnectionPoints.getX1() + ENDSIZE;
	final int y1 = pConnectionPoints.getY1();
	final int x2 = pConnectionPoints.getX2() - ENDSIZE;
	final int y2 = pConnectionPoints.getY2();
	final int xmid = (pConnectionPoints.getX1() + pConnectionPoints.getX2()) / 2;
	final int ymid = (pConnectionPoints.getY1() + pConnectionPoints.getY2()) / 2;
    
	MoveTo moveTo = new MoveTo(pConnectionPoints.getX1(), y1);
	LineTo lineTo1 = new LineTo(x1, y1);
	QuadCurveTo quadTo1 = new QuadCurveTo((x1 + xmid) / 2, y1, xmid, ymid);
	QuadCurveTo quadTo2 = new QuadCurveTo((x2 + xmid) / 2, y2, x2, y2);
	LineTo lineTo2 = new LineTo(pConnectionPoints.getX2(), y2);
	
	Path path = new Path();
	path.getElements().addAll(moveTo, lineTo1, quadTo1, quadTo2, lineTo2);
	return path;
}
 
protected Rectangle2D getBounds(int start, int end) {
	PathElement[] shape = getShape(start, end);
	double minX = 0, minY = 0, maxX = 0, maxY = 0;
	for (PathElement pathElement : shape) {
		if (pathElement instanceof MoveTo) {
			MoveTo moveTo = (MoveTo) pathElement;
			minX = maxX = moveTo.getX();
			minY = maxY = moveTo.getY();
		} else if (pathElement instanceof LineTo) {
			LineTo lineTo = (LineTo) pathElement;
			double x = lineTo.getX();
			double y = lineTo.getY();
			minX = Math.min(minX, x);
			minY = Math.min(minY, y);
			maxX = Math.max(maxX, x);
			maxY = Math.max(maxY, y);
		}
	}
	return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
 
源代码11 项目: JetUML   文件: ObjectReferenceEdgeViewer.java
private Path getCShape(Line pConnectionPoints)
{
	final int x1 = Math.max(pConnectionPoints.getX1(), pConnectionPoints.getX2()) + ENDSIZE;
	final int y1 = pConnectionPoints.getY1();
	final int x2 = x1 + ENDSIZE;
	final int y2 = pConnectionPoints.getY2();
	final int ymid = (pConnectionPoints.getY1() + pConnectionPoints.getY2()) / 2;
	
	MoveTo moveTo = new MoveTo(pConnectionPoints.getX1(), y1);
	LineTo lineTo1 = new LineTo(x1, y1);
	QuadCurveTo quadTo1 = new QuadCurveTo(x2, y1, x2, ymid);
	QuadCurveTo quadTo2 = new QuadCurveTo(x2, y2, x1, y2);
	LineTo lineTo2 = new LineTo(pConnectionPoints.getX2(), y2);
	
	Path path = new Path();
	path.getElements().addAll(moveTo, lineTo1, quadTo1, quadTo2, lineTo2);
	return path;
}
 
源代码12 项目: tilesfx   文件: RadarNodeChart.java
private void addCircle(final Path PATH, final double CENTER_X, final double CENTER_Y, final double RADIUS) {
    // Control point calculation: (4/3)*tan(pi/8) = 4*(sqrt(2)-1)/3 = 0.552284749831
    double cp = RADIUS * 0.552284749831;
    MoveTo       mt1 = new MoveTo(CENTER_X, CENTER_Y - RADIUS);
    CubicCurveTo cc1 = new CubicCurveTo(CENTER_X + cp, CENTER_Y - RADIUS,
                                        CENTER_X + RADIUS, CENTER_Y - cp,
                                        CENTER_X + RADIUS, CENTER_Y);
    CubicCurveTo cc2 = new CubicCurveTo(CENTER_X + RADIUS, CENTER_Y + cp,
                                        CENTER_X + cp, CENTER_Y + RADIUS,
                                        CENTER_X, CENTER_Y + RADIUS);
    CubicCurveTo cc3 = new CubicCurveTo(CENTER_X - cp, CENTER_Y + RADIUS,
                                        CENTER_X - RADIUS, CENTER_Y + cp,
                                        CENTER_X - RADIUS, CENTER_Y);
    CubicCurveTo cc4 = new CubicCurveTo(CENTER_X - RADIUS, CENTER_Y - cp,
                                        CENTER_X - cp, CENTER_Y - RADIUS,
                                        CENTER_X, CENTER_Y - RADIUS);
    PATH.getElements().addAll(mt1, cc1, cc2, cc3, cc4);
}
 
源代码13 项目: medusademo   文件: CustomPlainAmpSkin.java
private void drawAverage() {
    double scaledWidth = width * 1.106;
    double centerX     = width * 0.5;
    double centerY     = height * 1.4;
    double minValue    = gauge.getMinValue();
    // Draw average
    average.getElements().clear();
    double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep;
    double averageSize  = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth);
    double sinValue     = Math.sin(Math.toRadians(averageAngle));
    double cosValue     = Math.cos(Math.toRadians(averageAngle));
    average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    average.getElements().add(new ClosePath());
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
源代码14 项目: Medusa   文件: PlainAmpSkin.java
private void drawAverage() {
    double scaledWidth = width * 1.106;
    double centerX     = width * 0.5;
    double centerY     = height * 1.4;
    double minValue    = gauge.getMinValue();
    // Draw average
    average.getElements().clear();
    double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep;
    double averageSize  = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth);
    double sinValue     = Math.sin(Math.toRadians(averageAngle));
    double cosValue     = Math.cos(Math.toRadians(averageAngle));
    average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    average.getElements().add(new ClosePath());
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
源代码15 项目: JetUML   文件: StateTransitionEdgeViewer.java
@Override
public Canvas createIcon(Edge pEdge)
{   //CSOFF: Magic numbers
	Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE);
	GraphicsContext graphics = canvas.getGraphicsContext2D();
	graphics.scale(0.6, 0.6);
	Line line = new Line(new Point(2,2), new Point(40,40));
	final double tangent = Math.tan(Math.toRadians(DEGREES_10));
	double dx = (line.getX2() - line.getX1()) / 2;
	double dy = (line.getY2() - line.getY1()) / 2;
	Point control = new Point((int)((line.getX1() + line.getX2()) / 2 + tangent * dy), 
			(int)((line.getY1() + line.getY2()) / 2 - tangent * dx));         
	
	Path path = new Path();
	MoveTo moveTo = new MoveTo(line.getPoint1().getX(), line.getPoint1().getY());
	QuadCurveTo curveTo = new QuadCurveTo(control.getX(), control.getY(), line.getPoint2().getX(), line.getPoint2().getY());
	path.getElements().addAll(moveTo, curveTo);
	
	ToolGraphics.strokeSharpPath(graphics, path, LineStyle.SOLID);
	ArrowHead.V.view().draw(graphics, control, new Point(40, 40));
	return canvas;
}
 
源代码16 项目: OpenLabeler   文件: AppUtils.java
public static List<Double> getPolygonPoints(javafx.scene.shape.Path path) {
   List<Double> points = new ArrayList(path.getElements().size());
   IntStream.range(0, path.getElements().size()).forEach(idx -> {
      var el = path.getElements().get(idx);
      if (el instanceof MoveTo) {
         points.add(((MoveTo) el).getX());
         points.add(((MoveTo) el).getY());
      }
      else if (el instanceof LineTo) {
         points.add(((LineTo) el).getX());
         points.add(((LineTo) el).getY());
      }
   });
   return points;
}
 
源代码17 项目: JavaFX-Chat   文件: Bubble.java
private void drawRectBubbleLeftBaselineIndicator() {
	getElements().addAll(new MoveTo(1.2f, 1.0f),
			new HLineTo(3f),
			new VLineTo(4f),
			new HLineTo(1.0f),
			new LineTo(1.2f, 3.8f),
			new VLineTo(1f)
			);
}
 
源代码18 项目: chart-fx   文件: ToolBarShapeHelper.java
public static Shape getToolBarShape(final double width, final double height, final double radii) {
    final double centreX = 0.0;
    final double centreY = 0.0;
    final double halfWidth = 0.5 * width + 2 * radii;
    final double halfHeight = 0.5 * height;

    Path path = new Path();

    // go to left-top most corner
    path.getElements().add(new MoveTo(centreX - halfWidth - 4 * radii, centreY - halfHeight));

    // cubic sweep down
    path.getElements().add(new CubicCurveTo(//
            centreX - halfWidth - 2 * radii, centreY - halfHeight, // first control point
            centreX - halfWidth - 2 * radii, centreY + halfHeight, // second control point
            centreX - halfWidth, centreY + halfHeight)); // to coordinate
    // line on bottom
    path.getElements().add(new LineTo(centreX + halfWidth, centreY + halfHeight));

    // cubic sweep up
    path.getElements().add(new CubicCurveTo(//
            centreX + halfWidth + 2 * radii, centreY + halfHeight, // first control point
            centreX + halfWidth + 2 * radii, centreY - halfHeight, // second control point
            centreX + halfWidth + 4 * radii, centreY - halfHeight)); // to coordinate

    // return to top left corner
    path.getElements().add(new LineTo(centreX - halfWidth - 2 * radii, centreY - halfHeight));
    return path;
}
 
源代码19 项目: RichTextFX   文件: ParagraphText.java
private PathElement[] createRectangle(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY) {
    return new PathElement[] {
            new MoveTo(topLeftX, topLeftY),
            new LineTo(bottomRightX, topLeftY),
            new LineTo(bottomRightX, bottomRightY),
            new LineTo(topLeftX, bottomRightY),
            new LineTo(topLeftX, topLeftY)
    };
}
 
源代码20 项目: OEE-Designer   文件: SparkLineTileSkin.java
@SuppressWarnings("unused")
private void smooth(final List<Double> DATA_LIST) {
       int      size   = DATA_LIST.size();
       Point[]  points = new Point[size];

       low  = Statistics.getMin(DATA_LIST);
       high = Statistics.getMax(DATA_LIST);
       if (Helper.equals(low, high)) {
           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++) {
           points[i] = new Point(minX + i * stepX, maxY - Math.abs(low - DATA_LIST.get(i)) * stepY);
       }

       Point[] smoothedPoints = Helper.subdividePoints(points, 16);
       int length = smoothedPoints.length;
       sparkLine.getElements().clear();
       sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY()));
       for (int i = 1 ; i < length - 1 ; i++) {
           sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY()));
       }
       dot.setCenterX(smoothedPoints[length - 1].getX());
       dot.setCenterY(smoothedPoints[length - 1].getY());
   }
 
源代码21 项目: Medusa   文件: BatterySkin.java
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;
}
 
源代码22 项目: gef   文件: Geometry2Shape.java
/**
 * Converts the given {@link Path} to an array of JavaFX {@link PathElement}
 * s.
 *
 * @param path
 *            The {@link Path} to convert.
 * @return The new array of {@link PathElement}s.
 */
public static PathElement[] toPathElements(Path path) {
	Segment[] segments = path.getSegments();
	PathElement[] elements = new PathElement[segments.length];
	for (int i = 0; i < segments.length; i++) {
		Point[] points = segments[i].getPoints();
		// if (points.length > 0) {
		// System.out.println(i + ": " + points[points.length - 1]);
		// }
		switch (segments[i].getType()) {
		case Segment.MOVE_TO:
			elements[i] = new MoveTo(points[0].x, points[0].y);
			break;
		case Segment.LINE_TO:
			elements[i] = new LineTo(points[0].x, points[0].y);
			break;
		case Segment.QUAD_TO:
			elements[i] = new QuadCurveTo(points[0].x, points[0].y,
					points[1].x, points[1].y);
			break;
		case Segment.CUBIC_TO:
			elements[i] = new CubicCurveTo(points[0].x, points[0].y,
					points[1].x, points[1].y, points[2].x, points[2].y);
			break;
		case Segment.CLOSE:
			elements[i] = new ClosePath();
			break;
		default:
			throw new IllegalStateException(
					"Unknown Path.Segment: <" + segments[i] + ">");
		}
	}
	return elements;
}
 
源代码23 项目: OEE-Designer   文件: GaugeSparkLineTileSkin.java
@SuppressWarnings("unused")
private void smooth(final List<Double> DATA_LIST) {
       int     size   = DATA_LIST.size();
       Point[] points = new Point[size];

       low  = Statistics.getMin(DATA_LIST);
       high = Statistics.getMax(DATA_LIST);
       if (Helper.equals(low, high)) {
           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++) {
           points[i] = new Point(minX + i * stepX, maxY - Math.abs(low - DATA_LIST.get(i)) * stepY);
       }

       Point[] smoothedPoints = Helper.subdividePoints(points, 16);
       int length = smoothedPoints.length;
       sparkLine.getElements().clear();
       sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY()));
       for (int i = 1 ; i < length - 1 ; i++) {
           sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY()));
       }
       dot.setCenterX(smoothedPoints[length - 1].getX());
       dot.setCenterY(smoothedPoints[length - 1].getY());
   }
 
源代码24 项目: JetUML   文件: CallEdgeViewer.java
@Override
public Canvas createIcon(Edge pEdge)
{
	final float scale = 0.6f;
	final int offset = 15;
	Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE);
	GraphicsContext graphics = canvas.getGraphicsContext2D();
	canvas.getGraphicsContext2D().scale(scale, scale);
	Path path = new Path();
	path.getElements().addAll(new MoveTo(1, offset), new LineTo(BUTTON_SIZE*(1/scale)-1, offset));
	ToolGraphics.strokeSharpPath(graphics, path, LineStyle.SOLID);
	ArrowHead.V.view().draw(graphics, new Point(1, offset), new Point((int)(BUTTON_SIZE*(1/scale)-1), offset));
	return canvas;
}
 
源代码25 项目: OEE-Designer   文件: StockTileSkin.java
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);
}
 
源代码26 项目: Medusa   文件: QuarterSkin.java
private void drawAverage() {
    double scaledSize = size * 1.95;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.38 * sinValue, centerY + scaledSize * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.465 * sinValue, centerY + scaledSize * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
源代码27 项目: OEE-Designer   文件: SmoothedChart.java
private double[] getXYFromPathElement(final PathElement ELEMENT) {
    if (ELEMENT instanceof MoveTo) {
        return new double[]{ ((MoveTo) ELEMENT).getX(), ((MoveTo) ELEMENT).getY() };
    } else if (ELEMENT instanceof LineTo) {
        return new double[] { ((LineTo) ELEMENT).getX(), ((LineTo) ELEMENT).getY() };
    } else {
        return new double[] { -1, -1 };
    }
}
 
源代码28 项目: OEE-Designer   文件: SunburstChart.java
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    return path;
}
 
源代码29 项目: JetUML   文件: StateTransitionEdgeViewer.java
private Shape getNormalEdgeShape(Edge pEdge)
{
	Line line = getConnectionPoints(pEdge);
	Path path = new Path();
	MoveTo moveTo = new MoveTo(line.getPoint1().getX(), line.getPoint1().getY());
	QuadCurveTo curveTo = new QuadCurveTo(getControlPoint(pEdge).getX(), getControlPoint(pEdge).getY(), 
			line.getPoint2().getX(), line.getPoint2().getY());
	path.getElements().addAll(moveTo, curveTo);
	return path;
}
 
源代码30 项目: marathonv5   文件: PathSample.java
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
}
 
 类所在包
 同包方法