Java 类javafx.scene.shape.Line 实例源码

项目:marathonv5    文件:LineSample.java   
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
}
项目:lttng-scope    文件:UiModelApp2.java   
private static void drawBackground(Group parent, Pane parentPane) {
        DoubleStream.iterate(ENTRY_HEIGHT / 2, i -> i + ENTRY_HEIGHT).limit(10)
                .mapToObj(y -> {
                    Line line = new Line();
                    line.setStartX(0);
                    line.endXProperty().bind(parentPane.widthProperty());
//                    line.setEndX(MAX_WIDTH);
                    line.setStartY(y);
                    line.setEndY(y);

                    line.setStroke(BACKGROUD_LINES_COLOR);
                    line.setStrokeWidth(1.0);
                    return line;
                })
                .forEach(parent.getChildren()::add);
    }
项目:lttng-scope    文件:UiModelApp.java   
private static void drawBackground(Group parent, Pane content) {
        DoubleStream.iterate(ENTRY_HEIGHT / 2, i -> i + ENTRY_HEIGHT).limit(10)
                .mapToObj(y -> {
                    Line line = new Line();
                    line.setStartX(0);
                    line.endXProperty().bind(content.widthProperty());
//                    line.setEndX(MAX_WIDTH);
                    line.setStartY(y);
                    line.setEndY(y);

                    line.setStroke(BACKGROUD_LINES_COLOR);
                    line.setStrokeWidth(1.0);
                    return line;
                })
                .forEach(parent.getChildren()::add);
    }
项目:marathonv5    文件:StringBindingSample.java   
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);
}
项目:marathonv5    文件:LineSample.java   
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
}
项目:marathonv5    文件:StringBindingSample.java   
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);
}
项目:MultiAxisScatterChart    文件:MultiAxisScatterChart.java   
private void addYTickLine(String value, double x, double y, int index) {
    Line line = new Line(x - 5, y, x + 5, y);
    axisComponts.add(line);

    Text text = new Text(value);
    axisComponts.add(text);

    if (index == 0) {
        text.setX(x - 40);
    } else {
        text.setX(x + 15);
    }
    text.setY(y + 5);

    getChildren().addAll(line, text);

}
项目:Curriculum-design-of-data-structure    文件:ShowArrayListController.java   
protected void initialInsert(){
    setLabel();

    showList.getChildren().clear();

    for (int i = 0; i < capacitySize; i++) {

        //添加矩形
        Rectangle rectangle = new Rectangle(START_X + i * WIDTH, START_Y, WIDTH, HEIGHT);
        rectangle.setFill(Color.WHITE);
        rectangle.setStroke(Color.BLACK);
        rectangle.setOpacity(0.3);
        showList.getChildren().add(rectangle);

        //添加线
        Line line = new Line(rectangle.getX(), rectangle.getY() + HEIGHT, rectangle.getX() + WIDTH, rectangle.getY());
        showList.getChildren().add(line);
    }
}
项目:H-Uppaal    文件:DropDownMenu.java   
public void addSpacerElement() {
    final Region space1 = new Region();
    space1.setMinHeight(8);
    list.getChildren().add(space1);

    final Line sep = new Line(0, 0, width - 1, 0);
    sep.setStroke(Color.GREY.getColor(Color.Intensity.I300));
    list.getChildren().add(sep);

    final Region space2 = new Region();
    space2.setMinHeight(8);
    list.getChildren().add(space2);

    space1.setOnMouseEntered(event -> canIShowSubMenu.set(false));
    space2.setOnMouseEntered(event -> canIShowSubMenu.set(false));
}
项目:octoBubbles    文件:MessageEdgeView.java   
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);
    }
}
项目:octoBubbles    文件:MessageEdgeView.java   
/**
 * 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;
    }
}
项目:octoBubbles    文件:AssociationEdgeView.java   
/**
 * 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;
}
项目:octoBubbles    文件:PackageNodeView.java   
private void createHandles(){

        shortHandleLine = new Line();
        longHandleLine = new Line();

        shortHandleLine.startXProperty().bind(body.widthProperty().subtract(7));
        shortHandleLine.startYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(3)));
        shortHandleLine.endXProperty().bind(body.widthProperty().subtract(3));
        shortHandleLine.endYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(7)));
        longHandleLine.startXProperty().bind(body.widthProperty().subtract(15));
        longHandleLine.startYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(3)));
        longHandleLine.endXProperty().bind(body.widthProperty().subtract(3));
        longHandleLine.endYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(15)));

        this.getChildren().addAll(shortHandleLine, longHandleLine);
    }
项目:octoBubbles    文件:NodeController.java   
/**
 * 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);
}
项目:stvs    文件:TimingDiagramView.java   
/**
 * <b>copied from super and modified</b>
 *
 * <p>Called when a data item has been added to a series. This is where implementations of XYChart
 * can create/add new nodes to getPlotChildren to represent this data item.
 *
 * <p>The following nodes are created here:
 * <ul>
 * <li>Horizontal lines for values</li>
 * <li>Vertical lines to connect values</li>
 * <li>Rectangles to perform selections and highlighting</li>
 * <li>Tooltips to show the value of a specific item</li>
 * </ul>
 *
 * @param series The series the data item was added to
 * @param itemIndex The index of the new item within the series
 * @param item The new data item that was added
 */
