Class Tile

    • Field Detail

      • identifier

        protected java.lang.String identifier
    • Constructor Detail

      • Tile

        public Tile​(java.lang.String name,
                    java.lang.String identifier,
                    double ppi)
        Creates a new tile.
        Parameters:
        name - the user-friendly tile name
        identifier - the identifier used to determine the image to display
        ppi - the tile image resolution, in pixels per inch
    • 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()
      • 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 interface PageItem
        Overrides:
        paint in class AbstractRenderedItem
        Parameters:
        g - the graphics context to paint to
        target - the type of destination being drawn to
        renderResolutionHint - 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 class AbstractRenderedItem
        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 class AbstractRenderedItem
        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 the super implementation. Calls getImageFromIdentifier(), if required, to generate the tile image. As tiles are fixed in resolution, the other parameters are ignored. The paint(java.awt.Graphics2D, ca.cgjennings.apps.arkham.sheet.RenderTarget, double) implementation correctly scales the image when painting.

        Specified by:
        renderImage in class AbstractRenderedItem
        Parameters:
        target - the target type for rendering
        resolution - 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
        Returns true 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 returns true, then the highest resolution MIP map image will be scaled up to the requested resolution. If it returns false, 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 class AbstractRenderedItem
        Parameters:
        target - the rendering target of the request
        resolution - 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()
        Returns true 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 returns true.)

        Tiles currently disable MIP map caching, but this could change in a future version.

        Overrides:
        isMipMapCacheEnabledByDefault in class AbstractRenderedItem
        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()
        Returns true 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 to true.
        Parameters:
        allowsOutlineDrawing - true to allow drawing as an outline
      • writeImpl

        protected void writeImpl​(java.io.ObjectOutputStream out)
                          throws java.io.IOException
        Overrides:
        writeImpl in class AbstractRenderedItem
        Throws:
        java.io.IOException
      • readImpl

        protected void readImpl​(java.io.ObjectInputStream in)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Overrides:
        readImpl in class AbstractRenderedItem
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException