當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。