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

项目:tilesfx    文件:Helper.java   
public static final boolean isInPolygon(final double X, final double Y, final Polygon POLYGON) {
    List<Double> points              = POLYGON.getPoints();
    int          noOfPointsInPolygon = POLYGON.getPoints().size() / 2;
    double[]     pointsX             = new double[noOfPointsInPolygon];
    double[]     pointsY             = new double[noOfPointsInPolygon];
    int          pointCounter        = 0;
    for (int i = 0 ; i < points.size() ; i++) {
        if (i % 2 == 0) {
            pointsX[i] = points.get(pointCounter);
        } else {
            pointsY[i] = points.get(pointCounter);
            pointCounter++;
        }
    }
    return isInPolygon(X, Y, noOfPointsInPolygon, pointsX, pointsY);
}
项目:marathonv5    文件:TranslateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 20, 20);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(29);
    polygon.setLayoutY(21);
    polygon.setRotate(135);


    Rectangle r2 = new Rectangle (50, 50, 20, 20);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00"));
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:ShearSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (22, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00",0.5));
    r1.getTransforms().add(new Shear(-0.35, 0));

    Polygon polygon = createArrow();
    polygon.setLayoutX(-5);
    polygon.setLayoutY(-2);
    polygon.setRotate(90);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00", 0.25));
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:RotateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(65);
    polygon.setLayoutY(5);
    polygon.setRotate(165);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(15);
    r2.setArcWidth(15);
    r2.setFill(Color.web("#ed4b00"));
    r2.setRotate(60);
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:ScaleSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (50, 50, 14, 14);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(68);
    polygon.setLayoutY(25);
    polygon.setRotate(45);

    Rectangle r3 = new Rectangle (25, 25, 64, 64);
    r3.setArcHeight(15);
    r3.setArcWidth(15);
    r3.setFill(Color.web("#f49b00"));
    javafx.scene.Group g = new javafx.scene.Group(r3,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:PolygonSample.java   
public static Node createIconContent() {
    Polygon polygon = new Polygon(new double[]{
        45 , 10 ,
        10 , 80 ,
        80 , 80 ,
    });
    polygon.setStroke(Color.web("#b9c0c5"));
    polygon.setStrokeWidth(5);
    polygon.getStrokeDashArray().addAll(15d,15d);
    polygon.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));
    polygon.setEffect(effect);
    return polygon;
}
项目:marathonv5    文件:TranslateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 20, 20);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(29);
    polygon.setLayoutY(21);
    polygon.setRotate(135);


    Rectangle r2 = new Rectangle (50, 50, 20, 20);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00"));
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:ShearSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (22, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00",0.5));
    r1.getTransforms().add(new Shear(-0.35, 0));

    Polygon polygon = createArrow();
    polygon.setLayoutX(-5);
    polygon.setLayoutY(-2);
    polygon.setRotate(90);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00", 0.25));
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:RotateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(65);
    polygon.setLayoutY(5);
    polygon.setRotate(165);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(15);
    r2.setArcWidth(15);
    r2.setFill(Color.web("#ed4b00"));
    r2.setRotate(60);
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:ScaleSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (50, 50, 14, 14);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(68);
    polygon.setLayoutY(25);
    polygon.setRotate(45);

    Rectangle r3 = new Rectangle (25, 25, 64, 64);
    r3.setArcHeight(15);
    r3.setArcWidth(15);
    r3.setFill(Color.web("#f49b00"));
    javafx.scene.Group g = new javafx.scene.Group(r3,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:marathonv5    文件:PolygonSample.java   
public static Node createIconContent() {
    Polygon polygon = new Polygon(new double[]{
        45 , 10 ,
        10 , 80 ,
        80 , 80 ,
    });
    polygon.setStroke(Color.web("#b9c0c5"));
    polygon.setStrokeWidth(5);
    polygon.getStrokeDashArray().addAll(15d,15d);
    polygon.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));
    polygon.setEffect(effect);
    return polygon;
}
项目:gemoc-studio-modeldebugging    文件:TimelineDiffViewerRenderer.java   
private void setupBox(VBox box, String labelString, VBox content) {
    final HBox boxLabel = new HBox();
    final Polygon arrow = new Polygon(2.5, 10, 10, 5, 2.5, 0);
    final Label label = new Label(labelString);
    boxLabel.setBackground(HEADER_BACKGROUND);
    label.setFont(GROUP_FONT);
    HBox.setMargin(arrow, HALF_MARGIN_INSETS);
    boxLabel.setAlignment(Pos.CENTER_LEFT);
    boxLabel.getChildren().addAll(arrow, label);
    boxLabel.setCursor(Cursor.HAND);
    box.getChildren().add(boxLabel);
    boxLabel.setOnMouseClicked(e -> {
        if (box.getChildren().size() > 1) {
            box.getChildren().remove(content);
            arrow.setRotate(0);
        } else {
            box.getChildren().add(content);
            arrow.setRotate(90);
        }
    });
}
项目:Hive_Game    文件:GameScreenController.java   
private void drawPolygonPopUp(int deplacement, Tile tile) {
    Hexagon hex = new Hexagon();
    hex.setxPixel(0.0);
    hex.setyPixel(0.0);
    hex.calculHex();
    double x[] = hex.getListXCoord();
    double y[] = hex.getListYCoord();
    int placement = (int) (Consts.SIDE_SIZE);
    Piece piece = tile.getPiece();

    Polygon p = new Polygon();
    p.setFill(new ImagePattern(piece.getImage()));
    p.getPoints().addAll(new Double[]{
        x[0]+placement, y[0] + (Consts.SIDE_SIZE * deplacement),
        x[1]+placement, y[1] + Consts.SIDE_SIZE * deplacement,
        x[2]+placement, y[2] + Consts.SIDE_SIZE * deplacement,
        x[3]+placement, y[3] + Consts.SIDE_SIZE * deplacement,
        x[4]+placement, y[4] + Consts.SIDE_SIZE * deplacement,
        x[5]+placement, y[5] + Consts.SIDE_SIZE * deplacement});
    popup.getContent().add(p);

}
项目:LivroJavaComoProgramar10Edicao    文件:DrawStarsController.java   
public void initialize() 
{
   // points that define a five-pointed star shape
   Double[] points = {205.0,150.0, 217.0,186.0, 259.0,186.0, 
      223.0,204.0, 233.0,246.0, 205.0,222.0, 177.0,246.0, 187.0,204.0, 
      151.0,186.0, 193.0,186.0};

   // create 18 more stars
   for (int count = 0; count < 18; ++count)
   {
      // create a new Polygon and copy existing points into it
      Polygon newStar = new Polygon();
      newStar.getPoints().addAll(points); 

      // create random Color and set as newStar's fill
      newStar.setStroke(Color.GREY);
      newStar.setFill(Color.rgb(random.nextInt(255), 
         random.nextInt(255), random.nextInt(255), 
         random.nextDouble())); 

      // apply a rotation to the shape
      newStar.getTransforms().add(
         Transform.rotate(count * 20, 150, 150));
      anchorPane.getChildren().add(newStar);
   } 
}
项目:voogasalad-ltub    文件:CollisionOfImage.java   
public boolean isCollided(Image a, double xPos1, double yPos1, Image b, double xPos2, double yPos2){
    //Get the Polygon contour of the main character in the image with a background color COLOR
    ImageToPolygon imA = new ImageToPolygon(a, COLOR);      
    ImageToPolygon imB = new ImageToPolygon(b, COLOR);

    Polygon polygonA = imA.getPolygon();    
    Polygon polygonB = imB.getPolygon();
    //translate the image to correct location 
    polygonA.setTranslateX(xPos1);
    polygonA.setTranslateY(yPos1);

    polygonB.setTranslateX(xPos2);
    polygonB.setTranslateY(yPos2);
    //check collision of the two nodes
    return polygonA.getBoundsInParent().intersects(polygonB.getBoundsInParent());
}
项目:voogasalad-ltub    文件:ImageToPolygon.java   
/**
 * @return Polygon
 * Create a polygon hull of the given image by deleting the transparent pixels
 * There are two methods: convex_hull and hull
 */
