javafx.scene.shape.Rectangle#setWidth ( )源码实例Demo

下面列出了javafx.scene.shape.Rectangle#setWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MyBox   文件: ImageItem.java
public Node makeNode(int size) {
    try {
        if (isColor()) {
            Rectangle rect = new Rectangle();
            rect.setFill(Color.web(address.substring(6)));
            rect.setWidth(size);
            rect.setHeight(size);
            rect.setStyle("-fx-padding: 10 10 10 10;-fx-background-radius: 10;");
            rect.setUserData(index);
            return rect;
        } else {
            if (image == null) {
                readImage();
            }
            ImageView view = new ImageView(image);
            view.setPreserveRatio(false);
            view.setFitWidth(size);
            view.setFitHeight(size);
            view.setUserData(index);
            return view;
        }
    } catch (Exception e) {
        return null;
    }
}
 
源代码2 项目: gef   文件: PolygonLayoutBoundsBug.java
@Override
public void start(Stage primaryStage) throws Exception {
	final Polygon p = new Polygon(10, 30, 20, 20, 20, 40);
	p.setFill(Color.RED);
	p.setStroke(Color.BLACK);

	final Rectangle r = new Rectangle();
	r.setFill(new Color(0, 0, 1, 0.5));
	r.setX(p.getLayoutBounds().getMinX());
	r.setY(p.getLayoutBounds().getMinY());
	r.setWidth(p.getLayoutBounds().getWidth());
	r.setHeight(p.getLayoutBounds().getHeight());

	Group g = new Group(r, p);
	g.getTransforms().add(new Scale(10, 10));
	Scene scene = new Scene(g, 500, 500);
	primaryStage.setScene(scene);
	primaryStage.sizeToScene();
	primaryStage.show();
}
 
源代码3 项目: FXGLGames   文件: StarsComponent.java
private void respawn(Rectangle star) {
    star.setWidth(random(0.5f, 2.5f));
    star.setHeight(random(0.5f, 2.5f));
    star.setArcWidth(random(0.5f, 2.5f));
    star.setArcHeight(random(0.5f, 2.5f));

    star.setFill(Color.color(
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.5f, 1.0f)
    ));

    star.setTranslateX(random(0, FXGL.getAppWidth()));
    star.setTranslateY(-random(10, FXGL.getAppHeight()));
}
 
源代码4 项目: scenic-view   文件: SCUtils.java
static void updateRect(final Parent overlayParent, final Node node, final Bounds bounds, final double tx, final double ty, final Rectangle rect) {
    final Bounds b = toSceneBounds(overlayParent, node, bounds, tx, ty);
    rect.setX(b.getMinX());
    rect.setY(b.getMinY());
    rect.setWidth(b.getMaxX() - b.getMinX());
    rect.setHeight(b.getMaxY() - b.getMinY());
}
 
源代码5 项目: DevToolBox   文件: Piece.java
private Rectangle createPieceRectangle() {
    Rectangle rec = new Rectangle();
    rec.setX(-50);
    rec.setY(-50);
    rec.setWidth(SIZE);
    rec.setHeight(SIZE);
    return rec;
}
 
源代码6 项目: MyBox   文件: ListImageCheckBoxCell.java
private void init() {
    view = new ImageView();
    view.setPreserveRatio(true);
    view.setFitHeight(imageSize);
    rect = new Rectangle();
    rect.setWidth(40);
    rect.setHeight(40);
    Callback<ImageItem, ObservableValue<Boolean>> itemToBoolean
            = (ImageItem item) -> item.getSelected();
    setSelectedStateCallback(itemToBoolean);
}
 
源代码7 项目: games_oop_javafx   文件: SeaBattle.java
private Rectangle buildRectangle(int x, int y, int size) {
    Rectangle rect = new Rectangle();
    rect.setX(x * size);
    rect.setY(y * size);
    rect.setHeight(size);
    rect.setWidth(size);
    rect.setFill(Color.WHITE);
    rect.setStroke(Color.BLACK);
    return rect;
}
 
