public class Canvas extends javax.swing.JPanel implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.KeyListener, CElement
A canvas that displays a scene composed of graphical objects. A canvas handles
a display list containing CShape
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 display list contains CShape
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.
CStateMachine
is a class that implements state machines dedicated
to program interaction with a 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. State machines can be attached
to a subpart of a canvas, i.e. a shape or a tag, to reduce their scope.
Events handled by state machines are mouse events, the keyboard events,
the time out events (triggered by armTimer
) and animation events.
CStateMachine
,
CShape
,
Serialized FormTOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Canvas()
Builds a Canvas.
|
Canvas(int w,
int h)
Builds a Canvas.
|
Modifier and Type | Method and Description |
---|---|
CElement |
above(CElement before)
Does Anything.
|
CElement |
aboveAll()
Does Anything.
|
void |
addGhost()
Calls addGhost() on every CShape contained in this
CElement . |
Canvas |
addShape(CShape sms)
Adds a shape to the canvas.
|
CElement |
addTag(CExtensionalTag t)
Calls
addTag(Canvas.Tag t) for every CShape contained in this CElement . |
CElement |
addTag(java.lang.String t)
Calls
addTag(String t) for every CShape contained in this CElement . |
CElement |
animate(Animation anim)
Calls
animate(Animation animTagScale) for every CShape
contained in this Canvas . |
void |
attachSM(CStateMachine sm,
boolean reset)
Attaches a state machine to this
CElement to describe its behavior. |
CElement |
below(CElement after)
Does Anything.
|
CElement |
belowAll()
Does Anything.
|
static boolean |
contains(CElement container,
CElement element)
Tests if a
CElement is a subset of another
CElement . |
CShape |
contains(double x,
double y)
Returns the topmost CShape containing the point (x, y).
|
CShape |
contains(double x,
double y,
double w,
double h)
Returns the topmost CShape containing a given rectangle R.
|
CShape |
contains(java.awt.geom.Point2D p)
Returns the topmost CShape containing the point p.
|
CShape |
contains(java.awt.Rectangle r)
Returns the topmost CShape containing a given rectangle.
|
void |
detachSM(CStateMachine sm)
Detaches a state machine from this
CElement . |
CShape |
firstShape()
Returns the first shape contained in this
CElement . |
CElement |
fixReferenceShapeToCurrent() |
java.util.List<CTag> |
getAllTags() |
java.util.LinkedList<CShape> |
getAntialiasedShapes()
Returns the list of CShape that have this tag and that are antialiased.
|
CRectangle |
getBoundingBox() |
Canvas |
getCanvas()
Returns the canvas in which this CElement is displayed.
|
double |
getCenterX() |
double |
getCenterY() |
java.awt.Shape |
getClip() |
java.util.List<CShape> |
getDisplayList() |
java.util.LinkedList<CShape> |
getFilledShapes()
Returns the list of CShape that have this tag and that are filled.
|
CShape |
getFirstAntialiasedShape()
Returns the first antialiased CShape contained in this
CElement . |
CShape |
getFirstFilledShape()
Returns the first CShape contained in this
CElement and that is filled. |
CShape |
getFirstHavingTag(CTag t)
Returns the topmost CShape that has tag t.
|
CShape |
getFirstOutlinedShape()
Returns the first CShape contained in this
CElement and that is outlined. |
CPolyLine |
getIntersection(CShape s)
Tests whether a
CShape s intersects this
CElement . |
double |
getMaxX() |
double |
getMaxY() |
double |
getMinX() |
double |
getMinY() |
java.util.LinkedList<CShape> |
getOutlinedShapes()
Returns the list of CShape that have this tag and that are outlined.
|
java.util.List<CStateMachine> |
getSMs()
Returns the state machines attached to this canvas.
|
ClassTag |
getTag(java.lang.Class tagClass)
Returns an intentional tag object grouping shapes having a tag of a given
class.
|
CNamedTag |
getTag(java.lang.String tag)
Returns the tag object given its name.
|
boolean |
hasTag(CTag t)
Returns true if every shape with this tag also has tag t.
|
boolean |
hasTag(java.lang.String t)
Returns true if every shape with this tag also has tag t.
|
CShape |
intersects(CShape s)
Returns the topmost
CShape that intersects the given CShape s. |
boolean |
isAntialiased()
Returns True if the canvas is antialiased.
|
boolean |
isDrawable()
Returns true if every shape contained in this
CElement is drawable. |
boolean |
isFilled()
Calls
isFilled() for every CShape contained in this CElement . |
CShape |
isOnOutline(java.awt.geom.Point2D p)
Returns the topmost CShape whose outline contains the point p.
|
boolean |
isOutlined()
Returns true if every shape contained in this
CElement is outlined. |
boolean |
isPickable()
Returns true if every shape contained in this
CElement is pickable. |
boolean |
isTracking(CElement element)
Tests if one of the attached state machines is waiting for changes of
element . |
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 event) |
void |
mouseDragged(java.awt.event.MouseEvent event) |
void |
mouseEntered(java.awt.event.MouseEvent event) |
void |
mouseExited(java.awt.event.MouseEvent event) |
void |
mouseMoved(java.awt.event.MouseEvent arg0) |
void |
mousePressed(java.awt.event.MouseEvent event) |
void |
mouseReleased(java.awt.event.MouseEvent event) |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent event) |
CDynamicWidget |
newDynamicWidget(javax.swing.JComponent b,
double x,
double y,
int delayInMilliseconds)
Create a new dynamic widget and add it to the canvas (i.e.
|
CEllipse |
newEllipse(double x,
double y,
double w,
double h)
Creates a new ellipse and add it to the canvas.
|
CEllipse |
newEllipse(java.awt.geom.Point2D p,
double w,
double h)
Creates a new ellipse and add it to the canvas.
|
CImage |
newImage(double x,
double y,
java.awt.image.BufferedImage image)
Create a new image and add it to the canvas.
|
CImage |
newImage(double x,
double y,
java.io.InputStream imageStream)
Create a new image and add it to the canvas.
|
CImage |
newImage(double x,
double y,
java.lang.String imageFile)
Create a new image and add it to the canvas.
|
CImage |
newImage(double x,
double y,
java.net.URL imageURL)
Create a new image and add it to the canvas.
|
CPolyLine |
newPolyLine()
Create a new empty polyline and add it to the canvas.
|
CPolyLine |
newPolyLine(double x,
double y)
Create a new polyline and add it to the canvas.
|
CPolyLine |
newPolyLine(java.awt.geom.Point2D p)
Create a new polyline and add it to the canvas.
|
CRectangle |
newRectangle(double x,
double y,
double w,
double h)
Creates a new rectangle and add it to the canvas.
|
CRectangle |
newRectangle(java.awt.geom.Point2D p,
double w,
double h)
Creates a new rectangle and add it to the canvas.
|
CRectangle |
newRoundRectangle(double x,
double y,
double w,
double h,
double arcw,
double arch)
Creates a new rectangle and add it to the canvas.
|
CRectangle |
newRoundRectangle(java.awt.geom.Point2D p,
double w,
double h,
double arcw,
double arch)
Creates a new rectangle and add it to the canvas.
|
CSegment |
newSegment(double x1,
double y1,
double x2,
double y2)
Creates a new segment and add it to the canvas.
|
CSegment |
newSegment(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Creates a new segment and add it to the canvas.
|
CNamedTag |
newTag(java.lang.String t)
Returns a named tag object given its name.
|
CText |
newText(double x,
double y,
java.lang.String text)
Create a new text and add it to the canvas.
|
CText |
newText(double x,
double y,
java.lang.String text,
java.awt.Font font)
Create a new text and add it to the canvas.
|
CText |
newText(java.awt.geom.Point2D p,
java.lang.String text)
Create a new text and add it to the canvas.
|
CText |
newText(java.awt.geom.Point2D p,
java.lang.String text,
java.awt.Font font)
Create a new text and add it to the canvas.
|
CWidget |
newWidget(javax.swing.JComponent b)
Create a new widget and add it to the canvas.
|
CWidget |
newWidget(javax.swing.JComponent b,
double x,
double y)
Create a new widget and add it to the canvas (i.e.
|
CWidget |
newWidget(javax.swing.JComponent b,
double x,
double y,
double w,
double h)
Create a new widget and add it to the canvas.
|
void |
paintComponent(java.awt.Graphics g) |
CShape |
pick(java.awt.geom.Point2D p)
Returns the topmost shape at a given position.
|
java.util.LinkedList<CShape> |
pickAll(java.awt.geom.Point2D p)
Returns a list containing all the shapes at a given position.
|
CShape |
pickShapeHavingTag(java.awt.geom.Point2D p,
CTag tag)
Returns the top most shape having a given tag at a given position.
|
CShape |
pickShapeHavingTag(java.awt.geom.Point2D p,
java.lang.String tag)
Returns the top most shape having a given named tag at a given position.
|
void |
processEvent(java.lang.String event,
java.awt.geom.Point2D pt)
Processes an event to all the state machines that monitor this canvas, a
shape in this canvas or a tag attached to shapes in this canvas.
|
void |
processEvent(VirtualEvent virtualEvent)
Processes an event to all the state machines that monitor this canvas, a
shape in this canvas or a tag attached to shapes in this canvas.
|
Canvas |
removeAllShapes()
Removes all shapes from this canvas.
|
void |
removeGhost()
Calls removeGhost() on every CShape contained in this
CElement . |
Canvas |
removeShape(CShape shape)
Removes a shape from the canvas.
|
Canvas |
removeShapes(CTag shapes)
Removes a set of tagged shapes from the canvas.
|
CElement |
removeTag(CExtensionalTag t)
Calls
removeTag(Tag t) for every CShape contained in this CElement only if t is a SMExtensionalTag ,
does nothing otherwise. |
CElement |
removeTag(java.lang.String t)
Calls
removeTag(String t) for every CShape contained in this CElement . |
CElement |
rotateBy(double theta)
Calls
rotateBy(double theta) for every CShape contained in this CElement . |
CElement |
rotateTo(double theta)
Calls
rotateTo(double theta) for every CShape contained in this CElement . |
CElement |
scaleBy(double s)
Calls
scaleBy(double s) for every CShape contained in this CElement . |
CElement |
scaleBy(double sx,
double sy)
Calls
scale(double sx, double sy) for every CShape contained in this CElement . |
CElement |
scaleTo(double s)
Calls
scaleTo(double s) for every CShape contained in this CElement . |
CElement |
scaleTo(double sx,
double sy)
Calls
scaleTo(double sx, double sy) for every CShape contained in this CElement . |
CElement |
setAntialiased(boolean a)
Sets the antialiasing for every CShape drawn in this canvas (global
antialiasing).
|
CElement |
setClip(CShape clip)
Sets the clip for every CShape drawn in this canvas (global rendering
hints).
|
void |
setClip(java.awt.Shape clip) |
CElement |
setDrawable(boolean f)
Calls
setDrawable(boolean) for every CShape contained in this CElement . |
CElement |
setFilled(boolean f)
Calls
setFilled(boolean) for every CShape contained in this CElement . |
CElement |
setFillPaint(java.awt.Paint fp)
Calls
setFillPaint(Paint fp) for every CShape contained in this CElement . |
CElement |
setOutlined(boolean f)
Calls
setOutlined(boolean) for every CShape contained in this CElement . |
CElement |
setOutlinePaint(java.awt.Paint op)
Calls
setOutlinePaint(Paint op) for every CShape contained in this CElement . |
CElement |
setParent(CShape parent)
Calls
setParent(CShape parent) for every CShape contained in this CElement . |
CElement |
setPickable(boolean pick)
Calls
setPickable(boolean) for every CShape contained in this CElement . |
CElement |
setReferencePoint(double x,
double y)
Calls
setReferencePoint(double x, double y) for every CShape contained in this CElement . |
CElement |
setRenderingHint(java.awt.RenderingHints.Key hintKey,
java.lang.Object hintValue)
Sets the rendering hints for every CShape drawn in this canvas (global
rendering hints).
|
CElement |
setShape(java.awt.Shape sh)
Calls
setShape(Shape sh) for every CShape contained in this CElement . |
CElement |
setStroke(java.awt.Stroke str)
Calls
setStroke(Shape sh) for every CShape contained in this CElement . |
CElement |
setTransformToIdentity()
Calls
setTransformToIdentity() for every CShape contained in this CElement . |
CElement |
setTransparencyFill(java.awt.AlphaComposite transparencyFill)
Calls
setTransparencyFill(AlphaComposite transparencyFill) for every CShape contained in this CElement . |
CElement |
setTransparencyFill(float alpha)
Calls
setTransparencyFill(float alpha) for every CShape contained in this CElement . |
CElement |
setTransparencyOutline(java.awt.AlphaComposite transparencyOutline)
Calls
setTransparencyOutline(AlphaComposite transparencyOutline) for every CShape contained in this CElement . |
CElement |
setTransparencyOutline(float alpha)
Calls
setTransparencyOutline(float alpha) for every CShape contained in this CElement . |
CElement |
translateBy(double tx,
double ty)
Calls
translateBy(double tx, double ty) for every CShape contained in this CElement . |
CElement |
translateTo(double tx,
double ty)
Calls
translateTo(double tx, double ty) every CShape contained in this CElement . |
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public Canvas()
public Canvas(int w, int h)
w
- The width of the canvash
- The height of the canvaspublic java.util.List<CTag> getAllTags()
Canvas
.public CNamedTag getTag(java.lang.String tag)
tag
- The name of the tagpublic ClassTag getTag(java.lang.Class tagClass)
tagClass
- The class of the tagpublic void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void processEvent(java.lang.String event, java.awt.geom.Point2D pt)
pt
.event
- The name of the virtual event to process.pt
- The point on which this event occurred.public void processEvent(VirtualEvent virtualEvent)
virtualEvent
has the type VirtualCanvasEvent
,
this method performs picking on the canvas so transitions EventOnShape
and EventOnTag
can be triggered.virtualEvent
- The virtual event to process.public static boolean contains(CElement container, CElement element)
CElement
is a subset of another
CElement
.container
- The CElement
containerelement
- The CElement
containedelement
is a subset of
container
.public boolean isTracking(CElement element)
element
. (if there is one machine whose current state
contains a CElementEvent(element, ...)
transition).element
- The element.element
is tracked by a machine, false
otherwise.public void mouseWheelMoved(java.awt.event.MouseWheelEvent event)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
public void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent event)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent event)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent event)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent event)
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 event)
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 CShape pick(java.awt.geom.Point2D p)
p
- The position.p
, or null
if there is no shape at this postion.public java.util.LinkedList<CShape> pickAll(java.awt.geom.Point2D p)
p
- The position.public CShape pickShapeHavingTag(java.awt.geom.Point2D p, CTag tag)
p
- The position.tag
- The tag.p
.public CShape pickShapeHavingTag(java.awt.geom.Point2D p, java.lang.String tag)
p
- The position.tag
- The name of the tag.p
.public Canvas addShape(CShape sms)
sms
- the shape to add.public Canvas removeShape(CShape shape)
setDrawable
in class CShape
.shape
- The shape to remove from this canvas.CShape.setDrawable(boolean)
public Canvas removeShapes(CTag shapes)
shapes
- The shapes that have to be deleted.public Canvas removeAllShapes()
public CSegment 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 CSegment 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 CRectangle 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 CRectangle 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 CRectangle newRoundRectangle(double x, double y, double w, double h, double arcw, double arch)
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.arcw
- The width of the arc to use to round off the corners of the
newly constructed CRectangle
arch
- The height of the arc to use to round off the corners of the
newly constructed CRectangle
CRectangle
.public CRectangle newRoundRectangle(java.awt.geom.Point2D p, double w, double h, double arcw, double arch)
p
- The upper left point of the bounding box.w
- The width of the bounding box.h
- The height of the bounding box.arcw
- The width of the arc to use to round off the corners of the
newly constructed CRectangle
arch
- The height of the arc to use to round off the corners of the
newly constructed CRectangle
CRectangle
.public CEllipse 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 CEllipse 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 CPolyLine newPolyLine(java.awt.geom.Point2D p)
p
- The starting point.public CPolyLine newPolyLine()
public CPolyLine newPolyLine(double x, double y)
x
- The x coordinate of the starting point.y
- The y coordinate of the starting point.public CText 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 CText newText(java.awt.geom.Point2D p, java.lang.String text)
p
- The lower left point.text
- The text to display.public CText 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 CText newText(double x, double y, java.lang.String text)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.text
- The text to display.public CImage newImage(double x, double y, java.lang.String imageFile)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.imageFile
- The name of the file image (gif, jpeg or png)public CImage newImage(double x, double y, java.net.URL imageURL)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.imageURL
- The url of the file image (gif, jpeg or png)public CImage newImage(double x, double y, java.awt.image.BufferedImage image)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.image
- The imagepublic CImage newImage(double x, double y, java.io.InputStream imageStream)
x
- The x coordinate of the lower left point.y
- The y coordinate of the lower left point.imageStream
- The url of the file image (gif, jpeg or png)public CWidget newWidget(javax.swing.JComponent b)
b
- The swing widget.public CWidget 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 CDynamicWidget newDynamicWidget(javax.swing.JComponent b, double x, double y, int delayInMilliseconds)
delayInMilliseconds
milliseconds,
e.g. a video or an animated widget).b
- The swing widget.x
- The x coordinate of the upper left point.y
- The y coordinate of the upper left point.delayInMilliseconds
- The refreshing ratepublic CWidget 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.List<CStateMachine> getSMs()
public boolean isAntialiased()
isAntialiased
in interface CElement
CShape.isAntialiased()
public CElement setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
setRenderingHint
for each shape in the canvas is more
efficient (the same RenderingHints
is referenced by all
shapes).setRenderingHint
in interface CElement
hintKey
- The hint keyhintValue
- The hint valuepublic CElement setAntialiased(boolean a)
setAntialiased
for each shape in the canvas is more
efficient (the same RenderingHints
is referenced by all
shapes).setAntialiased
in interface CElement
a
- True if the canvas is antialiased.CShape.setAntialiased(boolean)
public CNamedTag newTag(java.lang.String t)
t
- The name of the tagpublic Canvas getCanvas()
public void attachSM(CStateMachine sm, boolean reset)
CElement
to describe its behavior.public void detachSM(CStateMachine sm)
CElement
.public CElement setShape(java.awt.Shape sh)
setShape(Shape sh)
for every CShape contained in this CElement
.setShape
in interface CElement
sh
- The shapeCElement
CShape.setShape(java.awt.Shape)
public CElement setParent(CShape parent)
setParent(CShape parent)
for every CShape contained in this CElement
.setParent
in interface CElement
parent
- The parent shapeCElement
CShape.setParent(CShape)
public CElement setStroke(java.awt.Stroke str)
setStroke(Shape sh)
for every CShape contained in this CElement
.setStroke
in interface CElement
str
- The strokeCElement
CShape.setStroke(java.awt.Stroke)
public CElement setTransparencyFill(java.awt.AlphaComposite transparencyFill)
setTransparencyFill(AlphaComposite transparencyFill)
for every CShape contained in this CElement
.setTransparencyFill
in interface CElement
transparencyFill
- The transparencyCElement
CShape.setTransparencyFill(AlphaComposite)
public CElement setTransparencyFill(float alpha)
setTransparencyFill(float alpha)
for every CShape contained in this CElement
.setTransparencyFill
in interface CElement
alpha
- The transparencyCElement
CShape.setTransparencyFill(float)
public CElement setTransparencyOutline(java.awt.AlphaComposite transparencyOutline)
setTransparencyOutline(AlphaComposite transparencyOutline)
for every CShape contained in this CElement
.setTransparencyOutline
in interface CElement
transparencyOutline
- The transparencyCElement
CShape.setTransparencyOutline(AlphaComposite)
public CElement setTransparencyOutline(float alpha)
setTransparencyOutline(float alpha)
for every CShape contained in this CElement
.setTransparencyOutline
in interface CElement
alpha
- The transparencyCElement
CShape.setTransparencyOutline(float)
public CElement setFillPaint(java.awt.Paint fp)
setFillPaint(Paint fp)
for every CShape contained in this CElement
.setFillPaint
in interface CElement
fp
- The paint valueCElement
CShape.setFillPaint(Paint)
public CElement setOutlinePaint(java.awt.Paint op)
setOutlinePaint(Paint op)
for every CShape contained in this CElement
.setOutlinePaint
in interface CElement
op
- The paint valueCElement
CShape.setOutlinePaint(Paint)
public java.util.LinkedList<CShape> getAntialiasedShapes()
getAntialiasedShapes
in interface CElement
CShape.isAntialiased()
public boolean isFilled()
isFilled()
for every CShape contained in this CElement
.isFilled
in interface CElement
CElement
is filled.CShape.isFilled()
public java.util.LinkedList<CShape> getFilledShapes()
getFilledShapes
in interface CElement
CShape.isFilled()
public CElement setFilled(boolean f)
setFilled(boolean)
for every CShape contained in this CElement
.setFilled
in interface CElement
f
- True if the shape must be filled, false otherwise.CElement
CShape.setFilled(boolean)
public boolean isOutlined()
CElement
is outlined.isOutlined
in interface CElement
CElement
is outlined.CShape.isOutlined()
public java.util.LinkedList<CShape> getOutlinedShapes()
getOutlinedShapes
in interface CElement
CShape.isOutlined()
public CElement setOutlined(boolean f)
setOutlined(boolean)
for every CShape contained in this CElement
.setOutlined
in interface CElement
f
- True if the shape must be outlined, false otherwise.CElement
CShape.setOutlined(boolean)
public boolean isDrawable()
CElement
is drawable.isDrawable
in interface CElement
CElement
is drawable.CShape.isDrawable()
public CElement setDrawable(boolean f)
setDrawable(boolean)
for every CShape contained in this CElement
.setDrawable
in interface CElement
f
- True if the shape must be drawn, false otherwise.CElement
CShape.setDrawable(boolean)
public boolean isPickable()
CElement
is pickable.isPickable
in interface CElement
CElement
is pickable.CShape.isPickable()
public CElement setPickable(boolean pick)
setPickable(boolean)
for every CShape contained in this CElement
.setPickable
in interface CElement
pick
- True if the shape must be pickable, false otherwise.CElement
CShape.setOutlined(boolean)
public CElement setReferencePoint(double x, double y)
setReferencePoint(double x, double y)
for every CShape contained in this CElement
.setReferencePoint
in interface CElement
x
- The x coordinate of the new reference point.y
- The y coordinate of the new reference point.CElement
CShape.setReferencePoint(double, double)
public CElement fixReferenceShapeToCurrent()
fixReferenceShapeToCurrent
in interface CElement
public CElement setTransformToIdentity()
setTransformToIdentity()
for every CShape contained in this CElement
.setTransformToIdentity
in interface CElement
CElement
CShape.setTransformToIdentity()
public CElement translateBy(double tx, double ty)
translateBy(double tx, double ty)
for every CShape contained in this CElement
.translateBy
in interface CElement
tx
- The x offsetty
- The y offsetCElement
CShape.translateBy(double, double)
public CElement translateTo(double tx, double ty)
translateTo(double tx, double ty)
every CShape contained in this CElement
.translateTo
in interface CElement
tx
- The x coordinatety
- The y coordinateCElement
CShape.translateTo(double, double)
public CElement scaleBy(double sx, double sy)
scale(double sx, double sy)
for every CShape contained in this CElement
.scaleBy
in interface CElement
sx
- The x scale factorsy
- The y scale factorCElement
CShape.scaleBy(double, double)
public CElement scaleBy(double s)
scaleBy(double s)
for every CShape contained in this CElement
.scaleBy
in interface CElement
s
- The scale factorCElement
CShape.scaleBy(double)
public CElement scaleTo(double sx, double sy)
scaleTo(double sx, double sy)
for every CShape contained in this CElement
.scaleTo
in interface CElement
sx
- The x scalesy
- The y scaleCElement
CShape.scaleTo(double, double)
public CElement scaleTo(double s)
scaleTo(double s)
for every CShape contained in this CElement
.scaleTo
in interface CElement
s
- The scale valueCElement
CShape.scaleTo(double)
public CElement rotateBy(double theta)
rotateBy(double theta)
for every CShape contained in this CElement
.rotateBy
in interface CElement
theta
- The angle offsetCElement
CShape.rotateBy(double)
public CElement rotateTo(double theta)
rotateTo(double theta)
for every CShape contained in this CElement
.rotateTo
in interface CElement
theta
- The angleCElement
CShape.rotateTo(double)
public CShape contains(double x, double y)
contains
in interface CElement
x
- The x coordinatey
- The y coordinateCShape.contains(double, double)
public CShape contains(java.awt.geom.Point2D p)
contains
in interface CElement
p
- The point.CShape.contains(Point2D)
public CShape contains(double x, double y, double w, double h)
contains
in interface CElement
x
- The x coordinate of the upper left corner of Ry
- The y coordinate of the upper left corner of Rw
- The width of Rh
- The height of RCShape.contains(double, double, double, double)
public CShape contains(java.awt.Rectangle r)
contains
in interface CElement
r
- The rectangleCShape.contains(Rectangle)
public CShape isOnOutline(java.awt.geom.Point2D p)
isOnOutline
in interface CElement
p
- The pointCShape.isOnOutline(Point2D)
public CShape intersects(CShape s)
CShape
that intersects the given CShape
s.intersects
in interface CElement
s
- The shapeCShape
that intersects the given CShape
, null if no CShape
intersects s.CShape.intersects(CShape)
public CPolyLine getIntersection(CShape s)
CShape
s intersects this
CElement
.getIntersection
in interface CElement
s
- The shapeCPolyLine
if s intersects
it, null otherwise.CShape.getIntersection(CShape)
public CShape getFirstHavingTag(CTag t)
getFirstHavingTag
in interface CElement
t
- The tagCShape.hasTag(fr.lri.swingstates.canvas.CTag)
public boolean hasTag(java.lang.String t)
hasTag
in interface CElement
t
- The name of the tagCShape.hasTag(String)
public boolean hasTag(CTag t)
public CElement above(CElement before)
before
, this method does nothing.above
in interface CElement
before
- The element that must be right below every shape contained in this CElement
in the display listCElement
CShape.below(CElement)
public CElement aboveAll()
aboveAll()
for every CShape contained in this CElement
.aboveAll
in interface CElement
CElement
CShape.aboveAll()
public CElement below(CElement after)
after
, this method does nothing.below
in interface CElement
after
- The element that must be right above every shape contained in this CElement
in the display listCShape.below(CElement)
public CElement belowAll()
belowAll()
for every CShape contained in this CElement
.belowAll
in interface CElement
CElement
CShape.belowAll()
public CElement setClip(CShape clip)
setClip
for each shape in the canvas is more efficient (the same
CShape
clip is referenced by all shapes).setClip
in interface CElement
clip
- The clipping shapeCShape.setClip(CShape)
public void addGhost()
CElement
.addGhost
in interface CElement
CShape.addGhost()
public void removeGhost()
CElement
.removeGhost
in interface CElement
CShape.removeGhost()
public CRectangle getBoundingBox()
getBoundingBox
in interface CElement
CElement
.public double getMinX()
public double getMaxX()
public double getCenterX()
getCenterX
in interface CElement
CElement
.public double getMinY()
public double getMaxY()
public double getCenterY()
getCenterY
in interface CElement
CElement
.public CShape firstShape()
CElement
.firstShape
in interface CElement
CElement
, null if no shape is contained.public CShape getFirstAntialiasedShape()
CElement
.getFirstAntialiasedShape
in interface CElement
CElement
, null if no CShape is antialiased.CShape.isAntialiased()
public CShape getFirstFilledShape()
CElement
and that is filled.getFirstFilledShape
in interface CElement
CElement
and that is filled, null if no CShape is filled.CShape.isFilled()
public CShape getFirstOutlinedShape()
CElement
and that is outlined.getFirstOutlinedShape
in interface CElement
CElement
and that is outlined, null if no CShape is outlined.CShape.isOutlined()
public CElement addTag(CExtensionalTag t)
addTag(Canvas.Tag t)
for every CShape contained in this CElement
.public CElement addTag(java.lang.String t)
addTag(String t)
for every CShape contained in this CElement
.addTag
in interface CElement
t
- The name of the tagCElement
CShape.addTag(String)
public CElement removeTag(CExtensionalTag t)
removeTag(Tag t)
for every CShape contained in this CElement
only if t is a SMExtensionalTag
,
does nothing otherwise.removeTag
in interface CElement
t
- The tagCElement
CShape.removeTag(CExtensionalTag)
public CElement removeTag(java.lang.String t)
removeTag(String t)
for every CShape contained in this CElement
.removeTag
in interface CElement
t
- The name of the tagCElement
CShape.removeTag(String)
public CElement animate(Animation anim)
animate(Animation animTagScale)
for every CShape
contained in this Canvas
.animate
in interface CElement
anim
- The animation to associate to each shape in this
Canvas
.Canvas
as a CElement
CShape.animate(Animation)
public java.util.List<CShape> getDisplayList()
public java.awt.Shape getClip()
public void setClip(java.awt.Shape clip)