author | anthony |
Tue, 12 Aug 2014 14:22:05 +0400 | |
changeset 26342 | 3637212ae8f2 |
parent 25195 | 9de77f5b0df2 |
permissions | -rw-r--r-- |
15983 | 1 |
/* |
2 |
* Copyright (c) 2013, 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.swing; |
|
27 |
||
28 |
import javax.swing.JComponent; |
|
26342
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
29 |
import java.awt.Component; |
20127 | 30 |
import java.awt.Cursor; |
26342
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
31 |
import java.awt.dnd.DragGestureEvent; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
32 |
import java.awt.dnd.DragGestureListener; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
33 |
import java.awt.dnd.DragGestureRecognizer; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
34 |
import java.awt.dnd.DragSource; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
35 |
import java.awt.dnd.DropTarget; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
36 |
import java.awt.dnd.InvalidDnDOperationException; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
37 |
import java.awt.dnd.peer.DragSourceContextPeer; |
15983 | 38 |
|
39 |
/** |
|
40 |
* The interface by means of which the {@link JLightweightFrame} class |
|
41 |
* communicates to its client application. |
|
42 |
* <p> |
|
43 |
* The client application implements this interface so it can response |
|
44 |
* to requests and process notifications from {@code JLightweightFrame}. |
|
45 |
* An implementation of this interface is associated with a {@code |
|
46 |
* JLightweightFrame} instance via the {@link JLightweightFrame#setContent} |
|
47 |
* method. |
|
48 |
* |
|
49 |
* A hierarchy of components contained in the {@code JComponent} instance |
|
50 |
* returned by the {@link #getComponent} method should not contain any |
|
51 |
* heavyweight components, otherwise {@code JLightweightFrame} may fail |
|
52 |
* to paint it. |
|
53 |
* |
|
54 |
* @author Artem Ananiev |
|
55 |
* @author Anton Tarasov |
|
56 |
* @author Jim Graham |
|
57 |
*/ |
|
58 |
public interface LightweightContent { |
|
59 |
||
60 |
/** |
|
61 |
* The client application overrides this method to return the {@code |
|
62 |
* JComponent} instance which the {@code JLightweightFrame} container |
|
63 |
* will paint as its lightweight content. A hierarchy of components |
|
64 |
* contained in this component should not contain any heavyweight objects. |
|
65 |
* |
|
66 |
* @return the component to paint |
|
67 |
*/ |
|
68 |
public JComponent getComponent(); |
|
69 |
||
70 |
/** |
|
71 |
* {@code JLightweightFrame} calls this method to notify the client |
|
72 |
* application that it acquires the paint lock. The client application |
|
73 |
* should implement the locking mechanism in order to synchronize access |
|
74 |
* to the content image data, shared between {@code JLightweightFrame} |
|
75 |
* and the client application. |
|
76 |
* |
|
77 |
* @see #paintUnlock |
|
78 |
*/ |
|
79 |
public void paintLock(); |
|
80 |
||
81 |
/** |
|
82 |
* {@code JLightweightFrame} calls this method to notify the client |
|
83 |
* application that it releases the paint lock. The client application |
|
84 |
* should implement the locking mechanism in order to synchronize access |
|
85 |
* to the content image data, shared between {@code JLightweightFrame} |
|
86 |
* and the client application. |
|
87 |
* |
|
88 |
* @see #paintLock |
|
89 |
*/ |
|
90 |
public void paintUnlock(); |
|
91 |
||
92 |
/** |
|
93 |
* {@code JLightweightFrame} calls this method to notify the client |
|
94 |
* application that a new data buffer has been set as a content pixel |
|
95 |
* buffer. Typically this occurs when a buffer of a larger size is |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
96 |
* created in response to a content resize event. |
15983 | 97 |
* <p> |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
98 |
* The method reports a reference to the pixel data buffer, the content |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
99 |
* image bounds within the buffer and the line stride of the buffer. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
100 |
* These values have the following correlation. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
101 |
* The {@code width} and {@code height} matches the layout size of the content |
15983 | 102 |
* (the component returned from the {@link #getComponent} method). The |
103 |
* {@code x} and {@code y} is the origin of the content, {@code (0, 0)} |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
104 |
* in the layout coordinate space of the content, appearing at |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
105 |
* {@code data[y * scale * linestride + x * scale]} in the buffer. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
106 |
* A pixel with indices {@code (i, j)}, where {@code (0 <= i < width)} and |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
107 |
* {@code (0 <= j < height)}, in the layout coordinate space of the content |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
108 |
* is represented by a {@code scale^2} square of pixels in the physical |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
109 |
* coordinate space of the buffer. The top-left corner of the square has the |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
110 |
* following physical coordinate in the buffer: |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
111 |
* {@code data[(y + j) * scale * linestride + (x + i) * scale]}. |
15983 | 112 |
* |
113 |
* @param data the content pixel data buffer of INT_ARGB_PRE type |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
114 |
* @param x the logical x coordinate of the image |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
115 |
* @param y the logical y coordinate of the image |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
116 |
* @param width the logical width of the image |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
117 |
* @param height the logical height of the image |
15983 | 118 |
* @param linestride the line stride of the pixel buffer |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
119 |
* @param scale the scale factor of the pixel buffer |
15983 | 120 |
*/ |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
121 |
default public void imageBufferReset(int[] data, |
15983 | 122 |
int x, int y, |
123 |
int width, int height, |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
124 |
int linestride, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
125 |
int scale) |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
126 |
{ |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
127 |
imageBufferReset(data, x, y, width, height, linestride); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
128 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
129 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
130 |
/** |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
131 |
* The default implementation for #imageBufferReset uses a hard-coded value |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
132 |
* of 1 for the scale factor. Both the old and the new methods provide |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
133 |
* default implementations in order to allow a client application to run |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
134 |
* with any JDK version without breaking backward compatibility. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
135 |
*/ |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
136 |
default public void imageBufferReset(int[] data, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
137 |
int x, int y, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
138 |
int width, int height, |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
139 |
int linestride) |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
140 |
{ |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
141 |
imageBufferReset(data, x, y, width, height, linestride, 1); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
20127
diff
changeset
|
142 |
} |
15983 | 143 |
|
144 |
/** |
|
145 |
* {@code JLightweightFrame} calls this method to notify the client |
|
146 |
* application that the content image bounds have been changed within the |
|
147 |
* image's pixel buffer. |
|
148 |
* |
|
149 |
* @param x the x coordinate of the image |
|
150 |
* @param y the y coordinate of the image |
|
151 |
* @param width the width of the image |
|
152 |
* @param height the height of the image |
|
153 |
* |
|
154 |
* @see #imageBufferReset |
|
155 |
*/ |
|
156 |
public void imageReshaped(int x, int y, int width, int height); |
|
157 |
||
158 |
/** |
|
159 |
* {@code JLightweightFrame} calls this method to notify the client |
|
160 |
* application that a part of the content image, or the whole image has |
|
161 |
* been updated. The method reports bounds of the rectangular dirty region. |
|
162 |
* The {@code dirtyX} and {@code dirtyY} is the origin of the dirty |
|
163 |
* rectangle, which is relative to the origin of the content, appearing |
|
164 |
* at {@code data[(y + dirtyY] * linestride + (x + dirtyX)]} in the pixel |
|
165 |
* buffer (see {@link #imageBufferReset}). All indices |
|
166 |
* {@code data[(y + dirtyY + j) * linestride + (x + dirtyX + i)]} where |
|
167 |
* {@code (0 <= i < dirtyWidth)} and {@code (0 <= j < dirtyHeight)} |
|
168 |
* will represent valid pixel data, {@code (i, j)} in the coordinate space |
|
169 |
* of the dirty rectangle. |
|
170 |
* |
|
171 |
* @param dirtyX the x coordinate of the dirty rectangle, |
|
172 |
* relative to the image origin |
|
173 |
* @param dirtyY the y coordinate of the dirty rectangle, |
|
174 |
* relative to the image origin |
|
175 |
* @param dirtyWidth the width of the dirty rectangle |
|
176 |
* @param dirtyHeight the height of the dirty rectangle |
|
177 |
* |
|
178 |
* @see #imageBufferReset |
|
179 |
* @see #imageReshaped |
|
180 |
*/ |
|
181 |
public void imageUpdated(int dirtyX, int dirtyY, |
|
182 |
int dirtyWidth, int dirtyHeight); |
|
183 |
||
184 |
/** |
|
185 |
* {@code JLightweightFrame} calls this method to notify the client |
|
186 |
* application that the frame has grabbed focus. |
|
187 |
*/ |
|
188 |
public void focusGrabbed(); |
|
189 |
||
190 |
/** |
|
191 |
* {@code JLightweightFrame} calls this method to notify the client |
|
192 |
* application that the frame has ungrabbed focus. |
|
193 |
*/ |
|
194 |
public void focusUngrabbed(); |
|
19026
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
195 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
196 |
/** |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
197 |
* {@code JLightweightFrame} calls this method to notify the client |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
198 |
* application that the content preferred size has changed. |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
199 |
*/ |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
200 |
public void preferredSizeChanged(int width, int height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
201 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
202 |
/** |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
203 |
* {@code JLightweightFrame} calls this method to notify the client |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
204 |
* application that the content maximum size has changed. |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
205 |
*/ |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
206 |
public void maximumSizeChanged(int width, int height); |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
207 |
|
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
208 |
/** |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
209 |
* {@code JLightweightFrame} calls this method to notify the client |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
210 |
* application that the content minimum size has changed. |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
211 |
*/ |
96141cb8d7eb
8020927: JLightweightFrame API should export layout properties change notifications
ant
parents:
15983
diff
changeset
|
212 |
public void minimumSizeChanged(int width, int height); |
20127 | 213 |
|
214 |
/** |
|
215 |
* {@code JLightweightFrame} calls this method to notify the client |
|
216 |
* application that in needs to set a cursor |
|
217 |
* @param cursor a cursor to set |
|
218 |
*/ |
|
219 |
default public void setCursor(Cursor cursor) { } |
|
26342
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
220 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
221 |
/** |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
222 |
* Create a drag gesture recognizer for the lightweight frame. |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
223 |
*/ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
224 |
default public <T extends DragGestureRecognizer> T createDragGestureRecognizer( |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
225 |
Class<T> abstractRecognizerClass, |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
226 |
DragSource ds, Component c, int srcActions, |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
227 |
DragGestureListener dgl) |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
228 |
{ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
229 |
return null; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
230 |
} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
231 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
232 |
/** |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
233 |
* Create a drag source context peer for the lightweight frame. |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
234 |
*/ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
235 |
default public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
236 |
{ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
237 |
return null; |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
238 |
} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
239 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
240 |
/** |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
241 |
* Adds a drop target to the lightweight frame. |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
242 |
*/ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
243 |
default public void addDropTarget(DropTarget dt) {} |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
244 |
|
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
245 |
/** |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
246 |
* Removes a drop target from the lightweight frame. |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
247 |
*/ |
3637212ae8f2
8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents:
25195
diff
changeset
|
248 |
default public void removeDropTarget(DropTarget dt) {} |
15983 | 249 |
} |