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);
}
}
}
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));
}
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());
}
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));
}
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?");
}
});
}
Aggregations