Java 类javafx.scene.shape.CubicCurve 实例源码

项目:marathonv5    文件:CubicCurveSample.java   
public static Node createIconContent() {
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(50);
    cubicCurve.setControlX1(20);
    cubicCurve.setControlY1(0);
    cubicCurve.setControlX2(70);
    cubicCurve.setControlY2(100);
    cubicCurve.setEndX(80);
    cubicCurve.setEndY(50);
    cubicCurve.setStroke(Color.web("#b9c0c5"));
    cubicCurve.setStrokeWidth(5);
    cubicCurve.getStrokeDashArray().addAll(15d,15d);
    cubicCurve.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    cubicCurve.setEffect(effect);
    return cubicCurve;
}
项目:marathonv5    文件:CubicCurveSample.java   
public static Node createIconContent() {
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(50);
    cubicCurve.setControlX1(20);
    cubicCurve.setControlY1(0);
    cubicCurve.setControlX2(70);
    cubicCurve.setControlY2(100);
    cubicCurve.setEndX(80);
    cubicCurve.setEndY(50);
    cubicCurve.setStroke(Color.web("#b9c0c5"));
    cubicCurve.setStrokeWidth(5);
    cubicCurve.getStrokeDashArray().addAll(15d,15d);
    cubicCurve.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    cubicCurve.setEffect(effect);
    return cubicCurve;
}
项目:Game-Engine-Vooga    文件:BezierCurve.java   
/**
 * Creates the starting Bezier curve and its controls.
 * @return
 */
