1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
736 0, 0, 3.0f, 1.0f, 10, 51, 51, 25, 25, 25, 25);
737 }
738 };
739
740 static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() {
741 Border getForegroundShadowBorder() {
742 return new AquaUtils.SlicedShadowBorder(new Painter() {
743 public void paint(final Graphics g, final int x, final int y, final int w, final int h) {
744 g.setColor(new Color(0, 0, 0, 128));
745 g.fillRect(x, y + 3, w, h - 3);
746 }
747 }, null,
748 0, 3, 1.0f, 1.0f, 10, 25, 25, 12, 12, 12, 12);
749 }
750
751 Border getBackgroundShadowBorder() {
752 return getForegroundShadowBorder();
753 }
754 };
755
756 static class CompoundUIBorder extends CompoundBorder implements UIResource {
757 public CompoundUIBorder(final Border inside, final Border outside) { super(inside, outside); }
758 }
759
760 abstract static class InternalFrameShadow extends RecyclableSingleton<Border> {
761 abstract Border getForegroundShadowBorder();
762 abstract Border getBackgroundShadowBorder();
763
764 protected Border getInstance() {
765 final Border fgShadow = getForegroundShadowBorder();
766 final Border bgShadow = getBackgroundShadowBorder();
767
768 return new Border() {
769 public Insets getBorderInsets(final Component c) {
770 return fgShadow.getBorderInsets(c);
771 }
772
773 public boolean isBorderOpaque() {
774 return false;
775 }
779 fgShadow.paintBorder(c, g, x, y, w, h);
780 } else {
781 bgShadow.paintBorder(c, g, x, y, w, h);
782 }
783 }
784 };
785 }
786 }
787
788 static final RecyclableSingleton<Icon> RESIZE_ICON = new RecyclableSingleton<Icon>() {
789 protected Icon getInstance() {
790 return new AquaIcon.CachableJRSUIIcon(11, 11) {
791 public void initIconPainter(final AquaPainter<JRSUIState> iconState) {
792 iconState.state.set(Widget.GROW_BOX_TEXTURED);
793 iconState.state.set(WindowType.UTILITY);
794 }
795 };
796 }
797 };
798
799 class ResizeBox extends JLabel implements MouseListener, MouseMotionListener, MouseWheelListener, ComponentListener, PropertyChangeListener, UIResource {
800 final JLayeredPane layeredPane;
801 Dimension originalSize;
802 Point originalLocation;
803
804 public ResizeBox(final JLayeredPane layeredPane) {
805 super(RESIZE_ICON.get());
806 setSize(11, 11);
807 this.layeredPane = layeredPane;
808
809 addMouseListener(this);
810 addMouseMotionListener(this);
811 addMouseWheelListener(this);
812 }
813
814 void addListeners() {
815 frame.addPropertyChangeListener("resizable", this);
816 }
817
818 void removeListeners() {
|
1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
736 0, 0, 3.0f, 1.0f, 10, 51, 51, 25, 25, 25, 25);
737 }
738 };
739
740 static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() {
741 Border getForegroundShadowBorder() {
742 return new AquaUtils.SlicedShadowBorder(new Painter() {
743 public void paint(final Graphics g, final int x, final int y, final int w, final int h) {
744 g.setColor(new Color(0, 0, 0, 128));
745 g.fillRect(x, y + 3, w, h - 3);
746 }
747 }, null,
748 0, 3, 1.0f, 1.0f, 10, 25, 25, 12, 12, 12, 12);
749 }
750
751 Border getBackgroundShadowBorder() {
752 return getForegroundShadowBorder();
753 }
754 };
755
756 @SuppressWarnings("serial") // Superclass is not serializable across versions
757 static class CompoundUIBorder extends CompoundBorder implements UIResource {
758 public CompoundUIBorder(final Border inside, final Border outside) { super(inside, outside); }
759 }
760
761 abstract static class InternalFrameShadow extends RecyclableSingleton<Border> {
762 abstract Border getForegroundShadowBorder();
763 abstract Border getBackgroundShadowBorder();
764
765 protected Border getInstance() {
766 final Border fgShadow = getForegroundShadowBorder();
767 final Border bgShadow = getBackgroundShadowBorder();
768
769 return new Border() {
770 public Insets getBorderInsets(final Component c) {
771 return fgShadow.getBorderInsets(c);
772 }
773
774 public boolean isBorderOpaque() {
775 return false;
776 }
780 fgShadow.paintBorder(c, g, x, y, w, h);
781 } else {
782 bgShadow.paintBorder(c, g, x, y, w, h);
783 }
784 }
785 };
786 }
787 }
788
789 static final RecyclableSingleton<Icon> RESIZE_ICON = new RecyclableSingleton<Icon>() {
790 protected Icon getInstance() {
791 return new AquaIcon.CachableJRSUIIcon(11, 11) {
792 public void initIconPainter(final AquaPainter<JRSUIState> iconState) {
793 iconState.state.set(Widget.GROW_BOX_TEXTURED);
794 iconState.state.set(WindowType.UTILITY);
795 }
796 };
797 }
798 };
799
800 @SuppressWarnings("serial") // Superclass is not serializable across versions
801 class ResizeBox extends JLabel implements MouseListener, MouseMotionListener, MouseWheelListener, ComponentListener, PropertyChangeListener, UIResource {
802 final JLayeredPane layeredPane;
803 Dimension originalSize;
804 Point originalLocation;
805
806 public ResizeBox(final JLayeredPane layeredPane) {
807 super(RESIZE_ICON.get());
808 setSize(11, 11);
809 this.layeredPane = layeredPane;
810
811 addMouseListener(this);
812 addMouseMotionListener(this);
813 addMouseWheelListener(this);
814 }
815
816 void addListeners() {
817 frame.addPropertyChangeListener("resizable", this);
818 }
819
820 void removeListeners() {
|