当前位置: 首页>>代码示例>>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;未经允许,请勿转载。