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

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

源代码1 项目: marathonv5   文件: StrokeTransitionSample.java
public StrokeTransitionSample() {
    super(150,150);
    Rectangle rect = new Rectangle(0, 0, 150, 150);
    rect.setArcHeight(20);
    rect.setArcWidth(20);
    rect.setFill(null);
    rect.setStroke(Color.DODGERBLUE);
    rect.setStrokeWidth(10);
    getChildren().add(rect);
    
    strokeTransition = StrokeTransitionBuilder.create()
        .duration(Duration.seconds(3))
        .shape(rect)
        .fromValue(Color.RED)
        .toValue(Color.DODGERBLUE)
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(true)
        .build();
}
 
源代码2 项目: mzmine3   文件: ColorPalettePreviewField.java
private void setRectangles() {
  rects.clear();

  if (palette == null || palette.isEmpty()) {
    return;
  }

  for (int i = 0; i < palette.size(); i++) {
    Color clr = palette.get(i);
    Rectangle rect = new DraggableRectangle(RECT_HEIGHT - STROKE_WIDTH / 2,
        RECT_HEIGHT - STROKE_WIDTH / 2);

    rects.add(rect);

    rect.setFill(clr);
    rect.setStroke(STROKE_CLR_DEFAULT);
    rect.setStrokeWidth(STROKE_WIDTH);

    rect.setOnMousePressed(e -> {
      setSelected(rect);
    });
  }
}
 
源代码3 项目: JavaFX   文件: KeyboardExample.java
public Node createNode() {
	final StackPane keyNode = new StackPane();
	keyNode.setFocusTraversable(true);
	installEventHandler(keyNode);

	final Rectangle keyBackground = new Rectangle(50, 50);
	keyBackground.fillProperty().bind(
			Bindings.when(pressedProperty)
					.then(Color.RED)
					.otherwise(
							Bindings.when(keyNode.focusedProperty())
									.then(Color.LIGHTGRAY)
									.otherwise(Color.WHITE)));
	keyBackground.setStroke(Color.BLACK);
	keyBackground.setStrokeWidth(2);
	keyBackground.setArcWidth(12);
	keyBackground.setArcHeight(12);

	final Text keyLabel = new Text(keyCode.getName());
	keyLabel.setFont(Font.font("Arial", FontWeight.BOLD, 20));

	keyNode.getChildren().addAll(keyBackground, keyLabel);

	return keyNode;
}
 
源代码4 项目: jfxutils   文件: JFXChartUtil.java
/**
 * Convenience method for simple and default setup of zooming on an {@link XYChart} via a
 * {@link ChartZoomManager}. Wraps the chart in the components required to implement zooming. The
 * current implementation wraps the chart in a StackPane, which has the chart and a blue
 * translucent rectangle as children. Returns the top level of the created components.
 * <p>
 * If the chart already has a parent, that parent must be a {@link Pane}, and the chart is
 * replaced with the wrapping region, and the return value could be ignored. If the chart does
 * not have a parent, the same wrapping node is returned, which will need to be added to some
 * parent.
 * <p>
 * The chart's axes must both be a type of ValueAxis.
 * <p>
 * The wrapping logic does not seem to be perfect, in fact there is a special case to handle
 * {@link BorderPane}s. If it's not found to be reliable, then create the wrapping components
 * yourself (such as in the FXML), or setup zooming before adding it to a parent.
 *
 * @param mouseFilter EventHandler that consumes events that should not trigger a zoom action
 *
 * @return The top-level Region
 */
public static Region setupZooming( XYChart<?, ?> chart,
                                   EventHandler<? super MouseEvent> mouseFilter ) {
	StackPane chartPane = new StackPane();

	if ( chart.getParent() != null )
		JFXUtil.replaceComponent( chart, chartPane );

	Rectangle selectRect = new Rectangle( 0, 0, 0, 0 );
	selectRect.setFill( Color.DODGERBLUE );
	selectRect.setMouseTransparent( true );
	selectRect.setOpacity( 0.3 );
	selectRect.setStroke( Color.rgb( 0, 0x29, 0x66 ) );
	selectRect.setStrokeType( StrokeType.INSIDE );
	selectRect.setStrokeWidth( 3.0 );
	StackPane.setAlignment( selectRect, Pos.TOP_LEFT );

	chartPane.getChildren().addAll( chart, selectRect );

	ChartZoomManager zoomManager = new ChartZoomManager( chartPane, selectRect, chart );
	zoomManager.setMouseFilter( mouseFilter );
	zoomManager.start();
	return chartPane;
}
 
