|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
sm.SMCanvas
A canvas that manages a display list.
The display list contains SMShape
objects.
It is ordered from back to front, i.e. the frontmost object is the last in the list.
Whenever the contents of the display list is modified, a repaint is triggered to update the display.
The state machines are used to manage interaction with the objects in the canvas.
See StateMachine
for a description of the syntax and use of state machines.
Once a state machine is attached to a canvas and is active, it receives and handles all input events.
The canvas may have several active state machines; they receive and handle the same events.
The events that are handled by the state machines are the mouse events, the keyboard events,
the time out events (triggered by armTimer
) and the gesture events.
Nested Class Summary |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Field Summary |
Fields inherited from class javax.swing.JComponent |
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
SMCanvas(int w,
int h)
Builds a SMCanvas. |
Method Summary | |
SMCanvas |
addShape(SMShape sms)
Adds a shape to the canvas. |
void |
attachSM(StateMachine sm,
boolean reset)
Attaches a state machine to this interactive object to describe its behavior. |
SMCanvas |
attachSM(java.lang.String machine,
boolean reset)
Attaches a state machine to the canvas and resets it. |
boolean |
containsPoint(double x,
double y)
Tests if a point is in this interactive object. |
boolean |
containsPoint(java.awt.geom.Point2D point)
Tests if a point is in this interactive object. |
void |
detachSM(StateMachine sm)
Detaches a state machine from this interactive object. |
SMCanvas |
getCanvas()
Returns the canvas in which this interactive object is displayed. |
java.awt.Dimension |
getPreferredSize()
|
java.util.Vector |
getSMs()
Returns the state machines attached to this canvas. |
boolean |
isAntialiased()
Returns True if the canvas is antialiased. |
void |
keyboardEnable(boolean keyboard)
Makes this canvas be able or disable to receive keyboard events. |
void |
keyPressed(java.awt.event.KeyEvent arg0)
|
void |
keyReleased(java.awt.event.KeyEvent arg0)
|
void |
keyTyped(java.awt.event.KeyEvent arg0)
|
void |
mouseClicked(java.awt.event.MouseEvent arg0)
|
void |
mouseDragged(java.awt.event.MouseEvent arg0)
|
void |
mouseEntered(java.awt.event.MouseEvent arg0)
|
void |
mouseExited(java.awt.event.MouseEvent arg0)
|
void |
mouseMoved(java.awt.event.MouseEvent arg0)
|
void |
mousePressed(java.awt.event.MouseEvent arg0)
|
void |
mouseReleased(java.awt.event.MouseEvent arg0)
|
SMEllipse |
newEllipse(double x,
double y,
double w,
double h)
Creates a new ellipse and adds it to the canvas. |
SMEllipse |
newEllipse(java.awt.geom.Point2D p,
double w,
double h)
Creates a new ellipse and adds it to the canvas. |
SMImage |
newImage(double x,
double y,
java.lang.String file)
Create a new image and adds it to the canvas |
SMPolyLine |
newPolyLine(double x,
double y)
Create a new polyline and adds it to the canvas. |
SMPolyLine |
newPolyLine(java.awt.geom.Point2D p)
Create a new polyline and adds it to the canvas. |
SMRectangle |
newRectangle(double x,
double y,
double w,
double h)
Creates a new rectangle and adds it to the canvas. |
SMRectangle |
newRectangle(java.awt.geom.Point2D p,
double w,
double h)
Creates a new rectangle and adds it to the canvas. |
SMSegment |
newSegment(double x1,
double y1,
double x2,
double y2)
Creates a new segment and adds it to the canvas. |
SMSegment |
newSegment(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Creates a new segment and adds it to the canvas. |
SMNamedTag |
newTag(java.lang.String t)
Returns a tag object given its name. |
SMText |
newText(double x,
double y,
java.lang.String text,
java.awt.Font font)
Create a new text and adds it to the canvas |
SMText |
newText(java.awt.geom.Point2D p,
java.lang.String text,
java.awt.Font font)
Create a new text and adds it to the canvas |
SMWidget |
newWidget(javax.swing.JComponent b)
Create a new widget and adds it to the canvas |
SMWidget |
newWidget(javax.swing.JComponent b,
double x,
double y)
Create a new widget and adds it to the canvas |
SMWidget |
newWidget(javax.swing.JComponent b,
double x,
double y,
double w,
double h)
Create a new widget and adds it to the canvas |
void |
paintComponent(java.awt.Graphics g)
|
SMShape |
pick(java.awt.geom.Point2D p)
Returns the topmost shape at a given position. |
java.util.LinkedList |
pickAll(java.awt.geom.Point2D p)
Returns a list containing all the shapes at a given position. |
SMCanvas |
removeShape(SMShape sms)
Removes a shape from the canvas. |
SMCanvas |
resume(StateMachine machine)
Resumes the state machine machine if it is associated to this canvas. |
SMCanvas |
resume(java.lang.String machine)
Resumes the state machine machine if it is associated to this canvas. |
SMCanvas |
setAntialiased(boolean a)
Sets the antialiasing for every SMShape drawn in this canvas (global antialiasing) |
SMCanvas |
suspend(StateMachine machine)
Suspends the state machine machine if it is associated to this canvas. |
SMCanvas |
suspend(java.lang.String machine)
Suspends the state machine machine if it is associated to this canvas. |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SMCanvas(int w, int h)
w
- The width of the canvash
- The height of the canvasMethod Detail |
public java.awt.Dimension getPreferredSize()
public void keyboardEnable(boolean keyboard)
keyboard
- True if the canvas must be able to handle keyboard events, false otherwise.public void paintComponent(java.awt.Graphics g)
public void mouseClicked(java.awt.event.MouseEvent arg0)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent arg0)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent arg0)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent arg0)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent arg0)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent arg0)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent arg0)
mousePressed
in interface java.awt.event.MouseListener
public void keyTyped(java.awt.event.KeyEvent arg0)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent arg0)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent arg0)
keyReleased
in interface java.awt.event.KeyListener
public SMShape pick(java.awt.geom.Point2D p)
p
- The position.
p
, or null
if there is no shape at this postion.public java.util.LinkedList pickAll(java.awt.geom.Point2D p)
p
- The position.
public SMCanvas addShape(SMShape sms)
sms
- the shape to add.
public SMCanvas removeShape(SMShape sms)
sms
- The shape that have to be deleted.
public SMSegment newSegment(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
p1
- The first point of the segment.p2
- The second point of the segment.
public SMSegment newSegment(double x1, double y1, double x2, double y2)
x1
- The x-coordinate of the first point of the segment.y1
- The y-coordinate of the first point of the segment.x2
- The x-coordinate of the second point of the segment.y2
- The y-coordinate of the second point of the segment.
public SMRectangle newRectangle(double x, double y, double w, double h)
x
- The x coordinate of the upper left point of the bounding box.y
- The y coordinate of the upper left point of the bounding box.w
- The width of the bounding box.h
- The height of the bounding box.
public SMRectangle newRectangle(java.awt.geom.Point2D p, double w, double h)
p
- The upper left point of the bounding box.w
- The width of the bounding box.h
- The height of the bounding box.
public SMEllipse newEllipse(java.awt.geom.Point2D p, double w, double h)
p
- The upper left point of the bounding box.w
- The width of the bounding box.h
- The height of the bounding box.
public SMEllipse newEllipse(double x, double y, double w, double h)
x
- The x coordinate of the upper left point of the bounding box.y
- The y coordinate of the upper left point of the bounding box.w
- The width of the bounding box.h
- The height of the bounding box.
public SMPolyLine newPolyLine(java.awt.geom.Point2D p)
p
- The starting point.
public SMPolyLine newPolyLine(double x, double y)
x
- The x coordinate of the starting point.y
- The y coordinate of the starting point.
public SMText newText(java.awt.geom.Point2D p, java.lang.String text, java.awt.Font font)
p
- The lower left point.text
- The text to display.font
- The font to use to render this text.
public SMText newText(double x, double y, java.lang.String text, java.awt.Font font)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.text
- The text to display.font
- The font to use to render this text.
public SMImage newImage(double x, double y, java.lang.String file)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.file
- The name of the file image (gif, jpeg or png)
public SMWidget newWidget(javax.swing.JComponent b)
b
- The swing widget.
public SMWidget newWidget(javax.swing.JComponent b, double x, double y)
b
- The swing widget.x
- The x coordinate of the upper left point.y
- The y coordinate of the upper left point.
public SMWidget newWidget(javax.swing.JComponent b, double x, double y, double w, double h)
b
- The swing widget.x
- The x coordinate of the upper left point.y
- The y coordinate of the upper left point.w
- The width of the bounding box.h
- The height of the bounding box.
public java.util.Vector getSMs()
public SMCanvas attachSM(java.lang.String machine, boolean reset) throws StateMachineNotfoundException
machine
- The name of the state machine.reset
- True if the machine must be reset.
StateMachineNotfoundException
- if the machine does not existpublic SMCanvas suspend(StateMachine machine)
machine
- The state machine.
StateMachine.suspend()
public SMCanvas suspend(java.lang.String machine) throws StateMachineNotfoundException
machine
- The name of the state machine.
StateMachineNotfoundException
- if the machine does not existStateMachine.suspend()
public SMCanvas resume(StateMachine machine)
machine
- The state machine.
StateMachine.resume()
public SMCanvas resume(java.lang.String machine) throws StateMachineNotfoundException
machine
- The name of the state machine.
StateMachineNotfoundException
- if the machine does not existStateMachine.resume()
public boolean isAntialiased()
public SMCanvas setAntialiased(boolean a)
a
- True if the canvas is antialiased.
public SMNamedTag newTag(java.lang.String t)
t
- The name of the tag
public SMCanvas getCanvas()
InteractiveObject
getCanvas
in interface InteractiveObject
public void attachSM(StateMachine sm, boolean reset)
InteractiveObject
attachSM
in interface InteractiveObject
sm
- The State machine that describes the behavior of this interactive object.reset
- True if the machine must be reset, false otherwise.public void detachSM(StateMachine sm)
InteractiveObject
detachSM
in interface InteractiveObject
sm
- The State machine to detach.public boolean containsPoint(java.awt.geom.Point2D point)
InteractiveObject
containsPoint
in interface InteractiveObject
point
- The point to test.
public boolean containsPoint(double x, double y)
InteractiveObject
containsPoint
in interface InteractiveObject
x
- The x-coordinate of the point to test.y
- The y-coordinate of the point to test.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |