APIdia Launch Partner
Top Description Methods
sun.swing

public Interface LightweightContent

Imports
javax.swing.JComponent, java.awt.Component, .Cursor, java.awt.dnd.DragGestureEvent, .DragGestureListener, .DragGestureRecognizer, .DragSource, .DropTarget, .InvalidDnDOperationException, java.awt.dnd.peer.DragSourceContextPeer

The interface by means of which the JLightweightFrame class communicates to its client application.

The client application implements this interface so it can response to requests and process notifications from JLightweightFrame. An implementation of this interface is associated with a JLightweightFrame instance via the JLightweightFrame#setContent method. A hierarchy of components contained in the JComponent instance returned by the getComponent method should not contain any heavyweight components, otherwise JLightweightFrame may fail to paint it.

Authors
Artem Ananiev, Anton Tarasov, Jim Graham

Method Summary

Modifier and TypeMethod and Description
public default void
addDropTarget(DropTarget dt)

Adds a drop target to the lightweight frame.

public default <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl)

Create a drag gesture recognizer for the lightweight frame.

public default DragSourceContextPeer
createDragSourceContextPeer(DragGestureEvent dge)

Create a drag source context peer for the lightweight frame.

public void
focusGrabbed()

JLightweightFrame calls this method to notify the client application that the frame has grabbed focus.

public void
focusUngrabbed()

JLightweightFrame calls this method to notify the client application that the frame has ungrabbed focus.

public JComponent

Returns:

the component to paint
getComponent
()

The client application overrides this method to return the JComponent instance which the JLightweightFrame container will paint as its lightweight content.

public default void
imageBufferReset(int[]
the content pixel data buffer of INT_ARGB_PRE type
data
,
int
the logical x coordinate of the image
x
,
int
the logical y coordinate of the image
y
,
int
the logical width of the image
width
,
int
the logical height of the image
height
,
int
the line stride of the pixel buffer
linestride
,
int
the scale factor of the pixel buffer
scale
)

JLightweightFrame calls this method to notify the client application that a new data buffer has been set as a content pixel buffer.

public default void
imageBufferReset(int[]
the content pixel data buffer of INT_ARGB_PRE type
data
,
int
the logical x coordinate of the image
x
,
int
the logical y coordinate of the image
y
,
int
the logical width of the image
width
,
int
the logical height of the image
height
,
int
the line stride of the pixel buffer
linestride
,
double
the x coordinate scale factor of the pixel buffer
scaleX
,
double
the y coordinate scale factor of the pixel buffer
scaleY
)

JLightweightFrame calls this method to notify the client application that a new data buffer has been set as a content pixel buffer.

public default void
imageBufferReset(int[] data, int x, int y, int width, int height, int linestride)

The default implementation for #imageBufferReset uses a hard-coded value of 1 for the scale factor.

public void
imageReshaped(int
the x coordinate of the image
x
,
int
the y coordinate of the image
y
,
int
the width of the image
width
,
int
the height of the image
height
)

JLightweightFrame calls this method to notify the client application that the content image bounds have been changed within the image's pixel buffer.

public void
imageUpdated(int
the x coordinate of the dirty rectangle, relative to the image origin
dirtyX
,
int
the y coordinate of the dirty rectangle, relative to the image origin
dirtyY
,
int
the width of the dirty rectangle
dirtyWidth
,
int
the height of the dirty rectangle
dirtyHeight
)

JLightweightFrame calls this method to notify the client application that a part of the content image, or the whole image has been updated.

public void
maximumSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content maximum size has changed.

public void
minimumSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content minimum size has changed.

public void
paintLock()

JLightweightFrame calls this method to notify the client application that it acquires the paint lock.

public void
paintUnlock()

JLightweightFrame calls this method to notify the client application that it releases the paint lock.

public void
preferredSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content preferred size has changed.

public default void
removeDropTarget(DropTarget dt)

Removes a drop target from the lightweight frame.

public default void
setCursor(Cursor
a cursor to set
cursor
)

JLightweightFrame calls this method to notify the client application that in needs to set a cursor

Method Detail

addDropTargetback to summary
public default void addDropTarget(DropTarget dt)

Adds a drop target to the lightweight frame.

createDragGestureRecognizerback to summary
public default <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl)

Create a drag gesture recognizer for the lightweight frame.

createDragSourceContextPeerback to summary
public default DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException

Create a drag source context peer for the lightweight frame.

focusGrabbedback to summary
public void focusGrabbed()

JLightweightFrame calls this method to notify the client application that the frame has grabbed focus.

focusUngrabbedback to summary
public void focusUngrabbed()

JLightweightFrame calls this method to notify the client application that the frame has ungrabbed focus.

getComponentback to summary
public JComponent getComponent()

The client application overrides this method to return the JComponent instance which the JLightweightFrame container will paint as its lightweight content. A hierarchy of components contained in this component should not contain any heavyweight objects.

Returns:JComponent

the component to paint

imageBufferResetback to summary
public default void imageBufferReset(int[] data, int x, int y, int width, int height, int linestride, int scale)

JLightweightFrame calls this method to notify the client application that a new data buffer has been set as a content pixel buffer. Typically this occurs when a buffer of a larger size is created in response to a content resize event.