@Override
protected void dataItemAdded(Series<Number, A> series, int itemIndex, Data<Number, A> item) {
  Line horizontalLine = new Line();
  horizontalLine.getStyleClass().add("valueLine");
  dataPane.getChildren().add(horizontalLine);
  dataPane.setMouseTransparent(true);
  durationLinesPane.setMouseTransparent(true);
  horizontalLines.add(horizontalLine);
  Rectangle cycleSelectionRectangle = new Rectangle();
  Tooltip tooltip = new Tooltip(item.getYValue().toString());
  Tooltip.install(cycleSelectionRectangle, tooltip);
  cycleSelectionRectangle.getStyleClass().add("cycleSelectionRectangle");
  cycleSelectionRectangle.setOpacity(0);
  cycleSelectionRectangles.add(cycleSelectionRectangle);
  cycleSelectionPane.getChildren().add(cycleSelectionRectangle);
  if (itemIndex > 0) {
    Line verticalLine = new Line();
    verticalLine.getStyleClass().add("valueLine");
    dataPane.getChildren().add(verticalLine);
    verticalLines.add(verticalLine);
    // updateYRange();
  }
}
项目:Breadth-First-Search    文件:Arrow.java   
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);
}
项目:population    文件:ChartSeries.java   
public void refreshStyle() {
    Path linePath = mLinePath;
    Label legendLabel = mLegendLabel;
    if (linePath == null && legendLabel == null) {
        return;
    }
    String style = buildStyle();
    if (linePath != null) {
        linePath.setStyle(style);
    }
    if (legendLabel != null) {
        Line line = new Line(0, 0, 36, 0);
        line.setStyle(style);
        legendLabel.setGraphic(line);
    }
}
项目:JNFP    文件:PolygonPairStages.java   
private static Stage drawPair(MultiPolygon[] multiPolys) {

    Stage stage = new Stage();

    Group multiPolygonPairGroup = new Group();
    Scene scene = new Scene(multiPolygonPairGroup, sceneSizeX, sceneSizeY, Color.WHITESMOKE);

    Line xAxis = new Line(0,sceneSizeY/2,10000,sceneSizeY/2);
    Line yAxis = new Line(sceneSizeX/2,0,sceneSizeX/2,10000);

    multiPolygonPairGroup.getChildren().add(xAxis);
    multiPolygonPairGroup.getChildren().add(yAxis);

    double biggestXCoordValue = multiPolys[0].getBiggestX().doubleValue() + multiPolys[1].getBiggestX().doubleValue();//biggest value of x and y coords of the polygons, used for autoscaling
    double biggestYCoordValue = multiPolys[0].getBiggestY().doubleValue() + multiPolys[1].getBiggestY().doubleValue();
    double biggestValue = Math.max(biggestXCoordValue, biggestYCoordValue);

    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[0], 0, biggestValue);
    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[1],1, biggestValue);

       stage.setScene(scene);
       return stage;
}
项目:JNFP    文件:PolygonPairStages.java   
private static Stage drawPair(MultiPolygon[] multiPolys) {

    Stage stage = new Stage();

    Group multiPolygonPairGroup = new Group();
    Scene scene = new Scene(multiPolygonPairGroup, sceneSizeX, sceneSizeY, Color.WHITESMOKE);

    Line xAxis = new Line(0,sceneSizeY/2,10000,sceneSizeY/2);
    Line yAxis = new Line(sceneSizeX/2,0,sceneSizeX/2,10000);

    multiPolygonPairGroup.getChildren().add(xAxis);
    multiPolygonPairGroup.getChildren().add(yAxis);

    double biggestXCoordValue = multiPolys[0].getBiggestX() + multiPolys[1].getBiggestX();//biggest value of x and y coords of the polygons, used for autoscaling
    double biggestYCoordValue = multiPolys[0].getBiggestY() + multiPolys[1].getBiggestY();;
    double biggestValue = Math.max(biggestXCoordValue, biggestYCoordValue);

    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[0], 0, biggestValue);
    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[1],1, biggestValue);

       stage.setScene(scene);
       return stage;
}
项目:JNFP    文件:PolygonPairStages.java   
private static Stage drawPair(MultiPolygon[] multiPolys) {

    Stage stage = new Stage();

    Group multiPolygonPairGroup = new Group();
    Scene scene = new Scene(multiPolygonPairGroup, sceneSizeX, sceneSizeY, Color.WHITESMOKE);

    Line xAxis = new Line(0,sceneSizeY/2,10000,sceneSizeY/2);
    Line yAxis = new Line(sceneSizeX/2,0,sceneSizeX/2,10000);

    multiPolygonPairGroup.getChildren().add(xAxis);
    multiPolygonPairGroup.getChildren().add(yAxis);

    double biggestXCoordValue = multiPolys[0].getBiggestX() + multiPolys[1].getBiggestX();//biggest value of x and y coords of the polygons, used for autoscaling
    double biggestYCoordValue = multiPolys[0].getBiggestY() + multiPolys[1].getBiggestY();;
    double biggestValue = Math.max(biggestXCoordValue, biggestYCoordValue);

    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[0], 0, biggestValue);
    makeMultiPolygonScene(multiPolygonPairGroup, multiPolys[1],1, biggestValue);

       stage.setScene(scene);
       //stage.show();
       return stage;
}
项目:OctoUML    文件:MessageEdgeView.java   
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);
    }
}
项目:OctoUML    文件:MessageEdgeView.java   
/**
 * 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;
    }
}
项目:OctoUML    文件:AssociationEdgeView.java   
/**
 * 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;
}
项目:OctoUML    文件:ClassNodeView.java   
private void createHandles(){

        shortHandleLine = new Line();
        longHandleLine = new Line();

        shortHandleLine.startXProperty().bind(rectangle.widthProperty().subtract(7));
        shortHandleLine.startYProperty().bind(rectangle.heightProperty().subtract(3));
        shortHandleLine.endXProperty().bind(rectangle.widthProperty().subtract(3));
        shortHandleLine.endYProperty().bind(rectangle.heightProperty().subtract(7));
        longHandleLine.startXProperty().bind(rectangle.widthProperty().subtract(15));
        longHandleLine.startYProperty().bind(rectangle.heightProperty().subtract(3));
        longHandleLine.endXProperty().bind(rectangle.widthProperty().subtract(3));
        longHandleLine.endYProperty().bind(rectangle.heightProperty().subtract(15));

        this.getChildren().addAll(shortHandleLine, longHandleLine);
    }
项目:OctoUML    文件:PackageNodeView.java   
private void createHandles(){

        shortHandleLine = new Line();
        longHandleLine = new Line();

        shortHandleLine.startXProperty().bind(body.widthProperty().subtract(7));
        shortHandleLine.startYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(3)));
        shortHandleLine.endXProperty().bind(body.widthProperty().subtract(3));
        shortHandleLine.endYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(7)));
        longHandleLine.startXProperty().bind(body.widthProperty().subtract(15));
        longHandleLine.startYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(3)));
        longHandleLine.endXProperty().bind(body.widthProperty().subtract(3));
        longHandleLine.endYProperty().bind(body.heightProperty().add(top.heightProperty().subtract(15)));

        this.getChildren().addAll(shortHandleLine, longHandleLine);
    }
项目:OctoUML    文件:NodeController.java   
/**
 * 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);
}
项目:Game-Engine-Vooga    文件:TestAddSpritesUseCase.java   
public static void main (String[] args){

    Rectangle r1 = new Rectangle(3,5);
    Line l2 = new Line(3,5,6,9);
    Rectangle r2 = new Rectangle(7,19);
    Rectangle r3 = new Rectangle(3,9);
    List<Node> sprites = new ArrayList<Node>();

    sprites.add(r1);
    sprites.add(l2);
    sprites.add(r2);
    sprites.add(r3);


    XStream mySerializer = new XStream(new DomDriver());
    try {
        mySerializer.toXML(sprites,new FileOutputStream(new File("game_data/ExampleData.xml")));
    }
    catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}
项目:FXGLGames    文件:TicTacToeApp.java   
@Override
protected void initUI() {
    Line line1 = new Line(getWidth() / 3, 0, getWidth() / 3, 0);
    Line line2 = new Line(getWidth() / 3 * 2, 0, getWidth() / 3 * 2, 0);
    Line line3 = new Line(0, getHeight() / 3, 0, getHeight() / 3);
    Line line4 = new Line(0, getHeight() / 3 * 2, 0, getHeight() / 3 * 2);

    getGameScene().addUINodes(line1, line2, line3, line4);

    // animation
    KeyFrame frame1 = new KeyFrame(Duration.seconds(0.5),
            new KeyValue(line1.endYProperty(), getHeight()));

    KeyFrame frame2 = new KeyFrame(Duration.seconds(1),
            new KeyValue(line2.endYProperty(), getHeight()));

    KeyFrame frame3 = new KeyFrame(Duration.seconds(0.5),
            new KeyValue(line3.endXProperty(), getWidth()));

    KeyFrame frame4 = new KeyFrame(Duration.seconds(1),
            new KeyValue(line4.endXProperty(), getWidth()));

    Timeline timeline = new Timeline(frame1, frame2, frame3, frame4);
    timeline.play();
}
项目:FXGLGames    文件:TicTacToeApp.java   
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();
}
项目:jfxgauge    文件:ThermometerSkin.java   
private void drawMarking(double value, HorizontalDirection side, double markWidth, String... styles) {
    double y = getValueHeight(value);
    double x = (side == HorizontalDirection.LEFT) ? (bottomRadius - topRadius - markWidth) : (bottomRadius + topRadius);
    Line line = new Line(x, y, x + markWidth, y);
    line.getStyleClass().setAll(Arrays.stream(styles).map(style -> style + "-marking").collect(Collectors.toList()));
    pane.getChildren().add(line);
    markings.add(line);

    Text text = new Text(gauge.getFormattedValue(value));
    text.setY(y + 4);
    text.getStyleClass().setAll(Arrays.stream(styles).map(style -> style + "-text").collect(Collectors.toList()));
    if(side == HorizontalDirection.LEFT) {
        text.setTextAlignment(TextAlignment.RIGHT);
        double wrappingWidth = restrain(2 * bottomRadius, 60, 240);
        text.setWrappingWidth(wrappingWidth);
        text.setX(x - wrappingWidth - 4);
    } else {
        text.setTextAlignment(TextAlignment.LEFT);
        text.setX(x + markWidth + 4);
    }
    pane.getChildren().add(text);
    markings.add(text);
}
项目:openjfx-8u-dev-tests    文件:PieChartDescriptionProvider.java   
/**
 * On input receives array of items, and return array of lines in the same
 * order, as labels came on input.
 *
 * @param pathLines
 * @param getLabels
 * @return
 */