CubicCurve createStartingCurve() {
    curve = new CubicCurve();
    curve.setStartX(START_X);
    curve.setStartY(START_Y);
    curve.setControlX1(CONTROL_X1);
    curve.setControlY1(CONTROL_Y1);
    curve.setControlX2(CONTROL_X2);
    curve.setControlY2(CONTROL_Y2);
    curve.setEndX(END_X);
    curve.setEndY(END_Y);
    curve.setStroke(Color.CADETBLUE);
    curve.setStrokeWidth(WIDTH);
    curve.setStrokeLineCap(StrokeLineCap.ROUND);
    curve.setFill(Color.CORNSILK.deriveColor(0, SATURATION_FACTOR, 1, OPACITY_FACTOR));
    this.getChildren().add(curve);
    return curve;
}
项目:viskell    文件:Connection.java   
/** Returns the current bezier offset based on the current start and end positions. */
private static double getBezierYOffset(CubicCurve wire) {
    double distX = Math.abs(wire.getEndX() - wire.getStartX())/3;
    double diffY = wire.getEndY() - wire.getStartY();
    double distY = diffY > 0 ? diffY/2 : Math.max(0, -diffY-10); 
    if (distY < BEZIER_CONTROL_OFFSET) {
        if (distX < BEZIER_CONTROL_OFFSET) {
            // short lines are extra flexible
            return Math.max(1, Math.max(distX, distY));
        } else {
            return BEZIER_CONTROL_OFFSET;
        }
    } else {
        return Math.cbrt(distY / BEZIER_CONTROL_OFFSET) * BEZIER_CONTROL_OFFSET;
    }
}
项目:JavaFxNodeToSvg    文件:ShapeConverter.java   
public static String convertCubicCurve(final CubicCurve CUBIC_CURVE) {
    final StringBuilder fxPath = new StringBuilder();
    fxPath
            .append("M ")
            .append(CUBIC_CURVE.getStartX())
            .append(" ")
            .append(CUBIC_CURVE.getStartY())
            .append(" ")
            .append("C ")
            .append(CUBIC_CURVE.getControlX1())
            .append(" ")
            .append(CUBIC_CURVE.getControlY1())
            .append(" ")
            .append(CUBIC_CURVE.getControlX2())
            .append(" ")
            .append(CUBIC_CURVE.getControlY2())
            .append(" ")
            .append(CUBIC_CURVE.getEndX())
            .append(" ")
            .append(CUBIC_CURVE.getEndY());
    return fxPath.toString();
}
项目:kotlinfx-ensemble    文件:CubicCurveSample.java   
public static Node createIconContent() {
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(50);
    cubicCurve.setControlX1(20);
    cubicCurve.setControlY1(0);
    cubicCurve.setControlX2(70);
    cubicCurve.setControlY2(100);
    cubicCurve.setEndX(80);
    cubicCurve.setEndY(50);
    cubicCurve.setStroke(Color.web("#b9c0c5"));
    cubicCurve.setStrokeWidth(5);
    cubicCurve.getStrokeDashArray().addAll(15d,15d);
    cubicCurve.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    cubicCurve.setEffect(effect);
    return cubicCurve;
}
项目:marathonv5    文件:CubicCurveSample.java   
public CubicCurveSample() {
    super(180,90);
    // Create cubicCurve shape
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(45);
    cubicCurve.setControlX1(30);
    cubicCurve.setControlY1(10);
    cubicCurve.setControlX2(150);
    cubicCurve.setControlY2(80);
    cubicCurve.setEndX(180);
    cubicCurve.setEndY(45);
    cubicCurve.setStroke(Color.RED);
    cubicCurve.setFill(Color.ROSYBROWN);
    cubicCurve.setStrokeWidth(2d);

    // show the cubicCurve shape;
    getChildren().add(cubicCurve);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Cubic Curve Fill", cubicCurve.fillProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Stroke", cubicCurve.strokeProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Start X", cubicCurve.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Cubic Curve Start Y", cubicCurve.startYProperty(), 10d, 80d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X1", cubicCurve.controlX1Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", cubicCurve.controlY1Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X2", cubicCurve.controlX2Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y2", cubicCurve.controlY2Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve End X", cubicCurve.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve End Y", cubicCurve.endYProperty(), 10d, 80d)
    );
    // END REMOVE ME
}
项目:marathonv5    文件:CubicCurveSample.java   
public CubicCurveSample() {
    super(180,90);
    // Create cubicCurve shape
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(45);
    cubicCurve.setControlX1(30);
    cubicCurve.setControlY1(10);
    cubicCurve.setControlX2(150);
    cubicCurve.setControlY2(80);
    cubicCurve.setEndX(180);
    cubicCurve.setEndY(45);
    cubicCurve.setStroke(Color.RED);
    cubicCurve.setFill(Color.ROSYBROWN);
    cubicCurve.setStrokeWidth(2d);

    // show the cubicCurve shape;
    getChildren().add(cubicCurve);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Cubic Curve Fill", cubicCurve.fillProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Stroke", cubicCurve.strokeProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Start X", cubicCurve.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Cubic Curve Start Y", cubicCurve.startYProperty(), 10d, 80d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X1", cubicCurve.controlX1Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", cubicCurve.controlY1Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X2", cubicCurve.controlX2Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y2", cubicCurve.controlY2Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve End X", cubicCurve.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve End Y", cubicCurve.endYProperty(), 10d, 80d)
    );
    // END REMOVE ME
}
项目:viskell    文件:Connection.java   
/** Updates the Bezier offset (curviness) according to the current start and end positions. */
protected static void updateBezierControlPoints(CubicCurve wire) {
    double yOffset = getBezierYOffset(wire);
    wire.setControlX1(wire.getStartX());
    wire.setControlY1(wire.getStartY() + yOffset);
    wire.setControlX2(wire.getEndX());
    wire.setControlY2(wire.getEndY() - yOffset);
}
项目:FXImgurUploader    文件:ShapeConverter.java   
public static String shapeToSvgString(final Shape SHAPE) {
    final StringBuilder fxPath = new StringBuilder();
    if (Line.class.equals(SHAPE.getClass())) {
        fxPath.append(convertLine((Line) SHAPE));
    } else if (Arc.class.equals(SHAPE.getClass())) {
        fxPath.append(convertArc((Arc) SHAPE));
    } else if (QuadCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertQuadCurve((QuadCurve) SHAPE));
    } else if (CubicCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCubicCurve((CubicCurve) SHAPE));
    } else if (Rectangle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertRectangle((Rectangle) SHAPE));
    } else if (Circle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCircle((Circle) SHAPE));
    } else if (Ellipse.class.equals(SHAPE.getClass())) {
        fxPath.append(convertEllipse((Ellipse) SHAPE));
    } else if (Text.class.equals(SHAPE.getClass())) {
        Path path = (Path)(Shape.subtract(SHAPE, new Rectangle(0, 0)));
        fxPath.append(convertPath(path));
    } else if (Path.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPath((Path) SHAPE));
    } else if (Polygon.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolygon((Polygon) SHAPE));
    } else if (Polyline.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolyline((Polyline) SHAPE));
    } else if (SVGPath.class.equals(SHAPE.getClass())) {
        fxPath.append(((SVGPath) SHAPE).getContent());
    }
    return fxPath.toString();
}
项目:FXImgurUploader    文件:ShapeConverter.java   
public static String convertCubicCurve(final CubicCurve CUBIC_CURVE) {
    final StringBuilder fxPath = new StringBuilder();
    fxPath.append("M ").append(CUBIC_CURVE.getStartX()).append(" ").append(CUBIC_CURVE.getStartY()).append(" ")
          .append("C ").append(CUBIC_CURVE.getControlX1()).append(" ").append(CUBIC_CURVE.getControlY1()).append(" ")
          .append(CUBIC_CURVE.getControlX2()).append(" ").append(CUBIC_CURVE.getControlY2()).append(" ")
          .append(CUBIC_CURVE.getEndX()).append(" ").append(CUBIC_CURVE.getEndY());
    return fxPath.toString();
}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetCubicCurveAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(CubicCurve.class);

    assertThat(adjuster, is(instanceOf(CubicCurveAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(CubicCurve.class)));
}
项目:kotlinfx-ensemble    文件:CubicCurveSample.java   
public CubicCurveSample() {
    super(180,90);
    // Create cubicCurve shape
    CubicCurve cubicCurve = new CubicCurve();
    cubicCurve.setStartX(0);
    cubicCurve.setStartY(45);
    cubicCurve.setControlX1(30);
    cubicCurve.setControlY1(10);
    cubicCurve.setControlX2(150);
    cubicCurve.setControlY2(80);
    cubicCurve.setEndX(180);
    cubicCurve.setEndY(45);
    cubicCurve.setStroke(Color.RED);
    cubicCurve.setFill(Color.ROSYBROWN);
    cubicCurve.setStrokeWidth(2d);

    // show the cubicCurve shape;
    getChildren().add(cubicCurve);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Cubic Curve Fill", cubicCurve.fillProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Stroke", cubicCurve.strokeProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Start X", cubicCurve.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Cubic Curve Start Y", cubicCurve.startYProperty(), 10d, 80d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X1", cubicCurve.controlX1Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", cubicCurve.controlY1Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X2", cubicCurve.controlX2Property(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y2", cubicCurve.controlY2Property(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve End X", cubicCurve.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve End Y", cubicCurve.endYProperty(), 10d, 80d)
    );
    // END REMOVE ME
}
项目:Enzo    文件:ShapeConverter.java   
public static String shapeToSvgString(final Shape SHAPE) {
    final StringBuilder fxPath = new StringBuilder();
    if (Line.class.equals(SHAPE.getClass())) {
        fxPath.append(convertLine((Line) SHAPE));
    } else if (Arc.class.equals(SHAPE.getClass())) {
        fxPath.append(convertArc((Arc) SHAPE));
    } else if (QuadCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertQuadCurve((QuadCurve) SHAPE));
    } else if (CubicCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCubicCurve((CubicCurve) SHAPE));
    } else if (Rectangle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertRectangle((Rectangle) SHAPE));
    } else if (Circle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCircle((Circle) SHAPE));
    } else if (Ellipse.class.equals(SHAPE.getClass())) {
        fxPath.append(convertEllipse((Ellipse) SHAPE));
    } else if (Text.class.equals(SHAPE.getClass())) {
        Path path = (Path)(Shape.subtract(SHAPE, new Rectangle(0, 0)));
        fxPath.append(convertPath(path));
    } else if (Path.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPath((Path) SHAPE));
    } else if (Polygon.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolygon((Polygon) SHAPE));
    } else if (Polyline.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolyline((Polyline) SHAPE));
    } else if (SVGPath.class.equals(SHAPE.getClass())) {
        fxPath.append(((SVGPath) SHAPE).getContent());
    }
    return fxPath.toString();
}
项目:Enzo    文件:ShapeConverter.java   
public static String convertCubicCurve(final CubicCurve CUBIC_CURVE) {
    final StringBuilder fxPath = new StringBuilder();
    fxPath.append("M ").append(CUBIC_CURVE.getStartX()).append(" ").append(CUBIC_CURVE.getStartY()).append(" ")
          .append("C ").append(CUBIC_CURVE.getControlX1()).append(" ").append(CUBIC_CURVE.getControlY1()).append(" ")
          .append(CUBIC_CURVE.getControlX2()).append(" ").append(CUBIC_CURVE.getControlY2()).append(" ")
          .append(CUBIC_CURVE.getEndX()).append(" ").append(CUBIC_CURVE.getEndY());
    return fxPath.toString();
}
项目:PSE    文件:Edge.java   
/**
 * setupLine. This method is invoked whenever a line is being
 * created. Both the coordinates and the event are set here.
 * @return Returns the line created.
 */
