javafx.scene.shape.Line Java Examples

The following examples show how to use javafx.scene.shape.Line. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Edge.java    From fxgraph with Do What The F*ck You Want To Public License 7 votes vote down vote up
public EdgeGraphic(Graph graph, Edge edge, StringProperty textProperty) {
	group = new Group();
	line = new Line();

	final DoubleBinding sourceX = edge.getSource().getXAnchor(graph, edge);
	final DoubleBinding sourceY = edge.getSource().getYAnchor(graph, edge);
	final DoubleBinding targetX = edge.getTarget().getXAnchor(graph, edge);
	final DoubleBinding targetY = edge.getTarget().getYAnchor(graph, edge);

	line.startXProperty().bind(sourceX);
	line.startYProperty().bind(sourceY);

	line.endXProperty().bind(targetX);
	line.endYProperty().bind(targetY);
	group.getChildren().add(line);

	final DoubleProperty textWidth = new SimpleDoubleProperty();
	final DoubleProperty textHeight = new SimpleDoubleProperty();
	text = new Text();
	text.textProperty().bind(textProperty);
	text.getStyleClass().add("edge-text");
	text.xProperty().bind(line.startXProperty().add(line.endXProperty()).divide(2).subtract(textWidth.divide(2)));
	text.yProperty().bind(line.startYProperty().add(line.endYProperty()).divide(2).subtract(textHeight.divide(2)));
	final Runnable recalculateWidth = () -> {
		textWidth.set(text.getLayoutBounds().getWidth());
		textHeight.set(text.getLayoutBounds().getHeight());
	};
	text.parentProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run());
	text.textProperty().addListener((obs, oldVal, newVal) -> recalculateWidth.run());
	group.getChildren().add(text);
	getChildren().add(group);
}
 
Example #2
Source File: LineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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
}
 
Example #3
Source File: DoubleLines.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public boolean include(double x, double y) {
    if (!isValid()) {
        return false;
    }
    int lastx, lasty = -1, thisx, thisy;
    Point2D point = new Point2D(x, y);
    for (List<DoublePoint> lineData : lines) {
        lastx = -1;
        for (DoublePoint linePoint : lineData) {
            thisx = (int) Math.round(linePoint.getX());
            thisy = (int) Math.round(linePoint.getY());
            if (lastx >= 0) {
                Line line = new Line(lastx, lasty, thisx, thisy);
                if (line.contains(point)) {
                    return true;
                }
            }
            lastx = thisx;
            lasty = thisy;
        }
    }
    return false;
}
 
Example #4
Source File: LineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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
}
 
Example #5
Source File: DoubleLines.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public List<Line> directLines() {
    List<Line> dlines = new ArrayList<>();
    int lastx, lasty = -1, thisx, thisy;
    for (List<DoublePoint> lineData : lines) {
        lastx = -1;
        for (DoublePoint linePoint : lineData) {
            thisx = (int) Math.round(linePoint.getX());
            thisy = (int) Math.round(linePoint.getY());
            if (lastx >= 0) {
                Line line = new Line(lastx, lasty, thisx, thisy);
                dlines.add(line);
            }
            lastx = thisx;
            lasty = thisy;
        }
    }
    return dlines;
}
 
Example #6
Source File: TicTacToeApp.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
protected void initUI() {
    Line line1 = new Line(getAppWidth() / 3, 0, getAppWidth() / 3, 0);
    Line line2 = new Line(getAppWidth() / 3 * 2, 0, getAppWidth() / 3 * 2, 0);
    Line line3 = new Line(0, getAppHeight() / 3, 0, getAppHeight() / 3);
    Line line4 = new Line(0, getAppHeight() / 3 * 2, 0, getAppHeight() / 3 * 2);

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

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

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

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

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

    Timeline timeline = new Timeline(frame1, frame2, frame3, frame4);
    timeline.play();
}
 
Example #7
Source File: TicTacToeApp.java    From FXGLGames with MIT License 6 votes vote down vote up
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();
}
 
Example #8
Source File: TrackerSnapConstraint.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param toolkit
 *  @param group Group where snap lines are added
 */
public TrackerSnapConstraint(final JFXRepresentation toolkit, final Group group)
{
    this.toolkit = toolkit;
    horiz_guide = new Line();
    horiz_guide.getStyleClass().add("guide_line");
    horiz_guide.setVisible(false);
    horiz_guide.setManaged(false);

    vert_guide = new Line();
    vert_guide.getStyleClass().add("guide_line");
    vert_guide.setVisible(false);
    vert_guide.setManaged(false);

    group.getChildren().addAll(horiz_guide, vert_guide);
}
 
