1 /*
2 * Copyright (c) 2011, 2012, 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
99 class DockLayoutManager implements LayoutManager {
100 public void addLayoutComponent(final String name, final Component comp) {
101 }
102
103 public void removeLayoutComponent(final Component comp) {
104 }
105
106 public Dimension preferredLayoutSize(final Container parent) {
107 return parent.getSize();
108 }
109
110 public Dimension minimumLayoutSize(final Container parent) {
111 return parent.getSize();
112 }
113
114 public void layoutContainer(final Container parent) {
115 if (fDock != null) ((Dock)fDock).updateSize();
116 }
117 }
118
119 class Dock extends JComponent implements Border {
120 static final int DOCK_EDGE_SLACK = 8;
121
122 Dock(final JComponent parent) {
123 setBorder(this);
124 setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
125 setVisible(false);
126 }
127
128 public void removeNotify() {
129 fDock = null;
130 super.removeNotify();
131 }
132
133 void updateSize() {
134 final Dimension d = getPreferredSize();
135 setBounds((getParent().getWidth() - d.width) / 2, getParent().getHeight() - d.height, d.width, d.height);
136 }
137
138 public Component add(final Component c) {
168 if (!(g instanceof Graphics2D)) return;
169 final Graphics2D g2d = (Graphics2D)g;
170
171 final int height = getHeight();
172 final int width = getWidth();
173
174 final Object priorAA = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
175 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
176
177 g2d.setColor(UIManager.getColor("DesktopIcon.borderColor"));
178 g2d.fillRoundRect(4, 4, width - 9, height + DOCK_EDGE_SLACK, DOCK_EDGE_SLACK, DOCK_EDGE_SLACK);
179
180 g2d.setColor(UIManager.getColor("DesktopIcon.borderRimColor"));
181 g2d.setStroke(new BasicStroke(2.0f));
182 g2d.drawRoundRect(4, 4, width - 9, height + DOCK_EDGE_SLACK, DOCK_EDGE_SLACK, DOCK_EDGE_SLACK);
183
184 if (priorAA != null) g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, priorAA);
185 }
186 }
187
188 class AquaDockingDesktopManager extends AquaInternalFrameManager {
189 public void openFrame(final JInternalFrame f) {
190 final JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
191 final Container dock = desktopIcon.getParent();
192 if (dock == null) return;
193
194 if (dock.getParent() != null) dock.getParent().add(f);
195 removeIconFor(f);
196 }
197
198 public void deiconifyFrame(final JInternalFrame f) {
199 final JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
200 final Container dock = desktopIcon.getParent();
201 if (dock == null) return;
202
203 if (dock.getParent() != null) dock.getParent().add(f);
204 removeIconFor(f);
205 // <rdar://problem/3712485> removed f.show(). show() is now deprecated and
206 // it wasn't sending our frame to front nor selecting it. Now, we move it
207 // to front and select it manualy. (vm)
|
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
99 class DockLayoutManager implements LayoutManager {
100 public void addLayoutComponent(final String name, final Component comp) {
101 }
102
103 public void removeLayoutComponent(final Component comp) {
104 }
105
106 public Dimension preferredLayoutSize(final Container parent) {
107 return parent.getSize();
108 }
109
110 public Dimension minimumLayoutSize(final Container parent) {
111 return parent.getSize();
112 }
113
114 public void layoutContainer(final Container parent) {
115 if (fDock != null) ((Dock)fDock).updateSize();
116 }
117 }
118
119 @SuppressWarnings("serial") // Superclass is not serializable across versions
120 class Dock extends JComponent implements Border {
121 static final int DOCK_EDGE_SLACK = 8;
122
123 Dock(final JComponent parent) {
124 setBorder(this);
125 setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
126 setVisible(false);
127 }
128
129 public void removeNotify() {
130 fDock = null;
131 super.removeNotify();
132 }
133
134 void updateSize() {
135 final Dimension d = getPreferredSize();
136 setBounds((getParent().getWidth() - d.width) / 2, getParent().getHeight() - d.height, d.width, d.height);
137 }
138
139 public Component add(final Component c) {
169 if (!(g instanceof Graphics2D)) return;
170 final Graphics2D g2d = (Graphics2D)g;
171
172 final int height = getHeight();
173 final int width = getWidth();
174
175 final Object priorAA = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
176 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
177
178 g2d.setColor(UIManager.getColor("DesktopIcon.borderColor"));
179 g2d.fillRoundRect(4, 4, width - 9, height + DOCK_EDGE_SLACK, DOCK_EDGE_SLACK, DOCK_EDGE_SLACK);
180
181 g2d.setColor(UIManager.getColor("DesktopIcon.borderRimColor"));
182 g2d.setStroke(new BasicStroke(2.0f));
183 g2d.drawRoundRect(4, 4, width - 9, height + DOCK_EDGE_SLACK, DOCK_EDGE_SLACK, DOCK_EDGE_SLACK);
184
185 if (priorAA != null) g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, priorAA);
186 }
187 }
188
189 @SuppressWarnings("serial") // JDK implementation class
190 class AquaDockingDesktopManager extends AquaInternalFrameManager {
191 public void openFrame(final JInternalFrame f) {
192 final JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
193 final Container dock = desktopIcon.getParent();
194 if (dock == null) return;
195
196 if (dock.getParent() != null) dock.getParent().add(f);
197 removeIconFor(f);
198 }
199
200 public void deiconifyFrame(final JInternalFrame f) {
201 final JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
202 final Container dock = desktopIcon.getParent();
203 if (dock == null) return;
204
205 if (dock.getParent() != null) dock.getParent().add(f);
206 removeIconFor(f);
207 // <rdar://problem/3712485> removed f.show(). show() is now deprecated and
208 // it wasn't sending our frame to front nor selecting it. Now, we move it
209 // to front and select it manualy. (vm)
|