Package gamedata

Class AbstractExpansionSymbolTemplate

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canGenerateVariantsAutomatically()
      Returns true 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 the nth 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()
      Returns true 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
    • Constructor Detail

      • AbstractExpansionSymbolTemplate

        public AbstractExpansionSymbolTemplate()
    • 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 interface ExpansionSymbolTemplate
        Returns:
        the number of logical variants
      • getLogicalVariantName

        public java.lang.String getLogicalVariantName​(int variant)
        Returns the name of the nth 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 interface ExpansionSymbolTemplate
        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 interface ExpansionSymbolTemplate
        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 interface ExpansionSymbolTemplate
        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 returns null, a default paint will be used.

        This abstract base class always returns null, yielding a default backdrop paint.

        Specified by:
        getDesignBackdropForVariant in interface ExpansionSymbolTemplate
        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
      • 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() returns false, then this method throws an UnsupportedOperationException. 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:

        1. Convert the image to greyscale.
        2. Assume one of three cases:
          1. The user has passed in a single-colour logo with proper transparency.
          2. The user has passed in a single-colour logo with no transparency, such as a scan of a paper sketch.
          3. The user has passed in a mixed-colour logo (the new style) with proper transparency.
          To determine which case applies, the image pixels are analyzed. If none of the pixels have any transparency (alpha=255), case 2 is assumed. If there is a small range of pixel values, case 1 is assumed (the small range allows for some noise). Otherwise, case 3 is assumed.
        3. 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.
        4. 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 interface ExpansionSymbolTemplate
        Parameters:
        baseSymbol - the example symbol to base the new design on; usually it has the same style as the symbol at position 0
        variant - the number of the symbol design to generate
        Returns:
        the generated symbol for position n
      • isCustomDrawn

        public boolean isCustomDrawn()
        Returns true 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 interface ExpansionSymbolTemplate
        Returns:
        true if the component is responsible for drawing