author | serb |
Fri, 17 Apr 2015 16:54:13 +0300 | |
changeset 30469 | bac0a7ff7e1e |
parent 28231 | b608ffcaed74 |
child 42199 | 8c0e8e13d4d8 |
permissions | -rw-r--r-- |
15983 | 1 |
/* |
30469 | 2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
15983 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.swing; |
|
27 |
||
28 |
import java.awt.BorderLayout; |
|
29 |
import java.awt.Color; |
|
30 |
import java.awt.Component; |
|
31 |
import java.awt.Container; |
|
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
32 |
import java.awt.Dimension; |
15983 | 33 |
import java.awt.EventQueue; |
34 |
import java.awt.Graphics; |
|
35 |
import java.awt.Graphics2D; |
|
20127 | 36 |
import java.awt.MouseInfo; |
37 |
import java.awt.Point; |
|
15983 | 38 |
import java.awt.Rectangle; |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
39 |
import java.awt.Window; |
26342
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
40 |
import java.awt.dnd.DragGestureEvent; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
41 |
import java.awt.dnd.DragGestureListener; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
42 |
import java.awt.dnd.DragGestureRecognizer; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
43 |
import java.awt.dnd.DragSource; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
44 |
import java.awt.dnd.DropTarget; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
45 |
import java.awt.dnd.InvalidDnDOperationException; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
46 |
import java.awt.dnd.peer.DragSourceContextPeer; |
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
47 |
import java.awt.event.ContainerEvent; |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
48 |
import java.awt.event.ContainerListener; |
15983 | 49 |
import java.awt.image.BufferedImage; |
50 |
import java.awt.image.DataBufferInt; |
|
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
51 |
import java.beans.PropertyChangeEvent; |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
52 |
import java.beans.PropertyChangeListener; |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
53 |
import java.security.AccessController; |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
54 |
import javax.swing.JComponent; |
15983 | 55 |
|
56 |
import javax.swing.JLayeredPane; |
|
57 |
import javax.swing.JPanel; |
|
58 |
import javax.swing.JRootPane; |
|
59 |
import javax.swing.LayoutFocusTraversalPolicy; |
|
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
60 |
import javax.swing.RepaintManager; |
15983 | 61 |
import javax.swing.RootPaneContainer; |
20127 | 62 |
import javax.swing.SwingUtilities; |
15983 | 63 |
|
30469 | 64 |
import sun.awt.AWTAccessor; |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
65 |
import sun.awt.DisplayChangedListener; |
15983 | 66 |
import sun.awt.LightweightFrame; |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
67 |
import sun.security.action.GetPropertyAction; |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
68 |
import sun.swing.SwingUtilities2.RepaintListener; |
15983 | 69 |
|
70 |
/** |
|
71 |
* The frame serves as a lightweight container which paints its content |
|
72 |
* to an offscreen image and provides access to the image's data via the |
|
73 |
* {@link LightweightContent} interface. Note, that it may not be shown |
|
74 |
* as a standalone toplevel frame. Its purpose is to provide functionality |
|
75 |
* for lightweight embedding. |
|
76 |
* |
|
77 |
* @author Artem Ananiev |
|
78 |
* @author Anton Tarasov |
|
79 |
*/ |
|
22618 | 80 |
@SuppressWarnings("serial") // JDK-implementation class |
15983 | 81 |
public final class JLightweightFrame extends LightweightFrame implements RootPaneContainer { |
82 |
||
83 |
private final JRootPane rootPane = new JRootPane(); |
|
84 |
||
85 |
private LightweightContent content; |
|
86 |
||
87 |
private Component component; |
|
88 |
private JPanel contentPane; |
|
89 |
||
90 |
private BufferedImage bbImage; |
|
91 |
||
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
92 |
private volatile int scaleFactor = 1; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
93 |
|
15983 | 94 |
/** |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
95 |
* {@code copyBufferEnabled}, true by default, defines the following strategy. |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
96 |
* A duplicating (copy) buffer is created for the original pixel buffer. |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
97 |
* The copy buffer is synchronized with the original buffer every time the |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
98 |
* latter changes. {@code JLightweightFrame} passes the copy buffer array |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
99 |
* to the {@link LightweightContent#imageBufferReset} method. The code spot |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
100 |
* which synchronizes two buffers becomes the only critical section guarded |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
101 |
* by the lock (managed with the {@link LightweightContent#paintLock()}, |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
102 |
* {@link LightweightContent#paintUnlock()} methods). |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
103 |
*/ |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
104 |
private static boolean copyBufferEnabled; |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
105 |
private int[] copyBuffer; |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
106 |
|
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
107 |
private PropertyChangeListener layoutSizeListener; |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
108 |
private RepaintListener repaintListener; |
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
109 |
|
20127 | 110 |
static { |
111 |
SwingAccessor.setJLightweightFrameAccessor(new SwingAccessor.JLightweightFrameAccessor() { |
|
112 |
@Override |
|
113 |
public void updateCursor(JLightweightFrame frame) { |
|
114 |
frame.updateClientCursor(); |
|
115 |
} |
|
116 |
}); |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
117 |
copyBufferEnabled = "true".equals(AccessController. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
118 |
doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); |
20127 | 119 |
} |
120 |
||
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
121 |
/** |
15983 | 122 |
* Constructs a new, initially invisible {@code JLightweightFrame} |
123 |
* instance. |
|
124 |
*/ |
|
125 |
public JLightweightFrame() { |
|
126 |
super(); |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
127 |
copyBufferEnabled = "true".equals(AccessController. |
20136
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
128 |
doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
129 |
|
15983 | 130 |
add(rootPane, BorderLayout.CENTER); |
131 |
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); |
|
16706
4b243017cd27
8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents:
15983
diff
changeset
|
132 |
if (getGraphicsConfiguration().isTranslucencyCapable()) { |
4b243017cd27
8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents:
15983
diff
changeset
|
133 |
setBackground(new Color(0, 0, 0, 0)); |
4b243017cd27
8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents:
15983
diff
changeset
|
134 |
} |
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
135 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
136 |
layoutSizeListener = new PropertyChangeListener() { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
137 |
@Override |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
138 |
public void propertyChange(PropertyChangeEvent e) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
139 |
Dimension d = (Dimension)e.getNewValue(); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
140 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
141 |
if ("preferredSize".equals(e.getPropertyName())) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
142 |
content.preferredSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
143 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
144 |
} else if ("maximumSize".equals(e.getPropertyName())) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
145 |
content.maximumSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
146 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
147 |
} else if ("minimumSize".equals(e.getPropertyName())) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
148 |
content.minimumSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
149 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
150 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
151 |
}; |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
152 |
|
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
153 |
repaintListener = (JComponent c, int x, int y, int w, int h) -> { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
154 |
Window jlf = SwingUtilities.getWindowAncestor(c); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
155 |
if (jlf != JLightweightFrame.this) { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
156 |
return; |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
157 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
158 |
Point p = SwingUtilities.convertPoint(c, x, y, jlf); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
159 |
Rectangle r = new Rectangle(p.x, p.y, w, h).intersection( |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
160 |
new Rectangle(0, 0, bbImage.getWidth() / scaleFactor, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
161 |
bbImage.getHeight() / scaleFactor)); |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
162 |
|
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
163 |
if (!r.isEmpty()) { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
164 |
notifyImageUpdated(r.x, r.y, r.width, r.height); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
165 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
166 |
}; |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
167 |
|
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
168 |
SwingAccessor.getRepaintManagerAccessor().addRepaintListener( |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
169 |
RepaintManager.currentManager(this), repaintListener); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
170 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
171 |
|
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
172 |
@Override |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
173 |
public void dispose() { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
174 |
SwingAccessor.getRepaintManagerAccessor().removeRepaintListener( |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
175 |
RepaintManager.currentManager(this), repaintListener); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
176 |
super.dispose(); |
15983 | 177 |
} |
178 |
||
179 |
/** |
|
180 |
* Sets the {@link LightweightContent} instance for this frame. |
|
181 |
* The {@code JComponent} object returned by the |
|
182 |
* {@link LightweightContent#getComponent()} method is immediately |
|
183 |
* added to the frame's content pane. |
|
184 |
* |
|
185 |
* @param content the {@link LightweightContent} instance |
|
186 |
*/ |
|
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
187 |
public void setContent(final LightweightContent content) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
188 |
if (content == null) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
189 |
System.err.println("JLightweightFrame.setContent: content may not be null!"); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
190 |
return; |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
191 |
} |
15983 | 192 |
this.content = content; |
193 |
this.component = content.getComponent(); |
|
194 |
||
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
195 |
Dimension d = this.component.getPreferredSize(); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
196 |
content.preferredSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
197 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
198 |
d = this.component.getMaximumSize(); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
199 |
content.maximumSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
200 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
201 |
d = this.component.getMinimumSize(); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
202 |
content.minimumSizeChanged(d.width, d.height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
203 |
|
15983 | 204 |
initInterior(); |
205 |
} |
|
206 |
||
207 |
@Override |
|
208 |
public Graphics getGraphics() { |
|
209 |
if (bbImage == null) return null; |
|
210 |
||
211 |
Graphics2D g = bbImage.createGraphics(); |
|
212 |
g.setBackground(getBackground()); |
|
213 |
g.setColor(getForeground()); |
|
214 |
g.setFont(getFont()); |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
215 |
g.scale(scaleFactor, scaleFactor); |
15983 | 216 |
return g; |
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* {@inheritDoc} |
|
221 |
* |
|
222 |
* @see LightweightContent#focusGrabbed() |
|
223 |
*/ |
|
224 |
@Override |
|
225 |
public void grabFocus() { |
|
226 |
if (content != null) content.focusGrabbed(); |
|
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* {@inheritDoc} |
|
231 |
* |
|
232 |
* @see LightweightContent#focusUngrabbed() |
|
233 |
*/ |
|
234 |
@Override |
|
235 |
public void ungrabFocus() { |
|
236 |
if (content != null) content.focusUngrabbed(); |
|
237 |
} |
|
238 |
||
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
239 |
@Override |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
240 |
public int getScaleFactor() { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
241 |
return scaleFactor; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
242 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
243 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
244 |
@Override |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
245 |
public void notifyDisplayChanged(final int scaleFactor) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
246 |
if (scaleFactor != this.scaleFactor) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
247 |
if (!copyBufferEnabled) content.paintLock(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
248 |
try { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
249 |
if (bbImage != null) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
250 |
resizeBuffer(getWidth(), getHeight(), scaleFactor); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
251 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
252 |
} finally { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
253 |
if (!copyBufferEnabled) content.paintUnlock(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
254 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
255 |
this.scaleFactor = scaleFactor; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
256 |
} |
30469 | 257 |
final Object peer = AWTAccessor.getComponentAccessor().getPeer(this); |
258 |
if (peer instanceof DisplayChangedListener) { |
|
259 |
((DisplayChangedListener) peer).displayChanged(); |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
260 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
261 |
repaint(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
262 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
263 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
264 |
@Override |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
265 |
public void addNotify() { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
266 |
super.addNotify(); |
30469 | 267 |
final Object peer = AWTAccessor.getComponentAccessor().getPeer(this); |
268 |
if (peer instanceof DisplayChangedListener) { |
|
269 |
((DisplayChangedListener) peer).displayChanged(); |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
270 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
271 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
272 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
273 |
private void syncCopyBuffer(boolean reset, int x, int y, int w, int h, int scale) { |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
274 |
content.paintLock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
275 |
try { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
276 |
int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
277 |
if (reset) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
278 |
copyBuffer = new int[srcBuffer.length]; |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
279 |
} |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
280 |
int linestride = bbImage.getWidth(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
281 |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
282 |
x *= scale; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
283 |
y *= scale; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
284 |
w *= scale; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
285 |
h *= scale; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
286 |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
287 |
for (int i=0; i<h; i++) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
288 |
int from = (y + i) * linestride + x; |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
289 |
System.arraycopy(srcBuffer, from, copyBuffer, from, w); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
290 |
} |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
291 |
} finally { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
292 |
content.paintUnlock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
293 |
} |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
294 |
} |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
295 |
|
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
296 |
private void notifyImageUpdated(int x, int y, int width, int height) { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
297 |
if (copyBufferEnabled) { |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
298 |
syncCopyBuffer(false, x, y, width, height, scaleFactor); |
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
299 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
300 |
content.imageUpdated(x, y, width, height); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
301 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
20136
diff
changeset
|
302 |
|
22618 | 303 |
@SuppressWarnings("serial") // anonymous class inside |
15983 | 304 |
private void initInterior() { |
305 |
contentPane = new JPanel() { |
|
306 |
@Override |
|
307 |
public void paint(Graphics g) { |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
308 |
if (!copyBufferEnabled) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
309 |
content.paintLock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
310 |
} |
15983 | 311 |
try { |
312 |
super.paint(g); |
|
313 |
||
314 |
final Rectangle clip = g.getClipBounds() != null ? |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
315 |
g.getClipBounds() : |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
316 |
new Rectangle(0, 0, contentPane.getWidth(), contentPane.getHeight()); |
15983 | 317 |
|
318 |
clip.x = Math.max(0, clip.x); |
|
319 |
clip.y = Math.max(0, clip.y); |
|
320 |
clip.width = Math.min(contentPane.getWidth(), clip.width); |
|
321 |
clip.height = Math.min(contentPane.getHeight(), clip.height); |
|
322 |
||
323 |
EventQueue.invokeLater(new Runnable() { |
|
324 |
@Override |
|
325 |
public void run() { |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
326 |
Rectangle c = contentPane.getBounds().intersection(clip); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
327 |
notifyImageUpdated(c.x, c.y, c.width, c.height); |
15983 | 328 |
} |
329 |
}); |
|
330 |
} finally { |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
331 |
if (!copyBufferEnabled) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
332 |
content.paintUnlock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
333 |
} |
15983 | 334 |
} |
335 |
} |
|
336 |
@Override |
|
337 |
protected boolean isPaintingOrigin() { |
|
338 |
return true; |
|
339 |
} |
|
340 |
}; |
|
341 |
contentPane.setLayout(new BorderLayout()); |
|
342 |
contentPane.add(component); |
|
20136
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
343 |
if ("true".equals(AccessController. |
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
344 |
doPrivileged(new GetPropertyAction("swing.jlf.contentPaneTransparent", "false")))) |
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
345 |
{ |
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
346 |
contentPane.setOpaque(false); |
594c0830f18c
8022512: JLightweightFrame: the content pane should be transparent
ant
parents:
20127
diff
changeset
|
347 |
} |
15983 | 348 |
setContentPane(contentPane); |
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
349 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
350 |
contentPane.addContainerListener(new ContainerListener() { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
351 |
@Override |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
352 |
public void componentAdded(ContainerEvent e) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
353 |
Component c = JLightweightFrame.this.component; |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
354 |
if (e.getChild() == c) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
355 |
c.addPropertyChangeListener("preferredSize", layoutSizeListener); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
356 |
c.addPropertyChangeListener("maximumSize", layoutSizeListener); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
357 |
c.addPropertyChangeListener("minimumSize", layoutSizeListener); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
358 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
359 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
360 |
@Override |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
361 |
public void componentRemoved(ContainerEvent e) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
362 |
Component c = JLightweightFrame.this.component; |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
363 |
if (e.getChild() == c) { |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
364 |
c.removePropertyChangeListener(layoutSizeListener); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
365 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
366 |
} |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
17415
diff
changeset
|
367 |
}); |
15983 | 368 |
} |
369 |
||
370 |
@SuppressWarnings("deprecation") |
|
371 |
@Override public void reshape(int x, int y, int width, int height) { |
|
372 |
super.reshape(x, y, width, height); |
|
373 |
||
374 |
if (width == 0 || height == 0) { |
|
375 |
return; |
|
376 |
} |
|
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
377 |
if (!copyBufferEnabled) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
378 |
content.paintLock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
379 |
} |
15983 | 380 |
try { |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
381 |
boolean createBB = (bbImage == null); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
382 |
int newW = width; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
383 |
int newH = height; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
384 |
if (bbImage != null) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
385 |
int imgWidth = bbImage.getWidth() / scaleFactor; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
386 |
int imgHeight = bbImage.getHeight() / scaleFactor; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
387 |
if (width != imgWidth || height != imgHeight) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
388 |
createBB = true; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
389 |
if (bbImage != null) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
390 |
int oldW = imgWidth; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
391 |
int oldH = imgHeight; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
392 |
if ((oldW >= newW) && (oldH >= newH)) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
393 |
createBB = false; |
15983 | 394 |
} else { |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
395 |
if (oldW >= newW) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
396 |
newW = oldW; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
397 |
} else { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
398 |
newW = Math.max((int)(oldW * 1.2), width); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
399 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
400 |
if (oldH >= newH) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
401 |
newH = oldH; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
402 |
} else { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
403 |
newH = Math.max((int)(oldH * 1.2), height); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
404 |
} |
15983 | 405 |
} |
406 |
} |
|
407 |
} |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
408 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
409 |
if (createBB) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
410 |
resizeBuffer(newW, newH, scaleFactor); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
411 |
return; |
15983 | 412 |
} |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
413 |
content.imageReshaped(0, 0, width, height); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
414 |
|
15983 | 415 |
} finally { |
17415
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
416 |
if (!copyBufferEnabled) { |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
417 |
content.paintUnlock(); |
62b97a10da72
8014227: JLightweightFrame needs another synchronization policy
ant
parents:
16706
diff
changeset
|
418 |
} |
15983 | 419 |
} |
420 |
} |
|
421 |
||
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
422 |
private void resizeBuffer(int width, int height, int newScaleFactor) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
423 |
bbImage = new BufferedImage(width*newScaleFactor,height*newScaleFactor, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
424 |
BufferedImage.TYPE_INT_ARGB_PRE); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
425 |
int[] pixels= ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
426 |
if (copyBufferEnabled) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
427 |
syncCopyBuffer(true, 0, 0, width, height, newScaleFactor); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
428 |
pixels = copyBuffer; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
429 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
430 |
content.imageBufferReset(pixels, 0, 0, width, height, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
431 |
width * newScaleFactor, newScaleFactor); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
432 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
23281
diff
changeset
|
433 |
|
15983 | 434 |
@Override |
435 |
public JRootPane getRootPane() { |
|
436 |
return rootPane; |
|
437 |
} |
|
438 |
||
439 |
@Override |
|
440 |
public void setContentPane(Container contentPane) { |
|
441 |
getRootPane().setContentPane(contentPane); |
|
442 |
} |
|
443 |
||
444 |
@Override |
|
445 |
public Container getContentPane() { |
|
446 |
return getRootPane().getContentPane(); |
|
447 |
} |
|
448 |
||
449 |
@Override |
|
450 |
public void setLayeredPane(JLayeredPane layeredPane) { |
|
451 |
getRootPane().setLayeredPane(layeredPane); |
|
452 |
} |
|
453 |
||
454 |
@Override |
|
455 |
public JLayeredPane getLayeredPane() { |
|
456 |
return getRootPane().getLayeredPane(); |
|
457 |
} |
|
458 |
||
459 |
@Override |
|
460 |
public void setGlassPane(Component glassPane) { |
|
461 |
getRootPane().setGlassPane(glassPane); |
|
462 |
} |
|
463 |
||
464 |
@Override |
|
465 |
public Component getGlassPane() { |
|
466 |
return getRootPane().getGlassPane(); |
|
467 |
} |
|
20127 | 468 |
|
469 |
||
470 |
/* |
|
471 |
* Notifies client toolkit that it should change a cursor. |
|
472 |
* |
|
473 |
* Called from the peer via SwingAccessor, because the |
|
474 |
* Component.updateCursorImmediately method is final |
|
475 |
* and could not be overridden. |
|
476 |
*/ |
|
477 |
private void updateClientCursor() { |
|
478 |
Point p = MouseInfo.getPointerInfo().getLocation(); |
|
479 |
SwingUtilities.convertPointFromScreen(p, this); |
|
480 |
Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y); |
|
481 |
if (target != null) { |
|
482 |
content.setCursor(target.getCursor()); |
|
483 |
} |
|
484 |
} |
|
26342
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
485 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
486 |
public <T extends DragGestureRecognizer> T createDragGestureRecognizer( |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
487 |
Class<T> abstractRecognizerClass, |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
488 |
DragSource ds, Component c, int srcActions, |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
489 |
DragGestureListener dgl) |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
490 |
{ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
491 |
return content == null ? null : content.createDragGestureRecognizer( |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
492 |
abstractRecognizerClass, ds, c, srcActions, dgl); |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
493 |
} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
494 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
495 |
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
496 |
return content == null ? null : content.createDragSourceContextPeer(dge); |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
497 |
} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
498 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
499 |
public void addDropTarget(DropTarget dt) { |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
500 |
if (content == null) return; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
501 |
content.addDropTarget(dt); |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
502 |
} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
503 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
504 |
public void removeDropTarget(DropTarget dt) { |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
505 |
if (content == null) return; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
506 |
content.removeDropTarget(dt); |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
507 |
} |
15983 | 508 |
} |