源代码5 项目: FXGLGames   文件: SpaceInvadersFactory.java
@Spawns("LaserBeam")
public Entity newLaserBeam(SpawnData data) {
    Rectangle view = new Rectangle(10, Config.HEIGHT - 25, Color.color(1.0, 1.0, 1.0, 0.86));
    view.setArcWidth(15);
    view.setArcHeight(15);
    view.setStroke(Color.BLUE);
    view.setStrokeWidth(1);

    return entityBuilder()
            .from(data)
            .type(LASER_BEAM)
            .viewWithBBox(view)
            .with(new CollidableComponent(true))
            .with(new LaserBeamComponent())
            .build();
}
 
源代码6 项目: constellation   文件: OverviewPanel.java
/**
 * Helper method that creates and styles a POV object.
 *
 * The POV object is a styled rectangle that is used to indicate the
 * currently observed time range (aka time extent) on the timeline. It can
 * also be used to quickly interact with the time extent.
 *
 * @return A formatted POV object.
 */
private Rectangle createPOV() {
    final Rectangle rect = new Rectangle(135, 25, 60, 1);

    // Bind the height of the POV to the Height of the histogram:
    rect.yProperty().bind(histogram.heightProperty());
    rect.heightProperty().bind(innerPane.prefHeightProperty());
    rect.setManaged(true);

    // Style the rectangle:
    rect.setStroke(Color.DODGERBLUE);
    rect.setStrokeWidth(2d);
    final LinearGradient gradient
            = new LinearGradient(0.0, 0.0, 0.0, 0.5, true, CycleMethod.NO_CYCLE, new Stop[]{
        new Stop(0, Color.LIGHTBLUE.darker()),
        new Stop(1, Color.TRANSPARENT)
    });
    rect.setFill(gradient);
    rect.setSmooth(true);

    // Round the edges of the rectangle:
    rect.setArcWidth(5.0);
    rect.setArcHeight(5.0);

    // Set the POV mouse event handlers:
    final POVMouseEventHandler handler = new POVMouseEventHandler(rect);
    rect.setOnMouseMoved(handler);
    rect.setOnMousePressed(handler);
    rect.setOnMouseDragged(handler);
    rect.setOnMouseReleased(handler);

    // Make the POV object the top-most object on this panel:
    rect.toFront();

    return rect;
}
 
源代码7 项目: mzmine3   文件: ColorPaletteCell.java
protected Rectangle makeRect(@Nonnull Color clr) {
  Rectangle rect = new Rectangle(height - STROKE_WIDTH * 2, height - STROKE_WIDTH * 2);
  rect.setFill(clr);
  rect.setStroke(STROKE_CLR);
  rect.setStrokeWidth(STROKE_WIDTH);
  return rect;
}
 
源代码8 项目: FXTutorials   文件: DesktopApp.java
DesktopIcon(String name, Class<? extends Application> appClass) {
    this.name = name;
    this.appClass = appClass;

    Rectangle bg = new Rectangle(100, 100, null);
    bg.setStroke(Color.BLACK);
    bg.setStrokeWidth(2.5);

    Text text = new Text(name);

    getChildren().addAll(bg, text);
}
 
源代码9 项目: latexdraw   文件: PageView.java
/**
 * Creates a view of a page.
 * @param origin The origin point where the page has to be placed. Cannot be null.
 */
public PageView(final @NotNull PreferencesService prefs, final Point origin) {
	super();

	recPage = new Rectangle();
	recShadowBottom = new Rectangle();
	recShadowRight = new Rectangle();

	recPage.setStrokeWidth(1d);
	recPage.setStroke(Color.BLACK);
	recPage.setFill(null);
	recPage.setX(origin.getX());
	recPage.setY(origin.getY());

	recShadowRight.setStroke(null);
	recShadowBottom.setStroke(null);
	recShadowRight.setFill(Color.GRAY);
	recShadowBottom.setFill(Color.GRAY);

	getChildren().add(recShadowBottom);
	getChildren().add(recShadowRight);
	getChildren().add(recPage);

	recPage.toFront();
	setMouseTransparent(true);
	setFocusTraversable(false);

	update(prefs.getPage());
	prefs.pageProperty().addListener((observable, oldValue, newValue) -> update(newValue));
}
 
源代码10 项目: marathonv5   文件: RectangleSample.java
public static Node createIconContent() {
    Rectangle rectangle = new Rectangle(40,40);
    rectangle.setStroke(Color.web("#b9c0c5"));
    rectangle.setStrokeWidth(5);
    rectangle.getStrokeDashArray().addAll(15d,15d);
    rectangle.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));
    rectangle.setEffect(effect);
    return rectangle;
}
 
