Interface PageItem
-
- All Superinterfaces:
java.lang.Cloneable,java.io.Serializable
- All Known Subinterfaces:
FlippablePageItem,SizablePageItem
- All Known Implementing Classes:
AbstractFlippableItem,AbstractItem,AbstractRenderedItem,CardFace,Curve,CustomTile,Line,OutlinedTile,RotatableTile,TextBox,Tile,TuckBox
public interface PageItem extends java.lang.Cloneable, java.io.SerializableAn item that can be placed in a deck.- Author:
- Chris Jennings
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classPageItem.SnapClassAn enumeration of the general classes of items used to determine how an item will behave when snapped and what it can snap against.static classPageItem.SnapTargetAn enumeration of the algorithms used to determine the position of an item when it is snapped against another item.
-
Field Summary
Fields Modifier and Type Field Description static intICON_SIZEstatic intORIENT_MIRROR_TURN_LEFTThe orientation of flippable cards that are turned 90 degrees counter-clockwise and mirror imaged.static intORIENT_MIRROR_TURN_RIGHTThe orientation of flippable cards that are turned 90 degrees clockwise and mirror imaged.static intORIENT_MIRROR_UPRIGHTThe orientation of flippable cards that are mirror imaged.static intORIENT_MIRROR_UPSIDEDOWNThe orientation of flippable cards that are turned 180 and mirror imaged.static intORIENT_TURN_LEFTThe orientation of flippable cards that are turned 90 degrees counter-clockwise.static intORIENT_TURN_RIGHTThe orientation of flippable cards that are turned 90 degrees clockwise.static intORIENT_UPRIGHTThe orientation of flippable cards that are not turned or mirrored.static intORIENT_UPSIDEDOWNThe orientation of flippable cards that are turned 180 degrees.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PageItemclone()Returns a new page item, using this item as a template.voidcustomizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)Allows a page item the opportunity to customize the popup menu before it is displayed.doublegetBleedMargin()Returns the bleed margin used for any automatic crop marks, in points.java.util.EnumSet<PageItem.SnapClass>getClassesSnappedTo()Get the set of classes this card snaps against.java.lang.StringgetClientProperty(java.lang.String propertyName)Returns the value of a client property of this page item, ornullif the property is not defined.DragHandle[]getDragHandles()Returns an array of the customDragHandles for this item.double[]getFoldMarks()Return an array of the relative positions and directions of extra fold marks for this item.GroupgetGroup()Returns theGroupthat this item belongs to, ornull.doublegetHeight()Return the height of this item, in points.java.awt.geom.Point2DgetLocation()Returns the location of this item as aPoint2D.java.lang.StringgetName()Return the user-friendly short name of this item.intgetOrientation()Return an the item's current orientation.java.awt.ShapegetOutline()Return aShapethat corresponds to the outline of this item.PagegetPage()Return the page that owns this item, ornullif it has no parent.java.awt.geom.Rectangle2D.DoublegetRectangle()Return a rectangle of the bounds of this item.PageItem.SnapClassgetSnapClass()Get the class this item counts as for snapping.PageItem.SnapTargetgetSnapTarget()Get the snap target rule for this item.javax.swing.IcongetThumbnailIcon()Returns a small representative icon for this item.doublegetWidth()Return the width of this item, in points.doublegetX()Returns the current x-position of this card.doublegetY()Returns the current y-position of this card.booleanhasExteriorHandles()Returnstrueif this item has one or more drag handles that may lie outside of the item's bounding box.booleanhitTest(java.awt.geom.Point2D point)Returnstrueifpointis inside the visible bounds of this object.booleanisBleedMarginMarked()Returnstrueif this item should have crop marks added to it.booleanisHorizontal()Returnstrueif this is in a horizontal orientation (turned 90 degrees from normal).booleanisMirrored()Returnstrueif this item is mirror-imaged.booleanisSelectionLocked()Returnstrueif this item is locked against selection.booleanisTurned0DegreesFrom(PageItem rhs)Returnstrueif this item has the same orientation rotation as another item.booleanisTurned180DegreesFrom(PageItem rhs)Returns true if this item's orientation is turned 180 degrees relative to another item.booleanisTurned90DegreesFrom(PageItem rhs)Returns true if this item's orientation is turned 90 degrees relative to another item.booleanisVertical()Returnstrueif card is in a vertical orientation.voidpaint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)Paint this item at its current location.voidprepareToPaint(RenderTarget target, double renderResolutionHint)Update any cached representations needed to paint this item at the specified settings.voidputClientProperty(java.lang.String propertyName, java.lang.String value)Sets a client property on this page item.voidsetClassesSnappedTo(java.util.EnumSet<PageItem.SnapClass> snapClass)Set the set of classes this card snaps against.voidsetGroup(Group g)Sets theGroupfor this item.voidsetLocation(double x, double y)Set the location of this item.voidsetLocation(java.awt.geom.Point2D loc)Set the location of this item.voidsetPage(Page parent)Set the page which is the parent of this card, ornullto clear its parent.voidsetSelectionLocked(boolean lock)Set the state of the item's selection lock.voidsetSnapClass(PageItem.SnapClass snapClass)Set the class this item counts as for snapping.voidsetSnapTarget(PageItem.SnapTarget target)Set the snap target rule for this item.voidsetX(double x)Set the x-location of this item.voidsetY(double y)Set the y-location of this item.
-
-
-
Field Detail
-
ORIENT_UPRIGHT
static final int ORIENT_UPRIGHT
The orientation of flippable cards that are not turned or mirrored.- See Also:
- Constant Field Values
-
ORIENT_TURN_LEFT
static final int ORIENT_TURN_LEFT
The orientation of flippable cards that are turned 90 degrees counter-clockwise.- See Also:
- Constant Field Values
-
ORIENT_UPSIDEDOWN
static final int ORIENT_UPSIDEDOWN
The orientation of flippable cards that are turned 180 degrees.- See Also:
- Constant Field Values
-
ORIENT_TURN_RIGHT
static final int ORIENT_TURN_RIGHT
The orientation of flippable cards that are turned 90 degrees clockwise.- See Also:
- Constant Field Values
-
ORIENT_MIRROR_UPRIGHT
static final int ORIENT_MIRROR_UPRIGHT
The orientation of flippable cards that are mirror imaged.- See Also:
- Constant Field Values
-
ORIENT_MIRROR_TURN_LEFT
static final int ORIENT_MIRROR_TURN_LEFT
The orientation of flippable cards that are turned 90 degrees counter-clockwise and mirror imaged.- See Also:
- Constant Field Values
-
ORIENT_MIRROR_UPSIDEDOWN
static final int ORIENT_MIRROR_UPSIDEDOWN
The orientation of flippable cards that are turned 180 and mirror imaged.- See Also:
- Constant Field Values
-
ORIENT_MIRROR_TURN_RIGHT
static final int ORIENT_MIRROR_TURN_RIGHT
The orientation of flippable cards that are turned 90 degrees clockwise and mirror imaged.- See Also:
- Constant Field Values
-
ICON_SIZE
static final int ICON_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
clone
PageItem clone()
Returns a new page item, using this item as a template. The new item should generally be a deep copy, not sharing any objects with the original unless those objects are immutable. The deck editor absolutely relies on this method being implemented correctly! (For example, drag-and-drop and clipboard operations use clones to create copies of existing items.)- Returns:
- a new copy of this page item
-
getFoldMarks
double[] getFoldMarks()
Return an array of the relative positions and directions of extra fold marks for this item. These fold marks are in addition to any fold marks that are generated automatically based on the juxtaposition ofCardFaceitems. They are intraitem fold marks that are added along the edges of some objects. For example, foldable tome leaves always have a fold mark along their spine, which runs vertically down the centre of the face.The returned array consists of two points for each mark in (x1,y1),(x2,y2) order. (x1,y1) is a point relative to the width and height of the card, e.g. 0.5, 0 is the center of the top edge. (x2,y2) is a unit vector that indicates the direction of the line that should be drawn from the first point. (This means that the direction of the fold mark line will be the same as that of the line segment from (0,0) to (x2, y2) and that
Math.sqrt( x2*x2 + y2*y2 ) = 1.Returns
nullif there are no extra fold marks for this sheet.- Returns:
- an array of fold mark data in the format described above, or
nullif there are no extra fold marks
-
getWidth
double getWidth()
Return the width of this item, in points.- Returns:
- the item's width
-
getHeight
double getHeight()
Return the height of this item, in points.- Returns:
- the item's height
-
getName
java.lang.String getName()
Return the user-friendly short name of this item.- Returns:
- a name that describes the card or its general kind
-
getOrientation
int getOrientation()
Return an the item's current orientation. If the item does not implementFlippablePageItem, it should always returnORIENT_UPRIGHT.- Returns:
- the item's orientation value
-
getPage
Page getPage()
Return the page that owns this item, ornullif it has no parent.- Returns:
- the page that this item is on
-
getRectangle
java.awt.geom.Rectangle2D.Double getRectangle()
Return a rectangle of the bounds of this item.- Returns:
- a bounding rectangle for the item
-
getOutline
java.awt.Shape getOutline()
Return aShapethat corresponds to the outline of this item. In the simplest case, this can return the same result asgetRectangle(). If precise geometry is available for the item, then this should return a more accurate bounding shape.- Returns:
- the outline of this object
-
getDragHandles
DragHandle[] getDragHandles()
Returns an array of the customDragHandles for this item. If the item has no handles, returnsnull.- Returns:
- an array of drag handles for manipulating the object
-
getSnapClass
PageItem.SnapClass getSnapClass()
Get the class this item counts as for snapping.- Returns:
- the snap class of this item
-
setSnapClass
void setSnapClass(PageItem.SnapClass snapClass)
Set the class this item counts as for snapping.- Parameters:
snapClass- the new snap class for this item
-
getClassesSnappedTo
java.util.EnumSet<PageItem.SnapClass> getClassesSnappedTo()
Get the set of classes this card snaps against. The item will only snap to the kinds of objects that are included in this class.- Returns:
- the snap classes that determine the objects that this item will snap against
-
setClassesSnappedTo
void setClassesSnappedTo(java.util.EnumSet<PageItem.SnapClass> snapClass)
Set the set of classes this card snaps against.- Parameters:
snapClass- the snap classes that determine the objects that this item will snap against
-
getSnapTarget
PageItem.SnapTarget getSnapTarget()
Get the snap target rule for this item.- Returns:
- the rule describing how this object snaps to other objects
-
setSnapTarget
void setSnapTarget(PageItem.SnapTarget target)
Set the snap target rule for this item.- Parameters:
target- the rule describing how this object snaps to other objects
-
getThumbnailIcon
javax.swing.Icon getThumbnailIcon()
Returns a small representative icon for this item. The icon should beICON_SIZEpixels wide and high.
-
getX
double getX()
Returns the current x-position of this card.
-
getY
double getY()
Returns the current y-position of this card.
-
isBleedMarginMarked
boolean isBleedMarginMarked()
Returnstrueif this item should have crop marks added to it. The crop marks will be placedgetBleedMargin()points from the ends of each edge.
-
getBleedMargin
double getBleedMargin()
Returns the bleed margin used for any automatic crop marks, in points.- Returns:
- the bleed margin for this item
-
hitTest
boolean hitTest(java.awt.geom.Point2D point)
Returnstrueifpointis inside the visible bounds of this object.- Parameters:
point- a point in document coordinates (points from the upper-left corner of the page)- Returns:
trueif the point lies inside the bounds of the object
-
isHorizontal
boolean isHorizontal()
Returnstrueif this is in a horizontal orientation (turned 90 degrees from normal). If this is not aFlippablePageItem, it must returnfalse.
-
isVertical
boolean isVertical()
Returnstrueif card is in a vertical orientation. If this is not aFlippablePageItem, it must returntrue.
-
isMirrored
boolean isMirrored()
Returnstrueif this item is mirror-imaged. If this is not aFlippablePageItem, it must returnfalse.
-
isTurned0DegreesFrom
boolean isTurned0DegreesFrom(PageItem rhs)
Returnstrueif this item has the same orientation rotation as another item.
-
isTurned180DegreesFrom
boolean isTurned180DegreesFrom(PageItem rhs)
Returns true if this item's orientation is turned 180 degrees relative to another item.
-
isTurned90DegreesFrom
boolean isTurned90DegreesFrom(PageItem rhs)
Returns true if this item's orientation is turned 90 degrees relative to another item.
-
paint
void paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)Paint this item at its current location. The graphics context will be scaled so that 1 unit represents 1 point. The resolution hint is a suggestion as to the resolution the item should be rendered at if it must be converted to a bitmap before being drawn. It may or may not represent the actual resolution of the output target.- Parameters:
g- the graphics context to paint totarget- the type of destination being drawn torenderResolutionHint- a source resolution hint
-
prepareToPaint
void prepareToPaint(RenderTarget target, double renderResolutionHint)
Update any cached representations needed to paint this item at the specified settings. It is not required that this be called prior to callingpaint(java.awt.Graphics2D, ca.cgjennings.apps.arkham.sheet.RenderTarget, double). Rather, the intent is that if this method returns without throwing any exceptions (such asOutOfMemoryError), then a call topaint(java.awt.Graphics2D, ca.cgjennings.apps.arkham.sheet.RenderTarget, double)with the same settings is also expected to succeed. Thus, this method may be called prior to rendering at high resolution and if it throws anOutOfMemoryError, the application can attempt to recover by freeing up resources before trying to paint again.If this
PageItemdoes not require rendering to a buffer, then this method may do nothing.- Parameters:
target- the rendering targetrenderResolutionHint- a hint regarding output resolution- See Also:
paint(java.awt.Graphics2D, ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
-
setPage
void setPage(Page parent)
Set the page which is the parent of this card, ornullto clear its parent. ThePageclass will set the parent automatically when a card is added or removed from it.
-
setX
void setX(double x)
Set the x-location of this item.- Parameters:
x- the new x-location
-
setY
void setY(double y)
Set the y-location of this item.- Parameters:
y- the new y-location
-
setLocation
void setLocation(double x, double y)Set the location of this item.- Parameters:
x- the new x-locationy- the new y-location
-
setLocation
void setLocation(java.awt.geom.Point2D loc)
Set the location of this item.- Parameters:
loc- the new location
-
getLocation
java.awt.geom.Point2D getLocation()
Returns the location of this item as aPoint2D.- Returns:
- the location of this item on the page
-
setSelectionLocked
void setSelectionLocked(boolean lock)
Set the state of the item's selection lock. Locked items cannot be selected or dragged.- Parameters:
lock- iftrue, prevent selecting or moving the item
-
isSelectionLocked
boolean isSelectionLocked()
Returnstrueif this item is locked against selection.- Returns:
trueif the object is locked
-
customizePopupMenu
void customizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)Allows a page item the opportunity to customize the popup menu before it is displayed. When a popup menu is constructed for a page view, the items in the selection will be offered the opportunity to customize the menu. Generally, only the last item (if any) makes any changes.- Parameters:
menu- the menu that will be displayedselection- the selected items; this should be considered read-onlyisSelectionFocus- iftrue, this is the last item in the selection
-
getGroup
Group getGroup()
Returns theGroupthat this item belongs to, ornull.- Returns:
- the group the object is in, or
nullif it isn't in a group
-
setGroup
void setGroup(Group g)
Sets theGroupfor this item. This should not be called directly, but rather the item should be added to a group usingGroup.add(ca.cgjennings.apps.arkham.deck.item.PageItem).- Parameters:
g- theGroupto add this to
-
hasExteriorHandles
boolean hasExteriorHandles()
Returnstrueif this item has one or more drag handles that may lie outside of the item's bounding box. The editor normally only tests handles that lie within the bounding box to see if the user has pointed at them; if this method returnstruethen the item's handles are always tested.- Returns:
trueif some handles may be outside the bounding box
-
putClientProperty
void putClientProperty(java.lang.String propertyName, java.lang.String value)Sets a client property on this page item. Client properties can be used by plug-ins to tag page items with plug-in specific data. Client properties are saved as part a deck save file. To delete a client property, use this method to set its value tonull.- Parameters:
propertyName- the property namevalue- the value to associate with the property- Throws:
java.lang.NullPointerException- if the property name isnull
-
getClientProperty
java.lang.String getClientProperty(java.lang.String propertyName)
Returns the value of a client property of this page item, ornullif the property is not defined.- Parameters:
propertyName- the property name- Returns:
- the value associated with the property, or
null - Throws:
java.lang.NullPointerException- if the property name isnull
-
-