Example #9
Source File: FridayFunSkin.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
private Group createTicks(double cx, double cy, int numberOfTicks, double overallAngle, double tickLength, double indent, double startingAngle, String styleClass) {
  Group group = new Group();

  double degreesBetweenTicks = overallAngle == 360 ?
      overallAngle / numberOfTicks :
      overallAngle / (numberOfTicks - 1);
  double outerRadius = Math.min(cx, cy) - indent;
  double innerRadius = Math.min(cx, cy) - indent - tickLength;

  for (int i = 0; i < numberOfTicks; i++) {
    double angle = 180 + startingAngle + i * degreesBetweenTicks;

    Point2D startPoint = pointOnCircle(cx, cy, outerRadius, angle);
    Point2D endPoint = pointOnCircle(cx, cy, innerRadius, angle);

    Line tick = new Line(startPoint.getX(), startPoint.getY(), endPoint.getX(), endPoint.getY());
    tick.getStyleClass().add(styleClass);
    group.getChildren().add(tick);
  }

  return group;
}
 
Example #10
Source File: DoubleLines.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public boolean include(Point2D point) {
    if (!isValid()) {
        return false;
    }
    int lastx, lasty = -1, thisx, thisy;
    for (List<DoublePoint> lineData : lines) {
        lastx = -1;
        for (DoublePoint linePoint : lineData) {
            thisx = (int) Math.round(linePoint.getX());
            thisy = (int) Math.round(linePoint.getY());
            if (lastx >= 0) {
                Line line = new Line(lastx, lasty, thisx, thisy);
                if (line.contains(point)) {
                    return true;
                }
            }
            lastx = thisx;
            lasty = thisy;
        }
    }
    return false;
}
 
Example #11
Source File: HangmanMain.java    From FXTutorials with MIT License 6 votes vote down vote up
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());
}
 
Example #12
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
protected void buildAnimation(Node head,
                            Line beginLeaderLine,
                            Line endLeaderLine,
                            HBox mainTitle,
                            Rectangle subTitleRect,
                            HBox subTitle) {

    // generate a sequence animation
    calloutAnimation = new SequentialTransition();

    // Allow animation to go in reverse
    calloutAnimation.setCycleCount(2);
    calloutAnimation.setAutoReverse(true);

    // Animation of head
    calloutAnimation.getChildren().add(buildHeadAnim(head));

    // Animation of the beginning leader line.
    calloutAnimation.getChildren().add(buildBeginLeaderLineAnim(beginLeaderLine));

    // Animation of the ending leader line.
    calloutAnimation.getChildren().add(buildEndLeaderLineAnim(endLeaderLine));

    // Animation of the main title
    calloutAnimation.getChildren().add(buildMainTitleAnim(mainTitle));

    // Animation of the subtitle rectangle
    calloutAnimation.getChildren().add(buildSubtitleRectAnim(mainTitle, subTitleRect));

    // Animation of the subtitle
    calloutAnimation.getChildren().add(buildSubTitleAnim(mainTitle, subTitle));

    Timeline pause = new Timeline(new KeyFrame(Duration.millis(getPauseTime()/2)));
    calloutAnimation.getChildren().add(pause);

}
 
Example #13
Source File: Fx3DStageController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void setRtAxis() {
  axes.getRtAxis().getChildren().clear();
  double rtDelta = (rtRange.upperEndpoint() - rtRange.lowerEndpoint()) / 7;
  double rtScaleValue = rtRange.upperEndpoint();
  Text rtLabel = new Text("Retention Time");
  rtLabel.setRotationAxis(Rotate.X_AXIS);
  rtLabel.setRotate(-45);
  rtLabel.setTranslateX(SIZE * 3 / 8);
  rtLabel.setTranslateZ(-25);
  rtLabel.setTranslateY(13);
  axes.getRtAxis().getChildren().add(rtLabel);
  for (int y = 0; y <= SIZE; y += SIZE / 7) {
    Line tickLineX = new Line(0, 0, 0, 9);
    tickLineX.setRotationAxis(Rotate.X_AXIS);
    tickLineX.setRotate(-90);
    tickLineX.setTranslateY(-5);
    tickLineX.setTranslateX(y);
    tickLineX.setTranslateZ(-3.5);
    float roundOff = (float) (Math.round(rtScaleValue * 10.0) / 10.0);
    Text text = new Text("" + roundOff);
    text.setRotationAxis(Rotate.X_AXIS);
    text.setRotate(-45);
    text.setTranslateY(9);
    text.setTranslateX(y - 5);
    text.setTranslateZ(-15);
    rtScaleValue -= rtDelta;
    axes.getRtAxis().getChildren().addAll(text, tickLineX);
  }
  Line lineX = new Line(0, 0, SIZE, 0);
  axes.getRtAxis().getChildren().add(lineX);
  axes.getRtRotate().setAngle(180);
  axes.getRtTranslate().setZ(-SIZE);
  axes.getRtTranslate().setX(-SIZE);
}
 
