当前位置: 首页>>代码示例>>Java>>正文


Java Ellipse.setCenterX方法代码示例

本文整理汇总了Java中javafx.scene.shape.Ellipse.setCenterX方法的典型用法代码示例。如果您正苦于以下问题:Java Ellipse.setCenterX方法的具体用法?Java Ellipse.setCenterX怎么用?Java Ellipse.setCenterX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.shape.Ellipse的用法示例。


在下文中一共展示了Ellipse.setCenterX方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encloseLabelWithOval

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
private Group encloseLabelWithOval(DrawingEntity entity, Label label) {
    Ellipse ellipse = new Ellipse();
    ellipse.getStyleClass().add("outline");
    ellipse.setFill(entity.getColor());

    ellipse.setCenterX(0);
    ellipse.setCenterY(0);

    int insets = 5;

    label.boundsInLocalProperty().addListener((observable, oldValue, newValue) -> {
        double halfWidth = newValue.getWidth() / 2;
        double halfHeight = newValue.getHeight() / 2;
        label.setLayoutX(-halfWidth);
        label.setLayoutY(-halfHeight);
        // Calculate the relevant radii of the ellipse while maintaining
        // aspect ratio.
        // Thanks: http://stackoverflow.com/questions/433371/ellipse-bounding-a-rectangle
        ellipse.setRadiusX((halfWidth + insets) * SQRT2);
        ellipse.setRadiusY((halfHeight + insets) * SQRT2);
    });

    return new Group(ellipse, label);
}
 
开发者ID:fuzzyBSc,项目名称:systemdesign,代码行数:25,代码来源:FXMLDrawingNode.java

示例2: start

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws IOException {
	Group root = new Group();
	// describes the window itself: name, size
	primaryStage.setTitle(" Aufgabe 10 by John Malc ");
	primaryStage.setScene(new Scene(root));
	// say: center on screen, user can resize, and it will in general exists
	primaryStage.centerOnScreen();
	primaryStage.setResizable(true);
	primaryStage.show();

	// Ellipse alone
	Ellipse a = new Ellipse();
	a.setFill(Color.RED);
	a.setCenterX(205);
	a.setCenterY(150);
	a.setRadiusX(80);
	a.setRadiusY(30);

	// shows Ellipse and it will add it to the group
	root.getChildren().add(new Group(a));
}
 
开发者ID:dmpe,项目名称:JavaFX,代码行数:23,代码来源:Main.java