public Polygon getPolygon(){
    ImageTransformation transformation = new ImageTransformation();
    Set<Point2D> set = transformation.getMask(image, backgroundColor);          
    ConvexHull convexHull = new ConvexHull(set);
    //Get the convex hull point of the outline of the image
    List<Point2D> pointList = convexHull.getConvexHull();
    double[] pointsToDraw = new double[2 * pointList.size()];
    int k = 0;
    for(Point2D p : pointList){
        pointsToDraw[k] = p.getX();
        pointsToDraw[k + 1] = p.getY();
        k += 2;
    }
    return new Polygon( pointsToDraw);
}
项目:charts    文件:Helper.java   
public static final boolean isInPolygon(final double X, final double Y, final Polygon POLYGON) {
    List<Double> points              = POLYGON.getPoints();
    int          noOfPointsInPolygon = POLYGON.getPoints().size() / 2;
    double[]     pointsX             = new double[noOfPointsInPolygon];
    double[]     pointsY             = new double[noOfPointsInPolygon];
    int          pointCounter        = 0;
    for (int i = 0 ; i < points.size() ; i++) {
        if (i % 2 == 0) {
            pointsX[i] = points.get(pointCounter);
        } else {
            pointsY[i] = points.get(pointCounter);
            pointCounter++;
        }
    }
    return isInPolygon(X, Y, noOfPointsInPolygon, pointsX, pointsY);
}
项目:JNFP    文件:NoFitPolygonStages.java   
private static void makeMultiPolygonScene(Group group, MultiPolygon mPolygon, int color,
        double biggestValue) {
    //sceneSize divided by 2 because x and y axis are in the middle
    double resizeFactor = sceneSizeY/biggestValue/2;

       Polygon polygon = mPolygon.makeOuterPolygon(sceneSizeX, sceneSizeY, resizeFactor);

       switch(color){
       case 0: polygon.setFill(Color.GREY);break;
       case 1: polygon.setFill(Color.DARKGREY);break;
       }
       polygon.setStrokeWidth(1);
       polygon.setStroke(Color.BLACK);

       group.getChildren().add(polygon);

       Polygon[] holes = mPolygon.makeHoles(sceneSizeX, sceneSizeY, resizeFactor);

       for(Polygon hole: holes){
           hole.setFill(Color.WHITESMOKE);
           hole.setStrokeWidth(1);
           hole.setStroke(Color.BLACK);
           group.getChildren().add(hole);
       }

}
项目:JNFP    文件:PolygonPairStages.java   
public static void makeMultiPolygonScene(Group group, MultiPolygon mPolygon, int color, double biggestValue) {

//sceneSize divided by 2 because x and y axis are in the middle
double resizeFactor = sceneSizeY/biggestValue/2;

      Polygon polygon = mPolygon.makeOuterPolygon(sceneSizeX, sceneSizeY, resizeFactor);
      switch(color){
      case 0: polygon.setFill(Color.GREY);break;
      case 1: polygon.setFill(Color.DARKGREY);break;
      }
      polygon.setStrokeWidth(1);
      polygon.setStroke(Color.BLACK);

      group.getChildren().add(polygon);

      Polygon[] holes = mPolygon.makeHoles(sceneSizeX, sceneSizeY, resizeFactor);

      for(Polygon hole: holes){
          hole.setFill(Color.WHITESMOKE);
          hole.setStrokeWidth(1);
          hole.setStroke(Color.BLACK);
          group.getChildren().add(hole);
      }   
  }
