javafx.geometry.Rectangle2D Java Examples

The following examples show how to use javafx.geometry.Rectangle2D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameEntityFactory.java    From FXGLGames with MIT License 6 votes vote down vote up
@Spawns("asteroid")
public Entity newAsteroid(SpawnData data) {
    var hp = new HealthIntComponent(2);

    var hpView = new ProgressBar(false);
    hpView.setFill(Color.LIGHTGREEN);
    hpView.setMaxValue(2);
    hpView.setWidth(85);
    hpView.setTranslateY(90);
    hpView.currentValueProperty().bind(hp.valueProperty());

    return entityBuilder()
            .type(EntityType.ASTEROID)
            .from(data)
            .viewWithBBox("asteroid.png")
            .view(hpView)
            .with(hp)
            .with(new RandomMoveComponent(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()), 100))
            .collidable()
            .build();
}
 
Example #2
Source File: WhitespaceOverlayFactory.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
void layoutOverlayNodes(int paragraphIndex, List<Node> nodes) {
	Insets insets = getInsets();
	double leftInsets = insets.getLeft();
	double topInsets = insets.getTop();

	// all paragraphs except last one have line separators
	boolean showEOL = (paragraphIndex < getTextArea().getParagraphs().size() - 1);
	Node eolNode = nodes.get(nodes.size() - 1);
	if (eolNode.isVisible() != showEOL)
		eolNode.setVisible(showEOL);

	for (Node node : nodes) {
		Range range = (Range) node.getUserData();
		Rectangle2D bounds = getBounds(range.start, range.end);
		node.setLayoutX(leftInsets + (node == eolNode ? bounds.getMaxX() : bounds.getMinX()));
		node.setLayoutY(topInsets + bounds.getMinY());
	}
}
 
Example #3
Source File: SpriteView.java    From training with MIT License 6 votes vote down vote up
public SpriteView(Image spriteSheet, Main.Location loc) {
    imageView = new ImageView(spriteSheet);
    this.location.set(loc);
    setTranslateX(loc.getX() * Main.CELL_SIZE);
    setTranslateY(loc.getY() * Main.CELL_SIZE);
    ChangeListener<Object> updateImage = (ov, o, o2) -> imageView.setViewport(
        new Rectangle2D(frame.get() * spriteWidth,
            direction.get().getOffset() * spriteHeight,
            spriteWidth, spriteHeight));
    direction.addListener(updateImage);
    frame.addListener(updateImage);
    spriteWidth = (int) (spriteSheet.getWidth() / 3);
    spriteHeight = (int) (spriteSheet.getHeight() / 4);
    direction.set(Main.Direction.RIGHT);
    getChildren().add(imageView);
}
 
Example #4
Source File: ReadMessageController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example #5
Source File: AdminController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
private void showSettings() throws IOException
{
    Stage stage = new Stage();
    SettingsController settings = new SettingsController(admin,this);
    settings.loadConfigFile();
    
    Scene scene = new Scene(settings);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show(); 
}
 
Example #6
Source File: TrackerSnapConstraint.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param x Requested X position
 *  @param y Requested Y position
 *  @param widget Widget where corners are checked as snap candidates
 *  @return {@link SnapResult}
 */
private SnapResult checkWidget(final double x, final double y, final Widget widget)
{
    // System.out.println("Checking " + widget.getClass().getSimpleName() + " in " + Thread.currentThread().getName());
    final SnapResult result = new SnapResult();

    // Do _not_ snap to one of the active widgets,
    // because that would lock their coordinates.
    if (selected_widgets.contains(widget))
        return result;

    // Check all widget corners
    final Rectangle2D bounds = GeometryTools.getDisplayBounds(widget);
    updateSnapResult(result, x, y, bounds.getMinX(), bounds.getMinY());
    updateSnapResult(result, x, y, bounds.getMaxX(), bounds.getMinY());
    updateSnapResult(result, x, y, bounds.getMaxX(), bounds.getMaxY());
    updateSnapResult(result, x, y, bounds.getMinX(), bounds.getMaxY());

    final ChildrenProperty children = ChildrenProperty.getChildren(widget);
    if (children != null)
        result.updateFrom(checkWidgets(children.getValue()));
    return result;
}
 
