Search in sources :

Example 26 with Rectangle2D

use of javafx.geometry.Rectangle2D in project kanonizo by kanonizo.

the class KanonizoFrame method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    assert sourceTree != null : "fx:id sourceTree was not injected";
    this.fw = Framework.getInstance();
    fw.addPropertyChangeListener(Framework.ROOT_FOLDER_PROPERTY_NAME, (e) -> {
        File newRoot = (File) e.getNewValue();
        rootFolderTextField.setText(newRoot.getAbsolutePath());
        sourceTree.setRoot(GuiUtils.createDynamicFileTree(newRoot));
        testTree.setRoot(GuiUtils.createDynamicFileTree(newRoot));
    });
    fw.addPropertyChangeListener(Framework.ALGORITHM_PROPERTY_NAME, (e) -> {
        SearchAlgorithm alg = (SearchAlgorithm) e.getNewValue();
        // remove existing children
        paramLayout.getChildren().clear();
        addParams(alg, paramLayout, true);
        addErrors(alg);
    });
    fw.addPropertyChangeListener(Framework.INSTRUMENTER_PROPERTY_NAME, (e) -> {
        org.kanonizo.framework.instrumentation.Instrumenter inst = (org.kanonizo.framework.instrumentation.Instrumenter) e.getNewValue();
        instParamLayout.getChildren().clear();
        addParams(inst, instParamLayout, false);
        addErrors(inst);
    });
    fw.addPropertyChangeListener(Framework.LIBS_PROPERTY_NAME, (e) -> {
        libs.getItems().add((File) e.getNewValue());
    });
    fw.setDisplay(this);
    Screen main = Screen.getPrimary();
    Rectangle2D bounds = main.getVisualBounds();
    rootFolderTextField.setText(fw.getRootFolder().getAbsolutePath());
    addSourceListeners();
    addTestListeners();
    addLibListeners();
    selectRoot.setOnAction(ev -> selectRoot());
    try {
        algorithmChoices.getItems().addAll(Framework.getAvailableAlgorithms());
        algorithmChoices.setConverter(new ReadableConverter());
        algorithmChoices.valueProperty().addListener((ov, t, t1) -> {
            SearchAlgorithm alg = (SearchAlgorithm) ov.getValue();
            fw.setAlgorithm(alg);
        });
        algorithmChoices.getSelectionModel().select(fw.getAlgorithm());
        instrumenterChoices.getItems().addAll(Framework.getAvailableInstrumenters());
        instrumenterChoices.setConverter(new ReadableConverter());
        instrumenterChoices.valueProperty().addListener((ov, t, t1) -> {
            org.kanonizo.framework.instrumentation.Instrumenter inst = (org.kanonizo.framework.instrumentation.Instrumenter) ov.getValue();
            fw.setInstrumenter(inst);
        });
        instrumenterChoices.getSelectionModel().select(fw.getInstrumenter());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ReadableConverter(org.kanonizo.display.fx.converters.ReadableConverter) Screen(javafx.stage.Screen) SearchAlgorithm(org.kanonizo.algorithms.SearchAlgorithm) Rectangle2D(javafx.geometry.Rectangle2D) File(java.io.File) ScriptException(javax.script.ScriptException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 27 with Rectangle2D

use of javafx.geometry.Rectangle2D in project DeskChan by DeskChan.

the class SeparateStage method resizeToDesktopSize.

protected void resizeToDesktopSize() {
    Rectangle2D rect = getDesktopSize();
    setX(rect.getMinX());
    setY(rect.getMinY());
    setWidth(rect.getWidth());
    setHeight(rect.getHeight());
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Example 28 with Rectangle2D

use of javafx.geometry.Rectangle2D in project DeskChan by DeskChan.

the class Character method setDefaultPosition.

@Override
public void setDefaultPosition() {
    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
    setPosition(new Point2D(screenBounds.getMaxX() - getWidth(), screenBounds.getMaxY() - getHeight()));
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle2D(javafx.geometry.Rectangle2D)

Example 29 with Rectangle2D

use of javafx.geometry.Rectangle2D in project DeskChan by DeskChan.

the class MovablePane method getCurrentPositionStorageKey.

private String getCurrentPositionStorageKey() {
    if (positionStorageID == null) {
        return null;
    }
    final StringBuilder key = new StringBuilder();
    final Rectangle2D desktopSize = OverlayStage.getDesktopSize();
    key.append(positionStorageID);
    if (positionRelativeToDesktopSize) {
        key.append('.');
        key.append(desktopSize.getMinX());
        key.append('_');
        key.append(desktopSize.getMinY());
        key.append('_');
        key.append(desktopSize.getWidth());
        key.append('_');
        key.append(desktopSize.getHeight());
    }
    return key.toString();
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Example 30 with Rectangle2D

use of javafx.geometry.Rectangle2D in project FXyzLib by Birdasaur.

the class Skybox method loadSingleImageViewports.

/**
 * this will layout the viewports to this style pattern
 *              ____
 *             |top |
 *         ____|____|____ ____
 *        |left|fwd |rght|back|
 *        |____|____|____|____|
 *             |bot |
 *             |____|
 */
private void loadSingleImageViewports() {
    layoutViews();
    double width = singleImg.getWidth(), height = singleImg.getHeight();
    // simple chack to see if cells will be square
    if (width / 4 != height / 3) {
        throw new UnsupportedOperationException("Image does not comply with size constraints");
    }
    double cellSize = singleImg.getWidth() - singleImg.getHeight();
    recalculateSize(cellSize);
    double topx = cellSize, topy = 0, botx = cellSize, boty = cellSize * 2, leftx = 0, lefty = cellSize, rightx = cellSize * 2, righty = cellSize, fwdx = cellSize, fwdy = cellSize, backx = cellSize * 3, backy = cellSize;
    // add top padding x+, y+, width-, height
    top.setViewport(new Rectangle2D(topx, topy, cellSize, cellSize));
    // add left padding x, y+, width, height-
    left.setViewport(new Rectangle2D(leftx, lefty, cellSize - 1, cellSize - 1));
    // add front padding x+, y+, width-, height
    back.setViewport(new Rectangle2D(fwdx, fwdy, cellSize, cellSize));
    // add right padding x, y+, width, height-
    right.setViewport(new Rectangle2D(rightx, righty, cellSize, cellSize));
    // add back padding x, y+, width, height-
    front.setViewport(new Rectangle2D(backx + 1, backy - 1, cellSize - 1, cellSize - 1));
    // add bottom padding x+, y, width-, height-
    bottom.setViewport(new Rectangle2D(botx, boty, cellSize, cellSize));
    for (ImageView v : views) {
        v.setImage(singleImg);
    // System.out.println(v.getId() + v.getViewport() + cellSize);
    }
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D) ImageView(javafx.scene.image.ImageView)

Aggregations

Rectangle2D (javafx.geometry.Rectangle2D)76 Image (javafx.scene.image.Image)14 Scene (javafx.scene.Scene)10 Screen (javafx.stage.Screen)10 Stage (javafx.stage.Stage)7 Point2D (javafx.geometry.Point2D)6 IOException (java.io.IOException)5 ImageView (javafx.scene.image.ImageView)5 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)4 List (java.util.List)4 Color (javafx.scene.paint.Color)4 Optional (java.util.Optional)3 Level (java.util.logging.Level)3 Application (javafx.application.Application)3 Platform (javafx.application.Platform)3 Menu (javafx.scene.control.Menu)3 MenuBar (javafx.scene.control.MenuBar)3 MenuItem (javafx.scene.control.MenuItem)3 Pane (javafx.scene.layout.Pane)3