|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.ZSceneGraphObject | +--edu.umd.cs.jazz.ZVisualComponent | +--edu.umd.cs.jazz.component.ZSwing
ZSwing is a Visual Component wrapper used to add Swing Components to a Jazz ZCanvas.
Example: adding a swing JButton to a ZCanvas:
ZCanvas canvas = new ZCanvas(); JButton button = new JButton("Button"); swing = new ZSwing(canvas, button); leaf = new ZVisualLeaf(swing); canvas.getLayer().addChild(leaf);NOTE: ZSwing has the current limitation that it does not listen for Container events. This is only an issue if you create a ZSwing and later add Swing components to the ZSwing's component hierarchy that do not have double buffering turned off or have a smaller font size than the minimum font size of the original ZSwing's component hierarchy. For instance, the following bit of code will give unexpected results:JPanel panel = new JPanel(); ZSwing swing = new ZSwing(panel); JPanel newChild = new JPanel(); newChild.setDoubleBuffered(true); panel.add(newChild);Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.
Field Summary | |
protected javax.swing.JComponent |
component
The Swing component that this Visual Component wraps |
protected java.awt.Font |
defaultFont
The default font |
protected java.awt.Stroke |
defaultStroke
The default stroke |
protected double |
minFontSize
The minimum font size in the Swing hierarchy rooted at the component |
protected double |
renderCutoff
The cutoff at which the Swing component is rendered greek |
static java.lang.String |
VISUAL_COMPONENT_KEY
Used as a hashtable key for this object in the Swing component's client properties. |
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
bounds, listenerList, volatileBounds, volatileBounds_DEFAULT |
Constructor Summary | |
ZSwing(ZCanvas zbc,
javax.swing.JComponent component)
Constructs a new visual component wrapper for the Swing component and adds the Swing component to the SwingWrapper component of the ZCanvas |
Method Summary | |
void |
computeBounds()
Sets the Swing component's bounds to its preferred bounds unless it already is set to its preferred size. |
javax.swing.JComponent |
getComponent()
Returns the Swing component that this visual component wraps |
void |
paint(java.awt.Graphics2D g2)
Forwards the paint request to the Swing component to paint normally |
void |
paintAsGreek(java.awt.Graphics2D g2)
Paints the Swing component as greek. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Listens for changes in font on components rooted at this ZSwing |
void |
render(ZRenderContext renderContext)
Determines if the Swing component should be rendered normally or as a filled rectangle. |
void |
repaint(ZBounds repaintBounds)
Repaint's the specified portion of this visual component Note that the input parameter may be modified as a result of this call. |
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent |
addParent, duplicateObject, getNumParents, getParents, getParentsReference, getRoot, pick, pickBounds, removeParent, repaint, setState, trimToSize, updateBounds, updateObjectReferences, updateParentBounds, updateVolatility, writeObject, writeObjectRecurse |
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
addMouseListener, addMouseMotionListener, clone, dump, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getListenerList, getVolatileBounds, hasLisenerOfType, hasMouseListener, processMouseEvent, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected double renderCutoff
protected javax.swing.JComponent component
protected double minFontSize
protected transient java.awt.Stroke defaultStroke
protected java.awt.Font defaultFont
public static final java.lang.String VISUAL_COMPONENT_KEY
Constructor Detail |
public ZSwing(ZCanvas zbc, javax.swing.JComponent component)
zbc
- The ZCanvas to which the Swing component will
be addedcomponent
- The swing component to be wrappedMethod Detail |
public void render(ZRenderContext renderContext)
The transform, clip, and composite will be set appropriately when this object is rendered. It is up to this object to restore the transform, clip, and composite of the Graphics2D if this node changes any of them. However, the color, font, and stroke are unspecified by Jazz. This object should set those things if they are used, but they do not need to be restored.
render
in class ZVisualComponent
renderContext
- Contains information about current render.public void paintAsGreek(java.awt.Graphics2D g2)
g2
- The graphics used to render the filled rectanglepublic void paint(java.awt.Graphics2D g2)
paint
in class ZVisualComponent
g2
- The graphics this visual component should pass to the Swing
componentpublic void repaint(ZBounds repaintBounds)
repaint
in class ZVisualComponent
repaintBounds
- The bounding box to repaint within this componentpublic void computeBounds()
computeBounds
in class ZSceneGraphObject
public javax.swing.JComponent getComponent()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |