Class AbstractExpansionSymbolTemplate
- java.lang.Object
-
- gamedata.AbstractExpansionSymbolTemplate
-
- All Implemented Interfaces:
ExpansionSymbolTemplate
public abstract class AbstractExpansionSymbolTemplate extends java.lang.Object implements ExpansionSymbolTemplate
An abstract base class that provides default implementations for some methods inExpansionSymbolTemplate
.- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description AbstractExpansionSymbolTemplate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canGenerateVariantsAutomatically()
Returnstrue
if this template can automatically generate a family of variants given an example image.java.awt.image.BufferedImage
generateVariant(java.awt.image.BufferedImage baseSymbol, int variant)
Given an example image, generates a symbol variant automatically.java.awt.Paint
getDesignBackdropForVariant(int variant)
Returns a suggested paint to use as a backdrop for this variant.int
getLogicalVariantCount()
Returns the number of logical variants for games that distinguish between visual variants and logical variants.javax.swing.Icon
getLogicalVariantIcon(int variant)
Returns an icon that can accompany the logical variant name to visually distinguish the the variant.java.lang.String
getLogicalVariantName(int variant)
Returns the name of then
th logical variant for games that distinguish between visual variants and logical variants.javax.swing.Icon
getVariantIcon(int variant)
Returns an icon that can accompany the variant name to visually distinguish the style of the variant.boolean
isCustomDrawn()
Returnstrue
if the components for this game will draw the expansion symbols themselves instead of relying on the default mechanism.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gamedata.ExpansionSymbolTemplate
getDefaultSymbol, getVariantCount, getVariantName
-
-
-
-
Method Detail
-
getLogicalVariantCount
public int getLogicalVariantCount()
Returns the number of logical variants for games that distinguish between visual variants and logical variants.The abstract base class will return the same value as
getVariantCount()
.- Specified by:
getLogicalVariantCount
in interfaceExpansionSymbolTemplate
- Returns:
- the number of logical variants
-
getLogicalVariantName
public java.lang.String getLogicalVariantName(int variant)
Returns the name of then
th logical variant for games that distinguish between visual variants and logical variants.The abstract base class will return the same value as
getVariantName( variant )
.- Specified by:
getLogicalVariantName
in interfaceExpansionSymbolTemplate
- Parameters:
variant
- the logical variant number- Returns:
- a description of the logical variant
-
getLogicalVariantIcon
public javax.swing.Icon getLogicalVariantIcon(int variant)
Returns an icon that can accompany the logical variant name to visually distinguish the the variant.The abstract base class will return the same value as
getVariantIcon()
.- Specified by:
getLogicalVariantIcon
in interfaceExpansionSymbolTemplate
- Parameters:
variant
- the logical variant number- Returns:
- a simple icon that helps distinguish the logical variant
-
getVariantIcon
public javax.swing.Icon getVariantIcon(int variant)
Returns an icon that can accompany the variant name to visually distinguish the style of the variant. A typical icon is a disc filled with a characteristic colour taken from the variant's design.The abstract base class returns a icons that match the default variant styles.
- Specified by:
getVariantIcon
in interfaceExpansionSymbolTemplate
- Parameters:
variant
- the variant number- Returns:
- a simple icon that helps distinguish the variant
- See Also:
SymbolVariantUtilities.createDefaultVariantIcon(java.awt.Paint)
-
getDesignBackdropForVariant
public java.awt.Paint getDesignBackdropForVariant(int variant)
Returns a suggested paint to use as a backdrop for this variant. This can be used when selecting or editing a symbol with this variant. For example, the end user expansion dialog (Expansion|New) will use this for the drop boxes that the user drops symbol images on. If this method returnsnull
, a default paint will be used.This abstract base class always returns
null
, yielding a default backdrop paint.- Specified by:
getDesignBackdropForVariant
in interfaceExpansionSymbolTemplate
- Parameters:
variant
- the index of the variant to obtain a backdrop for- Returns:
- a paint to use as the backdrop, or
null
to use the default
-
canGenerateVariantsAutomatically
public boolean canGenerateVariantsAutomatically()
Returnstrue
if this template can automatically generate a family of variants given an example image.This abstract base class returns
false
.- Specified by:
canGenerateVariantsAutomatically
in interfaceExpansionSymbolTemplate
- Returns:
true
ifgenerateVariant(java.awt.image.BufferedImage, int)
is supported
-
generateVariant
public java.awt.image.BufferedImage generateVariant(java.awt.image.BufferedImage baseSymbol, int variant)
Given an example image, generates a symbol variant automatically.If
canGenerateVariantsAutomatically()
returnsfalse
, then this method throws anUnsupportedOperationException
. Otherwise, the abstract base class provides a default variant-generating algorithm based on the icons for Arkham Horror. This can be used as-is when appropriate, or if useful it can be used as a starting point for generating an appropriate image for the game in question. (For example, you could request variant 0 to get an image that is known to be black-and-white and have an alpha channel as described below.)Details of the default implementation: In Arkham Horror, there are two different styles for expansion symbols. Older expansions used a single-colour dark logo which was inverted on cards with a dark background. Newer expansions use a single logo embedded in a circle. The circle has a dark outline and a light background, over which is laid a dark logo. This allows the same graphic to be seen easily on both light and dark cards. With Miskatonic Horror, a new "required" variant has been added that replaces the dark colour with a golden one.
To recreate these styles, this method proceeds as follows:
- Convert the image to greyscale.
- Assume one of three cases:
- The user has passed in a single-colour logo with proper transparency.
- The user has passed in a single-colour logo with no transparency, such as a scan of a paper sketch.
- The user has passed in a mixed-colour logo (the new style) with proper transparency.
- Cases 1 and 2 are based on the older single-colour logos. A logo is created by setting each pixel to an appropriate colour for the variant type. For case 1, the original transparency is kept. For case 2, the transparency is taken from the pixel brightness: white pixels (paper) will become transparent.
- For case 3, the range of brightness values present in the original image will be mapped to a range of colours appropriate for the variant. For variants 0 and 1, this is dark to white, For variant 2, this is golden to white.
- Specified by:
generateVariant
in interfaceExpansionSymbolTemplate
- Parameters:
baseSymbol
- the example symbol to base the new design on; usually it has the same style as the symbol at position 0variant
- the number of the symbol design to generate- Returns:
- the generated symbol for position
n
-
isCustomDrawn
public boolean isCustomDrawn()
Returnstrue
if the components for this game will draw the expansion symbols themselves instead of relying on the default mechanism.This abstract base class returns
false
.- Specified by:
isCustomDrawn
in interfaceExpansionSymbolTemplate
- Returns:
true
if the component is responsible for drawing
-
-