public List<Map.Entry<Line, Wrap<? extends Text>>> matchLinesToLabels(Line[] pathLines, ArrayList<Wrap<? extends Text>> labels) {
    Assert.assertEquals(pathLines.length, labels.size());
    List<Map.Entry<Line, Wrap<? extends Text>>> result = new ArrayList<Map.Entry<Line, Wrap<? extends Text>>>();
    for (Line line : pathLines) {
        Map.Entry<Line, Wrap<? extends Text>> entry = new AbstractMap.SimpleEntry<Line, Wrap<? extends Text>>(line, null);
        double min = Double.MAX_VALUE;
        for (Wrap wrap : labels) {
            double newMin = minDistance(getChartContent(), line, wrap);
            if (newMin < min) {
                min = newMin;
                entry.setValue(wrap);
            }
        }
        result.add(entry);
    }

    return result;
}
项目:openjfx-8u-dev-tests    文件:PieChartDescriptionProvider.java   
private Line findLineWithTheNearestAngle(PieInfo info, Line[] lines) {
    assertTrue(lines.length > 0);
    assertNotNull(info);

    int minAngleIndex = 0;
    double minAngleDiff = Double.MAX_VALUE;

    final List<Double> angles = getAngles(Arrays.asList(lines));

    for (int i = 0; i < angles.size(); i++) {
        if (Math.abs(reductionInto0to360(angles.get(i)) - reductionInto0to360(info.bisectAngle)) < minAngleDiff) {
            minAngleIndex = i;
            minAngleDiff = Math.abs(reductionInto0to360(angles.get(i)) - reductionInto0to360(info.bisectAngle));
        }
    }
    return lines[minAngleIndex];
}
项目:PL3-2016    文件:GraphView.java   
/**
 * Returns a group containing the edges between all the segment coordinates.
 */
