|
||||||||||
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 Piccolo 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 Font |
DEFAULT_FONT
Default font, 12 point "SansSerif" . |
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 | |
---|---|
void |
computeBounds()
Sets the Swing component's bounds to its preferred bounds unless it already is set to its preferred size. |
JComponent |
getComponent()
Return the Swing component that this Swing node wraps. |
double |
getGreekThreshold()
Return the greek threshold in scale. |
(package private) void |
init(Component c)
We need to turn off double buffering of Swing components within Piccolo since all components contained within a native container use the same buffer for double buffering. |
protected void |
paint(PPaintContext paintContext)
|
protected void |
paintComponent(PPaintContext paintContext)
Paint the Swing component with the specified paint context. |
protected void |
paintGreek(PPaintContext paintContext)
Paint the Swing component as greek with the specified paint context. |
void |
propertyChange(PropertyChangeEvent evt)
|
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. |
(package private) void |
reshape()
Ensures the bounds of the underlying component are accurate, and sets the bounds of this PNode. |
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. |
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
public static final Font DEFAULT_FONT
"SansSerif"
. Will be made final in
version 2.0.
Constructor Detail |
---|
public PSwing(JComponent component)
component
- Swing component to be wrappedpublic PSwing(PSwingCanvas swingCanvas, JComponent component)
PSwing(JComponent)
Method Detail |
---|
void reshape()
protected void paint(PPaintContext paintContext)
paint
in class PNode
public double getGreekThreshold()
DEFAULT_GREEK_THRESHOLD
.
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 scalepaintGreek(PPaintContext)
protected boolean shouldRenderGreek(PPaintContext paintContext)
paintContext
- paint context
protected void paintGreek(PPaintContext paintContext)
paintContext
- paint contextpublic void removeFromSwingWrapper()
protected void paintComponent(PPaintContext paintContext)
paintContext
- paint contextpublic void setVisible(boolean visible)
setVisible
in class PNode
public void repaint(PBounds repaintBounds)
repaintBounds
- public void computeBounds()
public JComponent getComponent()
void init(Component c)
c
- The Component to be recursively unDoubleBufferedpublic void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |