javafx.scene.shape.QuadCurve Java Examples

The following examples show how to use javafx.scene.shape.QuadCurve. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuadCurveSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    QuadCurve quadCurve = new QuadCurve();
    quadCurve.setStartX(0);
    quadCurve.setStartY(50);
    quadCurve.setControlX(20);
    quadCurve.setControlY(0);
    quadCurve.setEndX(80);
    quadCurve.setEndY(50);
    quadCurve.setStroke(Color.web("#b9c0c5"));
    quadCurve.setStrokeWidth(5);
    quadCurve.getStrokeDashArray().addAll(15d,15d);
    quadCurve.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));
    quadCurve.setEffect(effect);
    return quadCurve;
}
 
Example #2
Source File: QuadCurveSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    QuadCurve quadCurve = new QuadCurve();
    quadCurve.setStartX(0);
    quadCurve.setStartY(50);
    quadCurve.setControlX(20);
    quadCurve.setControlY(0);
    quadCurve.setEndX(80);
    quadCurve.setEndY(50);
    quadCurve.setStroke(Color.web("#b9c0c5"));
    quadCurve.setStrokeWidth(5);
    quadCurve.getStrokeDashArray().addAll(15d,15d);
    quadCurve.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));
    quadCurve.setEffect(effect);
    return quadCurve;
}
 
Example #3
Source File: QuadCurveSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public QuadCurveSample() {
    super(180,90);
    // Create quadCurve shape
    QuadCurve quadCurve = new QuadCurve();
    quadCurve.setStartX(0);
    quadCurve.setStartY(45);
    quadCurve.setControlX(50);
    quadCurve.setControlY(10);
    quadCurve.setEndX(180);
    quadCurve.setEndY(45);
    quadCurve.setStroke(Color.RED);
    quadCurve.setFill(Color.ROSYBROWN);
    quadCurve.setStrokeWidth(2d);

    // show the quadCurve shape;
    getChildren().add(quadCurve);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Cubic Curve Fill", quadCurve.fillProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Stroke", quadCurve.strokeProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Start X", quadCurve.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Cubic Curve Start Y", quadCurve.startYProperty(), 10d, 80d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X1", quadCurve.controlXProperty(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", quadCurve.controlYProperty(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve End X", quadCurve.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve End Y", quadCurve.endYProperty(), 10d, 80d)
    );
    // END REMOVE ME
}
 
Example #4
Source File: QuadCurveSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public QuadCurveSample() {
    super(180,90);
    // Create quadCurve shape
    QuadCurve quadCurve = new QuadCurve();
    quadCurve.setStartX(0);
    quadCurve.setStartY(45);
    quadCurve.setControlX(50);
    quadCurve.setControlY(10);
    quadCurve.setEndX(180);
    quadCurve.setEndY(45);
    quadCurve.setStroke(Color.RED);
    quadCurve.setFill(Color.ROSYBROWN);
    quadCurve.setStrokeWidth(2d);

    // show the quadCurve shape;
    getChildren().add(quadCurve);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Cubic Curve Fill", quadCurve.fillProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Stroke", quadCurve.strokeProperty()),
            new SimplePropertySheet.PropDesc("Cubic Curve Start X", quadCurve.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Cubic Curve Start Y", quadCurve.startYProperty(), 10d, 80d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control X1", quadCurve.controlXProperty(), 0d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", quadCurve.controlYProperty(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Cubic Curve End X", quadCurve.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Cubic Curve End Y", quadCurve.endYProperty(), 10d, 80d)
    );
    // END REMOVE ME
}
 
Example #5
Source File: Level8.java    From FXGLGames with MIT License 5 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {

            Entity enemy = spawnEnemy(50, 50 + y*50);

            QuadCurve path = new QuadCurve(50, 50 + y*50, 250, 200 + y * 20, Config.WIDTH - 50 - 40, 50 + y*50);

            Animation<?> anim = animationBuilder()
                    .delay(Duration.seconds(t))
                    .autoReverse(true)
                    .interpolator(Interpolators.BACK.EASE_IN_OUT())
                    .duration(Duration.seconds(3))
                    .repeat(Integer.MAX_VALUE)
                    .translate(enemy)
                    .alongPath(path)
                    .build();

            animations.add(anim);
            anim.start();

            t += 0.3;
        }
    }
}
 