private Group getGraphEdges() {
    Group res = new Group();
    ArrayList<ArrayList<Integer>> links = dbm.getDbReader().getLinks(genomeIds);
    ArrayList<ArrayList<Integer>> counts = dbm.getDbReader().getLinkWeights(genomeIds);
    ArrayList<Integer> xcoords = dbm.getDbReader().getAllXCoord();
    ArrayList<Integer> ycoords = dbm.getDbReader().getAllYCoord();

    for (int fromId = 1; fromId <= links.size(); fromId++) {
        for (int j = 0; j < links.get(fromId - 1).size(); j++) {
            int toId = links.get(fromId - 1).get(j);
            segmentIds.add(fromId);
            segmentIds.add(toId);
            Line line = new Line(xcoords.get(fromId - 1), ycoords.get(fromId - 1), 
                    xcoords.get(toId - 1), ycoords.get(toId - 1));
            line.setStrokeWidth(counts.get(fromId - 1).get(j));
            res.getChildren().add(line);
        }
    }
    System.out.println("Finished creating graph edges");
    return res;
}
项目:slogo    文件:LineStyleOptions.java   
/**
 * 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);
    }

}
项目:slogo    文件:GraphicsWindow.java   
/**
 * 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;
}
项目:qupath    文件:ChartToolsFX.java   
/**
 * Charts tend to show their legends with circular/square markers... which isn't much use 
 * when line strokes distinguish between different Series.
 * 
 * This method addresses this by setting the graphics for legend labels to be lines with the appropriate strokes.
 * 
 * @param chart
 * @param length
 */