Example #7
Source File: AllMessagesController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML private void showMessage()
{
    AllMessages message = (AllMessages)messagesTable.getSelectionModel().getSelectedItem();
    //System.out.println(message.getMessage());
    
    Stage stage= new Stage();
    ReadMessageController newMessage = new ReadMessageController(message,newSysUser);
    newMessage.fillMessage();
    Scene scene = new Scene(newMessage);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();   
    
}
 
Example #8
Source File: SettingsController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example #9
Source File: StateTransitionEdgeViewer.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Rectangle2D getSelfEdgeLabelBounds(StateTransitionEdge pEdge)
{
	Line line = getConnectionPoints(pEdge);
	adjustLabelFont(pEdge);
	Dimension textDimensions = getLabelBounds(pEdge.getMiddleLabel());
	if( getPosition(pEdge) == 1 )
	{
		return new Rectangle2D(line.getX1() + SELF_EDGE_OFFSET - textDimensions.getWidth()/2,	
				line.getY1() - SELF_EDGE_OFFSET*2, textDimensions.getWidth(), textDimensions.getHeight());
	}
	else
	{
		return new Rectangle2D(line.getX1() - textDimensions.getWidth()/2,	
				line.getY1() - SELF_EDGE_OFFSET * HEIGHT_RATIO, textDimensions.getWidth(), textDimensions.getHeight());
	}
}
 
Example #10
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Tests whether the bounds returned by UI.getStageBounds contain the following values when passed
 * multiple screens:
 * - minHeight: minimum height among screen bounds
 * - maxHeight: maximum height among screen bounds
 * - maxWidth: total width of screen bounds
 */
@Test
public void getPviewBounds_MultipleIntersectingScreens_StretchedBounds() {
    Rectangle2D bigScreenBound = new Rectangle2D(0, 0, 2400, 1600);
    Rectangle2D mediumScreenBound = new Rectangle2D(0, 0, 1440, 900);
    Rectangle2D smallScreenBound = new Rectangle2D(0, 0, 1024, 768);
    List<Rectangle2D> screenBoundsList = new ArrayList<>();
    screenBoundsList.add(bigScreenBound);
    screenBoundsList.add(mediumScreenBound);
    screenBoundsList.add(smallScreenBound);

    Region stageBounds = ScreenManager.getStageBounds(screenBoundsList);

    assertEquals(bigScreenBound.getWidth() + mediumScreenBound.getWidth() + smallScreenBound.getWidth(),
                 stageBounds.getMaxWidth(), 0.0);
    assertEquals(bigScreenBound.getHeight(), stageBounds.getMaxHeight(), 0.0);
    assertEquals(smallScreenBound.getHeight(), stageBounds.getMinHeight(), 0.0);
}
 
Example #11
Source File: Notifications.java    From oim-fx with MIT License 6 votes vote down vote up
public void show(Notifications notification) {
    Window window;
    if (notification.owner == null) {
        /*
         * If the owner is not set, we work with the whole screen.
         */
        Rectangle2D screenBounds = notification.screen.getVisualBounds();
        startX = screenBounds.getMinX();
        startY = screenBounds.getMinY();
        screenWidth = screenBounds.getWidth();
        screenHeight = screenBounds.getHeight();

        window = Utils.getWindow(null);
    } else {
        /*
         * If the owner is set, we will make the notifications popup
         * inside its window.
         */
        startX = notification.owner.getX();
        startY = notification.owner.getY();
        screenWidth = notification.owner.getWidth();
        screenHeight = notification.owner.getHeight();
        window = notification.owner;
    }
    show(window, notification);
}
 
