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


Java Line類代碼示例

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


Line類屬於javafx.scene.shape包,在下文中一共展示了Line類的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: drawBackground

import javafx.scene.shape.Line; //導入依賴的package包/類
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);
    }
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:17,代碼來源:UiModelApp2.java

示例3: drawBackground

import javafx.scene.shape.Line; //導入依賴的package包/類
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);
    }
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:17,代碼來源:UiModelApp.java

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

示例5: addYTickLine

import javafx.scene.shape.Line; //導入依賴的package包/類
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);

}
 
開發者ID:JKostikiadis,項目名稱:MultiAxisScatterChart,代碼行數:18,代碼來源:MultiAxisScatterChart.java

示例6: initialInsert

import javafx.scene.shape.Line; //導入依賴的package包/類
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);
    }
}
 
開發者ID:fankaljead,項目名稱:Curriculum-design-of-data-structure,代碼行數:20,代碼來源:ShowArrayListController.java

示例7: addSpacerElement

import javafx.scene.shape.Line; //導入依賴的package包/類
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));
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:17,代碼來源:DropDownMenu.java

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

示例9: 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:kaanburaksener,項目名稱:octoBubbles,代碼行數:32,代碼來源:MessageEdgeView.java

示例10: 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:kaanburaksener,項目名稱:octoBubbles,代碼行數:33,代碼來源:AssociationEdgeView.java

示例11: createHandles

import javafx.scene.shape.Line; //導入依賴的package包/類
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);
    }
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:17,代碼來源:PackageNodeView.java

示例12: distanceToLine

import javafx.scene.shape.Line; //導入依賴的package包/類
private double distanceToLine(Line l, double pointX, double pointY){
    double y1 = l.getStartY();
    double y2 = l.getEndY();
    double x1 = l.getStartX();
    double x2 = l.getEndX();

    double px = x2-x1;
    double py = y2-y1;

    double something = px*px + py*py;

    double u =  ((pointX - x1) * px + (pointY - y1) * py) / something;

    if (u > 1){
        u = 1;
    }
    else if (u < 0){
        u = 0;
    }

    double x = x1 + u * px;
    double y = y1 + u * py;

    double dx = x - pointX;
    double dy = y - pointY;

    double dist = Math.sqrt(dx*dx + dy*dy);

    return dist;

}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:32,代碼來源:SelectController.java

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

示例14: dataItemAdded

import javafx.scene.shape.Line; //導入依賴的package包/類
/**
 * <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();
  }
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:42,代碼來源:TimingDiagramView.java

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


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