當前位置: 首頁>>代碼示例>>Java>>正文


Java Line.setStartX方法代碼示例

本文整理匯總了Java中javafx.scene.shape.Line.setStartX方法的典型用法代碼示例。如果您正苦於以下問題:Java Line.setStartX方法的具體用法?Java Line.setStartX怎麽用?Java Line.setStartX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.shape.Line的用法示例。


在下文中一共展示了Line.setStartX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:25,代碼來源:NodeController.java

示例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);
}
 
開發者ID:steppp,項目名稱:Breadth-First-Search,代碼行數:20,代碼來源:Arrow.java

示例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();
}
 
開發者ID:AlmasB,項目名稱:FXGLGames,代碼行數:19,代碼來源:TicTacToeApp.java

示例4: populateLineStyleOptions

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Populates the combobox with linestyle options given a width
 * and color.
 * @param penWidth
 * @param penColor
 */
private void populateLineStyleOptions(double penWidth, Color penColor) {
	
	this.getItems().clear();
	
	LineStyle[] styles = LineStyle.values();
	
	for(LineStyle style : styles) {
		Line line = style.getLine();
		line.setStartX(-(WIDTH)/2);
		line.setEndX(WIDTH/2);
		line.setStrokeWidth(penWidth);
		line.setStroke(penColor);
		this.getItems().add(line);
	}
	
}
 
開發者ID:adisrini,項目名稱:slogo,代碼行數:23,代碼來源:LineStyleOptions.java

示例5: 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;
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:30,代碼來源:MyPopOverSkin.java

示例6: Indicator

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public Indicator() {
    Circle c = new Circle(5);
    Line l = new Line();
    l.setStartX(0);
    l.endXProperty().bind(this.widthProperty().subtract(10));
    c.getStyleClass().add("timeindicator");
    l.getStyleClass().add("timeindicator");

    StackPane.setAlignment(c, Pos.CENTER_LEFT);
    this.getChildren().add(l);
    this.getChildren().add(c);
    this.translateYProperty().bind(this.heightProperty().divide(2).negate());
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:14,代碼來源:TimeIndicator.java

示例7: 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);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:40,代碼來源:IntroPaneSkin.java

示例8: 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);
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:8,代碼來源:AnimatedIcon.java

示例9: 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
        */
    }
 
開發者ID:Naoghuman,項目名稱:Incubator,代碼行數:36,代碼來源:LineRotationForEndPoints.java

示例10: 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);

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:14,代碼來源:LineDrawItemSkin.java

示例11: 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);
    }
}
 
開發者ID:Heverton,項目名稱:grapheditor,代碼行數:42,代碼來源:GraphEditorGrid.java

示例12: 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;
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:35,代碼來源:JFXRepresentation.java

示例13: 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());
}
 
開發者ID:AlmasB,項目名稱:FXTutorials,代碼行數:38,代碼來源:HangmanMain.java

示例14: 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();
}
 
開發者ID:AlmasB,項目名稱:FXTutorials,代碼行數:16,代碼來源:TicTacToeApp.java

示例15: 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);
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:53,代碼來源:Arrow.java


注:本文中的javafx.scene.shape.Line.setStartX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。