项目:JNFP    文件:PolygonPairStages.java   
public static void makeMultiPolygonScene(Group group, MultiPolygon mPolygon, int color, double biggestValue) {

//sceneSize divided by 2 because x and y axis are in the middle
double resizeFactor = sceneSizeY/biggestValue/2;

      Polygon polygon = mPolygon.makeOuterPolygon(sceneSizeX, sceneSizeY, resizeFactor);
      switch(color){
      case 0: polygon.setFill(Color.GREY);break;
      case 1: polygon.setFill(Color.DARKGREY);break;
      }
      polygon.setStrokeWidth(1);
      polygon.setStroke(Color.BLACK);

      group.getChildren().add(polygon);

      Polygon[] holes = mPolygon.makeHoles(sceneSizeX, sceneSizeY, resizeFactor);

      for(Polygon hole: holes){
          hole.setFill(Color.WHITESMOKE);
          hole.setStrokeWidth(1);
          hole.setStroke(Color.BLACK);
          group.getChildren().add(hole);
      }   
  }
项目:JNFP    文件:PolygonPairStages.java   
public static void makeMultiPolygonScene(Group group, MultiPolygon mPolygon, int color, double biggestValue) {

//sceneSize divided by 2 because x and y axis are in the middle
double resizeFactor = sceneSizeY/biggestValue/2;

      Polygon polygon = mPolygon.makeOuterPolygon(sceneSizeX, sceneSizeY, resizeFactor);
      switch(color){
      case 0: polygon.setFill(Color.GREY);break;
      case 1: polygon.setFill(Color.DARKGREY);break;
      }
      polygon.setStrokeWidth(1);
      polygon.setStroke(Color.BLACK);

      group.getChildren().add(polygon);

      Polygon[] holes = mPolygon.makeHoles(sceneSizeX, sceneSizeY, resizeFactor);

      for(Polygon hole: holes){
          hole.setFill(Color.WHITESMOKE);
          hole.setStrokeWidth(1);
          hole.setStroke(Color.BLACK);
          group.getChildren().add(hole);
      }   
  }