源代码8 项目: games_oop_javafx   文件: SeaBattle.java
private void buildShip(Group board, int desk, int startX, int startY) {
    Rectangle rect = new Rectangle();
    rect.setX(startX);
    rect.setY(startY);
    rect.setHeight(25);
    rect.setWidth(desk * 25);
    rect.setFill(Color.BLACK);
    rect.setOnMouseDragged(
            event -> {
                rect.setX(event.getX());
                rect.setY(event.getY());
            }
    );
    rect.setOnMouseReleased(
            event -> {
                rect.setX((((int) event.getX() / 25) * 25));
                rect.setY(((int) event.getY() / 25) * 25);
            }
    );
    rect.setOnMouseClicked(
            event -> {
                if (event.getButton() != MouseButton.PRIMARY) {
                    Rectangle momento = new Rectangle(rect.getX(),
                            rect.getY(), rect.getWidth(), rect.getHeight());
                    rect.setWidth(momento.getHeight());
                    rect.setHeight(momento.getWidth());
                }
            }
    );
    board.getChildren().add(rect);
}
 
源代码9 项目: games_oop_javafx   文件: Puzzle.java
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    final Rectangle momento = new Rectangle(x, y);
    rect.setOnDragDetected(
            event -> {
                momento.setX(event.getX());
                momento.setY(event.getY());
            }
    );
    rect.setOnMouseDragged(
            event -> {
                rect.setX(event.getX() - size / 2);
                rect.setY(event.getY() - size / 2);
            }
    );
    rect.setOnMouseReleased(
            event -> {
                if (logic.move(this.extract(momento.getX(), momento.getY()),
                        this.extract(event.getX(), event.getY()))) {
                    rect.setX(((int) event.getX() / 40) * 40 + 5);
                    rect.setY(((int) event.getY() / 40) * 40 + 5);
                    checkWinner();
                } else {
                    rect.setX(((int) momento.getX() / 40) * 40 + 5);
                    rect.setY(((int) momento.getY() / 40) * 40 + 5);
                }
            }
    );
    return rect;
}
 
源代码10 项目: games_oop_javafx   文件: PackMan.java
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    return rect;
}
 
源代码11 项目: gef   文件: BendConnectionPolicyTests.java
@Override
protected void doRefreshVisual(final Rectangle visual) {
	final org.eclipse.gef.geometry.planar.Rectangle rect = ((org.eclipse.gef.geometry.planar.IShape) getContent())
			.getBounds();
	visual.setX(rect.getX());
	visual.setY(rect.getY());
	visual.setWidth(rect.getWidth());
	visual.setHeight(rect.getHeight());
}
 
源代码12 项目: games_oop_javafx   文件: Chess.java
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    final Rectangle momento = new Rectangle(x, y);
    rect.setOnDragDetected(
            event -> {
                momento.setX(event.getX());
                momento.setY(event.getY());
            }
    );
    rect.setOnMouseDragged(
            event -> {
                rect.setX(event.getX() - size / 2);
                rect.setY(event.getY() - size / 2);
            }
    );
    rect.setOnMouseReleased(
            event -> {
                try {
                    logic.move(
                            this.findBy(momento.getX(), momento.getY()),
                            this.findBy(event.getX(), event.getY()));
                    rect.setX(((int) event.getX() / 40) * 40 + 5);
                    rect.setY(((int) event.getY() / 40) * 40 + 5);
                } catch (Exception e) {
                    Alert info = new Alert(Alert.AlertType.ERROR);
                    info.setContentText(e.getClass().getName() +  " "  + e.getMessage());
                    info.show();
                    rect.setX(((int) momento.getX() / 40) * 40 + 5);
                    rect.setY(((int) momento.getY() / 40) * 40 + 5);
                }
            }
    );
    return rect;
}
 
