|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
org.jdesktop.jxlayer.plaf.LayerUI<V>
org.jdesktop.jxlayer.plaf.AbstractLayerUI<V>
org.pbjar.jxlayer.plaf.ext.MouseEventUI<JComponent>
org.pbjar.jxlayer.plaf.ext.TransformUI
public class TransformUI
This class provides for all necessary functionality when using
transformations in a LayerUI.
MouseEventUI because, when applying transformations, the
whereabouts of child components on screen (device space) do not necessarily
match the location according to their bounds as set by layout managers
(component space). So, mouse events must always be redirected to the intended
recipients.LayoutManager to
be used by JXLayer.JXLayer's inner area, it sets the size of the view to the view's
preferred size and centers it in the inner area. Also, when
calculating the preferred size of JXLayer, it transforms the normally
calculated size with the AffineTransform returned from
getPreferredTransform(Dimension, JXLayer).
BufferedImage the size of the
clip area, each time that the paint(Graphics, JComponent) method is
invoked. This is different from the implementation of
AbstractBufferedLayerUI, that maintains a cached image, the size of
the view. An important reason to not follow the
AbstractBufferedLayerUI strategy is that, when applying scaling
transformations with a large scaling factor, a OutOfMemoryError may
be thrown because it will try to allocate a buffer of an extreme size, even
if not all of its contents will actually be visible on the screen.AbstractLayerUI.configureGraphics(Graphics2D, JXLayer).
setRenderingHints(Map),
addRenderingHint(java.awt.RenderingHints.Key, Object) and
addRenderingHints(Map).TransformUI.TransformRepaintManager in order to have descendant's repaint requests
propagated up to the JXLayer ancestor. This TransformUI.TransformRepaintManager
will work well with and without other TransformUI.TransformRepaintManager that are either
subclasses of the WrappedRepaintManager or SwingX's
ForwardingRepaintManager. Other TransformUI.TransformRepaintManagers may cause
conflicts.
In Java versions 6u10 or higher, an attempt will be made to use the
new RepaintManager delegate facility that has been designed for JavaFX.
JXLayer. The result is that Borders and other content within
JXLayer's insets will generally either be invisible, or will be
rendered in a very undesirable way. If you want a Border to be
transformed together with JXLayer's view, that border should be set
on the view instead. On the other hand, if you want the Border not to
be transformed, that border must be set on JXLayer's parent.TransformUI instance cannot be shared and can be set
to a single JXLayer instance only.
| Nested Class Summary | |
|---|---|
protected static class |
TransformUI.TransformRepaintManager
A delegate RepaintManager that can be set on the view of a
JXLayer in Java versions starting with Java 6u10. |
| Constructor Summary | |
|---|---|
TransformUI()
Construct a TransformUI with a DefaultTransformModel. |
|
TransformUI(TransformModel model)
Construct a TransformUI with a specified model. |
|
| Method Summary | |
|---|---|
void |
addRenderingHint(RenderingHints.Key key,
Object value)
Add one rendering hint to the currently active rendering hints. |
void |
addRenderingHints(Map<RenderingHints.Key,Object> hints)
Add new rendering hints to the currently active rendering hints; |
TransformModel |
getModel()
Get the TransformModel. |
AffineTransform |
getPreferredTransform(Dimension size,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
Get a preferred AffineTransform. |
protected Map<RenderingHints.Key,Object> |
getRenderingHints(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
Get the rendering hints. |
protected AffineTransform |
getTransform(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
Get the AffineTransform customized for the layer
argument. |
void |
installUI(JComponent component)
Overridden to replace the LayoutManager, to add some listeners
and to ensure that an appropriate TransformUI.TransformRepaintManager is installed. |
void |
paint(Graphics g,
JComponent component)
This implementation does the following: A BufferedImage is created the size of the clip bounds of the
argument graphics object. |
protected void |
paintLayer(Graphics2D g2,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
If the view of the JXLayer is (partly) obscured by its parent
(this is the case when the size of the view (in component space) is
larger than the size of the JXLayer), the obscured parts will not
be painted by the super implementation. |
static void |
prepareForJTextComponent()
JTextComponent and its descendants have some caret position
problems when used inside a transformed JXLayer. |
void |
setEnabled(boolean enabled)
Overridden to also trigger JComponent.revalidate() and
Component.repaint(). |
void |
setModel(TransformModel transformModel)
Set a new TransformModel. |
void |
setRenderingHints(Map<RenderingHints.Key,Object> hints)
Replace the currently active rendering hints with new hints. |
Rectangle |
transform(Rectangle rect,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
Primarily intended for use by TransformUI.TransformRepaintManager. |
void |
uninstallUI(JComponent c)
Overridden to restore the original LayoutManager and remove some
listeners. |
void |
updateUI(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
Mark TransformUI as dirty if the LookAndFeel was changed. |
| Methods inherited from class org.pbjar.jxlayer.plaf.ext.MouseEventUI |
|---|
eventDispatched, getInstalledLayer, getLayerEventMask, processMouseWheelEvent |
| Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI |
|---|
configureGraphics, eventDispatched, getClip, getComposite, getRenderingHints, getTransform, handlePropertyChangeEvent, isDirty, paintLayer, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, setDirty |
| Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI |
|---|
addPropertyChangeListener, addPropertyChangeListener, contains, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener, updateUI |
| Methods inherited from class javax.swing.plaf.ComponentUI |
|---|
createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TransformUI()
TransformUI with a DefaultTransformModel.
public TransformUI(TransformModel model)
TransformUI with a specified model.
model - the model| Method Detail |
|---|
public static void prepareForJTextComponent()
JTextComponent and its descendants have some caret position
problems when used inside a transformed JXLayer. When you plan to
use JTextComponent(s) inside the hierarchy of a transformed
JXLayer, call this method in an early stage, before instantiating
any JTextComponent .
It executes the following method:
System.setProperty("i18n", Boolean.TRUE.toString());
As a result, a GlyphView.GlyphPainter will be selected that uses floating
point instead of fixed point calculations.
public void addRenderingHint(RenderingHints.Key key,
Object value)
key - the keyvalue - the valuepublic void addRenderingHints(Map<RenderingHints.Key,Object> hints)
hints - the new rendering hintspublic final TransformModel getModel()
TransformModel.
TransformModelsetModel(TransformModel)
public AffineTransform getPreferredTransform(Dimension size,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
AffineTransform. This method will typically be
invoked by programs that calculate a preferred size.
The size argument will be used to compute anchor values for some
types of transformations. If the size argument is null a
value of (0,0) is used for the anchor.
In enabled state this method is delegated to the
TransformModel that has been set. Otherwise null will be
returned.
size - a Dimension instance to be used for an anchor or
nulllayer - the JXLayer.
AffineTransform instance or nullpublic void installUI(JComponent component)
LayoutManager, to add some listeners
and to ensure that an appropriate TransformUI.TransformRepaintManager is installed.
installUI in class MouseEventUI<JComponent>uninstallUI(JComponent)
public final void paint(Graphics g,
JComponent component)
This implementation does the following:
BufferedImage is created the size of the clip bounds of the
argument graphics object.AbstractLayerUI.configureGraphics(Graphics2D, JXLayer) is invoked with the image
graphics as an argument.paintLayer(Graphics2D, JXLayer) is invoked with the image
graphics as an argument.
paint in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>public void setEnabled(boolean enabled)
JComponent.revalidate() and
Component.repaint().
public final void setModel(TransformModel transformModel)
throws NullPointerException
TransformModel. The new model may not be null.
transformModel - the new model
NullPointerException - if transformModel is nullgetModel()public void setRenderingHints(Map<RenderingHints.Key,Object> hints)
hints - the new rendering hints or null to clear all rendering
hints
public final Rectangle transform(Rectangle rect,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
TransformUI.TransformRepaintManager.
rect - a rectanglelayer - the layer
AffineTransform is
available, else a new rectanglepublic void uninstallUI(JComponent c)
LayoutManager and remove some
listeners.
uninstallUI in class MouseEventUI<JComponent>public void updateUI(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
TransformUI as dirty if the LookAndFeel was changed.
layer - the JXLayer this TransformUI is set toprotected Map<RenderingHints.Key,Object> getRenderingHints(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
setRenderingHints(Map),
addRenderingHints(Map),
addRenderingHint(java.awt.RenderingHints.Key, Object)protected final AffineTransform getTransform(org.jdesktop.jxlayer.JXLayer<JComponent> layer)
AffineTransform customized for the layer
argument.
In enabled state this method is delegated to the
TransformModel that has been set. Otherwise null will be
returned.
protected final void paintLayer(Graphics2D g2,
org.jdesktop.jxlayer.JXLayer<JComponent> layer)
JXLayer is (partly) obscured by its parent
(this is the case when the size of the view (in component space) is
larger than the size of the JXLayer), the obscured parts will not
be painted by the super implementation. Therefore, only under this
condition, a special painting technique is executed:
JXLayer are temporarily set to non double
buffered.In all other cases, the super method is invoked.
The g2 argument is a graphics object obtained from a
BufferedImage.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||