|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.PNode
edu.umd.cs.piccolox.pswing.PSwing
public class PSwing
PSwing is used to add Swing Components to a Piccolo2D canvas.
Example: adding a swing JButton to a PCanvas:
PSwingCanvas canvas = new PSwingCanvas(); JButton button = new JButton("Button"); swing = new PSwing(canvas, button); canvas.getLayer().addChild(swing);
NOTE: PSwing has the current limitation that it does not listen for Container events. This is only an issue if you create a PSwing and later add Swing components to the PSwing'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 PSwing's component hierarchy.
For instance, the following bit of code will give unexpected results:
JPanel panel = new JPanel(); PSwing swing = new PSwing(panel); JPanel newChild = new JPanel(); newChild.setDoubleBuffered(true); panel.add(newChild);
NOTE: PSwing cannot be correctly interacted with through multiple cameras. There is no support for it yet.
NOTE: PSwing is java.io.Serializable.
Warning: Serialized objects of this class will not be compatible with future Piccolo releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Piccolo. A future release of Piccolo will provide support for long term persistence.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode |
---|
PNode.PSceneGraphDelegate |
Field Summary | |
---|---|
static String |
PSWING_PROPERTY
Key for this object in the Swing component's client properties. |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PSwing(JComponent component)
Create a new visual component wrapper for the specified Swing component. |
|
PSwing(PSwingCanvas swingCanvas,
JComponent component)
Deprecated. by PSwing(JComponent) |
Method Summary | |
---|---|
JComponent |
getComponent()
Returns the Swing component that this visual component wraps. |
double |
getGreekThreshold()
Return the Greek threshold scale. |
void |
paint(Graphics2D g2)
Renders the wrapped component to the graphics context provided. |
void |
paint(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 PSwing. |
void |
removeFromSwingWrapper()
Remove from the SwingWrapper; throws an exception if no canvas is associated with this PSwing. |
void |
repaint(PBounds repaintBounds)
Repaints the specified portion of this visual component. |
void |
setGreekThreshold(double greekThreshold)
Set the Greek threshold in scale to greekThreshold . |
void |
setVisible(boolean visible)
|
protected boolean |
shouldRenderGreek(PPaintContext paintContext)
Return true if this Swing node should render as greek given the specified paint context. |
void |
updateBounds()
Ensures the bounds of the underlying component are accurate, and sets the bounds of this PNode. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PSWING_PROPERTY
Constructor Detail |
---|
public PSwing(JComponent component)
component
- Swing component to be wrappedpublic PSwing(PSwingCanvas swingCanvas, JComponent component)
PSwing(JComponent)
swingCanvas
- canvas on which the PSwing node will be embeddedcomponent
- not usedMethod Detail |
---|
public void updateBounds()
public void paint(PPaintContext renderContext)
paint
in class PNode
renderContext
- Contains information about current render.protected boolean shouldRenderGreek(PPaintContext paintContext)
paintContext
- paint context
public void paintAsGreek(Graphics2D g2)
g2
- The graphics used to render the filled rectanglepublic void setVisible(boolean visible)
setVisible
in class PNode
public void removeFromSwingWrapper()
public void paint(Graphics2D g2)
g2
- graphics context for rendering the JComponentpublic void repaint(PBounds repaintBounds)
repaintBounds
- bounds that need repaintingpublic JComponent getComponent()
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
evt
- property change event representing the change in fontpublic double getGreekThreshold()
DEFAULT_GREEK_THRESHOLD
.
PSwing#paintGreek(PPaintContext)
public void setGreekThreshold(double greekThreshold)
greekThreshold
. When the
scale will be below this threshold the Swing component is rendered as
'Greek' instead of painting the Swing component..
greekThreshold
- Greek threshold in scalePSwing#paintGreek(PPaintContext)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |