|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.icepdf.ri.util.jxlayer.JXLayer<V>
public final class JXLayer<V extends java.awt.Component>
The universal decorator for Swing components
with which you can implement various advanced painting effects
as well as receive notification of all MouseEvents,
KeyEvents and FocusEvents which generated within its borders.
JXLayer delegates its painting and input events handling
to its LayerUI object which performs the actual decoration.
The custom painting and events notification automatically work
for JXLayer itself and all its subcomponents.
This powerful combination makes it possible to enrich existing components
with new advanced functionality such as temporary locking of a hierarchy,
data tips for compound components, enhanced mouse scrolling etc...
JXLayer is a great solution if you just need to do custom painting
over compound component or catch input events of its subcomponents.
// create a component to be decorated with the layer
JPanel panel = new JPanel();
panel.add(new JButton("JButton"));
// This custom layerUI will fill the layer with translucent green
// and print out all mouseMotion events generated within its borders
AbstractLayerUI<JPanel> layerUI = new AbstractLayerUI<JPanel>() {
protected void paintLayer(Graphics2D g2, JXLayer<JPanel> l) {
// this paints the layer as is
super.paintLayer(g2, l);
// fill it with the translucent green
g2.setColor(new Color(0, 128, 0, 128));
g2.fillRect(0, 0, l.getWidth(), l.getHeight());
}
// overridden method which catches MouseMotion events
protected void processMouseMotionEvent(MouseEvent e) {
System.out.println("MouseMotionEvent detected: "
+ e.getX() + " " + e.getY());
}
};
// create the layer for the panel using our custom layerUI
JXLayer<JPanel> layer = new JXLayer<JPanel>(panel, layerUI);
// work with the layer as with any other Swing component
frame.add(layer);
Note: When a LayerUI instance is disabled or not set,
its JXLayers temporary lose all their decorations.
Note: JXLayer is very friendly to your application,
it uses only public Swing API and doesn't rely on any global settings
like custom RepaintManager or AWTEventListener.
It neither change the opaque state of its subcomponents
nor use the glassPane of its parent frame.
JXLayer can be used under restricted environment
(e.g. unsigned applets)
setUI(LayerUI),
LayerUI,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JXLayer()
Creates a new JXLayer object with empty view component
and empty LayerUI. |
|
JXLayer(V view)
Creates a new JXLayer object with empty LayerUI. |
|
JXLayer(V view,
LayerUI<V> ui)
Creates a new JXLayer object with provided view component
and LayerUI object. |
|
| Method Summary | |
|---|---|
protected void |
addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
This method is not supported by JXLayer
and always throws UnsupportedOperationException |
javax.swing.JPanel |
createGlassPane()
Called by the constructor methods to create the default glassPane. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
|
javax.swing.JPanel |
getGlassPane()
Returns the JXLayer's glassPane component or null. |
long |
getLayerEventMask()
Returns the bitmap of event mask to receive by this JXLayer
and its LayerUI. |
java.awt.Dimension |
getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for a view component. |
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation. |
boolean |
getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height of the layer, unless the preferred height of the layer is smaller than the viewports height. |
boolean |
getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width of the layer, unless the preferred width of the layer is smaller than the viewports width. |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. |
LayerUI<? super V> |
getUI()
Returns the LayerUI for this JXLayer. |
V |
getView()
Returns the JXLayer's view component or null. |
boolean |
isOptimizedDrawingEnabled()
To enable the correct painting of the glassPane and view component, the JXLayer overrides the default implementation of
this method to return false when the glassPane is visible. |
void |
paint(java.awt.Graphics g)
Delegates all painting to the LayerUI object. |
protected void |
paintComponent(java.awt.Graphics g)
This method is empty, because all painting is done by paint(Graphics) and
ComponentUI.update(Graphics, JComponent) methods |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
|
void |
remove(java.awt.Component comp)
|
void |
removeAll()
|
void |
setGlassPane(javax.swing.JPanel glassPane)
Sets the JXLayer's glassPane component, which can be null. |
void |
setLayerEventMask(long layerEventMask)
Sets the bitmask of event types to receive by this JXLayer. |
void |
setUI(LayerUI<? super V> ui)
Sets the LayerUI which will perform painting
and receive input events for this JXLayer. |
void |
setView(V view)
Sets the JXLayer's view component, which can be null. |
void |
updateUI()
Delegates its functionality to the LayerUI.updateUI(JXLayer) method,
if LayerUI is set. |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JXLayer()
JXLayer object with empty view component
and empty LayerUI.
setView(V),
setUI(org.icepdf.ri.util.jxlayer.plaf.LayerUI super V>)public JXLayer(V view)
JXLayer object with empty LayerUI.
view - the component to be decorated with this JXLayersetUI(org.icepdf.ri.util.jxlayer.plaf.LayerUI super V>)
public JXLayer(V view,
LayerUI<V> ui)
JXLayer object with provided view component
and LayerUI object.
view - the component to be decoratedui - the LayerUI delegate
to be used by this JXLayer| Method Detail |
|---|
public V getView()
JXLayer's view component or null.
JXLayer's view component
or null if none existssetView(Component)public void setView(V view)
JXLayer's view component, which can be null.
view - the view component for this JXLayergetView()public void setUI(LayerUI<? super V> ui)
LayerUI which will perform painting
and receive input events for this JXLayer.
ui - the LayerUI for this JXLayerpublic LayerUI<? super V> getUI()
LayerUI for this JXLayer.
LayerUI for this JXLayerpublic javax.swing.JPanel getGlassPane()
JXLayer's glassPane component or null.
JXLayer's glassPane component
or null if none existssetGlassPane(JPanel)public void setGlassPane(javax.swing.JPanel glassPane)
JXLayer's glassPane component, which can be null.
glassPane - the glassPane component of this JXLayergetGlassPane()public javax.swing.JPanel createGlassPane()
glassPane.
By default this method creates a new JPanel
with visibility set to true and opacity set to false.
glassPane
protected void addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
JXLayer
and always throws UnsupportedOperationException
addImpl in class java.awt.Containerjava.lang.UnsupportedOperationException - this method is not supportedsetView(Component),
setGlassPane(JPanel)public void remove(java.awt.Component comp)
remove in class java.awt.Containerpublic void removeAll()
removeAll in class java.awt.Containerpublic void paint(java.awt.Graphics g)
LayerUI object.
paint in class javax.swing.JComponentg - the Graphics to render toprotected void paintComponent(java.awt.Graphics g)
paint(Graphics) and
ComponentUI.update(Graphics, JComponent) methods
paintComponent in class javax.swing.JComponentpublic boolean isOptimizedDrawingEnabled()
JXLayer overrides the default implementation of
this method to return false when the glassPane is visible.
isOptimizedDrawingEnabled in class javax.swing.JComponentJXLayer's glassPane is visiblepublic void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerpublic void setLayerEventMask(long layerEventMask)
JXLayer.
Here is the list of the supported event types:
LayerUI is installed,
LayerUI.eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask.
Here is an example how to correclty use this method
in the LayerUI implementations:
public void installUI(JComponent c) {
super.installUI(c);
JXLayer l = (JXLayer) c;
// this LayerUI will receive only key and focus events
l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JXLayer l = (JXLayer) c;
// JXLayer must be returned to its initial state
l.setLayerEventMask(0);
}
By default JXLayer receives no events.
layerEventMask - the bitmask of event types to receive
java.lang.IllegalArgumentException - if the layerEventMask parameter
contains unsupported event typesgetLayerEventMask()public long getLayerEventMask()
JXLayer
and its LayerUI.
It means that LayerUI.eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask.
By default JXLayer receives no events.
JXLayerpublic void updateUI()
LayerUI.updateUI(JXLayer) method,
if LayerUI is set.
updateUI in class javax.swing.JComponentpublic java.awt.Dimension getPreferredScrollableViewportSize()
LayerUI.getPreferredScrollableViewportSize(JXLayer)
getPreferredScrollableViewportSize in interface javax.swing.ScrollableScrollable,
LayerUI.getPreferredScrollableViewportSize(JXLayer)
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
LayerUI.getScrollableBlockIncrement(JXLayer, Rectangle, int, int)
getScrollableBlockIncrement in interface javax.swing.ScrollableScrollable,
LayerUI.getScrollableBlockIncrement(JXLayer, Rectangle, int, int)public boolean getScrollableTracksViewportHeight()
LayerUI.getScrollableTracksViewportHeight(JXLayer)
getScrollableTracksViewportHeight in interface javax.swing.ScrollableScrollable,
LayerUI.getScrollableTracksViewportHeight(JXLayer)public boolean getScrollableTracksViewportWidth()
LayerUI.getScrollableTracksViewportWidth(JXLayer)
getScrollableTracksViewportWidth in interface javax.swing.ScrollableScrollable,
LayerUI.getScrollableTracksViewportWidth(JXLayer)
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
LayerUI.getScrollableUnitIncrement(JXLayer, Rectangle, int, int)
getScrollableUnitIncrement in interface javax.swing.ScrollableScrollable,
LayerUI.getScrollableUnitIncrement(JXLayer, Rectangle, int, int)public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext in interface javax.accessibility.AccessiblegetAccessibleContext in class javax.swing.JComponent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||