本文整理汇总了Java中javafx.scene.shape.Polygon.setFill方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.setFill方法的具体用法?Java Polygon.setFill怎么用?Java Polygon.setFill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Polygon
的用法示例。
在下文中一共展示了Polygon.setFill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: DynamicArrowView
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
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);
}
示例5: 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);
}
}
示例6: 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;
}
示例7: setupResizer
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
/** 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));
}
示例8: setComplete
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
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);
}
示例9: displayTriangles
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
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);
}
}
示例10: displayTriangles
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
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);
}
}
示例11: createArrow
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public static Polygon createArrow() {
Polygon polygon = new Polygon(new double[]{
7.5, 0,
15, 15,
10, 15,
10, 30,
5, 30,
5, 15,
0, 15
});
polygon.setFill(Color.web("#ff0900"));
return polygon;
}
示例12: createUMLArrow
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public static Polygon createUMLArrow() {
Polygon polygon = new Polygon(new double[]{
7.5, 0,
15, 15,
7.51, 15,
7.51, 40,
7.49, 40,
7.49, 15,
0, 15
});
polygon.setFill(Color.WHITE);
polygon.setStroke(Color.BLACK);
return polygon;
}
示例13: PolygonSample
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public PolygonSample() {
super(180,90);
// Simple red filled triangle
Polygon polygon1 = new Polygon(new double[]{
45 , 10 ,
10 , 80 ,
80 , 80 ,
});
polygon1.setFill(Color.RED);
// Blue stroked polygon
Polygon polygon2 = new Polygon(new double[]{
135, 15,
160, 30,
160, 60,
135, 75,
110, 60,
110, 30
});
polygon2.setStroke(Color.DODGERBLUE);
polygon2.setStrokeWidth(2);
polygon2.setFill(null);
// Create a group to show all the polygons);
getChildren().add(new Group(polygon1, polygon2));
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Polygon 1 Fill", polygon1.fillProperty()),
new SimplePropertySheet.PropDesc("Polygon 2 Stroke", polygon2.strokeProperty())
);
// END REMOVE ME
}
示例14: apply
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
@Override
public Node apply(int lineNumber) {
Polygon triangle = new Polygon(0.0, 0.0, 10.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;
}
示例15: makeNFPPolygonScene
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
private static void makeNFPPolygonScene(Group group,NoFitPolygon nfp, double biggestValue) {
//sceneSize divided by 2 because x and y axis are in the middle
double resizeFactor = sceneSizeY/(biggestValue)/2;
Polygon[] nfpPolygonList = nfp.toPolygonList(sceneSizeX, sceneSizeY, resizeFactor);
for(Polygon polygon : nfpPolygonList){
polygon.setStrokeWidth(6);
polygon.setStroke(Color.BLACK);
polygon.setFill(Color.TRANSPARENT);
group.getChildren().add(polygon);
}
}