源代码13 项目: oim-fx   文件: MessageItemRight.java
private void initComponent() {
	this.getChildren().add(rootPane);
	rootPane.setTop(timePane);
	rootPane.setLeft(leftBox);
	rootPane.setCenter(centerPane);
	rootPane.setRight(heahBox);
	
	leftBox.setPrefWidth(40);
	
	heahBox.setPrefHeight(20);
	timeLabel.setStyle("-fx-text-fill:#fff;"
			+ "-fx-background-color:#dadada;\r\n" + 
			"   -fx-background-radius:2;-fx-padding: 0 6px;");
	nameLabel.setStyle("-fx-text-fill:rgba(120, 120, 120, 1)");
	double value=38;
	Rectangle clip = new Rectangle();
	clip.setWidth(value);
	clip.setHeight(value);

	clip.setArcHeight(value);
	clip.setArcWidth(value);
	
	StackPane heahPane = new StackPane();
	heahPane.setClip(clip);
	heahPane.getChildren().add(headImageView);
	
	timePane.getChildren().add(timeLabel);
	heahBox.getChildren().add(heahPane);

	headImageView.setFitWidth(40);
	headImageView.setFitHeight(40);

	Polygon polygon = new Polygon(new double[] {

			0, 0,

			10, 10,

			0, 20,

	});

	polygon.setFill(Color.web("rgba(44, 217, 44, 1)"));
	//polygon.setStroke(Color.BLUE);
	//polygon.setStyle("-fx-background-color:rgba(245, 245, 245, 1);");
	VBox arrowBox = new VBox();
	arrowBox.setPadding(new Insets(3, 0, 0, 0));
	arrowBox.setAlignment(Pos.TOP_RIGHT);
	arrowBox.getChildren().add(polygon);
	
	contentBox.setStyle("-fx-background-color:rgba(44, 217, 44, 1);-fx-background-radius:3;");

	centerBox.setAlignment(Pos.CENTER_RIGHT);
	
	centerBox.getChildren().add(contentBox);
	centerBox.getChildren().add(arrowBox);
	
	HBox nameBox=new HBox();
	nameBox.setAlignment(Pos.TOP_RIGHT);
	nameBox.setPadding(new Insets(0, 10, 0, 10));
	nameBox.getChildren().add(nameLabel);
	
	centerPane.setTop(nameBox);
	centerPane.setCenter(centerBox);
}
 
源代码14 项目: JFoenix   文件: JFXRippler.java
protected void setOverLayBounds(Rectangle overlay) {
    overlay.setWidth(control.getLayoutBounds().getWidth());
    overlay.setHeight(control.getLayoutBounds().getHeight());
}
 
