Search in sources :

Example 16 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class ScriptSample2 method initGame.

@Override
protected void initGame() {
    Entity e = Entities.builder().type(EntityType.PC).at(300, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.BLUE)).with(new CollidableComponent(true)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
    Entities.builder().type(EntityType.NPC).at(400, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.RED)).with(new CollidableComponent(true)).buildAndAttach(getGameWorld());
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Entity(com.almasb.fxgl.entity.Entity) CollidableComponent(com.almasb.fxgl.entity.component.CollidableComponent) Rectangle(javafx.scene.shape.Rectangle)

Example 17 with Rectangle

use of javafx.scene.shape.Rectangle in project Board-Instrumentation-Framework by intel.

the class LcdClockSkin method initGraphics.

private void initGraphics() {
    main = new Region();
    main.getStyleClass().setAll("main");
    main.setOpacity(getSkinnable().isBackgroundVisible() ? 1 : 0);
    mainInnerShadow0 = new InnerShadow();
    mainInnerShadow0.setOffsetX(0.0);
    mainInnerShadow0.setOffsetY(0.0);
    mainInnerShadow0.setRadius(3.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow0.setColor(Color.web("0xffffff80"));
    mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1 = new InnerShadow();
    mainInnerShadow1.setOffsetX(0.0);
    mainInnerShadow1.setOffsetY(1.0);
    mainInnerShadow1.setRadius(2.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow1.setColor(Color.web("0x000000a6"));
    mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1.setInput(mainInnerShadow0);
    main.setEffect(getSkinnable().isMainInnerShadowVisible() ? mainInnerShadow1 : null);
    crystalClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT);
    crystalClip.setArcWidth(5);
    crystalClip.setArcHeight(5);
    crystalImage = createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8);
    crystalOverlay = new ImageView(crystalImage);
    crystalOverlay.setClip(this.crystalClip);
    crystalOverlay.setOpacity(getSkinnable().isCrystalOverlayVisible() ? 1 : 0);
    alarm = new Region();
    alarm.getStyleClass().setAll("alarm");
    alarm.setOpacity(getSkinnable().getAlarms().isEmpty() || allAlarmsInactive() ? 0 : 1);
    backgroundTimeText = new Text("");
    backgroundTimeText.getStyleClass().setAll("fg-trsp");
    backgroundTimeText.setOpacity((LcdClock.LcdFont.LCD == getSkinnable().getTimeFont() || LcdClock.LcdFont.ELEKTRA == getSkinnable().getTimeFont()) ? 1 : 0);
    timeText = new Text("");
    timeText.getStyleClass().setAll("fg");
    backgroundSecondText = new Text("");
    backgroundSecondText.getStyleClass().setAll("fg-trsp");
    backgroundSecondText.setOpacity((LcdClock.LcdFont.LCD == getSkinnable().getTimeFont() || LcdClock.LcdFont.ELEKTRA == getSkinnable().getTimeFont()) ? 1 : 0);
    secondText = new Text("");
    secondText.getStyleClass().setAll("fg");
    title = new Text(getSkinnable().getTitle());
    title.getStyleClass().setAll("fg");
    dateText = new Text(getSkinnable().getTime().getMonthValue() + "/" + getSkinnable().getTime().getDayOfMonth() + "/" + getSkinnable().getTime().getYear());
    dateText.getStyleClass().setAll("fg");
    dayOfWeekText = new Text("");
    dayOfWeekText.getStyleClass().setAll("fg");
    shadowGroup = new Group();
    shadowGroup.setEffect(getSkinnable().isForegroundShadowVisible() ? FOREGROUND_SHADOW : null);
    shadowGroup.getChildren().setAll(alarm, timeText, secondText, title, dateText, dayOfWeekText);
    pane = new Pane();
    pane.getChildren().setAll(main, crystalOverlay, backgroundTimeText, backgroundSecondText, shadowGroup);
    getChildren().setAll(pane);
    resize();
    updateLcd();
}
Also used : Group(javafx.scene.Group) InnerShadow(javafx.scene.effect.InnerShadow) Rectangle(javafx.scene.shape.Rectangle) Region(javafx.scene.layout.Region) Text(javafx.scene.text.Text) ImageView(javafx.scene.image.ImageView) Pane(javafx.scene.layout.Pane)