The method reports a reference to the pixel data buffer, the content image bounds within the buffer and the line stride of the buffer. These values have the following correlation. The width and height matches the layout size of the content (the component returned from the getComponent method). The x and y is the origin of the content, (0, 0) in the layout coordinate space of the content, appearing at data[y * scale * linestride + x * scale] in the buffer. A pixel with indices (i, j), where (0 <= i < width) and (0 <= j < height), in the layout coordinate space of the content is represented by a scale^2 square of pixels in the physical coordinate space of the buffer. The top-left corner of the square has the following physical coordinate in the buffer: data[(y + j) * scale * linestride + (x + i) * scale].

Parameters
data:int[]

the content pixel data buffer of INT_ARGB_PRE type

x:int

the logical x coordinate of the image

y:int

the logical y coordinate of the image

width:int

the logical width of the image

height:int

the logical height of the image

linestride:int

the line stride of the pixel buffer

scale:int

the scale factor of the pixel buffer

Annotations
@Deprecated
since:9
imageBufferResetback to summary
public default void imageBufferReset(int[] data, int x, int y, int width, int height, int linestride, double scaleX, double scaleY)

JLightweightFrame calls this method to notify the client application that a new data buffer has been set as a content pixel buffer. Typically this occurs when a buffer of a larger size is created in response to a content resize event.

The method reports a reference to the pixel data buffer, the content image bounds within the buffer and the line stride of the buffer. These values have the following correlation. The width and height matches the layout size of the content (the component returned from the getComponent method). The x and y is the origin of the content, (0, 0) in the layout coordinate space of the content, appearing at data[y * scaleY * linestride + x * scaleX] in the buffer. A pixel with indices (i, j), where (0 <= i < width) and (0 <= j < height), in the layout coordinate space of the content is represented by a scaleX * scaleY square of pixels in the physical coordinate space of the buffer. The top-left corner of the square has the following physical coordinate in the buffer: data[(y + j) * scaleY * linestride + (x + i) * scaleX].

Parameters
data:int[]

the content pixel data buffer of INT_ARGB_PRE type

x:int

the logical x coordinate of the image

y:int

the logical y coordinate of the image

width:int

the logical width of the image

height:int

the logical height of the image

linestride:int

the line stride of the pixel buffer

scaleX:double

the x coordinate scale factor of the pixel buffer

scaleY:double

the y coordinate scale factor of the pixel buffer

Since
9
imageBufferResetback to summary
public default void imageBufferReset(int[] data, int x, int y, int width, int height, int linestride)

The default implementation for #imageBufferReset uses a hard-coded value of 1 for the scale factor. Both the old and the new methods provide default implementations in order to allow a client application to run with any JDK version without breaking backward compatibility.

imageReshapedback to summary
public void imageReshaped(int x, int y, int width, int height)

JLightweightFrame calls this method to notify the client application that the content image bounds have been changed within the image's pixel buffer.

Parameters
x:int

the x coordinate of the image

y:int

the y coordinate of the image

width:int

the width of the image

height:int

the height of the image

See Also
imageBufferReset
imageUpdatedback to summary
public void imageUpdated(int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight)

JLightweightFrame calls this method to notify the client application that a part of the content image, or the whole image has been updated. The method reports bounds of the rectangular dirty region. The dirtyX and dirtyY is the origin of the dirty rectangle, which is relative to the origin of the content, appearing at data[(y + dirtyY] * linestride + (x + dirtyX)] in the pixel buffer (see imageBufferReset). All indices data[(y + dirtyY + j) * linestride + (x + dirtyX + i)] where (0 <= i < dirtyWidth) and (0 <= j < dirtyHeight) will represent valid pixel data, (i, j) in the coordinate space of the dirty rectangle.

Parameters
dirtyX:int

the x coordinate of the dirty rectangle, relative to the image origin

dirtyY:int

the y coordinate of the dirty rectangle, relative to the image origin

dirtyWidth:int

the width of the dirty rectangle

dirtyHeight:int

the height of the dirty rectangle

See Also
imageBufferReset, imageReshaped
maximumSizeChangedback to summary
public void maximumSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content maximum size has changed.

minimumSizeChangedback to summary
public void minimumSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content minimum size has changed.

paintLockback to summary
public void paintLock()

JLightweightFrame calls this method to notify the client application that it acquires the paint lock. The client application should implement the locking mechanism in order to synchronize access to the content image data, shared between JLightweightFrame and the client application.

See Also
paintUnlock
paintUnlockback to summary
public void paintUnlock()

JLightweightFrame calls this method to notify the client application that it releases the paint lock. The client application should implement the locking mechanism in order to synchronize access to the content image data, shared between JLightweightFrame and the client application.

See Also
paintLock
preferredSizeChangedback to summary
public void preferredSizeChanged(int width, int height)

JLightweightFrame calls this method to notify the client application that the content preferred size has changed.

removeDropTargetback to summary
public default void removeDropTarget(DropTarget dt)

Removes a drop target from the lightweight frame.

setCursorback to summary
public default void setCursor(Cursor cursor)

JLightweightFrame calls this method to notify the client application that in needs to set a cursor

Parameters
cursor:Cursor

a cursor to set