use of javafx.geometry.Rectangle2D in project DeskChan by DeskChan.
the class MovablePane method loadPositionFromStorage.
public void loadPositionFromStorage() {
try {
final String key = getCurrentPositionStorageKey();
if (key != null) {
final String value = Main.getProperties().getString(key);
if (value != null) {
String[] coords = value.split(";");
if (coords.length == 2) {
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
Rectangle2D desktop = OverlayStage.getDesktopSize();
if (desktop.getWidth() == 0 || desktop.getHeight() == 0)
return;
if (x + getHeight() > desktop.getMaxX() || x < -getHeight())
x = desktop.getMaxX() - getHeight();
if (y + getWidth() > desktop.getMaxY() || y < -getWidth())
y = desktop.getMaxY() - getWidth();
setPosition(new Point2D(x, y));
return;
}
}
}
} catch (Exception e) {
Main.log(e);
}
setDefaultPosition();
}
use of javafx.geometry.Rectangle2D in project DeskChan by DeskChan.
the class SeparateStage method getDesktopSize.
public static Rectangle2D getDesktopSize() {
Rectangle2D rect = Screen.getPrimary().getBounds();
double minX = rect.getMinX(), minY = rect.getMinY();
double maxX = rect.getMaxX(), maxY = rect.getMaxY();
for (Screen screen : Screen.getScreens()) {
Rectangle2D screenRect = screen.getBounds();
if (minX > screenRect.getMinX()) {
minX = screenRect.getMinX();
}
if (minY > screenRect.getMinY()) {
minY = screenRect.getMinY();
}
if (maxX < screenRect.getMaxX()) {
maxX = screenRect.getMaxX();
}
if (maxY < screenRect.getMaxY()) {
maxY = screenRect.getMaxY();
}
}
return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
use of javafx.geometry.Rectangle2D in project CapsLock by chrootRISCassembler.
the class MainFormController method onCreated.
void onCreated(MainHandler handler) {
this.handler = handler;
final double PanelImageSideLength;
Logger.INST.debug("Start calculation of dynamic UI.");
{
final Rectangle2D ScreenRect = Screen.getPrimary().getVisualBounds();
final double FullScreenWidth = ScreenRect.getWidth();
final double FullScreenHeight = ScreenRect.getHeight();
final double LeftSize = FullScreenWidth / 5 * 2;
LeftScrollPane.setPrefViewportWidth(LeftSize);
LeftScrollPane.setMinViewportWidth(LeftSize);
PanelImageSideLength = LeftSize * PANEL_RATIO;
final double Gap = LeftSize * PANEL_GAP_RATIO;
PanelTilePane.setPadding(new Insets(LeftSize / 12));
PanelTilePane.setVgap(Gap);
PanelTilePane.setHgap(Gap);
final double RightContentPadding = (FullScreenWidth - LeftSize) / 20;
RightVBox.setPadding(new Insets(RightContentPadding));
RightVBox.setMaxWidth(FullScreenWidth - LeftSize);
NameLabel.setFont(Font.font(FullScreenHeight / 20));
DescriptionLabel.setFont(Font.font(FullScreenHeight / 40));
}
Logger.INST.debug("Finished calculation of dynamic UI.");
final ColorSequencer sequencer = new ColorSequencer();
final Tooltip tooltip = new Tooltip("ダブルクリックでゲーム起動");
for (final Game game : handler.getGameList()) {
final Image panelImage;
final Path panelPath = game.getPanel();
if (panelPath == null) {
panelImage = CharPanelGenerator.generate(game.getName().charAt(0), sequencer.get());
} else {
panelImage = new Image(panelPath.toUri().toString());
}
final ImageView view = new ImageView(panelImage);
view.setPreserveRatio(false);
view.setFitWidth(PanelImageSideLength);
view.setFitHeight(PanelImageSideLength);
view.setOnMouseClicked(eve -> onPanelClicked(eve));
Tooltip.install(view, tooltip);
view.setUserData(game);
PanelTilePane.getChildren().add(view);
}
contentsAreaController = new ContentsAreaController(ViewStackPane, StackedMediaView, StackedImageView);
Logger.INST.debug("MainForm window is displayed.");
System.gc();
}
use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class CaptureSupportImplTest method capture_region.
@Test
public void capture_region() {
// when:
Image image = capturer.captureRegion(new Rectangle2D(0, 0, 100, 200));
// then:
assertThat(image.getWidth(), equalTo(100.0));
assertThat(image.getHeight(), equalTo(200.0));
}
use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class AwtRobotAdapterTest method getCaptureRegion.
@Test
public void getCaptureRegion() {
// given:
assumeThat(System.getenv("TRAVIS_OS_NAME"), is(not(equalTo("osx"))));
// when:
Rectangle2D region = new Rectangle2D(regionPoint.getX(), regionPoint.getY(), 10, 20);
Image regionImage = robotAdapter.getCaptureRegion(region);
// then:
assertThat(regionImage.getWidth(), is(10.0));
assertThat(regionImage.getHeight(), is(20.0));
assertThat(regionImage.getPixelReader().getColor(5, 10), is(Color.web("magenta")));
}
Aggregations