当前位置: 首页>>代码示例>>Java>>正文


Java Polygon类代码示例

本文整理汇总了Java中javafx.scene.shape.Polygon的典型用法代码示例。如果您正苦于以下问题:Java Polygon类的具体用法?Java Polygon怎么用?Java Polygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Polygon类属于javafx.scene.shape包,在下文中一共展示了Polygon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIconContent

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:RotateSample.java

示例2: createIconContent

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:ScaleSample.java

示例3: createIconContent

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:PolygonSample.java

示例4: createIconContent

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:TranslateSample.java

示例5: createIconContent

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ShearSample.java

示例6: setupBox

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
		}
	});
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:TimelineDiffViewerRenderer.java

示例7: drawPolygonPopUp

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);

}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:23,代码来源:GameScreenController.java

示例8: initialize

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
   } 
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:27,代码来源:DrawStarsController.java

示例9: isCollided

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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());
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:17,代码来源:CollisionOfImage.java

示例10: getPolygon

import javafx.scene.shape.Polygon; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:21,代码来源:ImageToPolygon.java

示例11: isInPolygon

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:17,代码来源:Helper.java

示例12: makeMultiPolygonScene

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
       }
	
}
 
开发者ID:TonyWauters,项目名称:JNFP,代码行数:27,代码来源:NoFitPolygonStages.java

示例13: makeMultiPolygonScene

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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);
      }   
  }
 
开发者ID:TonyWauters,项目名称:JNFP,代码行数:25,代码来源:PolygonPairStages.java

示例14: apply

import javafx.scene.shape.Polygon; //导入依赖的package包/类
@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;
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:18,代码来源:ArrowFactory.java

示例15: transformArrow

import javafx.scene.shape.Polygon; //导入依赖的package包/类
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());
}
 
开发者ID:alexejsailer,项目名称:FXGraphs,代码行数:17,代码来源:CircleArrowView.java


注:本文中的javafx.scene.shape.Polygon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。