public abstract class CIntentionalTag extends CTag
Intentional tags label graphical objects, i.e. CShapes, that verify a given property,
such as all objects of a given color. The collection of tagged objects
is recomputed each time the tag is used. You don't have to add them explicitely to
CShape
s.
Extends this CIntentionalTag
class
and overrides the method criterion
to specify the property.
Here is an example of a tag shared by all red shapes.
class RedTag extends CIntentionalTag { public RedTag(Canvas canvas) { super(canvas); reset(); } public boolean criterion(CShape s) { return s.getFillPaint() == Color.RED; } }
Constructor and Description |
---|
CIntentionalTag(Canvas c)
Builds a
CIntentionalTag . |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
criterion(CShape s)
The method to override to specify the property a shape must check to be tagged by this tag.
|
java.util.Collection<java.lang.Object> |
getCollection() |
void |
reset()
Inits the tag's iterator.
|
above, aboveAll, action, action, addGhost, addTag, addTag, and, and, animate, attachSM, below, belowAll, contains, contains, contains, contains, detachSM, firstShape, fixReferenceShapeToCurrent, getAntialiasedShapes, getBoundingBox, getCanvas, getCenterX, getCenterY, getFilledShapes, getFirstAntialiasedShape, getFirstFilledShape, getFirstHavingTag, getFirstOutlinedShape, getIntersection, getMaxX, getMaxY, getMinX, getMinY, getOutlinedShapes, getTopLeastShape, getTopMostShape, hasNext, hasTag, hasTag, intersects, isAntialiased, isDrawable, isFilled, isOnOutline, isOutlined, isPickable, next, nextShape, or, or, removeGhost, removeTag, removeTag, rotateBy, rotateTo, scaleBy, scaleBy, scaleTo, scaleTo, setAntialiased, setClip, setDrawable, setFilled, setFillPaint, setOutlined, setOutlinePaint, setParent, setPickable, setReferencePoint, setRenderingHint, setShape, setStroke, setTransformToIdentity, setTransparencyFill, setTransparencyFill, setTransparencyOutline, setTransparencyOutline, tagsShape, translateBy, translateTo
public CIntentionalTag(Canvas c)
CIntentionalTag
.c
- The canvas in which the shapes must be tagged.public abstract boolean criterion(CShape s)
s
- The shape.s
checks the property, false otherwise.public java.util.Collection<java.lang.Object> getCollection()
getCollection
in class Tag