项目:gitember    文件:ArrowFactory.java   
@Override
public Node apply(int lineNumber) {
    Polygon triangle = new Polygon(0.0, 0.0, 40.0, 5.0, 0.0, 10.0);
    triangle.setFill(Color.GREEN);

    ObservableValue<Boolean> visible = Val.map(
            shownLine,
            sl -> sl == lineNumber);

    triangle.visibleProperty().bind(
            Val.flatMap(triangle.sceneProperty(), scene -> {
                return scene != null ? visible : Val.constant(false);
            })
    );

    return triangle;
}
项目:FXGraphs    文件:CircleArrowView.java   
private void transformArrow(Node source, Node target, Polygon polygon) {
    updateNodePosition(source, target);
    transform = new ArrowTransform(sourceX, sourceY, targetX, targetY, 60d);
    if (polygon.getPoints().size() == 0) {
        polygon.getPoints()
                .addAll(new Double[] { transform.getArrow0X().get(), transform.getArrow0Y().get(),
                        transform.getArrow1X().get(), transform.getArrow1Y().get(), transform.getArrow2X().get(),
                        transform.getArrow2Y().get() });
    }
    polygon.getPoints().set(0, transform.getArrow0X().get());
    polygon.getPoints().set(1, transform.getArrow0Y().get());
    polygon.getPoints().set(2, transform.getArrow1X().get());
    polygon.getPoints().set(3, transform.getArrow1Y().get());
    polygon.getPoints().set(4, transform.getArrow2X().get());
    polygon.getPoints().set(5, transform.getArrow2Y().get());
}
项目:FXGraphs    文件:DynamicArrowView.java   
public DynamicArrowView(Shape source, Shape target) {
    Polygon polygon = new Polygon(0, 0, 30, 0, 15, 15);
    transformArrow(source, target, polygon);

    source.translateXProperty().addListener(getChangeListener(source, target, polygon));
    target.translateXProperty().addListener(getChangeListener(source, target, polygon));
    source.translateYProperty().addListener(getChangeListener(source, target, polygon));
    target.translateYProperty().addListener(getChangeListener(source, target, polygon));

    polygon.getTransforms().addAll(trans1, rot, trans2);
    trans2.setX(-15);
    trans2.setY(-15);
    polygon.setFill(Color.GRAY);

    getChildren().add(polygon);
}
项目:iso-game-engine    文件:Tile.java   
private Polygon getHighlightShape(final CameraAngle angle) {
    final List<Point2D> shape;
    switch (angle) {
        case UL: shape = shapeUL; break;
        case UR: shape = shapeUR; break;
        case LL: shape = shapeLL; break;
        case LR: shape = shapeLR; break;
        default:
            throw new RuntimeException("Invalid angle, this cannot happen");
    }

    final double[] pts = new double[shape.size() * 2];
    for (int i = 0; i < shape.size(); i++) {
        pts[i * 2] = shape.get(i).getX();
        pts[(i * 2) + 1] = shape.get(i).getY();
    }

    return new Polygon(pts);
}
项目:viskell    文件:Lane.java   
/** Add and initializes a resizer element to this block */
private void setupResizer() {
    Polygon triangle = new Polygon();
    triangle.getPoints().addAll(new Double[]{20.0, 20.0, 20.0, 0.0, 0.0, 20.0});
    triangle.setFill(Color.BLUE);

    this.resizer = new Pane(triangle);
    triangle.setLayoutX(10);
    triangle.setLayoutY(10);
    this.resizer.setManaged(false);
    this.getChildren().add(this.resizer);
    this.resizer.relocate(240-20, 320-20);

    DragContext sizeDrag = new DragContext(this.resizer);
    sizeDrag.setDragLimits(new BoundingBox(200, 200, Integer.MAX_VALUE, Integer.MAX_VALUE));
}
项目:JFoenix    文件:JFXTreeViewPath.java   
private JFXButton createNextButton(TreeItem temp) {
    return new JFXButton(temp.getValue().toString()) {
        {
            setPadding(new Insets(getOffset(), 1.5 * getOffset(), getOffset(), 2 * getOffset()));
            setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
        }

        @Override
        protected void layoutChildren() {
            super.layoutChildren();
            double width = getWidth();
            Polygon polygon = new Polygon();
            final double height = getHeight();
            polygon.getPoints().addAll(new Double[] {
                0.0, 0.0,
                width - getOffset(), 0.0,
                width, height / 2,
                width - getOffset(), height,
                0.0, height,
                getOffset(), height / 2});
            setClip(polygon);

        }
    };
}
项目:JFoenix    文件:JFXTreeViewPath.java   
public JFXButton createFirstButton(TreeItem temp) {
    return new JFXButton(temp.getValue().toString()) {
        {
            setPadding(new Insets(getOffset(), 1.5 * getOffset(), getOffset(), getOffset()));
            setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
        }

        @Override
        protected void layoutChildren() {
            super.layoutChildren();
            double width = getWidth();
            Polygon polygon = new Polygon();
            final double height = getHeight();
            polygon.getPoints().addAll(new Double[] {
                0.0, 0.0,
                width - getOffset(), 0.0,
                width, height / 2,
                width - getOffset(), height,
                0.0, height});
            setClip(polygon);
        }
    };
}
项目:JFoenix    文件:JFXTreeViewPath.java   
private JFXButton createLastButton(TreeItem temp, TreeItem parent) {
    return new JFXButton(temp.getValue().toString()) {
        private boolean noParent = parent == null;
        {
            setPadding(new Insets(getOffset(), getOffset(), getOffset(), (noParent? 1 : 2) * getOffset()));
            setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
        }

        @Override
        protected void layoutChildren() {
            super.layoutChildren();
            double width = getWidth();
            Polygon polygon = new Polygon();
            final double height = getHeight();
            polygon.getPoints().addAll(new Double[] {
                0.0, 0.0,
                width, 0.0,
                width, height,
                0.0, height,
                noParent ? 0 : getOffset(), noParent ? 0 : height / 2});
            setClip(polygon);
        }
    };
}
项目:clarity-analyzer    文件:PointingHeroIcon.java   
public PointingHeroIcon(ObservableEntity oe) {
    super(oe);

    shape = new Polygon(
        0, -200, -120, 200, 120, 200
    );

    shape.fillProperty().bind(getPlayerColor());

    ObjectBinding<Vector> angRotVector = oe.getPropertyBinding(Vector.class, "CBodyComponent.m_angRotation", null);
    DoubleBinding angRot = Bindings.createDoubleBinding(() -> (double) angRotVector.get().getElement(1), angRotVector);

    IntegerBinding angDiff = Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "m_anglediff", 0));

    shape.translateXProperty().bind(getMapX());
    shape.translateYProperty().bind(getMapY());
    shape.rotateProperty().bind(getBaseAngle().add(angRot).add(angDiff));
}
项目:FlagMaker-2    文件:OverlayImage.java   
@Override
protected Shape[] Thumbnail()
{
    Rectangle border = new Rectangle(25, 30, new Color(1, 1, 0, 0));
    border.setStrokeWidth(3);
    border.setLayoutX(2.5);

    Rectangle square = new Rectangle(8, 8);
    square.setLayoutX(7);
    square.setLayoutY(5);

    Ellipse circle = new Ellipse(19, 15, 4, 4);
    Polygon triangle = new Polygon(8, 25, 12, 17, 16, 25);

    return new Shape[]
    {
        border,
        square,
        circle,
        triangle
    };
}
项目:Consume    文件:LevelMenu.java   
public void setComplete() {
    complete = true;
    double rLen = this.getWidth() - 5;
    Polygon s1 = new Polygon(0, (rLen - 5) / 2,
            (rLen - 5) / 2, (rLen - 5) / 2,
            (rLen - 5) / 2, 0,
            (rLen + 5) / 2, 0,
            (rLen + 5) / 2, (rLen - 5) / 2,
            rLen, (rLen - 5) / 2,
            rLen, (rLen + 5) / 2,
            (rLen + 5) / 2, (rLen + 5) / 2,
            (rLen + 5) / 2, rLen,
            (rLen - 5) / 2, rLen,
            (rLen - 5) / 2, (rLen + 5) / 2,
            0, (rLen + 5) / 2);
    s1.setFill(Color.RED);
    s1.setRotate(45);
    s1.setStroke(Color.BLACK);
    s1.setStrokeWidth(3);
    getChildren().addAll(s1);
}
项目:Intro-to-Java-Programming    文件:Exercise_18_19.java   
private void displayTriangles(int order, Point2D p1,
        Point2D p2, Point2D p3) {
    if (order == 0) {
        // Draw a triangle to connect three points
        Polygon triangle = new Polygon();
        triangle.getPoints().addAll(p1.getX(), p1.getY(), p2.getX(),
            p2.getY(), p3.getX(), p3.getY());
        triangle.setStroke(Color.BLACK);
        triangle.setFill(Color.WHITE);

        this.getChildren().add(triangle);
    }
    else {
        //Get the midpoint on each edge in the triangle
        Point2D p12= p1.midpoint(p2);
        Point2D p23= p2.midpoint(p3);
        Point2D p31= p3.midpoint(p1);

        // Recursively display three triangles
        displayTriangles(order - 1, p1, p12, p31);
        displayTriangles(order - 1, p12, p2, p23);
        displayTriangles(order - 1, p31, p23, p3);
    }
}
项目:Intro-to-Java-Programming    文件:Exercise_18_36.java   
private void displayTriangles(int order, Point2D p1,
        Point2D p2, Point2D p3) {
    if (order == 0) {
        // Draw a triangle to connect three points
        Polygon triangle = new Polygon();
        triangle.getPoints().addAll(p1.getX(), p1.getY(), p2.getX(),
            p2.getY(), p3.getX(), p3.getY());
        triangle.setStroke(Color.BLACK);
        triangle.setFill(Color.BLACK);

        this.getChildren().add(triangle);
    }
    else {
        //Get the midpoint on each edge in the triangle
        Point2D p12= p1.midpoint(p2);
        Point2D p23= p2.midpoint(p3);
        Point2D p31= p3.midpoint(p1);

        // Recursively display three triangles
        displayTriangles(order - 1, p1, p12, p31);
        displayTriangles(order - 1, p12, p2, p23);
        displayTriangles(order - 1, p31, p23, p3);
    }
}
项目:GRIP    文件:HexagonGrid.java   
/**
 * Creates a new hexagon grid with the given number of rows and columns.
 *
 * @param cols    the number of columns in the grid
 * @param rows    the number of rows in the grid
 * @param radius  the radius of the hexagons in the grid
 * @param padding the padding between each hexagon
 */
