502 */
503 private DoubleProperty renderScaleY =
504 new SimpleDoubleProperty(this, "renderScaleY", 1.0) {
505 @Override
506 protected void invalidated() {
507 peerBoundsConfigurator.setRenderScaleY(get());
508 }
509 };
510 public final void setRenderScaleY(double scale) {
511 renderScaleY.set(scale);
512 }
513 public final double getRenderScaleY() {
514 return renderScaleY.get();
515 }
516 public final DoubleProperty renderScaleYProperty() {
517 return renderScaleY;
518 }
519
520 private boolean xExplicit = false;
521 /**
522 * The horizontal location of this {@code Stage} on the screen. Changing
523 * this attribute will move the {@code Stage} horizontally. Changing this
524 * attribute will not visually affect a {@code Stage} while
525 * {@code fullScreen} is true, but will be honored by the {@code Stage} once
526 * {@code fullScreen} becomes false.
527 */
528 private ReadOnlyDoubleWrapper x =
529 new ReadOnlyDoubleWrapper(this, "x", Double.NaN);
530
531 public final void setX(double value) {
532 setXInternal(value);
533 }
534 public final double getX() { return x.get(); }
535 public final ReadOnlyDoubleProperty xProperty() { return x.getReadOnlyProperty(); }
536
537 void setXInternal(double value) {
538 x.set(value);
539 peerBoundsConfigurator.setX(value, 0);
540 xExplicit = true;
541 }
542
543 private boolean yExplicit = false;
544 /**
545 * The vertical location of this {@code Stage} on the screen. Changing this
546 * attribute will move the {@code Stage} vertically. Changing this
547 * attribute will not visually affect a {@code Stage} while
548 * {@code fullScreen} is true, but will be honored by the {@code Stage} once
549 * {@code fullScreen} becomes false.
550 */
551 private ReadOnlyDoubleWrapper y =
552 new ReadOnlyDoubleWrapper(this, "y", Double.NaN);
553
554 public final void setY(double value) {
555 setYInternal(value);
556 }
557 public final double getY() { return y.get(); }
558 public final ReadOnlyDoubleProperty yProperty() { return y.getReadOnlyProperty(); }
559
560 void setYInternal(double value) {
561 y.set(value);
562 peerBoundsConfigurator.setY(value, 0);
563 yExplicit = true;
564 }
565
566 /**
567 * Notification from the windowing system that the window's position has
568 * changed.
569 *
570 * @param newX the new window x position
571 * @param newY the new window y position
572 */
573 void notifyLocationChanged(double newX, double newY) {
574 x.set(newX);
575 y.set(newY);
576 }
577
578 private boolean widthExplicit = false;
579
580 /**
581 * The width of this {@code Window}. Changing this attribute will narrow or
582 * widen the width of the {@code Window}. Changing this
583 * attribute will not visually affect a {@code Window} while
584 * {@code fullScreen} is true, but will be honored by the {@code Window} once
585 * {@code fullScreen} becomes false. This value includes any and all
586 * decorations which may be added by the Operating System such as resizable
587 * frame handles. Typical applications will set the {@link javafx.scene.Scene}
588 * width instead. This window will take its width from the scene if it has
589 * never been set by the application. Resizing the window by end user does
590 * not count as a setting the width by the application.
591 * <p>
592 * The property is read only because it can be changed externally
593 * by the underlying platform and therefore must not be bindable.
594 * </p>
595 */
596 private ReadOnlyDoubleWrapper width =
597 new ReadOnlyDoubleWrapper(this, "width", Double.NaN);
598
599 public final void setWidth(double value) {
600 width.set(value);
601 peerBoundsConfigurator.setWindowWidth(value);
602 widthExplicit = true;
603 }
604 public final double getWidth() { return width.get(); }
605 public final ReadOnlyDoubleProperty widthProperty() { return width.getReadOnlyProperty(); }
606
607 private boolean heightExplicit = false;
608 /**
609 * The height of this {@code Window}. Changing this attribute will shrink
610 * or heighten the height of the {@code Window}. Changing this
611 * attribute will not visually affect a {@code Window} while
612 * {@code fullScreen} is true, but will be honored by the {@code Window} once
613 * {@code fullScreen} becomes false. This value includes any and all
614 * decorations which may be added by the Operating System such as the title
615 * bar. Typical applications will set the {@link javafx.scene.Scene} height
616 * instead. This window will take its height from the scene if it has never
617 * been set by the application. Resizing this window by end user does not
618 * count as a setting the height by the application.
619 * <p>
620 * The property is read only because it can be changed externally
621 * by the underlying platform and therefore must not be bindable.
622 * </p>
623 */
624 private ReadOnlyDoubleWrapper height =
625 new ReadOnlyDoubleWrapper(this, "height", Double.NaN);
626
627 public final void setHeight(double value) {
628 height.set(value);
629 peerBoundsConfigurator.setWindowHeight(value);
630 heightExplicit = true;
631 }
632 public final double getHeight() { return height.get(); }
633 public final ReadOnlyDoubleProperty heightProperty() { return height.getReadOnlyProperty(); }
634
635 /**
636 * Notification from the windowing system that the window's size has
637 * changed.
638 *
735
736 /**
737 * Returns a previously set Object property, or null if no such property
738 * has been set using the {@link Window#setUserData(java.lang.Object)} method.
739 *
740 * @return The Object that was previously set, or null if no property
741 * has been set or if null was set.
742 *
743 * @since JavaFX 8u40
744 */
745 public Object getUserData() {
746 return getProperties().get(USER_DATA_KEY);
747 }
748
749 /**
750 * The {@code Scene} to be rendered on this {@code Window}. There can only
751 * be one {@code Scene} on the {@code Window} at a time, and a {@code Scene}
752 * can only be on one {@code Window} at a time. Setting a {@code Scene} on
753 * a different {@code Window} will cause the old {@code Window} to lose the
754 * reference before the new one gains it. You may swap {@code Scene}s on
755 * a {@code Window} at any time, even while in full-screen exclusive mode.
756 * If the width or height of this {@code Window} have never been set by the
757 * application, setting the scene will cause this {@code Window} to take its
758 * width or height from that scene. Resizing this window by end user does
759 * not count as setting the width or height by the application.
760 *
761 * An {@link IllegalStateException} is thrown if this property is set
762 * on a thread other than the JavaFX Application Thread.
763 *
764 * @defaultValue null
765 */
766 private SceneModel scene = new SceneModel();
767 protected void setScene(Scene value) { scene.set(value); }
768 public final Scene getScene() { return scene.get(); }
769 public final ReadOnlyObjectProperty<Scene> sceneProperty() { return scene.getReadOnlyProperty(); }
770
771 private final class SceneModel extends ReadOnlyObjectWrapper<Scene> {
772 private Scene oldScene;
773
774 @Override protected void invalidated() {
775 final Scene newScene = get();
819
820 @Override
821 public Object getBean() {
822 return Window.this;
823 }
824
825 @Override
826 public String getName() {
827 return "scene";
828 }
829
830 private void updatePeerScene(final TKScene tkScene) {
831 if (peer != null) {
832 // Set scene impl on stage impl
833 peer.setScene(tkScene);
834 }
835 }
836 }
837
838 /**
839 * Defines the opacity of the {@code Stage} as a value between 0.0 and 1.0.
840 * The opacity is reflected across the {@code Stage}, its {@code Decoration}
841 * and its {@code Scene} content. On a JavaFX runtime platform that does not
842 * support opacity, assigning a value to this variable will have no
843 * visible difference. A {@code Stage} with 0% opacity is fully translucent.
844 * Typically, a {@code Stage} with 0% opacity will not receive any mouse
845 * events.
846 *
847 * @defaultValue 1.0
848 */
849 private DoubleProperty opacity;
850
851 public final void setOpacity(double value) {
852 opacityProperty().set(value);
853 }
854
855 public final double getOpacity() {
856 return opacity == null ? 1.0 : opacity.get();
857 }
858
859 public final DoubleProperty opacityProperty() {
860 if (opacity == null) {
861 opacity = new DoublePropertyBase(1.0) {
862
863 @Override
864 protected void invalidated() {
1018 onHidden = new ObjectPropertyBase<EventHandler<WindowEvent>>() {
1019 @Override protected void invalidated() {
1020 setEventHandler(WindowEvent.WINDOW_HIDDEN, get());
1021 }
1022
1023 @Override
1024 public Object getBean() {
1025 return Window.this;
1026 }
1027
1028 @Override
1029 public String getName() {
1030 return "onHidden";
1031 }
1032 };
1033 }
1034 return onHidden;
1035 }
1036
1037 /**
1038 * Whether or not this {@code Stage} is showing (that is, open on the
1039 * user's system). The Stage might be "showing", yet the user might not
1040 * be able to see it due to the Stage being rendered behind another window
1041 * or due to the Stage being positioned off the monitor.
1042 *
1043 * @defaultValue false
1044 */
1045 private ReadOnlyBooleanWrapper showing = new ReadOnlyBooleanWrapper() {
1046 private boolean oldVisible;
1047
1048 @Override protected void invalidated() {
1049 final boolean newVisible = get();
1050 if (oldVisible == newVisible) {
1051 return;
1052 }
1053
1054 if (!oldVisible && newVisible) {
1055 fireEvent(new WindowEvent(Window.this, WindowEvent.WINDOW_SHOWING));
1056 } else {
1057 fireEvent(new WindowEvent(Window.this, WindowEvent.WINDOW_HIDING));
1058 }
|
502 */
503 private DoubleProperty renderScaleY =
504 new SimpleDoubleProperty(this, "renderScaleY", 1.0) {
505 @Override
506 protected void invalidated() {
507 peerBoundsConfigurator.setRenderScaleY(get());
508 }
509 };
510 public final void setRenderScaleY(double scale) {
511 renderScaleY.set(scale);
512 }
513 public final double getRenderScaleY() {
514 return renderScaleY.get();
515 }
516 public final DoubleProperty renderScaleYProperty() {
517 return renderScaleY;
518 }
519
520 private boolean xExplicit = false;
521 /**
522 * The horizontal location of this {@code Window} on the screen. Changing
523 * this attribute will move the {@code Window} horizontally. If this
524 * {@code Window} is an instance of {@code Stage}, changing this attribute
525 * will not visually affect the {@code Window} while {@link Stage#fullScreen}
526 * is true, but will be honored by the {@code Window} once
527 * {@link Stage#fullScreen} becomes false.
528 */
529 private ReadOnlyDoubleWrapper x =
530 new ReadOnlyDoubleWrapper(this, "x", Double.NaN);
531
532 public final void setX(double value) {
533 setXInternal(value);
534 }
535 public final double getX() { return x.get(); }
536 public final ReadOnlyDoubleProperty xProperty() { return x.getReadOnlyProperty(); }
537
538 void setXInternal(double value) {
539 x.set(value);
540 peerBoundsConfigurator.setX(value, 0);
541 xExplicit = true;
542 }
543
544 private boolean yExplicit = false;
545 /**
546 * The vertical location of this {@code Window} on the screen. Changing this
547 * attribute will move the {@code Window} vertically. If this
548 * {@code Window} is an instance of {@code Stage}, changing this attribute
549 * will not visually affect the {@code Window} while {@link Stage#fullScreen}
550 * is true, but will be honored by the {@code Window} once
551 * {@link Stage#fullScreen} becomes false.
552 */
553 private ReadOnlyDoubleWrapper y =
554 new ReadOnlyDoubleWrapper(this, "y", Double.NaN);
555
556 public final void setY(double value) {
557 setYInternal(value);
558 }
559 public final double getY() { return y.get(); }
560 public final ReadOnlyDoubleProperty yProperty() { return y.getReadOnlyProperty(); }
561
562 void setYInternal(double value) {
563 y.set(value);
564 peerBoundsConfigurator.setY(value, 0);
565 yExplicit = true;
566 }
567
568 /**
569 * Notification from the windowing system that the window's position has
570 * changed.
571 *
572 * @param newX the new window x position
573 * @param newY the new window y position
574 */
575 void notifyLocationChanged(double newX, double newY) {
576 x.set(newX);
577 y.set(newY);
578 }
579
580 private boolean widthExplicit = false;
581
582 /**
583 * The width of this {@code Window}. Changing this attribute will narrow or
584 * widen the width of the {@code Window}. This value includes any and all
585 * decorations which may be added by the Operating System such as resizable
586 * frame handles. Typical applications will set the {@link javafx.scene.Scene}
587 * width instead. This {@code Window} will take its width from the scene if
588 * it has never been set by the application. Resizing the window by end user
589 * does not count as a setting the width by the application. If this
590 * {@code Window} is an instance of {@code Stage}, changing this attribute
591 * will not visually affect a {@code Window} while {@link Stage#fullScreen}
592 * is true, but will be honored by the {@code Window} once
593 * {@link Stage#fullScreen} becomes false.
594 * <p>
595 * The property is read only because it can be changed externally
596 * by the underlying platform and therefore must not be bindable.
597 * </p>
598 */
599 private ReadOnlyDoubleWrapper width =
600 new ReadOnlyDoubleWrapper(this, "width", Double.NaN);
601
602 public final void setWidth(double value) {
603 width.set(value);
604 peerBoundsConfigurator.setWindowWidth(value);
605 widthExplicit = true;
606 }
607 public final double getWidth() { return width.get(); }
608 public final ReadOnlyDoubleProperty widthProperty() { return width.getReadOnlyProperty(); }
609
610 private boolean heightExplicit = false;
611 /**
612 * The height of this {@code Window}. Changing this attribute will shrink
613 * or heighten the height of the {@code Window}. This value includes any and all
614 * decorations which may be added by the Operating System such as the title
615 * bar. Typical applications will set the {@link javafx.scene.Scene} height
616 * instead. This window will take its height from the scene if it has never
617 * been set by the application. Resizing this window by end user does not
618 * count as a setting the height by the application. If this
619 * {@code Window} is an instance of {@code Stage}, changing this attribute
620 * will not visually affect a {@code Window} while {@link Stage#fullScreen}
621 * is true, but will be honored by the {@code Window} once
622 * {@link Stage#fullScreen} becomes false.
623 * <p>
624 * The property is read only because it can be changed externally
625 * by the underlying platform and therefore must not be bindable.
626 * </p>
627 */
628 private ReadOnlyDoubleWrapper height =
629 new ReadOnlyDoubleWrapper(this, "height", Double.NaN);
630
631 public final void setHeight(double value) {
632 height.set(value);
633 peerBoundsConfigurator.setWindowHeight(value);
634 heightExplicit = true;
635 }
636 public final double getHeight() { return height.get(); }
637 public final ReadOnlyDoubleProperty heightProperty() { return height.getReadOnlyProperty(); }
638
639 /**
640 * Notification from the windowing system that the window's size has
641 * changed.
642 *
739
740 /**
741 * Returns a previously set Object property, or null if no such property
742 * has been set using the {@link Window#setUserData(java.lang.Object)} method.
743 *
744 * @return The Object that was previously set, or null if no property
745 * has been set or if null was set.
746 *
747 * @since JavaFX 8u40
748 */
749 public Object getUserData() {
750 return getProperties().get(USER_DATA_KEY);
751 }
752
753 /**
754 * The {@code Scene} to be rendered on this {@code Window}. There can only
755 * be one {@code Scene} on the {@code Window} at a time, and a {@code Scene}
756 * can only be on one {@code Window} at a time. Setting a {@code Scene} on
757 * a different {@code Window} will cause the old {@code Window} to lose the
758 * reference before the new one gains it. You may swap {@code Scene}s on
759 * a {@code Window} at any time, even if it is an instance of {@code Stage}
760 * and while it is in {@link Stage#fullScreen} mode.
761 * If the width or height of this {@code Window} have never been set by the
762 * application, setting the scene will cause this {@code Window} to take its
763 * width or height from that scene. Resizing this window by end user does
764 * not count as setting the width or height by the application.
765 *
766 * An {@link IllegalStateException} is thrown if this property is set
767 * on a thread other than the JavaFX Application Thread.
768 *
769 * @defaultValue null
770 */
771 private SceneModel scene = new SceneModel();
772 protected void setScene(Scene value) { scene.set(value); }
773 public final Scene getScene() { return scene.get(); }
774 public final ReadOnlyObjectProperty<Scene> sceneProperty() { return scene.getReadOnlyProperty(); }
775
776 private final class SceneModel extends ReadOnlyObjectWrapper<Scene> {
777 private Scene oldScene;
778
779 @Override protected void invalidated() {
780 final Scene newScene = get();
824
825 @Override
826 public Object getBean() {
827 return Window.this;
828 }
829
830 @Override
831 public String getName() {
832 return "scene";
833 }
834
835 private void updatePeerScene(final TKScene tkScene) {
836 if (peer != null) {
837 // Set scene impl on stage impl
838 peer.setScene(tkScene);
839 }
840 }
841 }
842
843 /**
844 * Defines the opacity of the {@code Window} as a value between 0.0 and 1.0.
845 * The opacity is reflected across the {@code Window}, its {@code Decoration}
846 * and its {@code Scene} content. On a JavaFX runtime platform that does not
847 * support opacity, assigning a value to this variable will have no
848 * visible difference. A {@code Window} with 0% opacity is fully translucent.
849 * Typically, a {@code Window} with 0% opacity will not receive any mouse
850 * events.
851 *
852 * @defaultValue 1.0
853 */
854 private DoubleProperty opacity;
855
856 public final void setOpacity(double value) {
857 opacityProperty().set(value);
858 }
859
860 public final double getOpacity() {
861 return opacity == null ? 1.0 : opacity.get();
862 }
863
864 public final DoubleProperty opacityProperty() {
865 if (opacity == null) {
866 opacity = new DoublePropertyBase(1.0) {
867
868 @Override
869 protected void invalidated() {
1023 onHidden = new ObjectPropertyBase<EventHandler<WindowEvent>>() {
1024 @Override protected void invalidated() {
1025 setEventHandler(WindowEvent.WINDOW_HIDDEN, get());
1026 }
1027
1028 @Override
1029 public Object getBean() {
1030 return Window.this;
1031 }
1032
1033 @Override
1034 public String getName() {
1035 return "onHidden";
1036 }
1037 };
1038 }
1039 return onHidden;
1040 }
1041
1042 /**
1043 * Whether or not this {@code Window} is showing (that is, open on the
1044 * user's system). The Stage might be "showing", yet the user might not
1045 * be able to see it due to the Stage being rendered behind another window
1046 * or due to the Stage being positioned off the monitor.
1047 *
1048 * @defaultValue false
1049 */
1050 private ReadOnlyBooleanWrapper showing = new ReadOnlyBooleanWrapper() {
1051 private boolean oldVisible;
1052
1053 @Override protected void invalidated() {
1054 final boolean newVisible = get();
1055 if (oldVisible == newVisible) {
1056 return;
1057 }
1058
1059 if (!oldVisible && newVisible) {
1060 fireEvent(new WindowEvent(Window.this, WindowEvent.WINDOW_SHOWING));
1061 } else {
1062 fireEvent(new WindowEvent(Window.this, WindowEvent.WINDOW_HIDING));
1063 }
|