public CubicCurve setupLine()
{
    /* Appropriate circle. */
    Circle io = (nodeBoxSource == null) ? nodeBoxTarget.getNode().getInput()
            : nodeBoxSource.getNode().getOutput();

    /* Calculate the coordinates. */
    Coordinates coordinates = new Coordinates();
    Bounds bounds = io.localToScene( io.getBoundsInLocal() );
    coordinates.setX( (bounds.getMinX() + (bounds.getWidth()  / 2)) - 50 );
    coordinates.setY(  bounds.getMinY() + (bounds.getHeight() / 2)       );

    /* Create the line and setup the properties. */
    line = new CubicCurve();
    line.setFill(Color.TRANSPARENT);
    line.setStartX   ( coordinates.getX() );
    line.setStartY   ( coordinates.getY() );
    line.setControlX1( coordinates.getX() );
    line.setControlX2( coordinates.getX() );
    line.setControlY1( coordinates.getY() );
    line.setControlY2( coordinates.getY() );
    line.setEndX     ( coordinates.getX() );
    line.setEndY     ( coordinates.getY() );
    line.setStroke(Color.GREENYELLOW);
    line.setStrokeWidth(2);

    /*
     * Setup the mouse move event for the line, note
     * that we are using the workspace to handle the
     * event, since we need track the workspace.
     */
    filter = new EventHandler<MouseEvent>() {
        private Edge.IO io = Edge.this.lastConnection;

        @Override
        public void handle(MouseEvent event) {
            /* There's a line being created. */
            if (NodeBoxController.connAcc){
                double diff = Math.abs (Edge.this.line.getEndX() - Edge.this.line.getStartX());
                diff = (diff * 0.4);

                if (io.equals(IO.Input))
                    diff *= -1;

                Edge.this.line.setControlX1( Edge.this.line.getStartX() + diff );
                Edge.this.line.setControlY1( Edge.this.line.getStartY() );
                Edge.this.line.setControlX2( Edge.this.line.getEndX  () - diff );
                Edge.this.line.setControlY2( Edge.this.line.getEndY  () );

                Edge.this.line.setEndX( event.getX() );
                Edge.this.line.setEndY( event.getY() );
            }

            /* Consume event. */
            event.consume();
        }
    };

    /* Adds the event filter. */
    MainController.getInstance().getCurrentWorkspace().addEventFilter(MouseEvent.MOUSE_MOVED, filter);
    return line;
}
项目:Game-Engine-Vooga    文件:CubicCurvePath.java   
/**
 * Returns the relevant X controls for a Cubic Curve.
 */