Example #12
Source File: EnvironmentManagerImpl.java    From VocabHunter with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isVisible(final Placement placement) {
    ObservableList<Screen> screens = Screen.getScreensForRectangle(rectangle(placement));

    if (screens.size() == 1) {
        Screen screen = screens.get(0);
        Rectangle2D bounds = screen.getVisualBounds();

        if (placement.isPositioned()) {
            return bounds.contains(placement.getX(), placement.getY(), placement.getWidth(), placement.getHeight());
        } else {
            return bounds.getWidth() >= placement.getWidth() && bounds.getHeight() >= placement.getHeight();
        }
    } else {
        return false;
    }
}
 
Example #13
Source File: Tracker.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Create tracker with restricted position range
 *  @param restriction Bounds within which tracker will stay
 */
public Tracker(final Rectangle2D restriction)
{
    this.restriction = restriction;

    tracker.getStyleClass().add("tracker");

    handle_top_left = createHandle();
    handle_top = createHandle();
    handle_top_right = createHandle();
    handle_right = createHandle();
    handle_bottom_right = createHandle();
    handle_bottom = createHandle();
    handle_bottom_left = createHandle();
    handle_left = createHandle();

    locationLabel = createLabel(TextAlignment.LEFT, Pos.TOP_LEFT);
    sizeLabel = createLabel(TextAlignment.RIGHT, Pos.BOTTOM_RIGHT);

    getChildren().addAll(tracker, handle_top_left, handle_top, handle_top_right,
            handle_right, handle_bottom_right,
            handle_bottom, handle_bottom_left, handle_left, locationLabel, sizeLabel);

    hookEvents();
}
 
Example #14
Source File: PlayerComponent.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
public void onUpdate(double tpf) {
    speed = tpf * playerSpeed;

    if (!entity.getPosition().equals(oldPosition))
        entity.rotateToVector(entity.getPosition().subtract(oldPosition));

    oldPosition = entity.getPosition();

    // TODO: extract to KeepInBoundsComponent
    
    var viewport = new Rectangle2D(0, 0, getAppWidth(), getAppHeight());

    if (getEntity().getX() < viewport.getMinX()) {
        getEntity().setX(viewport.getMinX());
    } else if (getEntity().getRightX() > viewport.getMaxX()) {
        getEntity().setX(viewport.getMaxX() - getEntity().getWidth());
    }

    if (getEntity().getY() < viewport.getMinY()) {
        getEntity().setY(viewport.getMinY());
    } else if (getEntity().getBottomY() > viewport.getMaxY()) {
        getEntity().setY(viewport.getMaxY() - getEntity().getHeight());
    }
}
 
Example #15
Source File: UndecoratorController.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Based on mouse position returns dock side
 *
 * @param mouseEvent
 * @return DOCK_LEFT,DOCK_RIGHT,DOCK_TOP
 */
int getDockSide(MouseEvent mouseEvent) {
    double minX = Double.POSITIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxX = 0;
    double maxY = 0;
    // Get "big" screen bounds
    ObservableList<Screen> screens = Screen.getScreens();
    for (Screen screen : screens) {
        Rectangle2D visualBounds = screen.getVisualBounds();
        minX = Math.min(minX, visualBounds.getMinX());
        minY = Math.min(minY, visualBounds.getMinY());
        maxX = Math.max(maxX, visualBounds.getMaxX());
        maxY = Math.max(maxY, visualBounds.getMaxY());
    }
    // Dock Left
    if (mouseEvent.getScreenX() == minX) {
        return DOCK_LEFT;
    } else if (mouseEvent.getScreenX() >= maxX - 1) { // MaxX returns the width? Not width -1 ?!
        return DOCK_RIGHT;
    } else if (mouseEvent.getScreenY() <= minY) {   // Mac menu bar
        return DOCK_TOP;
    }
    return 0;
}
 