Example #14
Source File: SnappingFeedbackPart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Line doCreateVisual() {
	Line line = new Line();
	line.setStroke(Color.RED);
	line.setStrokeWidth(1);
	line.setStrokeType(StrokeType.CENTERED);
	line.setStrokeLineCap(StrokeLineCap.BUTT);
	line.setVisible(false);
	return line;
}
 
Example #15
Source File: Exercise_16_26.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create an image
	ImageView image = new ImageView(new Image(
		"http://cs.armstrong.edu/liang/common/image/flag6.gif"));

	// Create a media player
	MediaPlayer audio = new MediaPlayer(new Media(
		"http://cs.armstrong.edu/liang/common/audio/anthem/anthem6.mp3"));
	audio.play();

	// Create a line
	Line line = new Line(250, 600, 250, -70);

	// Create a pane
	Pane pane = new Pane(image);

	// Create a path transition
	PathTransition pt = new PathTransition();
	pt.setDuration(Duration.millis(70000));
	pt.setPath(line);
	pt.setNode(image);
	pt.setCycleCount(Timeline.INDEFINITE);
	pt.play();

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 500, 500);
	primaryStage.setTitle("Exercise_16_26"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example #16
Source File: BytesBar.java    From classpy with MIT License 5 votes vote down vote up
public void select(FilePart cc) {
    getChildren().clear();

    final double w = getWidth() - 4;
    final double h = getHeight();

    getChildren().add(new Line(0, h / 2, w, h / 2));
    getChildren().add(new Rectangle(w * cc.getOffset() / byteCount, 4,
            w * cc.getLength() / byteCount, h - 8));
}
 
Example #17
Source File: GraphEditorGrid.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #18
Source File: TestMagneticGrid.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testUpdateZoom() {
	prefs.gridStyleProperty().set(GridStyle.CUSTOMISED);
	final double x = ((Line) grid.getChildren().get(2)).getStartX();
	zoom.setValue(0.1);
	assertThat(x).isNotEqualTo(((Line) grid.getChildren().get(2)).getStartX());
}
 
Example #19
Source File: Exercise_14_16.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
public GridPane() {
	// Create four lines and set their properties
	Line line1 = new Line(0, 200 / 3, 200, 200 / 3);
	line1.startYProperty().bind(heightProperty().divide(3));
	line1.endYProperty().bind(heightProperty().divide(3));
	line1.endXProperty().bind(widthProperty());
	line1.setStroke(Color.BLUE);

	Line line2 = new Line();
	line2.startYProperty().bind(line1.startYProperty().multiply(2));
	line2.endYProperty().bind(line1.endYProperty().multiply(2));
	line2.endXProperty().bind(widthProperty());
	line2.setStroke(Color.BLUE);

	Line line3 = new Line(200 / 3, 0, 200 / 3, 200);
	line3.startXProperty().bind(widthProperty().divide(3));
	line3.endXProperty().bind(widthProperty().divide(3));
	line3.endYProperty().bind(heightProperty());
	line3.setStroke(Color.RED);

	Line line4 = new Line();
	line4.startXProperty().bind(line3.startXProperty().multiply(2));
	line4.endXProperty().bind(line3.endXProperty().multiply(2));
	line4.endYProperty().bind(heightProperty());
	line4.setStroke(Color.RED);

	// Place lines in pane
	getChildren().addAll(line1, line2, line3, line4); 
}
 
Example #20
Source File: LeaderBoardItem.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); // 11x7
        }
    }

    state = State.CONSTANT;

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    triangle.setRotate(state.angle);

    nameText = new Text(getName());
    nameText.setTextOrigin(VPos.TOP);

    valueText = new Text();
    valueText.setTextOrigin(VPos.TOP);
    updateValueText();

    separator = new Line();

    pane = new Pane(triangle, nameText, valueText, separator);
    pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example #21
Source File: Civ6MenuApp.java    From FXTutorials with MIT License 5 votes vote down vote up
private void addLine(double x, double y) {
    line = new Line(x, y, x, y + 300);
    line.setStrokeWidth(3);
    line.setStroke(Color.color(1, 1, 1, 0.75));
    line.setEffect(new DropShadow(5, Color.BLACK));
    line.setScaleY(0);

    root.getChildren().add(line);
}
 
Example #22
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
protected Animation buildBeginLeaderLineAnim(Line firstLeaderLine) {
    return new Timeline(
            new KeyFrame(Duration.millis(1),
                    new KeyValue(firstLeaderLine.visibleProperty(), true)), // show
            new KeyFrame(Duration.millis(300),
                    new KeyValue(firstLeaderLine.endXProperty(), getLeaderLineToPoint().getX()),
                    new KeyValue(firstLeaderLine.endYProperty(), getLeaderLineToPoint().getY())
            )
    );
}
 
