Java Code Examples for javafx.scene.shape.Polygon

The following are top voted examples for showing how to use javafx.scene.shape.Polygon. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: RotateSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 2
Project: marathonv5   File: ScaleSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: marathonv5   File: PolygonSample.java   View source code 6 votes vote down vote up
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;
}
 
Example 4
Project: marathonv5   File: TranslateSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: marathonv5   File: ShearSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 6
Project: marathonv5   File: RotateSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 7
Project: marathonv5   File: ScaleSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 8
Project: marathonv5   File: PolygonSample.java   View source code 6 votes vote down vote up
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;
}
 
Example 9
Project: gemoc-studio-modeldebugging   File: TimelineDiffViewerRenderer.java   View source code 6 votes vote down vote up
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);
		}
	});
}
 
Example 10
Project: Hive_Game   File: GameScreenController.java   View source code 6 votes vote down vote up
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);

}
 
Example 11
Project: LivroJavaComoProgramar10Edicao   File: DrawStarsController.java   View source code 6 votes vote down vote up
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);
   } 
}
 
Example 12
Project: voogasalad-ltub   File: CollisionOfImage.java   View source code 6 votes vote down vote up
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());
}
 
Example 13
Project: voogasalad-ltub   File: ImageToPolygon.java   View source code 6 votes vote down vote up
/**
 * @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);
}
 
Example 14
Project: charts   File: Helper.java   View source code 6 votes vote down vote up
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);
}
 
Example 15
Project: tilesfx   File: Helper.java   View source code 6 votes vote down vote up
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);
}
 
Example 16
Project: JNFP   File: NoFitPolygonStages.java   View source code 6 votes vote down vote up
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);
       }
	
}
 
Example 17
Project: JNFP   File: PolygonPairStages.java   View source code 6 votes vote down vote up
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);
      }   
  }
 
Example 18
Project: JNFP   File: PolygonPairStages.java   View source code 6 votes vote down vote up
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);
      }   
  }
 
Example 19
Project: JNFP   File: PolygonPairStages.java   View source code 6 votes vote down vote up
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);
      }   
  }
 
Example 20
Project: gitember   File: ArrowFactory.java   View source code 6 votes vote down vote up
@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;
}
 
Example 21
Project: FXGraphs   File: CircleArrowView.java   View source code 6 votes vote down vote up
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());
}
 
Example 22
Project: FXGraphs   File: DynamicArrowView.java   View source code 6 votes vote down vote up
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);
}
 
Example 23
Project: iso-game-engine   File: Tile.java   View source code 6 votes vote down vote up
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);
}
 
Example 24
Project: viskell   File: Lane.java   View source code 6 votes vote down vote up
/** 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));
}
 
Example 25
Project: JFoenix   File: JFXTreeViewPath.java   View source code 6 votes vote down vote up
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);

        }
    };
}
 
Example 26
Project: JFoenix   File: JFXTreeViewPath.java   View source code 6 votes vote down vote up
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);
        }
    };
}
 
Example 27
Project: JFoenix   File: JFXTreeViewPath.java   View source code 6 votes vote down vote up
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);
        }
    };
}
 
Example 28
Project: clarity-analyzer   File: PointingHeroIcon.java   View source code 6 votes vote down vote up
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));
}
 
Example 29
Project: FlagMaker-2   File: OverlayImage.java   View source code 6 votes vote down vote up
@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
	};
}
 
Example 30
Project: Consume   File: LevelMenu.java   View source code 6 votes vote down vote up
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);
}
 
Example 31
Project: Intro-to-Java-Programming   File: Exercise_18_19.java   View source code 6 votes vote down vote up
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);
	}
}
 
Example 32
Project: Intro-to-Java-Programming   File: Exercise_18_36.java   View source code 6 votes vote down vote up
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);
	}
}
 
Example 33
Project: GRIP   File: HexagonGrid.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
  }
}
 
Example 34
Project: JavaFxNodeToSvg   File: ShapeConverter.java   View source code 6 votes vote down vote up
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();
}
 
Example 35
Project: ModelDebugging   File: TimelineDiffViewerRenderer.java   View source code 6 votes vote down vote up
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);
		}
	});
}
 
Example 36
Project: kotlinfx-ensemble   File: TranslateSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 37
Project: kotlinfx-ensemble   File: ShearSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 38
Project: kotlinfx-ensemble   File: RotateSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 39
Project: kotlinfx-ensemble   File: ScaleSample.java   View source code 6 votes vote down vote up
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);
}
 
Example 40
Project: kotlinfx-ensemble   File: PolygonSample.java   View source code 6 votes vote down vote up
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;
}