public class PSwing extends edu.umd.cs.piccolo.PNode implements Serializable, PropertyChangeListener
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);
NOTE: ZSwing is not properly ZSerializable, but it is java.io.Serializable.
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.
| Modifier and Type | Field and Description |
|---|---|
protected JComponent |
component
The Swing component that this Visual Component wraps.
|
protected Font |
defaultFont
The default font.
|
protected 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 String |
VISUAL_COMPONENT_KEY
Used as a hashtable key for this object in the Swing component's client properties.
|
PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATENO_SUCH_PAGE, PAGE_EXISTS| Constructor and Description |
|---|
PSwing(PSwingCanvas zbc,
JComponent component)
Constructs a new visual component wrapper for the Swing component and adds the Swing component to the
SwingWrapper component of the ZCanvas.
|
| Modifier and Type | Method and Description |
|---|---|
void |
computeBounds()
Sets the Swing component's bounds to its preferred bounds unless it already is set to its preferred size.
|
JComponent |
getComponent()
Returns the Swing component that this visual component wraps.
|
double |
getCompositeMagnification(edu.umd.cs.piccolo.util.PPaintContext pPaintContext)
DOCUMENT ME!
|
void |
paint(Graphics2D g2)
Forwards the paint request to the Swing component to paint normally.
|
void |
paint(edu.umd.cs.piccolo.util.PPaintContext renderContext)
Determines if the Swing component should be rendered normally or as a filled rectangle.
|
void |
paintAsGreek(Graphics2D g2)
Paints the Swing component as greek.
|
void |
propertyChange(PropertyChangeEvent evt)
Listens for changes in font on components rooted at this ZSwing.
|
void |
repaint(edu.umd.cs.piccolo.util.PBounds repaintBounds)
Repaints the specified portion of this visual component Note that the input parameter may be modified as a result
of this call.
|
void |
reshape()
DOCUMENT ME!
|
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toString, transformBy, translate, validateFullBounds, validateFullPaintpublic static final String VISUAL_COMPONENT_KEY
protected double renderCutoff
protected JComponent component
protected double minFontSize
protected transient Stroke defaultStroke
protected Font defaultFont
public PSwing(PSwingCanvas zbc, JComponent component)
zbc - The ZCanvas to which the Swing component will be addedcomponent - The swing component to be wrappedpublic void reshape()
public void paint(edu.umd.cs.piccolo.util.PPaintContext 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.
paint in class edu.umd.cs.piccolo.PNoderenderContext - Contains information about current render.public double getCompositeMagnification(edu.umd.cs.piccolo.util.PPaintContext pPaintContext)
pPaintContext - DOCUMENT ME!public void paintAsGreek(Graphics2D g2)
g2 - The graphics used to render the filled rectanglepublic void paint(Graphics2D g2)
g2 - The graphics this visual component should pass to the Swing componentpublic void repaint(edu.umd.cs.piccolo.util.PBounds repaintBounds)
repaintBounds - DOCUMENT ME!public void computeBounds()
public JComponent getComponent()
public void propertyChange(PropertyChangeEvent evt)
propertyChange in interface PropertyChangeListenerevt - DOCUMENT ME!Copyright © 2012–2025 cismet GmbH. All rights reserved.