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


Java Line.setStroke方法代碼示例

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


在下文中一共展示了Line.setStroke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LineSample

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public LineSample() {
    super(180,90);
    // Create line shape
    Line line = new Line(5, 85, 175 , 5);
    line.setFill(null);
    line.setStroke(Color.RED);
    line.setStrokeWidth(2);

    // show the line shape;
    getChildren().add(line);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Line Stroke", line.strokeProperty()),
            new SimplePropertySheet.PropDesc("Line Start X", line.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Line Start Y", line.startYProperty(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Line End X", line.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Line End Y", line.endYProperty(), 0d, 90d)
    );
    // END REMOVE ME
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:LineSample.java

示例2: createIconContent

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public static Node createIconContent() {
    Text text = new Text("abc");
    text.setTextOrigin(VPos.TOP);
    text.setLayoutX(10);
    text.setLayoutY(11);
    text.setFill(Color.BLACK);
    text.setOpacity(0.5);
    text.setFont(Font.font(null, FontWeight.BOLD, 20));
    text.setStyle("-fx-font-size: 20px;");

    Text text2 = new Text("abc");
    text2.setTextOrigin(VPos.TOP);
    text2.setLayoutX(28);
    text2.setLayoutY(51);
    text2.setFill(Color.BLACK);
    text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
    text2.setStyle("-fx-font-size: 20px;");
            
    Line line = new Line(30, 32, 45, 57);
    line.setStroke(Color.DARKMAGENTA);

    return new javafx.scene.Group(text, line, text2);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:24,代碼來源:StringBindingSample.java

示例3: setSelected

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public void setSelected(boolean selected){
    super.setSelected(selected);
    Color color;
    if(selected){
        color = Constants.selected_color;
    } else {
        color = Color.BLACK;
    }

    for(Line l : arrowHeadLines){
        l.setStroke(color);
    }
    title.setFill(color);
    if(circleHandle != null){
        circleHandle.setFill(color);
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:18,代碼來源:MessageEdgeView.java

示例4: drawArrowHead

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Draws an ArrowHead and returns it in a group.
 * Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
 * @param startX
 * @param startY
 * @param endX
 * @param endY
 * @return Group.
 */
private void drawArrowHead(double startX, double startY, double endX, double endY) {
    arrowHead.getChildren().clear();
    double phi = Math.toRadians(30);
    int barb = 15;
    double dy = startY - endY;
    double dx = startX - endX;
    double theta = Math.atan2(dy, dx);
    double x, y, rho = theta + phi;

    for (int j = 0; j < 2; j++) {
        x = startX - barb * Math.cos(rho);
        y = startY - barb * Math.sin(rho);
        Line arrowHeadLine = new Line(startX, startY, x, y);
        arrowHeadLine.setStrokeWidth(super.STROKE_WIDTH);
        arrowHeadLines.add(arrowHeadLine);
        if(super.isSelected()){
            arrowHeadLine.setStroke(Constants.selected_color);
        }
        arrowHead.getChildren().add(arrowHeadLine);
        rho = theta - phi;
    }
}
 
開發者ID:Imarcus,項目名稱:OctoUML,代碼行數:32,代碼來源:MessageEdgeView.java

示例5: drawArrowHead

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Draws an ArrowHead and returns it in a group.
 * Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
 * @param startX
 * @param startY
 * @param endX
 * @param endY
 * @return Group.
 */
private Group drawArrowHead(double startX, double startY, double endX, double endY) {
    Group group = new Group();
    double phi = Math.toRadians(40);
    int barb = 20;
    double dy = startY - endY;
    double dx = startX - endX;
    double theta = Math.atan2(dy, dx);
    double x, y, rho = theta + phi;

    for (int j = 0; j < 2; j++) {
        x = startX - barb * Math.cos(rho);
        y = startY - barb * Math.sin(rho);
        Line arrowHeadLine = new Line(startX, startY, x, y);
        arrowHeadLine.setStrokeWidth(super.STROKE_WIDTH);
        arrowHeadLines.add(arrowHeadLine);
        if(super.isSelected()){
            arrowHeadLine.setStroke(Constants.selected_color);
        }
        group.getChildren().add(arrowHeadLine);
        rho = theta - phi;
    }
    return group;
}
 
開發者ID:Imarcus,項目名稱:OctoUML,代碼行數:33,代碼來源:AssociationEdgeView.java

示例6: 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

示例7: positionedLine

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Positions and styles the pen according to the information
 * from the turtle.
 * 
 * @param startx - starting X position
 * @param starty - starting Y position
 * @param endx - ending X position
 * @param endy - ending Y position
 * @param penColor - color of the stroke
 * @param penWidth - width of the stroke
 * @param penStyleIndex - style index from properties file
 * @return the positioned and styled line
 */
private Line positionedLine (double startx,
                             double starty,
                             double endx,
                             double endy,
                             Color penColor,
                             String penWidth,
                             int penStyleIndex) {

    Line line = new Line(startx, starty, endx, endy);
    line.setTranslateX(endx - (endx - startx) / 2);
    line.setTranslateY(endy - (endy - starty) / 2);
    line.setStroke(penColor);
    line.setStrokeWidth(Double.parseDouble(penWidth));
    line.getStrokeDashArray().clear();
    
    for(Double d : assignDashArray(penStyleIndex)) {
    	line.getStrokeDashArray().add(d);
    }
    
    return line;
}
 
開發者ID:adisrini,項目名稱:slogo,代碼行數:35,代碼來源:GraphicsWindow.java

示例8: setChildItems

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public void setChildItems(String gui, String[] item) {
        // 貰った親のアイテムを全てのアイテムの中から探して,同じものが選択されたとき,下にguiを追加
        // guiを設定する時は conBox に上に線を引いた上で追加する。

        if (childFlag) {
            removeChildGUI();
        }
        childFlag = true;
        Line vborderline = new Line(0, 0, box.initBoxSizeX, 0);
        vborderline.setStroke(Color.web("#B3B3B3"));
        conBox.getChildren().add(vborderline);

        System.out.println("----------------------------- in setChildItems");
        setGUI(gui, item, "child");

//        this.setChildItem(item[0]);
//        changeBoxSize();
    }
 
開發者ID:ryohashioka,項目名稱:Visual-Programming-Environment-for-Coordinating-Appliances-and-Services-in-a-Smart-House,代碼行數:19,代碼來源:BoxToSetUp.java

示例9: itemOnOff

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public void itemOnOff() {
    if (itemFlag) {
        vbox.getChildren().remove(1);
        boxSizeY = boxSizeY - initBoxSizeY;
        setBoxSize();
        itemFlag = false;
    } else {
        Label itemlabel = new Label();
        itemlabel.setAlignment(Pos.BASELINE_CENTER);
        itemlabel.setText(itemStr);
        // 條件文とオブジェクト名の間に入れる線
        Line borderline = new Line(0, 0, initBoxSizeX, 0);
        borderline.setStroke(Color.web("#B3B3B3"));

        itemlabel.setGraphic(borderline);
        itemlabel.setContentDisplay(ContentDisplay.TOP);
        vbox.getChildren().add(1, itemlabel);
        boxSizeY = boxSizeY + initBoxSizeY;
        setBoxSize();
        itemFlag = true;
        reSetItem();
    }
}
 
開發者ID:ryohashioka,項目名稱:Visual-Programming-Environment-for-Coordinating-Appliances-and-Services-in-a-Smart-House,代碼行數:24,代碼來源:Box.java

示例10: createSnapIndicators

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Initializes snap inidicators for AbstractNode.
 * @param n
 */
private void createSnapIndicators(AbstractNode n){
    Line xSnapIndicator = new Line(0,0,0,0);
    Line ySnapIndicator = new Line(0,0,0,0);
    xSnapIndicator.setStroke(Color.BLACK);
    ySnapIndicator.setStroke(Color.BLACK);
    aDrawPane.getChildren().addAll(xSnapIndicator, ySnapIndicator);
    xSnapIndicatorMap.put(n, xSnapIndicator);
    ySnapIndicatorMap.put(n, ySnapIndicator);
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:14,代碼來源:NodeController.java

示例11: drawGrid

import javafx.scene.shape.Line; //導入方法依賴的package包/類
void drawGrid() {
    grid.clear();
    for (int i = 0; i < 8000; i += Constants.GRID_DISTANCE) {
        Line line1 = new Line(i, 0, i, 8000);
        line1.setStroke(Color.LIGHTGRAY);
        Line line2 = new Line(0, i, 8000, i);
        line2.setStroke(Color.LIGHTGRAY);
        grid.add(line1);
        grid.add(line2);
        aDrawPane.getChildren().addAll(line1, line2);
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:13,代碼來源:GraphController.java

示例12: start

import javafx.scene.shape.Line; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
	Group root = new Group();
	Line seeSaw = new Line (60,340,340,140);
	seeSaw.setStroke(Color.BLACK);
	seeSaw.setStrokeWidth(15);
	Circle circle = new Circle(70,280,40);
	circle.setStroke(Color.GREENYELLOW);
	circle.setFill(Color.ORANGE);
	circle.setStrokeWidth(5);
	
	Rectangle rect = new Rectangle(240,90,80,70);
	rect.setStroke(Color.MEDIUMPURPLE);
	rect.setStrokeWidth(5);
	rect.setFill(Color.MEDIUMPURPLE);
	
	Line left = new Line (200,240,160,340);
	left.setStrokeWidth(5);
	Line right = new Line(200,240,240,340);
	right.setStrokeWidth(5);
	
	root.getChildren().addAll(seeSaw,rect,circle,left,right);
	
	
	
	Scene scene = new Scene(root, 400, 400,Color.WHITE);
	primaryStage.setTitle("SeeSaw");
	primaryStage.setScene(scene);
	primaryStage.show();
	
	
	
}
 
開發者ID:naeemkhan12,項目名稱:JavaFx-Material-Design,代碼行數:34,代碼來源:Playground.java

示例13: makeGroup

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Make group.
 */
public void makeGroup(){
    double displayNum = lineDensity;
    if (displayNum>100){
        displayNum = 100;
    }
    lines.getChildren().clear();
    for(int i=1; i<=displayNum*2; i+=2){
        Line line1 = new Line(i, 0, i, 100);
        line1.setStroke(WavelengthToColor.getColor(mmWavelength,1));
        lines.getChildren().add(line1);
    }

}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:17,代碼來源:GratingApertureDrawing.java

示例14: drawingArrowhead

import javafx.scene.shape.Line; //導入方法依賴的package包/類
protected void drawingArrowhead(double x1, double y1, double x2, double y2, Pane pane){

        Line line = new Line(x1, y1, x2, y2);
        line.setStrokeWidth(3);//設置線的寬度
        line.setFill(Color.RED);
        line.setStroke(Color.RED);
        pane.getChildren().add(line);

        // 斜率
        double slope = ((((double) y1) - (double) y2)) / (((double) x1) - (((double) x2)));

        double arctan = Math.atan(slope);

        // This will flip the arrow 45 off of a
        // perpendicular line at pt x2
        double set45 = 1.57 / 2;

        // 箭頭永遠指向i 而不是 i+1
        if (x1 < x2) {
            // add 90 degrees to arrow lines
            set45 = -1.57 * 1.5;
        }

        // set length of arrows
        int arrlen = 15;

        Line line1 = new Line(x2, y2, (x2 + (Math.cos(arctan + set45) * arrlen)), ((y2)) + (Math.sin(arctan + set45) * arrlen));
        Line line2 = new Line(x2, y2, (x2 + (Math.cos(arctan - set45) * arrlen)), ((y2)) + (Math.sin(arctan - set45) * arrlen));


        line1.setStrokeWidth(3);//設置線的寬度
        line1.setStrokeWidth(3);//設置線的寬度
        line1.setStroke(Color.RED);//顏色
        line2.setStroke(Color.RED);
        // 在線上加箭頭
        pane.getChildren().add(line1);
        pane.getChildren().add(line2);
    }
 
開發者ID:fankaljead,項目名稱:Curriculum-design-of-data-structure,代碼行數:39,代碼來源:DrawWeighedGraph.java

示例15: drawingArrowhead

import javafx.scene.shape.Line; //導入方法依賴的package包/類
protected void drawingArrowhead(double x1, double y1, double x2, double y2, Pane pane){

        Line line = new Line(x1, y1, x2, y2);
        line.setStrokeWidth(3);//設置線的寬度
        line.setFill(Color.RED);
        line.setStroke(Color.RED);
        pane.getChildren().add(line);

        // 斜率
        double slope = (y1 -  y2) / (x1 -  x2);

        double arctan = Math.atan(slope);

        // This will flip the arrow 45 off of a
        // perpendicular line at pt x2
        double set45 = 1.57 / 2;

        // 箭頭永遠指向i 而不是 i+1
        if (x1 < x2) {
            // add 90 degrees to arrow lines
            set45 = -1.57 * 1.5;
        }

        // set length of arrows
        int arrlen = 15;

        Line line1 = new Line(x2, y2, (x2 + (Math.cos(arctan + set45) * arrlen)), ((y2)) + (Math.sin(arctan + set45) * arrlen));
        Line line2 = new Line(x2, y2, (x2 + (Math.cos(arctan - set45) * arrlen)), ((y2)) + (Math.sin(arctan - set45) * arrlen));


        line1.setStrokeWidth(3);//設置線的寬度
        line2.setStrokeWidth(3);//設置線的寬度
        line1.setStroke(Color.RED);
        line2.setStroke(Color.RED);
        // 在線上加箭頭
        pane.getChildren().add(line1);
        pane.getChildren().add(line2);
    }
 
開發者ID:fankaljead,項目名稱:Curriculum-design-of-data-structure,代碼行數:39,代碼來源:DrawUnweighedtGraph.java


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