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

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

源代码1 项目: marathonv5   文件: PolylineSample.java
public static Node createIconContent() {
    Polyline polyline = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline.setStroke(Color.web("#b9c0c5"));
    polyline.setStrokeWidth(5);
    polyline.getStrokeDashArray().addAll(15d,15d);
    polyline.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));
    polyline.setEffect(effect);
    return polyline;
}
 
源代码2 项目: marathonv5   文件: PolylineSample.java
public static Node createIconContent() {
    Polyline polyline = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline.setStroke(Color.web("#b9c0c5"));
    polyline.setStrokeWidth(5);
    polyline.getStrokeDashArray().addAll(15d,15d);
    polyline.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));
    polyline.setEffect(effect);
    return polyline;
}
 
源代码3 项目: marathonv5   文件: PolylineSample.java
public PolylineSample() {
    super(180,90);
    // Red stroked not closed triangle
    Polyline polyline1 = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline1.setFill(Color.TRANSPARENT);
    polyline1.setStroke(Color.RED);

    // Blue stroked closed triangle
    Polyline polyline2 = new Polyline(new double[]{
        135, 10,
        100, 80,
        170, 80,
        135, 10,
    });
    polyline2.setStroke(Color.DODGERBLUE);
    polyline2.setStrokeWidth(2);
    polyline2.setFill(null);

    
    // Create a group to show all the polylines);
    getChildren().add(new Group(polyline1, polyline2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
            new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
    );
    // END REMOVE ME
}
 
源代码4 项目: marathonv5   文件: PolylineSample.java
public PolylineSample() {
    super(180,90);
    // Red stroked not closed triangle
    Polyline polyline1 = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline1.setFill(Color.TRANSPARENT);
    polyline1.setStroke(Color.RED);

    // Blue stroked closed triangle
    Polyline polyline2 = new Polyline(new double[]{
        135, 10,
        100, 80,
        170, 80,
        135, 10,
    });
    polyline2.setStroke(Color.DODGERBLUE);
    polyline2.setStrokeWidth(2);
    polyline2.setFill(null);

    
    // Create a group to show all the polylines);
    getChildren().add(new Group(polyline1, polyline2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
            new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
    );
    // END REMOVE ME
}
 
源代码5 项目: phoebus   文件: PolylineRepresentation.java
@Override
public Group createJFXNode() throws Exception
{
    final Polyline polyline = new Polyline();
    polyline.setStrokeLineJoin(StrokeLineJoin.MITER);
    polyline.setStrokeLineCap(StrokeLineCap.BUTT);
    return new Group(polyline, new Arrow(), new Arrow());
}
 
源代码6 项目: gef   文件: Shape2Geometry.java
/**
 * 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() + ">.");
	}
}
 
源代码7 项目: gef   文件: CustomNodeExample.java
@Override
protected Group doCreateVisual() {
	ImageView ian = new ImageView(new javafx.scene.image.Image(
			getClass().getResource("ibull.jpg").toExternalForm()));
	Polyline body = new Polyline(0, 0, 0, 60, 25, 90, 0, 60, -25, 90, 0,
			60, 0, 25, 25, 0, 0, 25, -25, 0);
	body.setTranslateX(ian.getLayoutBounds().getWidth() / 2
			- body.getLayoutBounds().getWidth() / 2 - 5);
	body.setTranslateY(-15);
	labelText = new Text();
	vbox = new VBox();
	vbox.getChildren().addAll(ian, body, labelText);
	return new Group(vbox);
}
 
源代码8 项目: gef   文件: JFaceCustomNodeExample.java
@Override
protected Group doCreateVisual() {
	ImageView ian = new ImageView(new javafx.scene.image.Image(
			getClass().getResource("ibull.jpg").toExternalForm()));
	Polyline body = new Polyline(0, 0, 0, 60, 25, 90, 0, 60, -25, 90, 0,
			60, 0, 25, 25, 0, 0, 25, -25, 0);
	body.setTranslateX(ian.getLayoutBounds().getWidth() / 2
			- body.getLayoutBounds().getWidth() / 2 - 5);
	body.setTranslateY(-15);
	labelText = new Text();
	vbox = new VBox();
	vbox.getChildren().addAll(ian, body, labelText);
	return new Group(vbox);
}
 
private void createOverlayBottomLineUp() {
    overlayBottomLineUp = new Polyline();
    overlayBottomLineUp.getPoints().addAll(
            new Double[]{
                    -10.0d, 4.0d,
                    0.0d, 0.0d,
                    10.0d, 4.0d}
    );
}
 
源代码10 项目: markdown-writer-fx   文件: EmbeddedImage.java
private Node createErrorNode() {
	Polyline errorNode = new Polyline(
		0, 0,  ERROR_SIZE, 0,  ERROR_SIZE, ERROR_SIZE,  0, ERROR_SIZE,  0, 0,	// rectangle
		ERROR_SIZE, ERROR_SIZE,  0, ERROR_SIZE,  ERROR_SIZE, 0);				// cross
	errorNode.setStroke(Color.RED); //TODO use CSS
	return errorNode;
}
 
源代码11 项目: Intro-to-Java-Programming   文件: Exercise_15_09.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a pane 
	Pane pane = new Pane();

	// Create a polyline
	Polyline polyline = new Polyline(new Double(100.0), new Double(100.0));
	polyline.setFill(Color.WHITE);
	polyline.setStroke(Color.BLACK);
	pane.getChildren().add(polyline);
	ObservableList<Double> list = polyline.getPoints();

	// Create and register handler
	pane.setOnKeyPressed(e -> {
		double x = 0, y = 0;
		double length = 10;
		switch (e.getCode()) {
			case DOWN: x = list.get(list.size() - 2);
						  y = list.get(list.size() - 1) + length; break;
			case UP: x = list.get(list.size() - 2);
						y = list.get(list.size() - 1) - length; break;
			case RIGHT: x = list.get(list.size() - 2) + length;
						  y = list.get(list.size() - 1); break;
			case LEFT: x = list.get(list.size() - 2) - length;
						  y = list.get(list.size() - 1); break;

		}
		list.add(x);
		list.add(y); 
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 200);
	primaryStage.setTitle("Exercise_15_09"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage

	pane.requestFocus(); // Pane is focused to receive key input 
}
 
源代码12 项目: 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();
}
 
源代码13 项目: Enzo   文件: ShapeConverter.java
public static String convertPolyline(final Polyline POLYLINE) {
    final StringBuilder fxPath = new StringBuilder();
    final int           size   = POLYLINE.getPoints().size();
    if (size % 2 == 0) {
        List<Double> coordinates     = POLYLINE.getPoints();
        for (int i = 0 ; i < size ; i += 2) {
            fxPath.append(i == 0 ? "M " : "L ")
                  .append(coordinates.get(i)).append(" ").append(coordinates.get(i + 1)).append(" ");
        }
    }
    return fxPath.toString();
}
 
源代码14 项目: MyBox   文件: DoublePolyline.java
public DoublePolyline() {
    points = new ArrayList<>();
    polyline = new Polyline();
}
 
源代码15 项目: MyBox   文件: DoublePolyline.java
public Polyline getPolyline() {
    polyline = new Polyline();
    polyline.getPoints().addAll(getData());
    return polyline;
}
 
源代码16 项目: MyBox   文件: DoublePolyline.java
public void clear() {
    points.clear();
    polyline = new Polyline();
}
 
源代码17 项目: MyBox   文件: DoublePolyline.java
public void setPolyline(Polyline polyline) {
    this.polyline = polyline;
}
 
源代码18 项目: Intro-to-Java-Programming   文件: Exercise_14_18.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create two panes
	Pane pane1 = new Pane();
	pane1.setRotate(180);
	pane1.setPadding(new Insets(72, 0, 0, 75));
	Pane pane2 = new Pane();

	// Create a polyline
	Polyline polyline1 = new Polyline();
	pane1.getChildren().add(polyline1);             
	ObservableList<Double> list = polyline1.getPoints();
	double scaleFactor = 0.0125;                       
	for (int x = -100; x <= 100; x++) {                
		list.add(x + 200.0);                            
		list.add(scaleFactor * x * x);                  
	}  

	// Create two lines
	Line lineX = new Line(10, 200, 350, 200);                                                
	//pane.getChildren().addAll(stackPane, lineX);

	Line lineY = new Line(lineX.getEndX() / 2, 250, lineX.getEndX() / 2, 30);                                                
	pane2.getChildren().addAll(pane1, lineX, lineY);

	// Create two polylines
	Polyline polyline2 = new Polyline();
	pane2.getChildren().add(polyline2);
	ObservableList<Double> list2 = polyline2.getPoints();
	list2.addAll(lineY.getEndX() - 10, lineY.getEndY() + 20, 
		lineY.getEndX(), lineY.getEndY(), lineY.getEndX() + 10, 
		lineY. getEndY() + 20);

	Polyline polyline3 = new Polyline();
	pane2.getChildren().add(polyline3);
	ObservableList<Double> list3 = polyline3.getPoints();
	list3.addAll(lineX.getEndX() - 20, lineX.getEndY() - 10, 
		lineX.getEndX(), lineX.getEndY(), lineX.getEndX() - 20, 
		lineX. getEndY() + 10);

	// Create two text objects
	Text textX = new Text(lineX.getEndX() - 10, lineX.getEndY() - 20, "X");
	Text textY = new Text(lineY.getEndX() + 20, lineY.getEndY() + 10, "Y");
	pane2.getChildren().addAll(textX, textY);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane2);
	primaryStage.setTitle("Exercise_14_18"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码19 项目: Intro-to-Java-Programming   文件: Exercise_14_17.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a pane
	Pane pane = new Pane();

	// Create three polylines and set their properties
	Polyline polyline1 = new Polyline();
	pane.getChildren().add(polyline1);
	polyline1.setStroke(Color.BLACK);
	ObservableList<Double> list = polyline1.getPoints();
	double x1 = 40.0;
	double y1 = 190.0;
	double y2 = 20.0;
	double x3 = 125.0;
	list.addAll(x1, y1, x1, y2, x3, y2, x3, y1 * .60);

	Polyline polyline2 = new Polyline();
	pane.getChildren().add(polyline2);
	polyline2.setStroke(Color.BLACK);
	ObservableList<Double> list2 = polyline2.getPoints();
	list2.addAll((x1 + x3) * .5, y1 * .5, x3, y1 * .25,
		x3 + (x3 - x1) * .5, y1 * .5);

	Polyline polyline3 = new Polyline();
	pane.getChildren().add(polyline3);
	polyline3.setStroke(Color.BLACK);
	ObservableList<Double> list3 = polyline3.getPoints();
	list3.addAll((x1 + x3) * .6, y1 * .80, x3, y1 * .60,
		x3 + (x3 - x1) * .3, y1 * .80);

	// Create a circle and set its properties
	Circle circle = new Circle(x3, y1 * .25, 15);
	circle.setFill(Color.WHITE);
	circle.setStroke(Color.BLACK);
	pane.getChildren().add(circle);

	// Create an arc and set its properties
	Arc arc = new Arc(x1, y1 + 1, 25, 15, 0, 180);
	arc.setFill(Color.WHITE);
	arc.setStroke(Color.BLACK);
	pane.getChildren().add(arc);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 200);
	primaryStage.setTitle("Exercise_14_17"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码20 项目: gef   文件: Shape2Geometry.java
/**
 * Converts the given JavaFX {@link Polyline} to a
 * {@link org.eclipse.gef.geometry.planar.Polyline}.
 *
 * @param polyline
 *            The JavaFX {@link Polyline} to convert.
 * @return The newly created
 *         {@link org.eclipse.gef.geometry.planar.Polyline} that describes
 *         the given {@link Polyline}.
 */
public static org.eclipse.gef.geometry.planar.Polyline toPolyline(
		Polyline polyline) {
	double[] coords = new double[polyline.getPoints().size()];
	for (int i = 0; i < coords.length; i++) {
		coords[i] = polyline.getPoints().get(i).doubleValue();
	}
	return new org.eclipse.gef.geometry.planar.Polyline(coords);
}
 
 类所在包
 同包方法