Example #6
Source File: Shape2Geometry.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an {@link IGeometry} that describes the geometric outline of the
 * given {@link Shape}, i.e. excluding the stroke.
 * <p>
 * The conversion is supported for the following {@link Shape}s:
 * <ul>
 * <li>{@link Arc}
 * <li>{@link Circle}
 * <li>{@link CubicCurve}
 * <li>{@link Ellipse}
 * <li>{@link Line}
 * <li>{@link Path}
 * <li>{@link Polygon}
 * <li>{@link Polyline}
 * <li>{@link QuadCurve}
 * <li>{@link Rectangle}
 * </ul>
 * The following {@link Shape}s cannot be converted, yet:
 * <ul>
 * <li>{@link Text}
 * <li>{@link SVGPath}
 * </ul>
 *
 * @param visual
 *            The {@link Shape} for which an {@link IGeometry} is
 *            determined.
 * @return The newly created {@link IGeometry} that best describes the
 *         geometric outline of the given {@link Shape}.
 * @throws IllegalStateException
 *             if the given {@link Shape} is not supported.
 */
public static IGeometry toGeometry(Shape visual) {
	if (visual instanceof Arc) {
		return toArc((Arc) visual);
	} else if (visual instanceof Circle) {
		return toEllipse((Circle) visual);
	} else if (visual instanceof CubicCurve) {
		return toCubicCurve((CubicCurve) visual);
	} else if (visual instanceof Ellipse) {
		return toEllipse((Ellipse) visual);
	} else if (visual instanceof Line) {
		return toLine((Line) visual);
	} else if (visual instanceof Path) {
		return toPath((Path) visual);
	} else if (visual instanceof Polygon) {
		return toPolygon((Polygon) visual);
	} else if (visual instanceof Polyline) {
		return toPolyline((Polyline) visual);
	} else if (visual instanceof QuadCurve) {
		QuadCurve quad = (QuadCurve) visual;
		return toQuadraticCurve(quad);
	} else if (visual instanceof Rectangle) {
		Rectangle rect = (Rectangle) visual;
		if (rect.getArcWidth() == 0 && rect.getArcHeight() == 0) {
			// corners are not rounded => normal rectangle is sufficient
			return toRectangle(rect);
		}
		return toRoundedRectangle((Rectangle) visual);
	} else {
		// Text and SVGPath shapes are currently not supported
		throw new IllegalStateException(
				"Cannot compute geometric outline for Shape of type <"
						+ visual.getClass() + ">.");
	}
}
 
Example #7
Source File: Level8.java    From FXGLGames with MIT License 5 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {

            Entity enemy = spawnEnemy(50, 50 + y*50);

            QuadCurve path = new QuadCurve(50, 50 + y*50, 250, 200 + y * 20, Config.WIDTH - 50 - 40, 50 + y*50);

            Animation<?> anim = animationBuilder()
                    .delay(Duration.seconds(t))
                    .autoReverse(true)
                    .interpolator(Interpolators.BACK.EASE_IN_OUT())
                    .duration(Duration.seconds(3))
                    .repeat(Integer.MAX_VALUE)
                    .translate(enemy)
                    .alongPath(path)
                    .build();

            animations.add(anim);
            anim.start();

            t += 0.3;
        }
    }
}
 
Example #8
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #9
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
public static String convertQuadCurve(final QuadCurve QUAD_CURVE) {
    final StringBuilder fxPath = new StringBuilder();
    fxPath.append("M ").append(QUAD_CURVE.getStartX()).append(" ").append(QUAD_CURVE.getStartY()).append(" ")
          .append("Q ").append(QUAD_CURVE.getControlX()).append(" ").append(QUAD_CURVE.getControlY())
          .append(QUAD_CURVE.getEndX()).append(" ").append(QUAD_CURVE.getEndY());
    return fxPath.toString();
}
 
Example #10
Source File: Shape2Geometry.java    From gef with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Converts the given JavaFX {@link QuadCurve} to a
 * {@link org.eclipse.gef.geometry.planar.QuadraticCurve}.
 *
 * @param quad
 *            The JavaFX {@link QuadCurve} to convert.
 * @return The newly created
 *         {@link org.eclipse.gef.geometry.planar.QuadraticCurve} that
 *         describes the given {@link QuadCurve}.
 */
public static org.eclipse.gef.geometry.planar.QuadraticCurve toQuadraticCurve(
		QuadCurve quad) {
	return new org.eclipse.gef.geometry.planar.QuadraticCurve(
			quad.getStartX(), quad.getStartY(), quad.getControlX(),
			quad.getControlY(), quad.getEndX(), quad.getEndY());
}