示例3: addLEDs

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
private void addLEDs(final Pane pane, final int w, final int h, final boolean horizontal)
{
    final int save_bits = numBits;
    final boolean save_sq = square_led;
    final Color [] save_colorVals = value_colors;
    final Shape [] leds = new Shape[save_bits];
    for (int i = 0; i < save_bits; i++)
    {
        final Shape led;
        if (save_sq)
        {
            final Rectangle rect = new Rectangle();
            rect.setX(horizontal ? i*w/save_bits : 0);
            rect.setY(horizontal ? 0 : i*h/save_bits);
            rect.setWidth(horizontal ? w/save_bits : w);
            rect.setHeight(horizontal ? h : h/save_bits);
            led = rect;
        }
        else
        {
            final Ellipse ell = new Ellipse();
            final int dh = horizontal ? w/save_bits : w;
            final int dv = horizontal ? h : h/save_bits;
            ell.setCenterX(horizontal ? dh/2 + i*dh : dh/2);
            ell.setCenterY(horizontal ? dv/2 : dv/2 + i*dv);
            ell.setRadiusX(dh/2);
            ell.setRadiusY(dv/2);
            led = ell;
        }
        led.getStyleClass().add("led");
        if (save_colorVals != null && i < save_colorVals.length)
            led.setFill( makeGradient(save_colorVals[i]) );
        leds[i] = led;
    }
    this.leds = leds;
    pane.getChildren().clear();
    pane.getChildren().addAll(leds);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:39,代码来源:ByteMonitorRepresentation.java

示例4: draw

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
@Override
public void draw(Group g) {
	DropShadow ds = new DropShadow();
	ds.setOffsetY(3.0);
	ds.setColor(Color.color(0.4, 0.4, 0.4));

	Ellipse ellipse = new Ellipse();
	ellipse.setCenterX(50.0f);
	ellipse.setCenterY(50.0f);
	ellipse.setRadiusX(50.0f);
	ellipse.setRadiusY(25.0f);
	ellipse.setFill(Color.RED);
	ellipse.setStroke(Color.BLACK);
	ellipse.setEffect(ds);
	g.getChildren().add(ellipse);

	g.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {

		if (ev.getClickCount() == 2 && MouseButton.PRIMARY == ev.getButton()) {
			if (ev.isConsumed())
				return;

			if (ellipse.getUserData() != null)
				return;

			JFXColorPicker picker = new JFXColorPicker();
			picker.setValue((Color) ellipse.getFill());
			picker.valueProperty().addListener(new ChangeListener<Color>() {

				@Override
				public void changed(ObservableValue<? extends Color> observable, Color oldValue, Color newValue) {
					ellipse.setFill(newValue);
				}
			});

			FxUtil.createStageAndShow(" select color ", picker, stage -> {

				ellipse.setUserData(new Object());

				stage.setAlwaysOnTop(true);

				stage.setOnCloseRequest(se -> {
					ellipse.setUserData(null);
				});
			});

			ev.consume();
		}
	});
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:51,代码来源:EllipseDrawItemSkin.java

示例5: updateChanges

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
@Override
public void updateChanges()
{
    if (typeChanged.checkAndClear())
    {
        createLED();
        styleChanged.mark();
        dirty_content.mark();
    }
    super.updateChanges();
    if (styleChanged.checkAndClear())
    {
        final Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        label.setTextFill(color);
        label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));

        final int w = model_widget.propWidth().getValue();
        final int h = model_widget.propHeight().getValue();

        jfx_node.setPrefSize(w, h);
        if (led instanceof Ellipse)
        {
            final Ellipse ell = (Ellipse) led;
            ell.setCenterX(w/2);
            ell.setCenterY(h/2);
            ell.setRadiusX(w/2);
            ell.setRadiusY(h/2);
        }
        else if (led instanceof Rectangle)
        {
            final Rectangle rect = (Rectangle) led;
            rect.setWidth(w);
            rect.setHeight(h);
        }
        label.setPrefSize(w, h);
    }
    if (dirty_content.checkAndClear())
    {
        led.setFill(
            // Put highlight in top-left corner, about 0.2 wide,
            // relative to actual size of LED
            new RadialGradient(0, 0, 0.3, 0.3, 0.4, true, CycleMethod.NO_CYCLE,
                               new Stop(0, value_color.interpolate(Color.WHITESMOKE, 0.8)),
                               new Stop(1, value_color)));
        label.setText(value_label);
    }
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:48,代码来源:BaseLEDRepresentation.java

示例6: start

import javafx.scene.shape.Ellipse; //导入方法依赖的package包/类
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a stack pane
	StackPane stackPane = new StackPane();
	StackPane stackPane2 = new StackPane();

	// Crate a pane
	Pane pane = new Pane();
	stackPane2.setPadding(new Insets(40, 40, 40, 40));

	// Create a circle and place it in a stack pane
	Circle circle = getCircle();
	stackPane.getChildren().add(circle);

	// Create a Polygon and place it in a stack pane
	Polygon polygon = getPolygon(circle);
	stackPane.getChildren().add(polygon);

	// Create two ellipse
	Ellipse ellipse1 = getEllipse(circle); 
	ellipse1.setCenterX(circle.getRadius() - circle.getRadius() / 2.5);
	Ellipse ellipse2 = getEllipse(circle); 
	ellipse2.setCenterX(circle.getRadius() + circle.getRadius() / 2.5);

	// Create two circles
	Circle circle2 = getCircle(ellipse1);
	Circle circle3 = getCircle(ellipse2);

	// Create an Arc
	Arc arc = getArc(circle);

	// Place nodes in a pane
	pane.getChildren().addAll(stackPane, ellipse1, 
		ellipse2, circle2, circle3, arc);

	// Place pane in a stack pane
	stackPane2.getChildren().add(pane);


	// Create a scene and place it in the stage
	Scene scene = new Scene(stackPane2);
	primaryStage.setTitle("Exercise_14_11"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:46,代码来源:Exercise_14_11.java


注:本文中的javafx.scene.shape.Ellipse.setCenterX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。