Search in sources :

Example 76 with Rectangle

use of javafx.scene.shape.Rectangle in project sis by apache.

the class FileAccessItem method resize.

/**
 * Sets a new total width (in pixels) for the bars to draw in {@link #accessView}.
 * This method adjust the sizes of all bars and the positions of cursor and seeks.
 */
private void resize(final double width) {
    final double old = columnWidth;
    columnWidth = width - MARGIN_RIGHT;
    final double scale = columnWidth / fileSize;
    if (Double.isFinite(scale)) {
        adjustSizes(scale, true);
        if (cursor != null) {
            final Rectangle r = (Rectangle) cursor.getNode();
            r.setX(Math.max(0, Math.min(scale * cursorPosition - CURSOR_WIDTH / 2, columnWidth - CURSOR_WIDTH)));
        }
        final double ratio = columnWidth / old;
        for (final Node node : seeksGroup) {
            final Line line = (Line) node;
            final double x = line.getStartX() * ratio;
            line.setStartX(x);
            line.setEndX(x);
        }
    }
}
Also used : Line(javafx.scene.shape.Line) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle)

Example 77 with Rectangle

use of javafx.scene.shape.Rectangle in project latexdraw by arnobl.

the class ExportTest method commonCanDoFixture.

@Override
protected void commonCanDoFixture() {
    BadaboomCollector.INSTANCE.clear();
    format = ExportFormat.BMP;
    canvas = Mockito.mock(Canvas.class);
    pstGen = Mockito.mock(PSTCodeGenerator.class);
    dialogueBox = Mockito.mock(FileChooser.class);
    views = new Group(new Rectangle(1, 2, 3, 4));
    Mockito.when(canvas.getScene()).thenReturn(Mockito.mock(Scene.class));
    Mockito.when(canvas.getViews()).thenReturn(views);
    file = Mockito.mock(File.class);
    Mockito.when(file.getName()).thenReturn("foo");
    psFile = Mockito.mock(File.class);
    Mockito.when(psFile.exists()).thenReturn(true);
    Mockito.when(pstGen.createPSFile(Mockito.any())).thenReturn(Optional.of(psFile));
    Mockito.when(pstGen.createEPSFile(Mockito.any())).thenReturn(Optional.of(psFile));
    Mockito.when(pstGen.createPDFFile(Mockito.any())).thenReturn(Optional.of(psFile));
}
Also used : Group(javafx.scene.Group) Canvas(net.sf.latexdraw.view.jfx.Canvas) FileChooser(javafx.stage.FileChooser) Rectangle(javafx.scene.shape.Rectangle) PSTCodeGenerator(net.sf.latexdraw.view.pst.PSTCodeGenerator) Scene(javafx.scene.Scene) File(java.io.File)

Example 78 with Rectangle

use of javafx.scene.shape.Rectangle in project TestFX by TestFX.

the class HDPIContractTest method setupHDPI.

@Before
public void setupHDPI() throws Exception {
    FxToolkit.registerPrimaryStage();
    // Provide some background component for the basic test, that can fetch
    // some key and mouse events.
    // See issue #593 (https://github.com/TestFX/TestFX/issues/593).
    FxToolkit.setupStage(stage -> {
        // don't mess up the primary stage!
        this.stage = new Stage();
        this.stage.initStyle(StageStyle.UNDECORATED);
        root = new Pane();
        String bg = "-fx-background-color: magenta;";
        root.setStyle(bg);
        bg = "-fx-background-color: black;";
        topLeft = new Rectangle(0, 0, 5, 5);
        topLeft.setStyle(bg);
        root.getChildren().add(topLeft);
        topRight = new Rectangle(95, 0, 5, 5);
        topRight.setStyle(bg);
        root.getChildren().add(topRight);
        bottomLeft = new Rectangle(0, 95, 5, 5);
        bottomLeft.setStyle(bg);
        root.getChildren().add(bottomLeft);
        bottomRight = new Rectangle(95, 95, 5, 5);
        bottomRight.setStyle(bg);
        root.getChildren().add(bottomRight);
        scene = new Scene(root);
        this.stage.setScene(scene);
        this.stage.show();
    });
    initRobots();
    log("JavaVersion: " + System.getProperty("java.version"));
    log("Java scaling x=" + JavaVersionAdapter.getScreenScaleX() + "Java scaling y=" + JavaVersionAdapter.getScreenScaleY());
}
Also used : Rectangle(javafx.scene.shape.Rectangle) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 79 with Rectangle

use of javafx.scene.shape.Rectangle in project TestFX by TestFX.

the class BoundsQueryUtilsTest method setupShape.

private static void setupShape() {
    // nodeBounds()
    shape = new Rectangle(0, 0, SHAPE_WIDTH, 0);
    // nodeBoundsInLocal()
    shape.setClip(new Rectangle(0, 0, CLIP_WIDTH, 0));
    // nodeBoundsInParent()
    shape.getTransforms().add(new Translate(TRANSLATE_X, 0));
    // nodeBounds()
    Shape altShape = new Rectangle(0, 0, SHAPE_WIDTH, 0);
    altShape.setFill(Color.GREEN);
    altShape.setStroke(Color.BLACK);
    altShape.setStrokeType(StrokeType.OUTSIDE);
    // nodeBounds(), nodeBoundsInParent()
    altShape.setStrokeWidth(5);
    // nodeBoundsInLocal()
    altShape.setEffect(new BoxBlur(10, 10, 1));
}
Also used : Shape(javafx.scene.shape.Shape) Rectangle(javafx.scene.shape.Rectangle) Translate(javafx.scene.transform.Translate) BoxBlur(javafx.scene.effect.BoxBlur)

Example 80 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)190 Point2D (javafx.geometry.Point2D)33 Text (javafx.scene.text.Text)28 Entity (com.almasb.fxgl.entity.Entity)27 Circle (javafx.scene.shape.Circle)20 Color (javafx.scene.paint.Color)18 HitBox (com.almasb.fxgl.physics.HitBox)16 Pane (javafx.scene.layout.Pane)16 Group (javafx.scene.Group)15 Node (javafx.scene.Node)14 PhysicsComponent (com.almasb.fxgl.physics.PhysicsComponent)12 Scene (javafx.scene.Scene)12 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Bounds (javafx.geometry.Bounds)7 KeyCode (javafx.scene.input.KeyCode)7