public class PCanvas extends JComponent implements PComponent
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static String |
PROPERTY_INTERACTING
The property name that identifies a change in the interacting state.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
PCanvas()
Construct a canvas with the basic scene graph consisting of a root,
camera, and layer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInputEventListener(PInputEventListener listener)
Add an input listener to the camera associated with this canvas.
|
protected PCamera |
createDefaultCamera()
Creates and returns a basic Scene Graph.
|
Timer |
createTimer(int delay,
ActionListener listener)
Helper for creating a timer.
|
boolean |
getAnimating()
Return true if any activities that respond with true to the method
isAnimating were run in the last PRoot.processInputs() loop.
|
int |
getAnimatingRenderQuality()
Returns the quality to use when animating.
|
PCamera |
getCamera()
Return the camera associated with this canvas.
|
PInputEventListener[] |
getInputEventListeners()
Returns the input event listeners registered to receive input events.
|
boolean |
getInteracting()
Return true if this canvas has been marked as interacting, or whether
it's root is interacting.
|
int |
getInteractingRenderQuality()
Returns the quality to use when interacting.
|
PLayer |
getLayer()
Return layer for this canvas.
|
int |
getNormalRenderQuality()
Returns the quality to use when not animating or interacting.
|
PPanEventHandler |
getPanEventHandler()
Get the pan event handler associated with this canvas.
|
PRoot |
getRoot()
Return root for this canvas.
|
PZoomEventHandler |
getZoomEventHandler()
Get the zoom event handler associated with this canvas.
|
protected void |
installInputSources()
This method installs mouse and key listeners on the canvas that forward
those events to piccolo.
|
void |
paintComponent(Graphics g) |
void |
paintImmediately()
If not painting immediately, send paint notification to RepaintManager,
otherwise does nothing.
|
void |
popCursor()
Pop the cursor on top of the cursorStack and set it as the canvas cursor.
|
void |
printAll(Graphics graphics)
Prints the entire scene regardless of what the viewable area is.
|
void |
pushCursor(Cursor cursor)
Set the canvas cursor, and remember the previous cursor on the cursor
stack.
|
void |
removeInputEventListener(PInputEventListener listener)
Remove an input listener to the camera associated with this canvas.
|
protected void |
removeInputSources()
This method removes mouse and key listeners on the canvas that forward
those events to piccolo.
|
void |
repaint(PBounds bounds)
Called to notify PComponent that given bounds need repainting.
|
protected void |
sendInputEventToInputManager(InputEvent event,
int type)
Sends the given input event with the given type to the current
InputManager.
|
void |
setAnimatingRenderQuality(int animatingRenderQuality)
Set the render quality that should be used when rendering this canvas
when it is animating.
|
void |
setBounds(int x,
int y,
int width,
int height)
Updates the bounds of the component and updates the camera accordingly.
|
void |
setCamera(PCamera newCamera)
Set the camera associated with this canvas.
|
void |
setDefaultRenderQuality(int defaultRenderQuality)
Set the render quality that should be used when rendering this canvas
when it is not interacting or animating.
|
void |
setEnabled(boolean enabled)
Override setEnabled to install/remove canvas input sources as needed.
|
void |
setInteracting(boolean isInteracting)
Set if this canvas is interacting.
|
void |
setInteractingRenderQuality(int interactingRenderQuality)
Set the render quality that should be used when rendering this canvas
when it is interacting.
|
void |
setPanEventHandler(PPanEventHandler handler)
Set the pan event handler associated with this canvas.
|
void |
setZoomEventHandler(PZoomEventHandler handler)
Set the zoom event handler associated with this canvas.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final String PROPERTY_INTERACTING
public PCanvas()
protected PCamera createDefaultCamera()
public PPanEventHandler getPanEventHandler()
public void setPanEventHandler(PPanEventHandler handler)
handler - the new zoom event handlerpublic PZoomEventHandler getZoomEventHandler()
public void setZoomEventHandler(PZoomEventHandler handler)
handler - the new zoom event handlerpublic PCamera getCamera()
public void setCamera(PCamera newCamera)
newCamera - the camera which this PCanvas should view the scenepublic PRoot getRoot()
public PLayer getLayer()
public void addInputEventListener(PInputEventListener listener)
listener - listener to register for event notificationspublic void removeInputEventListener(PInputEventListener listener)
listener - listener to unregister from event notificationspublic boolean getInteracting()
public boolean getAnimating()
public void setInteracting(boolean isInteracting)
setInteracting in interface PComponentisInteracting - whether the PCanvas should be considered interactingpublic void setDefaultRenderQuality(int defaultRenderQuality)
defaultRenderQuality - supports PPaintContext.HIGH_QUALITY_RENDERING
or PPaintContext.LOW_QUALITY_RENDERINGpublic void setAnimatingRenderQuality(int animatingRenderQuality)
animatingRenderQuality - supports
PPaintContext.HIGH_QUALITY_RENDERING or
PPaintContext.LOW_QUALITY_RENDERINGpublic void setInteractingRenderQuality(int interactingRenderQuality)
interactingRenderQuality - supports
PPaintContext.HIGH_QUALITY_RENDERING or
PPaintContext.LOW_QUALITY_RENDERINGpublic void pushCursor(Cursor cursor)
pushCursor in interface PComponentcursor - the cursor to push onto the cursor stackpublic void popCursor()
popCursor in interface PComponentpublic void setEnabled(boolean enabled)
setEnabled in class JComponentenabled - new enable status of the Pcanvasprotected void installInputSources()
protected void removeInputSources()
protected void sendInputEventToInputManager(InputEvent event, int type)
event - event to dispatchtype - type of event being dispatchedpublic void setBounds(int x,
int y,
int width,
int height)
public void repaint(PBounds bounds)
repaint in interface PComponentbounds - bounds needing repaintpublic void paintComponent(Graphics g)
paintComponent in class JComponentpublic void paintImmediately()
paintImmediately in interface PComponentpublic Timer createTimer(int delay, ActionListener listener)
delay - the number of milliseconds to wait before invoking the
listenerlistener - the listener to invoke after the delaypublic int getNormalRenderQuality()
public int getAnimatingRenderQuality()
public int getInteractingRenderQuality()
public PInputEventListener[] getInputEventListeners()
public void printAll(Graphics graphics)
printAll in class JComponentgraphics - Graphics context onto which to paint the scene for printingCopyright © 1995-2013 Piccolo2D. All Rights Reserved.