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.Stringnameprotected 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 aCardFacefor use in a deck.CardFace(java.lang.String name, Sheet<?> face, int index)Create aCardFacethat can be used on a temporary deck.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginEditing()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.doublegetBleedMarginWidth()Returns the bleed margin width to use when the relevant finish option is selected.FinishStylegetFinishStyle()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.StringgetName()Return the user-friendly short name of this item.java.lang.StringgetPath()Returns the path to the external data source.Sheet<?>getSheet()intgetSheetIndex()protected doublegetUprightHeight()Return the height of this item in its standard, upright orientation.protected doublegetUprightWidth()Return the width of this item in its standard, upright orientation.booleanisBleedMarginMarked()Returnstrueif this item should have crop marks added to it.protected voidreadImpl(java.io.ObjectInputStream in)booleanrefresh()Clears cached representation of the card face.booleanrefresh(GameComponent component)Allows for optimized updates when the same component occurs many times in the same deck.protected java.awt.image.BufferedImagerenderImage(RenderTarget target, double resolution)Render an image based on the target and resolution hints.protected booleanscaleMipMapUpAtHighZoom(RenderTarget target, double resolution)Returnstrueif the highest resolution MIP map image should be scaled up at high zoom levels.voidsetBleedMarginWidth(double widthInPoints)Sets the bleed margin width to use when the relevant finish option is selected.voidsetFinishStyle(FinishStyle style)Sets the edge finish style to use for this item, or null if the deck default option should be used.voidsetPath(java.lang.String path)Set the path the external data source.protected voidwriteImpl(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 aCardFacefor 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 aCardFacethat 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:BleedMarginStyleReturns the finish style set on this item, or null if the deck default style should be used.- Specified by:
getFinishStylein interfaceBleedMarginStyle- Returns:
- the finish style to use
-
setFinishStyle
public void setFinishStyle(FinishStyle style)
Description copied from interface:BleedMarginStyleSets the edge finish style to use for this item, or null if the deck default option should be used.- Specified by:
setFinishStylein interfaceBleedMarginStyle- Parameters:
style- the style to use
-
getBleedMarginWidth
public double getBleedMarginWidth()
Description copied from interface:BleedMarginStyleReturns the bleed margin width to use when the relevant finish option is selected.- Specified by:
getBleedMarginWidthin interfaceBleedMarginStyle- Returns:
- the positive width in points
-
setBleedMarginWidth
public void setBleedMarginWidth(double widthInPoints)
Description copied from interface:BleedMarginStyleSets the bleed margin width to use when the relevant finish option is selected.- Specified by:
setBleedMarginWidthin interfaceBleedMarginStyle- Parameters:
widthInPoints- the positive bleed margin width
-
getFoldMarks
public double[] getFoldMarks()
Description copied from interface:PageItemReturn 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.- Specified by:
getFoldMarksin interfacePageItem- Overrides:
getFoldMarksin classAbstractItem- Returns:
- an array of fold mark data in the format described above, or
nullif there are no extra fold marks
-
isBleedMarginMarked
public boolean isBleedMarginMarked()
Description copied from interface:PageItemReturnstrueif 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:
isBleedMarginMarkedin interfacePageItem- Overrides:
isBleedMarginMarkedin classAbstractItem
-
getBleedMargin
public double getBleedMargin()
Description copied from interface:PageItemReturns the bleed margin used for any automatic crop marks, in points.- Specified by:
getBleedMarginin interfacePageItem- Overrides:
getBleedMarginin classAbstractItem- Returns:
- the bleed margin for this item
-
getName
public java.lang.String getName()
Description copied from interface:PageItemReturn the user-friendly short name of this item.
-
getSheetIndex
public int getSheetIndex()
-
getSheet
public Sheet<?> getSheet()
-
getUprightWidth
protected double getUprightWidth()
Description copied from class:AbstractRenderedItemReturn the width of this item in its standard, upright orientation.- Specified by:
getUprightWidthin classAbstractRenderedItem- Returns:
- the width of the unoriented item
-
getUprightHeight
protected double getUprightHeight()
Description copied from class:AbstractRenderedItemReturn the height of this item in its standard, upright orientation.- Specified by:
getUprightHeightin classAbstractRenderedItem- Returns:
- the height of the unoriented item
-
renderImage
protected java.awt.image.BufferedImage renderImage(RenderTarget target, double resolution)
Description copied from class:AbstractRenderedItemRender 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 thesuperimplementation.- Specified by:
renderImagein 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:DependentPageItemReturns the path to the external data source.- Specified by:
getPathin interfaceDependentPageItem- Returns:
- the path to the data this item depends upon
-
setPath
public void setPath(java.lang.String path)
Description copied from interface:DependentPageItemSet the path the external data source.- Specified by:
setPathin 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:
refreshin 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:
trueif the existing component was replaced
-
beginEditing
public void beginEditing()
- Specified by:
beginEditingin interfaceEditablePageItem
-
customizePopupMenu
public void customizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)Description copied from interface:PageItemAllows 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:
customizePopupMenuin interfacePageItem- Overrides:
customizePopupMenuin 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:AbstractRenderedItemReturnstrueif 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:
scaleMipMapUpAtHighZoomin 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:
writeImplin classAbstractRenderedItem- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException- Overrides:
readImplin classAbstractRenderedItem- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-