Example 18 with Rectangle

use of javafx.scene.shape.Rectangle in project org.csstudio.display.builder by kasemir.

the class BaseLEDRepresentation method createLED.

private void createLED() {
    jfx_node.getChildren().clear();
    if (model_widget.propSquare().getValue())
        led = new Rectangle();
    else
        led = new Ellipse();
    led.getStyleClass().add("led");
    label = new Label();
    label.getStyleClass().add("led_label");
    label.setAlignment(Pos.CENTER);
    jfx_node.getChildren().addAll(led, label);
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Rectangle(javafx.scene.shape.Rectangle) Label(javafx.scene.control.Label)

Example 19 with Rectangle

use of javafx.scene.shape.Rectangle in project org.csstudio.display.builder by kasemir.

the class ByteMonitorRepresentation method addLEDs.

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);
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Shape(javafx.scene.shape.Shape) Color(javafx.scene.paint.Color) Rectangle(javafx.scene.shape.Rectangle)

Example 20 with Rectangle

use of javafx.scene.shape.Rectangle in project org.csstudio.display.builder by kasemir.

the class TabDemo method start.

@Override
public void start(final Stage stage) {
    // TabPane with some tabs
    final TabPane tabs = new TabPane();
    tabs.setStyle("-fx-background-color: red;");
    for (int i = 0; i < 3; ++i) {
        final Rectangle rect = new Rectangle(i * 100, 100, 10 + i * 100, 20 + i * 80);
        rect.setFill(Color.BLUE);
        final Pane content = new Pane(rect);
        final Tab tab = new Tab("Tab " + (i + 1), content);
        tab.setClosable(false);
        tabs.getTabs().add(tab);
    }
    tabs.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
    tabs.setPrefSize(400, 300);
    final Group widgets = new Group(tabs);
    widgets.setScaleX(0.5);
    widgets.setScaleY(0.5);
    final Group scroll_content = new Group(widgets);
    final ScrollPane scroll = new ScrollPane(scroll_content);
    final Scene scene = new Scene(scroll);
    stage.setTitle("Tab Demo");
    stage.setScene(scene);
    stage.show();
    // Unfortunately, the setup of ScrollPane -> Group -> Group -> TabPane
    // breaks the rendering of the TabPane.
    // While the red background shows the area occupied by TabPane,
    // the actual Tabs are missing..
    System.out.println("See anything?");
    scene.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.getCode() == KeyCode.SPACE) {
            // .. until 'side' or 'tabMinWidth' or .. are twiddled to force a refresh
            tabs.setSide(Side.BOTTOM);
            tabs.setSide(Side.TOP);
            System.out.println("See it now?");
        }
    });
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) TabPane(javafx.scene.control.TabPane) Group(javafx.scene.Group) Tab(javafx.scene.control.Tab) ScrollPane(javafx.scene.control.ScrollPane) Rectangle(javafx.scene.shape.Rectangle) Scene(javafx.scene.Scene) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)135 Text (javafx.scene.text.Text)23 Entity (com.almasb.fxgl.entity.Entity)21 Point2D (javafx.geometry.Point2D)17 Circle (javafx.scene.shape.Circle)16 Group (javafx.scene.Group)13 Pane (javafx.scene.layout.Pane)13 Scene (javafx.scene.Scene)11 Color (javafx.scene.paint.Color)11 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 HitBox (com.almasb.fxgl.physics.HitBox)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Node (javafx.scene.Node)7 PlayerControl (common.PlayerControl)6 Timeline (javafx.animation.Timeline)6 StackPane (javafx.scene.layout.StackPane)6 Stage (javafx.stage.Stage)6 Region (javafx.scene.layout.Region)5