源代码11 项目: netbeans   文件: StopWatch.java
private Rectangle createBackground(Color stroke, Color fill) {
    Rectangle background = new Rectangle(14, 17, fill);
    background.setStroke(stroke);
    background.setStrokeWidth(2);
    background.setEffect(new Lighting());
    background.setCache(true);
    return background;
}
 
源代码12 项目: FXGLGames   文件: SpaceLevel.java
public SpaceLevel() {
    Rectangle bg = new Rectangle(getAppWidth() - 20, 200, Color.color(0, 0, 0, 0.6));
    bg.setArcWidth(25);
    bg.setArcHeight(25);
    bg.setStroke(Color.color(0.1, 0.2, 0.86, 0.76));
    bg.setStrokeWidth(3);

    storyPane.setTranslateX(10);
    storyPane.setTranslateY(25);

    rootPane = new Pane(bg, storyPane);
    rootPane.setTranslateX(10);
    rootPane.setTranslateY(getAppHeight() - 200);
}
 
源代码13 项目: marathonv5   文件: ScaleSample.java
public ScaleSample() {
    super(180,180);
    // simple rectangle
    Rectangle rect1 = new Rectangle(0, 25, 25, 25);
    rect1.setArcHeight(15);
    rect1.setArcWidth(15);
    rect1.setFill(Color.WHITE);
    rect1.setStroke(Color.DODGERBLUE);
    rect1.setStrokeWidth(3);
    
    Polygon arrow = createArrow();
    arrow.setLayoutX(46);
    arrow.setLayoutY(22);
    arrow.setRotate(90);
    
    // simple rectangle with scale 2 in X axis and 0.5 in Y
    Rectangle rect2 = new Rectangle(95, 25, 25, 25);
    rect2.setArcHeight(15);
    rect2.setArcWidth(15);
    rect2.setFill(Color.WHITE);
    rect2.setStroke(Color.DODGERBLUE);
    rect2.setStrokeWidth(3);
    rect2.setScaleX(2);
    rect2.setScaleY(0.5);
    // rectangle with adjustable scale
    Rectangle rect3 = new Rectangle(40, 130, 25, 25);
    rect3.setArcHeight(15);
    rect3.setArcWidth(15);
    rect3.setFill(Color.WHITE);
    rect3.setStroke(Color.DODGERBLUE);
    rect3.setStrokeWidth(3);
    rect3.setScaleX(6);
    rect3.setScaleY(0.5);
    rect3.setTranslateX(rect3.getTranslateX()+30);
    //getChildren().addAll(rect1, rect2, rect3);
    getChildren().addAll(rect1, arrow, rect2, rect3);
    
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d),
            new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d)
    );
    // END REMOVE ME
}
 
源代码14 项目: marathonv5   文件: StopWatchSample.java
private Rectangle createDotBackground() {
    Rectangle background = new Rectangle(8, 17, Color.TRANSPARENT);
    background.setStroke(Color.TRANSPARENT);
    background.setStrokeWidth(2);
    return background;
}
 
源代码15 项目: 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
}
 
源代码16 项目: marathonv5   文件: ScaleSample.java
public ScaleSample() {
    super(180,180);
    // simple rectangle
    Rectangle rect1 = new Rectangle(0, 25, 25, 25);
    rect1.setArcHeight(15);
    rect1.setArcWidth(15);
    rect1.setFill(Color.WHITE);
    rect1.setStroke(Color.DODGERBLUE);
    rect1.setStrokeWidth(3);
    
    Polygon arrow = createArrow();
    arrow.setLayoutX(46);
    arrow.setLayoutY(22);
    arrow.setRotate(90);
    
    // simple rectangle with scale 2 in X axis and 0.5 in Y
    Rectangle rect2 = new Rectangle(95, 25, 25, 25);
    rect2.setArcHeight(15);
    rect2.setArcWidth(15);
    rect2.setFill(Color.WHITE);
    rect2.setStroke(Color.DODGERBLUE);
    rect2.setStrokeWidth(3);
    rect2.setScaleX(2);
    rect2.setScaleY(0.5);
    // rectangle with adjustable scale
    Rectangle rect3 = new Rectangle(40, 130, 25, 25);
    rect3.setArcHeight(15);
    rect3.setArcWidth(15);
    rect3.setFill(Color.WHITE);
    rect3.setStroke(Color.DODGERBLUE);
    rect3.setStrokeWidth(3);
    rect3.setScaleX(6);
    rect3.setScaleY(0.5);
    rect3.setTranslateX(rect3.getTranslateX()+30);
    //getChildren().addAll(rect1, rect2, rect3);
    getChildren().addAll(rect1, arrow, rect2, rect3);
    
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d),
            new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d)
    );
    // END REMOVE ME
}
 