@Override
public Double[] getXControls() {
    return new Double[] {((CubicCurve) myShape).getStartX(), ((CubicCurve) myShape).getControlX1(), ((CubicCurve) myShape).getControlX2(), ((CubicCurve) myShape).getEndX()};
}
项目:Game-Engine-Vooga    文件:CubicCurvePath.java   
/**
 * Returns the relevant Y controls for a Cubic Curve.
 */
@Override
public Double[] getYControls() {
    return new Double[] {((CubicCurve) myShape).getStartY(), ((CubicCurve) myShape).getControlY1(), ((CubicCurve) myShape).getControlY2(), ((CubicCurve) myShape).getEndY()};
}
项目:java_fx_node_link_demo    文件:DragIcon.java   
public void setType (DragIconType type) {

    mType = type;

    getStyleClass().clear();
    getStyleClass().add("dragicon");

    //added because the cubic curve will persist into other icons
    if (this.getChildren().size() > 0)
        getChildren().clear();

    switch (mType) {

    case cubic_curve:
        getStyleClass().add("icon-yellow");

        Pane  pane = new Pane();

        pane.setPrefWidth(64.0);
        pane.setPrefHeight(64.0);
        //pane.getStyleClass().add("icon-blue");
        pane.setLayoutX(0.0);
        pane.setLayoutY(0.0);

        CubicCurve curve = new CubicCurve();

        curve.setStartX(10.0);
        curve.setStartY(20.0);
        curve.setEndX(54.0);
        curve.setEndY(44.0);
        curve.setControlX1(64.0);
        curve.setControlY1(20.0);
        curve.setControlX2(0.0);
        curve.setControlY2(44.0);
        curve.getStyleClass().add("cubic-icon");

        pane.getChildren().add(curve);

        //r//oot_pane.
        getChildren().add(pane);

    break;

    case blue:
        getStyleClass().add("icon-blue");
    break;

    case red:
        getStyleClass().add("icon-red");            
    break;

    case green:
        getStyleClass().add("icon-green");
    break;

    case grey:
        getStyleClass().add("icon-grey");
    break;

    case purple:
        getStyleClass().add("icon-purple");
    break;

    case yellow:
        getStyleClass().add("icon-yellow");
    break;

    case black:
        getStyleClass().add("icon-black");
    break;

    default:
    break;
    }
}
项目:viskell    文件:Connection.java   
protected static double lengthSquared(CubicCurve wire) {
    double diffX = wire.getStartX() - wire.getEndX();
    double diffY = wire.getStartY() - wire.getEndY();
    return diffX*diffX + diffY*diffY;
}
项目:javafx-dpi-scaling    文件:CubicCurveAdjuster.java   
@Override
public Class<? extends Node> getNodeClass() {
    return CubicCurve.class;
}
项目:PSE    文件:Edge.java   
/**
 * Gets the current line used to illustrate the connection
 * between two NodeBox.
 * @return Returns the line.
 */
public CubicCurve getLine() {
    return line;
}
项目:PSE    文件:Edge.java   
/**
 * Sets the line to be used to connect two NodeBoxes.
 * @param line Line.
 */
public void setLine(CubicCurve line) {
    this.line = line;
}
项目:Game-Engine-Vooga    文件:BezierCurve.java   
/**
 * Returns the cubic curve component of the group.
 * @return a CubicCurve representing the Bezier curve.
 */
public CubicCurve getCurve() {
    return this.curve;
}