public HexagonGrid(int cols, int rows, double radius, double padding) {
  double xOffset = Math.cos(ang30) * (radius + padding);
  double yOffset = Math.sin(ang30) * (radius + padding) * 3;
  for (int row = 0; row < rows; row++) {
    for (int col = 0; col < cols; col++) {
      double x = xOffset * (col * 2 + row % 2);
      double y = radius + yOffset * row;
      Polygon hexagon = new Hexagon(radius);
      hexagon.setRotate(90);
      hexagon.setTranslateX(x);
      hexagon.setTranslateY(y);
      getChildren().add(hexagon);
    }
  }
}
项目:JavaFxNodeToSvg    文件:ShapeConverter.java   
public static String convertPolygon(final Polygon POLYGON) {
    final StringBuilder fxPath = new StringBuilder();
    final int size = POLYGON.getPoints().size();
    if (size % 2 == 0) {
        List<Double> coordinates = POLYGON.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(" ");
        }
        fxPath.append("Z");
    }
    return fxPath.toString();
}
项目:ModelDebugging    文件:TimelineDiffViewerRenderer.java   
private void setupBox(VBox box, String labelString, VBox content) {
    final HBox boxLabel = new HBox();
    final Polygon arrow = new Polygon(2.5, 10, 10, 5, 2.5, 0);
    final Label label = new Label(labelString);
    boxLabel.setBackground(HEADER_BACKGROUND);
    label.setFont(GROUP_FONT);
    HBox.setMargin(arrow, HALF_MARGIN_INSETS);
    boxLabel.setAlignment(Pos.CENTER_LEFT);
    boxLabel.getChildren().addAll(arrow, label);
    boxLabel.setCursor(Cursor.HAND);
    box.getChildren().add(boxLabel);
    boxLabel.setOnMouseClicked(e -> {
        if (box.getChildren().size() > 1) {
            box.getChildren().remove(content);
            arrow.setRotate(0);
        } else {
            box.getChildren().add(content);
            arrow.setRotate(90);
        }
    });
}
项目:kotlinfx-ensemble    文件:TranslateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 20, 20);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(29);
    polygon.setLayoutY(21);
    polygon.setRotate(135);


    Rectangle r2 = new Rectangle (50, 50, 20, 20);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00"));
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:kotlinfx-ensemble    文件:ShearSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (22, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00",0.5));
    r1.getTransforms().add(new Shear(-0.35, 0));

    Polygon polygon = createArrow();
    polygon.setLayoutX(-5);
    polygon.setLayoutY(-2);
    polygon.setRotate(90);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00", 0.25));
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
项目:kotlinfx-ensemble    文件:RotateSample.java   
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(65);
    polygon.setLayoutY(5);
    polygon.setRotate(165);


    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(15);
    r2.setArcWidth(15);
    r2.setFill(Color.web("#ed4b00"));
    r2.setRotate(60);
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}