Example #23
Source File: PopOverSkin.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #24
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    regularFont = Fonts.latoRegular(10);
    lightFont   = Fonts.latoLight(10);

    itemText = new Text("NAME");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(regularFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    vBoxTitles = new VBox(2, itemText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    vBoxValues = new VBox(2, itemNameText);

    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example #25
Source File: InfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    regularFont = Fonts.latoRegular(10);
    lightFont   = Fonts.latoLight(10);

    itemText = new Text("NAME");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(regularFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    vBoxTitles = new VBox(2, itemText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    vBoxValues = new VBox(2, itemNameText);

    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example #26
Source File: ClearingTextField.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public CustomSkin(TextField text)
{
    super(text);

    // Circle with central 'x' as clear button
    final Circle circle = new Circle();
    circle.setFill(Color.GRAY);
    circle.radiusProperty().bind(text.heightProperty().multiply(0.325));
    circle.setFocusTraversable(false);

    final Line line1 = new Line();
    line1.setStroke(Color.WHITE);
    line1.setStrokeWidth(1.7);
    line1.startXProperty().bind(text.heightProperty().multiply(-0.1));
    line1.startYProperty().bind(text.heightProperty().multiply(-0.1));
    line1.endXProperty().bind(text.heightProperty().multiply(0.1));
    line1.endYProperty().bind(text.heightProperty().multiply(0.1));

    final Line line2 = new Line();
    line2.setStroke(Color.WHITE);
    line2.setStrokeWidth(1.7);
    line2.startXProperty().bind(text.heightProperty().multiply(0.1));
    line2.startYProperty().bind(text.heightProperty().multiply(-0.1));
    line2.endXProperty().bind(text.heightProperty().multiply(-0.1));
    line2.endYProperty().bind(text.heightProperty().multiply(0.1));

    final Group clear_button = new Group(circle, line1, line2);
    // Move clear button from center of text field to right edge
    clear_button.translateXProperty().bind(text.widthProperty().subtract(text.heightProperty()).divide(2.0));

    // Appear as soon as text is entered
    clear_button.visibleProperty().bind(text.textProperty().greaterThan(""));
    getChildren().add(clear_button);

    // Clicking the button clears text
    clear_button.setOnMouseClicked(event -> text.setText(""));
}
 
Example #27
Source File: LineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Line line = new Line(0, 0, 70, 70);
    line.setStroke(Color.web("#b9c0c5"));
    line.setStrokeWidth(5);
    line.getStrokeDashArray().addAll(15d,15d);
    line.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    line.setEffect(effect);
    return line;
}
 
Example #28
Source File: LineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Line line = new Line(0, 0, 70, 70);
    line.setStroke(Color.web("#b9c0c5"));
    line.setStrokeWidth(5);
    line.getStrokeDashArray().addAll(15d,15d);
    line.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    line.setEffect(effect);
    return line;
}
 
Example #29
Source File: TicTacToe.java    From games_oop_javafx with Apache License 2.0 5 votes vote down vote up
private Group buildMarkX(double x, double y, int size) {
    Group group = new Group();
    group.getChildren().addAll(
            new Line(
                    x + 10, y  + 10,
                    x + size - 10, y + size - 10
            ),
            new Line(
                    x + size - 10, y + 10,
                    x + 10, y + size - 10
            )
    );
    return group;
}
 
Example #30
Source File: FarCry4Loading.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(APP_W, APP_H);

    Rectangle bg = new Rectangle(APP_W, APP_H);

    LoadingCircle loadingCircle = new LoadingCircle();
    loadingCircle.setTranslateX(APP_W - 120);
    loadingCircle.setTranslateY(APP_H - 100);

    LoadingArc loadingArc = new LoadingArc();
    loadingArc.setTranslateX(500);
    loadingArc.setTranslateY(300);

    Line loadingBarBG = new Line(100, APP_H - 70, APP_W - 100, APP_H - 70);
    loadingBarBG.setStroke(Color.GREY);

    loadingBar.setStartX(100);
    loadingBar.setStartY(APP_H - 70);
    loadingBar.setEndX(100);
    loadingBar.setEndY(APP_H - 70);
    loadingBar.setStroke(Color.WHITE);

    task.progressProperty().addListener((obs, old, newValue) -> {
        double progress = newValue.doubleValue();
        loadingBar.setEndX(100 + progress * (APP_W - 200));
    });

    root.getChildren().addAll(bg, loadingArc, loadingBarBG, loadingBar);
    return root;
}