本文整理汇总了Java中javafx.scene.shape.Line.setStartY方法的典型用法代码示例。如果您正苦于以下问题:Java Line.setStartY方法的具体用法?Java Line.setStartY怎么用?Java Line.setStartY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Line
的用法示例。
在下文中一共展示了Line.setStartY方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSnapIndicators
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Places snap indicators to where the node would be snapped to.
* @param move True if moving, false if resizing.
* @param xSnap
* @param ySnap
* @param n
*/
private void setSnapIndicators(int xSnap, int ySnap, AbstractNode n, boolean move){
Line xSnapIndicator = xSnapIndicatorMap.get(n);
Line ySnapIndicator = ySnapIndicatorMap.get(n);
xSnapIndicator.setStartX(xSnap);
xSnapIndicator.setEndX(xSnap);
xSnapIndicator.setStartY(ySnap);
if(move){ xSnapIndicator.setEndY(ySnap+Constants.GRID_DISTANCE);
} else { xSnapIndicator.setEndY(ySnap-Constants.GRID_DISTANCE);}
ySnapIndicator.setStartX(xSnap);
if (move) { ySnapIndicator.setEndX(xSnap+Constants.GRID_DISTANCE);
} else {ySnapIndicator.setEndX(xSnap-Constants.GRID_DISTANCE);}
ySnapIndicator.setStartY(ySnap);
ySnapIndicator.setEndY(ySnap);
}
示例2: Arrow
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public Arrow(Double fromX, Double fromY, Double toX, Double toY, Double radius) {
line = new Line();
line.setStartX(fromX);
line.setStartY(fromY);
line.setEndX(toX);
line.setEndY(toY);
line.setStrokeWidth(3);
line.setFill(Color.BLACK);
this.radius = radius;
indicator = createIndicator(toX, toY, radius);
indicator.setFill(Color.BLACK);
// calcolo il punto esatto in cui deve terminare la linea -- al centro del cerchio
this.calculateActualEnd();
this.getChildren().addAll(line, indicator);
}
示例3: playWinAnimation
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private void playWinAnimation(TileCombo combo) {
Line line = new Line();
line.setStartX(combo.getTile1().getCenter().getX());
line.setStartY(combo.getTile1().getCenter().getY());
line.setEndX(combo.getTile1().getCenter().getX());
line.setEndY(combo.getTile1().getCenter().getY());
line.setStroke(Color.YELLOW);
line.setStrokeWidth(3);
getGameScene().addUINode(line);
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1),
new KeyValue(line.endXProperty(), combo.getTile3().getCenter().getX()),
new KeyValue(line.endYProperty(), combo.getTile3().getCenter().getY())));
timeline.setOnFinished(e -> gameOver(combo.getWinSymbol()));
timeline.play();
}
示例4: createCloseIcon
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private Node createCloseIcon() {
Group group = new Group();
group.getStyleClass().add("graphics"); //$NON-NLS-1$
Circle circle = new Circle();
circle.getStyleClass().add("circle"); //$NON-NLS-1$
circle.setRadius(6);
circle.setCenterX(6);
circle.setCenterY(6);
group.getChildren().add(circle);
Line line1 = new Line();
line1.getStyleClass().add("line"); //$NON-NLS-1$
line1.setStartX(4);
line1.setStartY(4);
line1.setEndX(8);
line1.setEndY(8);
group.getChildren().add(line1);
Line line2 = new Line();
line2.getStyleClass().add("line"); //$NON-NLS-1$
line2.setStartX(8);
line2.setStartY(4);
line2.setEndX(4);
line2.setEndY(8);
group.getChildren().add(line2);
return group;
}
示例5: snapshotNode
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private void snapshotNode(Scene scene, Node node) {
SnapshotParameters params = new SnapshotParameters();
Bounds layoutBounds = node.getLayoutBounds();
Bounds bounds = node.localToScene(layoutBounds);
if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
return;
}
params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
writable = scene.getRoot().snapshot(params, writable);
ImageView imageView = new ImageView(writable);
imageView.getStyleClass().add("snapshot-image");
imageView.setManaged(false);
imageView.setLayoutX(bounds.getMinX());
imageView.setLayoutY(bounds.getMinY());
imageView.setFitWidth(bounds.getWidth());
imageView.setFitHeight(bounds.getHeight());
Region rect = new Region();
rect.getStyleClass().add("snapshot-background");
rect.setLayoutX(bounds.getMinX() - 5);
rect.setLayoutY(bounds.getMinY() - 5);
rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
rect.setManaged(false);
Line line = new Line();
line.setStartX(bounds.getMaxX() + 4);
line.setStartY(bounds.getMaxY() + 4);
line.setEndX(bounds.getMaxX() + 200);
line.setEndY(bounds.getMaxY() + 200);
line.setStroke(imagePattern);
line.setStrokeWidth(5);
line.setManaged(false);
getChildren().addAll(rect, imageView); //, line);
}
示例6: setLine
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public void setLine(Line line, double startX, double startY, double endX, double endY, boolean opaque) {
line.setStartX(startX);
line.setStartY(startY);
line.setEndX(endX);
line.setEndY(endY);
line.setOpacity(opaque ? 1 : 0);
}
示例7: start
import javafx.scene.shape.Line; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
AnchorPane ap = new AnchorPane();
final Scene scene = new Scene(ap, 600, 600);
primaryStage.setScene(scene);
primaryStage.show();
Line l = new Line();
l.setFill(Color.AQUAMARINE);
// l.setLayoutX(300);
// l.setLayoutY(300);
l.setStartX(300);
l.setStartY(300);
l.setEndX(300);
l.setEndY(100);
ap.getChildren().add(l);
System.out.println("1: " + l.toString() + " tx=" + l.getTranslateX() + ", ty="+l.getTranslateY());
// l.setRotate(45);
// System.out.println("2: " + l.toString() + " tx=" + l.getTranslateX() + ", ty="+l.getTranslateY());
// 300, 200
// l.getTransforms().add(new Rotate(72, 300, 300));
l.getTransforms().add(new Rotate(144, 300, 300));
// l.getTransforms().add(new Rotate(216, 300, 300));
// l.getTransforms().add(new Rotate(288, 300, 300));
System.out.println("3: " + l.toString() + " tx=" + l.getBoundsInParent().toString() + ", ty="+l.getTranslateY());
/*
1=centerx, centery - 200
2=centerx + 192.47137451171875, centery - 64.0634765625
3=centerx + 119.953857421875, centery + 164.2001953125
4=centerx - 119.953857421875, centery + 164.2001953125
5=centerx - 192.47137451171875, centery - 64.0634765625
*/
}
示例8: draw
import javafx.scene.shape.Line; //导入方法依赖的package包/类
@Override
public void draw(Line line) {
line.setStartX(0d);
line.setStartY(0d);
line.setEndX(200d);
line.setEndY(200d);
line.setStrokeWidth(10);
line.setStrokeLineCap(StrokeLineCap.BUTT);
line.getStrokeDashArray().addAll(15d, 5d, 15d, 15d, 20d);
line.setStrokeDashOffset(10);
}
示例9: draw
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Draws the grid for the given width and height.
*
* @param width the width of the editor region
* @param height the height of the editor region
*/
public void draw(final double width, final double height) {
final double spacing = editorProperties.getGridSpacing();
getChildren().clear();
final int hLineCount = (int) Math.floor((height + 1) / spacing);
final int vLineCount = (int) Math.floor((width + 1) / spacing);
for (int i = 0; i < hLineCount; i++) {
final Line hLine = new Line();
hLine.setStartX(0);
hLine.setEndX(width);
hLine.setStartY((i + 1) * spacing + HALF_PIXEL_OFFSET);
hLine.setEndY((i + 1) * spacing + HALF_PIXEL_OFFSET);
hLine.strokeProperty().bind(gridColor);
getChildren().add(hLine);
}
for (int i = 0; i < vLineCount; i++) {
final Line vLine = new Line();
vLine.setStartX((i + 1) * spacing + HALF_PIXEL_OFFSET);
vLine.setEndX((i + 1) * spacing + HALF_PIXEL_OFFSET);
vLine.setStartY(0);
vLine.setEndY(height);
vLine.strokeProperty().bind(gridColor);
getChildren().add(vLine);
}
}
示例10: createModelRoot
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/** Create scrollpane etc. for hosting the model
*
* @return ScrollPane
* @throws IllegalStateException if had already been called
*/
final public ScrollPane createModelRoot()
{
if (model_root != null)
throw new IllegalStateException("Already created model root");
widget_parent = new Pane();
scroll_body = new Group(widget_parent);
if (isEditMode())
{
horiz_bound = new Line();
horiz_bound.getStyleClass().add("display_model_bounds");
horiz_bound.setStartX(0);
vert_bound = new Line();
vert_bound.getStyleClass().add("display_model_bounds");
vert_bound.setStartY(0);
scroll_body.getChildren().addAll(vert_bound, horiz_bound);
}
model_root = new ScrollPane(scroll_body);
final InvalidationListener resized = prop -> handleViewportChanges();
model_root.widthProperty().addListener(resized);
model_root.heightProperty().addListener(resized);
return model_root;
}
示例11: HangmanImage
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public HangmanImage() {
Circle head = new Circle(20);
head.setTranslateX(SPINE_START_X);
Line spine = new Line();
spine.setStartX(SPINE_START_X);
spine.setStartY(SPINE_START_Y);
spine.setEndX(SPINE_END_X);
spine.setEndY(SPINE_END_Y);
Line leftArm = new Line();
leftArm.setStartX(SPINE_START_X);
leftArm.setStartY(SPINE_START_Y);
leftArm.setEndX(SPINE_START_X + 40);
leftArm.setEndY(SPINE_START_Y + 10);
Line rightArm = new Line();
rightArm.setStartX(SPINE_START_X);
rightArm.setStartY(SPINE_START_Y);
rightArm.setEndX(SPINE_START_X - 40);
rightArm.setEndY(SPINE_START_Y + 10);
Line leftLeg = new Line();
leftLeg.setStartX(SPINE_END_X);
leftLeg.setStartY(SPINE_END_Y);
leftLeg.setEndX(SPINE_END_X + 25);
leftLeg.setEndY(SPINE_END_Y + 50);
Line rightLeg = new Line();
rightLeg.setStartX(SPINE_END_X);
rightLeg.setStartY(SPINE_END_Y);
rightLeg.setEndX(SPINE_END_X - 25);
rightLeg.setEndY(SPINE_END_Y + 50);
getChildren().addAll(head, spine, leftArm, rightArm, leftLeg, rightLeg);
lives.set(getChildren().size());
}
示例12: playWinAnimation
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private void playWinAnimation(Combo combo) {
Line line = new Line();
line.setStartX(combo.tiles[0].getCenterX());
line.setStartY(combo.tiles[0].getCenterY());
line.setEndX(combo.tiles[0].getCenterX());
line.setEndY(combo.tiles[0].getCenterY());
root.getChildren().add(line);
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1),
new KeyValue(line.endXProperty(), combo.tiles[2].getCenterX()),
new KeyValue(line.endYProperty(), combo.tiles[2].getCenterY())));
timeline.play();
}
示例13: Arrow
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private Arrow(Line line, Line arrow1, Line arrow2) {
super(line, arrow1, arrow2);
this.line = line;
/* The color of the arrow should follow the color of the main line. */
arrow1.strokeProperty().bind(line.strokeProperty());
arrow2.strokeProperty().bind(line.strokeProperty());
/* Listener to redraw the arrow parts when the line position changes. */
InvalidationListener updater = o -> {
double ex = getEndX();
double ey = getEndY();
double sx = getStartX();
double sy = getStartY();
arrow1.setEndX(ex);
arrow1.setEndY(ey);
arrow2.setEndX(ex);
arrow2.setEndY(ey);
if (ex == sx && ey == sy) {
/* The line is just a point. Don't draw the arrowhead. */
arrow1.setStartX(ex);
arrow1.setStartY(ey);
arrow2.setStartX(ex);
arrow2.setStartY(ey);
} else {
double factor = ARROW_HEAD_LENGTH / Math.hypot(sx-ex, sy-ey);
double factorO = ARROW_HEAD_WIDTH / Math.hypot(sx-ex, sy-ey);
// part in direction of main line
double dx = (sx - ex) * factor;
double dy = (sy - ey) * factor;
// part ortogonal to main line
double ox = (sx - ex) * factorO;
double oy = (sy - ey) * factorO;
arrow1.setStartX(ex + dx - oy);
arrow1.setStartY(ey + dy + ox);
arrow2.setStartX(ex + dx + oy);
arrow2.setStartY(ey + dy - ox);
}
};
/* Attach updater to properties */
startXProperty().addListener(updater);
startYProperty().addListener(updater);
endXProperty().addListener(updater);
endYProperty().addListener(updater);
updater.invalidated(null);
}
示例14: initGame
import javafx.scene.shape.Line; //导入方法依赖的package包/类
@Override
protected void initGame() {
getGameWorld().addEntity(Entities.makeScreenBounds(50));
PhysicsComponent physics = new PhysicsComponent();
Entity block = Entities.builder()
.at(200, 200)
.viewFromNodeWithBBox(new Rectangle(50, 50))
.with(physics)
.buildAndAttach(getGameWorld());
PhysicsComponent physics2 = new PhysicsComponent();
physics2.setBodyType(BodyType.DYNAMIC);
FixtureDef fd = new FixtureDef();
fd.setDensity(1.0f);
physics2.setFixtureDef(fd);
Entity ball =Entities.builder()
.at(200, 300)
.bbox(new HitBox("main", BoundingShape.circle(15)))
.viewFromNode(getAssetLoader().loadTexture("ball.png", 30, 30))
.with(physics2)
.buildAndAttach(getGameWorld());
Line line = new Line();
line.setStartX(block.getCenter().getX());
line.setStartY(block.getCenter().getY());
//line.startXProperty().bind(block.getPositionComponent().xProperty());
//line.startYProperty().bind(block.getPositionComponent().yProperty());
line.endXProperty().bind(ball.getPositionComponent().xProperty().add(15));
line.endYProperty().bind(ball.getPositionComponent().yProperty().add(15));
getGameScene().addGameView(new EntityView(line, RenderLayer.BACKGROUND));
RevoluteJointDef rDef = new RevoluteJointDef();
rDef.bodyA = physics.getBody();
rDef.bodyB = physics2.getBody();
rDef.collideConnected = false;
rDef.localAnchorA = new Vec2(0, 0);
rDef.localAnchorB = new Vec2(0, 5);
rDef.enableLimit = true;
rDef.lowerAngle = FXGLMath.degreesToRadians * -180.0f;
rDef.upperAngle = FXGLMath.degreesToRadians * 180.0f;
rDef.enableMotor = true;
rDef.motorSpeed = FXGLMath.degreesToRadians * 30;
rDef.maxMotorTorque = 15.0f;
joint = (RevoluteJoint) getPhysicsWorld().getJBox2DWorld().createJoint(rDef);
}