Class CardFace
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.item.AbstractItem
-
- ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
-
- ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
-
- ca.cgjennings.apps.arkham.deck.item.CardFace
-
- All Implemented Interfaces:
BleedMarginStyle
,DependentPageItem
,EditablePageItem
,FlippablePageItem
,PageItem
,Style
,java.io.Serializable
,java.lang.Cloneable
public class CardFace extends AbstractRenderedItem implements DependentPageItem, EditablePageItem, BleedMarginStyle
A page item representing one face of a game component.- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
PageItem.SnapClass, PageItem.SnapTarget
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
name
protected Sheet<?>
sheet
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
render
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
orientation
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
dragHandles, group, parent, selectionLock, snapClass, snapTarget, snapToClasses, xOff, yOff
-
Fields inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
ICON_SIZE, ORIENT_MIRROR_TURN_LEFT, ORIENT_MIRROR_TURN_RIGHT, ORIENT_MIRROR_UPRIGHT, ORIENT_MIRROR_UPSIDEDOWN, ORIENT_TURN_LEFT, ORIENT_TURN_RIGHT, ORIENT_UPRIGHT, ORIENT_UPSIDEDOWN
-
-
Constructor Summary
Constructors Constructor Description CardFace(GameComponent component, java.lang.String path, int index)
Create aCardFace
for use in a deck.CardFace(java.lang.String name, Sheet<?> face, int index)
Create aCardFace
that can be used on a temporary deck.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginEditing()
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.double
getBleedMargin()
Returns the bleed margin used for any automatic crop marks, in points.double
getBleedMarginWidth()
Returns the bleed margin width to use when the relevant finish option is selected.FinishStyle
getFinishStyle()
Returns the finish style set on this item, or null if the deck default style should be used.double[]
getFoldMarks()
Return an array of the relative positions and directions of extra fold marks for this item.java.lang.String
getName()
Return the user-friendly short name of this item.java.lang.String
getPath()
Returns the path to the external data source.Sheet<?>
getSheet()
int
getSheetIndex()
protected double
getUprightHeight()
Return the height of this item in its standard, upright orientation.protected double
getUprightWidth()
Return the width of this item in its standard, upright orientation.boolean
isBleedMarginMarked()
Returnstrue
if this item should have crop marks added to it.protected void
readImpl(java.io.ObjectInputStream in)
boolean
refresh()
Clears cached representation of the card face.boolean
refresh(GameComponent component)
Allows for optimized updates when the same component occurs many times in the same deck.protected java.awt.image.BufferedImage
renderImage(RenderTarget target, double resolution)
Render an image based on the target and resolution hints.protected boolean
scaleMipMapUpAtHighZoom(RenderTarget target, double resolution)
Returnstrue
if the highest resolution MIP map image should be scaled up at high zoom levels.void
setBleedMarginWidth(double widthInPoints)
Sets the bleed margin width to use when the relevant finish option is selected.void
setFinishStyle(FinishStyle style)
Sets the edge finish style to use for this item, or null if the deck default option should be used.void
setPath(java.lang.String path)
Set the path the external data source.protected void
writeImpl(java.io.ObjectOutputStream out)
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
clearCachedIcon, clearCachedImages, clone, createOrientedImage, getHeight, getOrientedImage, getThumbnailIcon, getWidth, isMipMapCacheEnabled, isMipMapCacheEnabledByDefault, paint, prepareToPaint, setMipMapCacheEnabled
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
flip, getOrientation, setOrientation, turnLeft, turnRight
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
getClassesSnappedTo, getClientProperty, getDragHandles, getGroup, getLocation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getX, getY, hasExteriorHandles, hitTest, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, itemChanged, itemChanging, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, setX, setY, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
getClassesSnappedTo, getClientProperty, getDragHandles, getGroup, getLocation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getX, getY, hasExteriorHandles, hitTest, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, setX, setY
-
-
-
-
Field Detail
-
sheet
protected transient Sheet<?> sheet
-
name
protected transient java.lang.String name
-
-
Constructor Detail
-
CardFace
public CardFace(GameComponent component, java.lang.String path, int index)
Create aCardFace
for use in a deck.- Parameters:
component
- the game component to get the faces frompath
- the path that the game component can be loaded from in futureindex
- the index of the face of interest within the component
-
CardFace
public CardFace(java.lang.String name, Sheet<?> face, int index)
Create aCardFace
that can be used on a temporary deck. Temporary decks cannot be saved but can be printed.- Parameters:
name
- the name to use for the faceface
- the sheet to displayindex
- the index of the sheet in its source component
-
-
Method Detail
-
getFinishStyle
public FinishStyle getFinishStyle()
Description copied from interface:BleedMarginStyle
Returns the finish style set on this item, or null if the deck default style should be used.- Specified by:
getFinishStyle
in interfaceBleedMarginStyle
- Returns:
- the finish style to use
-
setFinishStyle
public void setFinishStyle(FinishStyle style)
Description copied from interface:BleedMarginStyle
Sets the edge finish style to use for this item, or null if the deck default option should be used.- Specified by:
setFinishStyle
in interfaceBleedMarginStyle
- Parameters:
style
- the style to use
-
getBleedMarginWidth
public double getBleedMarginWidth()
Description copied from interface:BleedMarginStyle
Returns the bleed margin width to use when the relevant finish option is selected.- Specified by:
getBleedMarginWidth
in interfaceBleedMarginStyle
- Returns:
- the positive width in points
-
setBleedMarginWidth
public void setBleedMarginWidth(double widthInPoints)
Description copied from interface:BleedMarginStyle
Sets the bleed margin width to use when the relevant finish option is selected.- Specified by:
setBleedMarginWidth
in interfaceBleedMarginStyle
- Parameters:
widthInPoints
- the positive bleed margin width
-
getFoldMarks
public double[] getFoldMarks()
Description copied from interface:PageItem
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 ofCardFace
items. 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
null
if there are no extra fold marks for this sheet.- Specified by:
getFoldMarks
in interfacePageItem
- Overrides:
getFoldMarks
in classAbstractItem
- Returns:
- an array of fold mark data in the format described above, or
null
if there are no extra fold marks
-
isBleedMarginMarked
public boolean isBleedMarginMarked()
Description copied from interface:PageItem
Returnstrue
if this item should have crop marks added to it. The crop marks will be placedPageItem.getBleedMargin()
points from the ends of each edge.- Specified by:
isBleedMarginMarked
in interfacePageItem
- Overrides:
isBleedMarginMarked
in classAbstractItem
-
getBleedMargin
public double getBleedMargin()
Description copied from interface:PageItem
Returns the bleed margin used for any automatic crop marks, in points.- Specified by:
getBleedMargin
in interfacePageItem
- Overrides:
getBleedMargin
in classAbstractItem
- Returns:
- the bleed margin for this item
-
getName
public java.lang.String getName()
Description copied from interface:PageItem
Return the user-friendly short name of this item.
-
getSheetIndex
public int getSheetIndex()
-
getSheet
public Sheet<?> getSheet()
-
getUprightWidth
protected double getUprightWidth()
Description copied from class:AbstractRenderedItem
Return the width of this item in its standard, upright orientation.- Specified by:
getUprightWidth
in classAbstractRenderedItem
- Returns:
- the width of the unoriented item
-
getUprightHeight
protected double getUprightHeight()
Description copied from class:AbstractRenderedItem
Return the height of this item in its standard, upright orientation.- Specified by:
getUprightHeight
in classAbstractRenderedItem
- Returns:
- the height of the unoriented item
-
renderImage
protected java.awt.image.BufferedImage renderImage(RenderTarget target, double resolution)
Description copied from class:AbstractRenderedItem
Render an image based on the target and resolution hints. This is called whenever the item's image is required. The image should always be rendered in the upright, unmirrored position. An oriented image will be generated automatically as needed.It is recommended that subclasses cache results if possible, in which case
AbstractRenderedItem.clearCachedImages()
should be overridden to clear the cached result before calling thesuper
implementation.- Specified by:
renderImage
in classAbstractRenderedItem
- Parameters:
target
- the target type for renderingresolution
- the resolution that the item should be rendered at- Returns:
- an image representing the item's current state
-
getPath
public java.lang.String getPath()
Description copied from interface:DependentPageItem
Returns the path to the external data source.- Specified by:
getPath
in interfaceDependentPageItem
- Returns:
- the path to the data this item depends upon
-
setPath
public void setPath(java.lang.String path)
Description copied from interface:DependentPageItem
Set the path the external data source.- Specified by:
setPath
in interfaceDependentPageItem
- Parameters:
path
- the path to the data this item depends upon
-
refresh
public boolean refresh()
Clears cached representation of the card face. The next time it is drawn, the sheet will be asked to redraw it from the component instance linked with the sheet. This is not suitable if the linked component needs to change (for example, if the file that the component is stored in is overwritten with a new component). In this case, seerefresh(ca.cgjennings.apps.arkham.component.GameComponent)
.- Specified by:
refresh
in interfaceDependentPageItem
- Returns:
- true if the refresh was successful
-
refresh
public boolean refresh(GameComponent component)
Allows for optimized updates when the same component occurs many times in the same deck. The component passed in as a replacement must have a valid set of sheets in place.- Parameters:
component
- the component to replace the existing one with- Returns:
true
if the existing component was replaced
-
beginEditing
public void beginEditing()
- Specified by:
beginEditing
in interfaceEditablePageItem
-
customizePopupMenu
public void customizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)
Description copied from interface:PageItem
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.- Specified by:
customizePopupMenu
in interfacePageItem
- Overrides:
customizePopupMenu
in classAbstractItem
- 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
-
scaleMipMapUpAtHighZoom
protected boolean scaleMipMapUpAtHighZoom(RenderTarget target, double resolution)
Description copied from class:AbstractRenderedItem
Returnstrue
if the highest resolution MIP map image should be scaled up at high zoom levels. This method is called when the MIP map cache is enabled but the current zoom level of the view requires an image with higher resolution than the maximum resolution used by the MIP map cache. If it returnstrue
, then the highest resolution MIP map image will be scaled up to the requested resolution. If it returnsfalse
, then a new rendering will be requested at the exact resolution needed, just as if the MIP map cache was disabled.It is generally faster and consumes less memory to scale up the MIP map image than to render a new image. However, scaling up the MIP map image reduces visual fidelity at high zoom levels. By overriding this method, subclasses can optimize this trade-off for their particular item type.
The value returned by the base class is unspecified because it may change in future versions.
- Overrides:
scaleMipMapUpAtHighZoom
in classAbstractRenderedItem
- Parameters:
target
- the rendering target of the requestresolution
- the desired image resolution- Returns:
- whether the rendering engine should scale up the highest resolution MIP map image or render the image at the exact resolution required
- See Also:
AbstractRenderedItem.setMipMapCacheEnabled(boolean)
-
writeImpl
protected void writeImpl(java.io.ObjectOutputStream out) throws java.io.IOException
- Overrides:
writeImpl
in classAbstractRenderedItem
- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Overrides:
readImpl
in classAbstractRenderedItem
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-