Example #16
Source File: ParagraphOverlayGraphicFactory.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected Rectangle2D getBounds(int start, int end) {
	PathElement[] shape = getShape(start, end);
	double minX = 0, minY = 0, maxX = 0, maxY = 0;
	for (PathElement pathElement : shape) {
		if (pathElement instanceof MoveTo) {
			MoveTo moveTo = (MoveTo) pathElement;
			minX = maxX = moveTo.getX();
			minY = maxY = moveTo.getY();
		} else if (pathElement instanceof LineTo) {
			LineTo lineTo = (LineTo) pathElement;
			double x = lineTo.getX();
			double y = lineTo.getY();
			minX = Math.min(minX, x);
			minY = Math.min(minY, y);
			maxX = Math.max(maxX, x);
			maxY = Math.max(maxY, y);
		}
	}
	return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
 
Example #17
Source File: LoginController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void loadPharmacist(String username)
{
    Stage stage = new Stage();
    PharmacistController pharmacist = new PharmacistController(username);
    
    pharmacist.loadProfileData(); 
    pharmacist.makeStockTable();
    pharmacist.fillBarChart();
    pharmacist.fillPieChart();
    pharmacist.setPaceholders();
    pharmacist.loadNameList();
    pharmacist.addFocusListener();
    
    stage.setScene(new Scene(pharmacist));
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.initStyle(StageStyle.UNDECORATED);
    stage.show();
}
 
Example #18
Source File: XYChartInfo.java    From jfxutils with Apache License 2.0 6 votes vote down vote up
/**
	 * Returns the plot area in the reference's coordinate space.
	 */
	public Rectangle2D getPlotArea() {
		Axis<?> xAxis = chart.getXAxis();
		Axis<?> yAxis = chart.getYAxis();

		double xStart = getXShift( xAxis, referenceNode );
		double yStart = getYShift( yAxis, referenceNode );

		//If the direct method to get the width (which is based on its Node dimensions) is not found to
		//be appropriate, an alternative method is commented.
//		double width = xAxis.getDisplayPosition( xAxis.toRealValue( xAxis.getUpperBound() ) );
		double width = xAxis.getWidth();
//		double height = yAxis.getDisplayPosition( yAxis.toRealValue( yAxis.getLowerBound() ) );
		double height = yAxis.getHeight();

		return new Rectangle2D( xStart, yStart, width, height );
	}
 
Example #19
Source File: Cutaway.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
private void redraw() {

        params.setViewport(new Rectangle2D(0, 0, imageView.getFitWidth(), imageView.getFitHeight()));
        if (image == null
                || image.getWidth() != imageView.getFitWidth() || image.getHeight() != imageView.getFitHeight()) {
            image = worldToView.snapshot(params, null);
        } else {
            worldToView.snapshot(params, image);
        }
        // set a clip to apply rounded border to the original image.
        Rectangle clip = new Rectangle(
            imageView.getFitWidth(), imageView.getFitHeight()
        );
        clip.setArcWidth(20);
        clip.setArcHeight(20);
        imageView.setClip(clip);        
        imageView.setImage(image);
    }
 
Example #20
Source File: MovablePane.java    From DeskChan with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static Rectangle2D anchorToEdges(Rectangle2D bounds, Rectangle2D screenBounds) {
	double x1 = bounds.getMinX(), y1 = bounds.getMinY();
	double x2 = bounds.getMaxX(), y2 = bounds.getMaxY();
	if (Math.abs(x1 - screenBounds.getMinX()) < SNAP_DISTANCE) {
		x1 = screenBounds.getMinX();
	}
	if (Math.abs(y1 - screenBounds.getMinY()) < SNAP_DISTANCE) {
		y1 = screenBounds.getMinY();
	}
	if (Math.abs(x2 - screenBounds.getMaxX()) < SNAP_DISTANCE) {
		x1 = screenBounds.getMaxX() - bounds.getWidth();
	}
	if (Math.abs(y2 - screenBounds.getMaxY()) < SNAP_DISTANCE) {
		y1 = screenBounds.getMaxY() - bounds.getHeight();
	}
	return new Rectangle2D(x1, y1, bounds.getWidth(), bounds.getHeight());
}
 
Example #21
Source File: AddNewDrugController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example #22
Source File: MovablePane.java    From DeskChan with GNU Lesser General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #23
Source File: OverlayStage.java    From DeskChan with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #24
Source File: ReceptionistController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML private void showAppointments()
{
    Stage stage= new Stage();
    AllAppointmentsController app = new AllAppointmentsController(receptionist);
    app.load();
    Scene scene = new Scene(app);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();

}
 
Example #25
Source File: MnistImageView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void zoom(double factor, double pivotX, double pivotY) {
    Rectangle2D viewport = this.getViewport();
    double scale = clamp(factor,
        Math.min(MIN_SIZE / viewport.getWidth(), MIN_SIZE / viewport.getHeight()),
        Math.max(INNER_WIDTH / viewport.getWidth(), INNER_HEIGHT / viewport.getHeight()));
    Point2D pivot = getImageCoordinates(pivotX, pivotY);

    double newWidth = viewport.getWidth() * scale;
    double newHeight = viewport.getHeight() * scale;

    // to zoom over the pivot, we have for x, y:
    // (x - newMinX) / (x - viewport.getMinX()) = scale
    // solving for newMinX, newMinY:
    double newMinX = clamp(pivot.getX() - (pivot.getX() - viewport.getMinX()) * scale, 
            0, IMAGE_WIDTH - newWidth);
    double newMinY = clamp(pivot.getY() - (pivot.getY() - viewport.getMinY()) * scale, 
            0, IMAGE_HEIGHT - newHeight);

    this.setViewport(new Rectangle2D(newMinX, newMinY, newWidth, newHeight));
}
 
Example #26
Source File: DisplayWindow.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ControllerStage(DisplayWindow stage) {
    this.displayWindow = stage;
    setTitle("Marathon Control Center");
    getIcons().add(FXUIUtils.getImageURL("logo16"));
    getIcons().add(FXUIUtils.getImageURL("logo32"));
    initComponents();
    Scene scene = new Scene(content);
    content.getStyleClass().add(StyleClassHelper.BACKGROUND);
    setScene(scene);
    setAlwaysOnTop(true);
    setOnShown((e) -> {
        Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
        setX(screenBounds.getWidth() - getWidth());
        setY(0);
    });
    sizeToScene();
    setResizable(false);
    setOnCloseRequest(e -> displayWindow.onStop());
}
 
Example #27
Source File: Tracker.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param event {@link MouseEvent} */
protected void startDrag(final MouseEvent event)
{
    // Take snapshot of current positions
    if ( event == null )
    {
        start_x = -1;
        start_y = -1;
    }
    else
    {
        event.consume();

        start_x = event.getX();
        start_y = event.getY();
    }

    orig = new Rectangle2D(tracker.getX(), tracker.getY(), tracker.getWidth(), tracker.getHeight());
}
 
Example #28
Source File: NotificationView.java    From Maus with GNU General Public License v3.0 6 votes vote down vote up
public static void openNotification(String text) {
    Stage stage = new Stage();
    stage.setWidth(300);
    stage.setHeight(125);
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    NotificationView notificationView = new NotificationView();
    stage.setScene(new Scene(notificationView.getNotificationView(), 300, 125));
    stage.setResizable(false);
    stage.setAlwaysOnTop(true);
    stage.setX(primaryScreenBounds.getMinX() + primaryScreenBounds.getWidth() - 300);
    stage.setY(primaryScreenBounds.getMinY() + primaryScreenBounds.getHeight() - 125);
    stage.initStyle(StageStyle.UNDECORATED);
    notificationView.getNotificationText().setWrapText(true);
    notificationView.getNotificationText().setAlignment(Pos.CENTER);
    notificationView.getNotificationText().setPadding(new Insets(0, 5, 0, 20));
    notificationView.getNotificationText().setText(text);
    stage.show();
    PauseTransition delay = new PauseTransition(Duration.seconds(5));
    delay.setOnFinished(event -> stage.close());
    delay.play();
}
 
Example #29
Source File: NewDoctorTimeSlotController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example #30
Source File: PharmacistController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML private void addNewDrug()
{
    
    Stage stage= new Stage();
    AddNewDrugController addDrug = new AddNewDrugController(pharmacist,this);
    addDrug.loadGenericNames();
    Scene scene = new Scene(addDrug);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();

}