源代码15 项目: MyBox   文件: EpidemicReportsSettingsController.java
protected void makeLocationsColors() {
    try {
        colorRects.clear();
        locationColorsBox.getChildren().clear();
        List<GeographyCode> locations = chartController.chartLocations;
        if (locations == null || locationColors == null) {
            return;
        }
        Collections.sort(locations, (GeographyCode p1, GeographyCode p2)
                -> p1.getFullName().compareTo(p2.getFullName()));
        for (int i = 0; i < locations.size(); i++) {
            GeographyCode location = locations.get(i);
            String name = location.getFullName();
            String color = locationColors.get(name);
            Label label = new Label(name);
            Rectangle rect = new Rectangle();
            rect.setWidth(15);
            rect.setHeight(15);
            Color c = Color.web(color);
            rect.setFill(c);
            FxmlControl.setTooltip(rect, new Tooltip(FxmlColor.colorNameDisplay(c)));
            rect.setUserData(name);
            colorRects.add(rect);

            Button button = new Button();
            ImageView image = new ImageView(ControlStyle.getIcon("iconPalette.png"));
            image.setFitWidth(AppVariables.iconSize);
            image.setFitHeight(AppVariables.iconSize);
            button.setGraphic(image);
            button.setOnAction((ActionEvent event) -> {
                showPalette(button, message("Settings") + " - " + name);
            });
            button.setUserData(i);
            VBox.setMargin(button, new Insets(0, 0, 0, 15));
            FxmlControl.setTooltip(button, message("Palette"));

            HBox line = new HBox();
            line.setAlignment(Pos.CENTER_LEFT);
            line.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            line.setSpacing(5);
            VBox.setVgrow(line, Priority.ALWAYS);
            HBox.setHgrow(line, Priority.ALWAYS);
            line.getChildren().addAll(label, rect, button);

            locationColorsBox.getChildren().add(line);
        }
    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
源代码16 项目: Intro-to-Java-Programming   文件: Exercise_16_03.java
@Override // Override the start method in the Application calss
public void start(Stage primaryStage) {
	// Create a vbox
	VBox paneForCircles = new VBox(5);
	paneForCircles.setAlignment(Pos.CENTER);

	// Create three circles
	Circle c1 = getCircle();
	Circle c2 = getCircle();
	Circle c3 = getCircle();
	c1.setFill(Color.RED);

	// Place circles in vbox
	paneForCircles.getChildren().addAll(c1, c2, c3);

	// Create a rectangle
	Rectangle rectangle = new Rectangle();
	rectangle.setFill(Color.WHITE);
	rectangle.setWidth(30);
	rectangle.setHeight(100);
	rectangle.setStroke(Color.BLACK);
	rectangle.setStrokeWidth(2);
	StackPane stopSign = new StackPane(rectangle, paneForCircles);

	// Create a hbox
	HBox paneForRadioButtons = new HBox(5);
	paneForRadioButtons.setAlignment(Pos.CENTER);

	// Create radio buttons
	RadioButton rbRed = new RadioButton("Red");
	RadioButton rbYellow = new RadioButton("Yellow");
	RadioButton rbGreen = new RadioButton("Green");

	// Create a toggle group
	ToggleGroup group = new ToggleGroup();
	rbRed.setToggleGroup(group);
	rbYellow.setToggleGroup(group);
	rbGreen.setToggleGroup(group);
	rbRed.setSelected(true);
	paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbGreen);

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setCenter(stopSign);
	pane.setBottom(paneForRadioButtons);

	// Create and register handlers
	rbRed.setOnAction(e -> {
		if (rbRed.isSelected()) {
			c1.setFill(Color.RED);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.WHITE);
		}
	});

	rbYellow.setOnAction(e -> {
		if (rbYellow.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.YELLOW);
			c3.setFill(Color.WHITE);
		}
	});

	rbGreen.setOnAction(e -> {
		if (rbGreen.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.GREEN);
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 150);
	primaryStage.setTitle("Exercise_16_03"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码17 项目: netbeans   文件: Level.java
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
源代码18 项目: marathonv5   文件: Level.java
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
源代码19 项目: gef   文件: RectangleSegmentHandlePart.java
/**
 * Updates the color of this part's visualization. If this handle part
 * represents a way or end point of an {@link Connection}, it's color will
 * be set to indicate whether the handle is connected to another part or
 * not.
 */
protected void updateColor() {
	// only update when bound to anchorage
	SetMultimap<IVisualPart<? extends Node>, String> anchorages = getAnchoragesUnmodifiable();
	if (getRoot() == null || anchorages.keySet().size() != 1) {
		return;
	}

	Rectangle visual = getVisual();
	// no need to update the color if we are invisible
	if (!visual.isVisible()) {
		return;
	}

	if (getSegmentParameter() == 0.5) {
		// move handle in the middle of a segment
		visual.setFill(getMoveFill());
	} else if (getSegmentParameter() != 0.0
			&& getSegmentParameter() != 1.0) {
		// quarter handles (creation)
		visual.setFill(getInsertFill());
		visual.setWidth(DEFAULT_LENGTH * 4d / 5d);
		visual.setHeight(DEFAULT_WIDTH * 4d / 5d);
		visual.setTranslateX(-DEFAULT_LENGTH / 2d + DEFAULT_LENGTH / 10d);
		visual.setTranslateY(-DEFAULT_WIDTH / 2d + DEFAULT_WIDTH / 10d);
	} else {
		visual.setTranslateX(-DEFAULT_LENGTH / 2);
		visual.setTranslateY(-DEFAULT_WIDTH / 2);
		visual.setWidth(DEFAULT_LENGTH);
		visual.setHeight(DEFAULT_WIDTH);
		// end point handles
		boolean connected = false;
		IVisualPart<? extends Node> targetPart = anchorages.keySet()
				.iterator().next();
		if (targetPart.getVisual() instanceof Connection) {
			Connection connection = (Connection) targetPart.getVisual();
			if (getSegmentIndex() + getSegmentParameter() == 0.0) {
				// handle at start point
				connected = connection.isStartConnected();
			} else if (getSegmentParameter()
					+ getSegmentIndex() == getSegmentsInScene().length) {
				// handle at end point
				connected = connection.isEndConnected();
			}
		}
		// update color according to connected state
		if (connected) {
			visual.setFill(getConnectedFill());
		} else {
			visual.setFill(getMoveFill());
		}
	}
}
 
源代码20 项目: marathonv5   文件: Level.java
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}