public static void setLineChartLegendLines(final Chart chart, final double length) {
    Region legend = (Region)chart.lookup(".chart-legend");
    int count = 0;
    for (Node legendItem : legend.getChildrenUnmodifiable()) {
        if (legendItem instanceof Label) {
            Label label = (Label)legendItem;
            Line line = new Line(0, 4, 25, 4);
            if (chart instanceof XYChart<?, ?>) {
                XYChart<?, ?> xyChart = (XYChart<?, ?>)chart;
                if (xyChart.getData().get(count).getData().isEmpty()) {
                    label.setGraphic(null);
                    count++;
                    continue;
                }
            }
            line.getStyleClass().setAll("chart-series-line", "default-color"+count);
            label.setGraphic(line);
            count++;
        }
    }
}
项目:sudokusolver    文件:SudokuGridPane.java   
public void scale(int buttonWidth, Font font) {
    for (Node cell : getChildren()) {
        if (cell instanceof Button) {
            ((Button) cell).setMinSize(buttonWidth, buttonWidth);
            ((Button) cell).setMaxSize(buttonWidth, buttonWidth);
            ((Button) cell).setFont(font);
        } else if (cell instanceof Line) {
            Line line = ((Line) cell);
            if (line.getEndX() > 1) {
                line.setEndX(buttonWidth);
            } else if (line.getEndY() > 1) {
                line.setEndY(buttonWidth);
            }
        }
    }
}
项目:viskell    文件:ApplyAnchor.java   
public ApplyAnchor(int baseArity) {
    super(); // block is to be set in initializeBlock
    this.baseArity = baseArity;
    this.setMinSize(60, 24);
    this.setMaxSize(60, 24);
    this.setPickOnBounds(false);
    this.invisibleAnchor = new Rectangle(40, 40);
    this.invisibleAnchor.getStyleClass().add("invisTouchZone");
    this.invisibleAnchor.setTranslateX(-10);
    this.invisibleAnchor.setTranslateY(-20);
    this.visibleAnchor = new Rectangle(48, 12);
    this.visibleAnchor.setTranslateY(3);
    this.visibleAnchor.getStyleClass().add("anchorPoint");
    this.visibleAnchor.setMouseTransparent(true);
    this.openWire = new Line(0, 0, 0, 8);
    this.openWire.setTranslateX(-8);
    this.openWire.setTranslateY(-8);
    this.openWire.setStrokeWidth(6);
    this.getChildren().addAll(this.invisibleAnchor, this.visibleAnchor, this.openWire);
    this.refreshedType(baseArity, new TypeScope());
}
项目:CodeIT    文件:PongGame.java   
public PongGame(Competitor<PongGame, PongMove> leftCompetitor, Competitor<PongGame, PongMove> rightCompetitor, int roundsLeft, int width, int height) {
    this.leftCompetitor = leftCompetitor;
    this.rightCompetitor = rightCompetitor;
    this.roundsLeft = roundsLeft;
    this.width = width;
    this.height = height;

    initializeGame();

    gameElements.add(leftPaddle);
    gameElements.add(rightPaddle);
    gameElements.add(ball);
    gameElements.add(new Line(0, 1, width, 1));
    gameElements.add(new Line(0, height - 1, width, height - 1));
    gameElements.add(new Line(1, 0, 1, height));
    gameElements.add(new Line(width, 0, width, height));
}
项目:FXGLGames    文件:TicTacToeApp.java   
@Override
protected void initUI() {
    Line line1 = new Line(getWidth() / 3, 0, getWidth() / 3, 0);
    Line line2 = new Line(getWidth() / 3 * 2, 0, getWidth() / 3 * 2, 0);
    Line line3 = new Line(0, getHeight() / 3, 0, getHeight() / 3);
    Line line4 = new Line(0, getHeight() / 3 * 2, 0, getHeight() / 3 * 2);

    getGameScene().addUINodes(line1, line2, line3, line4);

    // animation
    KeyFrame frame1 = new KeyFrame(Duration.seconds(0.5),
            new KeyValue(line1.endYProperty(), getHeight()));

    KeyFrame frame2 = new KeyFrame(Duration.seconds(1),
            new KeyValue(line2.endYProperty(), getHeight()));

    KeyFrame frame3 = new KeyFrame(Duration.seconds(0.5),
            new KeyValue(line3.endXProperty(), getWidth()));

    KeyFrame frame4 = new KeyFrame(Duration.seconds(1),
            new KeyValue(line4.endXProperty(), getWidth()));

    Timeline timeline = new Timeline(frame1, frame2, frame3, frame4);
    timeline.play();
}