Class Tile
- 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.Tile
-
- All Implemented Interfaces:
FlippablePageItem
,PageItem
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
CustomTile
,OutlinedTile
,RotatableTile
public class Tile extends AbstractRenderedItem
The base class for tiles, which are static bitmap graphics that can be placed in a deck.- 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
identifier
-
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 Tile(java.lang.String name, java.lang.String identifier, double ppi)
Creates a new tile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCachedImages()
Clear any cached image data held by this object.double
getDPI()
java.lang.String
getIdentifier()
protected java.awt.image.BufferedImage
getImageFromIdentifier()
Fetch this tile's image using its identifier.java.lang.String
getName()
Return the user-friendly short name of this item.double
getResolution()
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
isFastOutlineAllowed()
Returnstrue
if the tile can be painted as a simple outline when drawing a low quality preview.protected boolean
isMipMapCacheEnabledByDefault()
Returnstrue
if the MIP map cache should be enabled by default for this item type.void
paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)
Paint this item at its current location.protected void
readImpl(java.io.ObjectInputStream in)
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
setDPI(double dpi)
void
setFastOutlineAllowed(boolean allowsOutlineDrawing)
Sets whether the tile can be painted as a simple outline when drawing at low quality.void
setIdentifier(java.lang.String identifier)
void
setName(java.lang.String name)
Sets the user-friendly tile name.void
setOrientation(int orientation)
void
setResolution(double dpi)
protected void
writeImpl(java.io.ObjectOutputStream out)
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
clearCachedIcon, clone, createOrientedImage, getHeight, getOrientedImage, getThumbnailIcon, getWidth, isMipMapCacheEnabled, prepareToPaint, setMipMapCacheEnabled
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
flip, getOrientation, turnLeft, turnRight
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
customizePopupMenu, getBleedMargin, getClassesSnappedTo, getClientProperty, getDragHandles, getFoldMarks, getGroup, getLocation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getX, getY, hasExteriorHandles, hitTest, isBleedMarginMarked, 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
customizePopupMenu, getBleedMargin, getClassesSnappedTo, getClientProperty, getDragHandles, getFoldMarks, getGroup, getLocation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getX, getY, hasExteriorHandles, hitTest, isBleedMarginMarked, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, setX, setY
-
-
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
Sets the user-friendly tile name.- Parameters:
name
- the new, non-null
name
-
getName
public java.lang.String getName()
Description copied from interface:PageItem
Return the user-friendly short name of this item.- Returns:
- a name that describes the card or its general kind
-
setIdentifier
public void setIdentifier(java.lang.String identifier)
-
getIdentifier
public java.lang.String getIdentifier()
-
setOrientation
public void setOrientation(int orientation)
- Specified by:
setOrientation
in interfaceFlippablePageItem
- Overrides:
setOrientation
in classAbstractFlippableItem
-
clearCachedImages
public void clearCachedImages()
Description copied from class:AbstractRenderedItem
Clear any cached image data held by this object. The base class clears any cached oriented results and the MIP map cache (if enabled). Subclasses should override this (callingsuper.clearCachedImages
) if theAbstractRenderedItem.renderImage(ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
implementation caches results.- Overrides:
clearCachedImages
in classAbstractRenderedItem
-
setResolution
public void setResolution(double dpi)
-
getResolution
public double getResolution()
-
paint
public void paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)
Description copied from interface:PageItem
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.- Specified by:
paint
in interfacePageItem
- Overrides:
paint
in classAbstractRenderedItem
- Parameters:
g
- the graphics context to paint totarget
- the type of destination being drawn torenderResolutionHint
- a source resolution hint
-
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
-
getDPI
public double getDPI()
-
setDPI
public void setDPI(double dpi)
-
renderImage
protected java.awt.image.BufferedImage renderImage(RenderTarget target, double resolution)
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. CallsgetImageFromIdentifier()
, if required, to generate the tile image. As tiles are fixed in resolution, the other parameters are ignored. Thepaint(java.awt.Graphics2D, ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
implementation correctly scales the image when painting.- 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
-
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)
-
isMipMapCacheEnabledByDefault
protected boolean isMipMapCacheEnabledByDefault()
Returnstrue
if the MIP map cache should be enabled by default for this item type. Subclasses can override this to disable this mechanism. (The base class returnstrue
.)Tiles currently disable MIP map caching, but this could change in a future version.
- Overrides:
isMipMapCacheEnabledByDefault
in classAbstractRenderedItem
- Returns:
true
if the MIP map cache should automatically be enabled during construction or deserialization
-
getImageFromIdentifier
protected java.awt.image.BufferedImage getImageFromIdentifier()
Fetch this tile's image using its identifier. The base class uses the identifier as a URL relative to the resources folder. Subclasses may implement other algorithms.- Returns:
- the image referenced by the tile's identifier
-
isFastOutlineAllowed
public boolean isFastOutlineAllowed()
Returnstrue
if the tile can be painted as a simple outline when drawing a low quality preview.- Returns:
true
if the tile can be draw as an outline
-
setFastOutlineAllowed
public void setFastOutlineAllowed(boolean allowsOutlineDrawing)
Sets whether the tile can be painted as a simple outline when drawing at low quality. Typically, only items in the TILE tile class will set this totrue
.- Parameters:
allowsOutlineDrawing
-true
to allow drawing as an outline
-
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
-
-