源代码17 项目: marathonv5   文件: StopWatchSample.java
private Rectangle createDotBackground() {
    Rectangle background = new Rectangle(8, 17, Color.TRANSPARENT);
    background.setStroke(Color.TRANSPARENT);
    background.setStrokeWidth(2);
    return background;
}
 
源代码18 项目: marathonv5   文件: ToggleButtonSample.java
@Override
public void start(Stage stage) {
    stage.setTitle("Toggle Button Sample");
    stage.setWidth(250);
    stage.setHeight(180);

    HBox hbox = new HBox();
    VBox vbox = new VBox();

    Scene scene = new Scene(new Group(vbox));
    stage.setScene(scene);
    scene.getStylesheets().add("togglebuttonsample/ControlStyle.css");

    Rectangle rect = new Rectangle();
    rect.setHeight(50);
    rect.setFill(Color.WHITE);
    rect.setStroke(Color.DARKGRAY);
    rect.setStrokeWidth(2);
    rect.setArcHeight(10);
    rect.setArcWidth(10);

    final ToggleGroup group = new ToggleGroup();

    group.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) -> {
        if (new_toggle == null)
            rect.setFill(Color.WHITE);
        else
            rect.setFill((Color) group.getSelectedToggle().getUserData());
    });

    ToggleButton tb1 = new ToggleButton("Minor");
    tb1.setToggleGroup(group);
    tb1.setUserData(Color.LIGHTGREEN);
    tb1.setSelected(true);
    tb1.getStyleClass().add("toggle-button1");

    ToggleButton tb2 = new ToggleButton("Major");
    tb2.setToggleGroup(group);
    tb2.setUserData(Color.LIGHTBLUE);
    tb2.getStyleClass().add("toggle-button2");

    ToggleButton tb3 = new ToggleButton("Critical");
    tb3.setToggleGroup(group);
    tb3.setUserData(Color.SALMON);
    tb3.getStyleClass().add("toggle-button3");

    hbox.getChildren().addAll(tb1, tb2, tb3);

    vbox.getChildren().add(new Label("Priority:"));
    vbox.getChildren().add(hbox);
    vbox.getChildren().add(rect);
    vbox.setPadding(new Insets(20, 10, 10, 20));

    stage.show();
    rect.setWidth(hbox.getWidth());
}
 
源代码19 项目: netbeans   文件: StopWatch.java
private Rectangle createDotBackground() {
    Rectangle background = new Rectangle(8, 17, Color.TRANSPARENT);
    background.setStroke(Color.TRANSPARENT);
    background.setStrokeWidth(2);
    return background;
}
 
源代码20 项目: oim-fx   文件: TextFlowApp.java
public Parent createContent() {

		String family = "Helvetica";

		double size = 20;

		// Simple example

		textFlow = new TextFlow();
		
		textHello = new Text("Hello ");

		textHello.setFont(Font.font(family, size));
		textBold = new Text("Bold");
		textBold.setFont(Font.font(family, FontWeight.BOLD, size));
		textWorld = new Text(" World");
		textWorld.setFont(Font.font(family, FontPosture.ITALIC, size));
		textFlow.getChildren().addAll(textHello, textBold, textWorld);

		// Example with embedded objects

		TextFlow textFlowEmbedObj = new TextFlow();
		Text textEO1 = new Text("Lets have ");
		textEO1.setFont(Font.font(family, size));
		Text textEO2 = new Text("embedded objects: a Rectangle ");

		textEO2.setFont(Font.font(family, FontWeight.BOLD, size));

		Rectangle rect = new Rectangle(80, 60);

		rect.setFill(null);
		rect.setStroke(Color.GREEN);
		rect.setStrokeWidth(5);
		Text textEO3 = new Text(", then a button ");

		Button button = new Button("click me");
		Text textEO4 = new Text(", and finally an image ");

		ImageView imageView = new ImageView(image);
		Text textEO5 = new Text(".");

		textEO5.setFont(Font.font(family, size));

		textFlowEmbedObj.getChildren().addAll(textEO1, textEO2, rect, textEO3, button, textEO4, imageView, textEO5);

		VBox vbox = new VBox(18);

		VBox.setMargin(textFlow, new Insets(5, 5, 0, 5));

		VBox.setMargin(textFlowEmbedObj, new Insets(0, 5, 5, 5));

		vbox.getChildren().addAll(textFlow, textFlowEmbedObj);
		return vbox;

	}