Class DIYSheet


  • public final class DIYSheet
    extends Sheet<DIY>
    The Sheet implementation used by DIY components.
    Author:
    Chris Jennings
    • Method Detail

      • getRenderTarget

        public RenderTarget getRenderTarget()
        Returns the currently requested target when called while the sheet is being drawn. When called at any other time, returns the target of the most recent render request.
        Returns:
        the current render target
      • isHighResolutionRendering

        public boolean isHighResolutionRendering()
        Returns true if the current or most recent rendering was being done in high resolution mode. To return true, one of the following statements must hold:
        1. the high resolution substitution mode is set to FORCE, or
        2. the high resolution substitution mode is set to ENABLE, the render target is either PRINT or EXPORT, and the requested resolution is greater than the resolution of the template image.

        When this method returns true, painting methods should use the highest resolution source images available.

        Returns:
        true if in "high resolution" mode
        Since:
        2.1a11
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.lang.String imageKey,
                               int x,
                               int y)
        Paints an image at its normal size at the specified location. This method will perform automatic high resolution image substitution if there is a key with same name as imageKey but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
        imageKey - the settings key of the image
        x - the horizontal offset from the left side of the template image
        y - the vertical offset from the top edge of the template image
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.lang.String imageKey,
                               java.lang.String regionKey)
        Paints an image at a location and size that are taken from a region setting. This method will perform automatic high resolution image substitution if there is a key with same name as imageKey but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
        imageKey - the settings key of the image
        regionKey - the settings key of the region where the image should be drawn, without the "-region" suffix
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.lang.String sharedKey)
        Paints an image at a location and size that are taken from a region setting. The image resource is determined from the value of sharedKey, while the region is obtained by concatenating "-region" to the shared key name. This method will perform automatic high resolution image substitution if there is a key with same name as sharedKey but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
        sharedKey - the settings key of the image, and base name of the region key
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.lang.String imageKey,
                               int x,
                               int y,
                               int width,
                               int height)
        Paints an image at the specified location and size. This method will perform automatic high resolution image substitution if there is a key with same name as imageKey but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
        imageKey - the settings key of the image
        x - the horizontal offset from the left side of the template image
        y - the vertical offset from the top edge of the template image
        width - the width of the image
        height - the height of the image
      • paintNumberedImage

        public void paintNumberedImage​(java.awt.Graphics2D g,
                                       java.lang.String sharedKey,
                                       int number)
        Paints a numbered image at a location and size that are taken from a region setting. This is similar to painting an image with a shared key, but the image to paint is determined using Settings.getNumberedImageResource(java.lang.String, int). The image resource is determined from the value of sharedKey and number, while the region is obtained by concatenating "-region" to the shared key name. This method will perform automatic high resolution image substitution if there is a key with same name as sharedKey but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
        sharedKey - the settings key of the image, and base name of the region key
        number - the number of the image to load
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.awt.image.BufferedImage image,
                               java.lang.String regionKey)
        Paints an image at the specified location and size.
        Parameters:
        g - the graphics context to use for painting
        image - the image to draw
        regionKey - the settings key of the region where the image should be drawn, without the "-region" suffix
      • paintImage

        public void paintImage​(java.awt.Graphics2D g,
                               java.awt.image.BufferedImage image,
                               java.awt.Rectangle region)
        Paints an image at the specified location and size.
        Parameters:
        g - the graphics context to use for painting
        image - the image to draw
        region - the region in which to draw the image
      • paintTemplateImage

        public void paintTemplateImage​(java.awt.Graphics2D g)
        Paints the card template image that was set when the card was created. This method can perform automatic high resolution image substitution if there is a key with same name as the template key but with "-hires" appended.
        Parameters:
        g - the graphics context to use for painting
      • paintPortrait

        public void paintPortrait​(java.awt.Graphics2D g)
      • paintMarkerPortrait

        public void paintMarkerPortrait​(java.awt.Graphics2D g)
        Paints the portrait within the marker clip region for components with the DIY.FaceStyle.CARD_AND_MARKER face style.
        Parameters:
        g - the graphics context to paint the marker portrait into
        Throws:
        java.lang.IllegalStateException - if the component is not a CARD_AND_MARKER type
      • isTransparent

        public boolean isTransparent()
        Description copied from class: Sheet
        Returns true if the sheets for this card are transparent. The base class returns false; subclasses that want to create non-rectangular card faces must override this method. When this method returns true, the framework guarantees the following:
        1. the image buffer used for drawing will have an alpha channel (that is, it will keep track of how opaque each pixel is)
        2. the image buffer used for drawing will be completely transparent (alpha = 0) at the start of each call to Sheet.paint(ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
        Overrides:
        isTransparent in class Sheet<DIY>
        Returns:
        true if the card face may contain transparent or translucent areas
      • isVariableSize

        public boolean isVariableSize()
        Description copied from class: Sheet
        Returns true if the sheets created by this card can vary in size. Subclasses that wish to create variably-sized sheets must override this method to return true.

        Typically a variably-sized sheet is also transparent. When this is the case, and the sheet image has one or more edges that are completely transparent after Sheet.paint(ca.cgjennings.apps.arkham.sheet.RenderTarget, double) returns, then the transparent edges will be trimmed from the outside of the sheet and the size adjusted accordingly. Alternatively (or additionally), the size can be altered by replacing the template image at the start of painting.

        Overrides:
        isVariableSize in class Sheet<DIY>
        Returns:
        true if this card can have different sizes
        See Also:
        Sheet.isTransparent(), Sheet.replaceTemplateImage(java.awt.image.BufferedImage)
      • getDeckSnappingHint

        public Sheet.DeckSnappingHint getDeckSnappingHint()
        Description copied from class: Sheet
        Returns a hint describing how this sheet should behave when snapped in a deck. The default is CARD, meaning that the sheet behaves like one face of a playing card.
        Overrides:
        getDeckSnappingHint in class Sheet<DIY>
        Returns:
        a hint describing the default behaviour of this face when it is snapped against other objects in a deck
      • getBleedMargin

        public double getBleedMargin()
        Description copied from class: Sheet
        Returns the size of the bleed margin around the component edge that should be cropped off, measured in points. This bleed margin allows for slight misalignment when cutting the component from a larger sheet of paper. The bleed margin will be the same on all sides. The height and width of the component after cutting will be less than the original by twice this margin. If Sheet.hasCropMarks() returns true, then the automatic crop marks will be moved toward the inside of this component by an amount equal to the bleed margin.

        The base class looks up the setting templateKey-bleed-margin to determine the bleed margin, defaulting to 0 if none is defined.

        In the example below, the actual component to be cut and kept is indicated by the blank area, while the X'd area indicates the bleed margin. Component content covers the entire area, including the bleed margin, but nothing important should appear in the bleed margin or within a distance about the same size as the bleed margin on the component interior.

         XXXXXXXXXXXXXXXXXX
         XX              XX
         X                X
         X                X
         X     Actual     X
         X    Component   X
         X     Content    X
         X       (tm)     X
         X                X
         X                X
         X                X
         XX              XX
         XXXXXXXXXXXXXXXXXX
         

        By default, this method returns 0, meaning that the design includes no bleed margin. If the bleed margin is 0, Strange Eons will attempt to synthesize bleed margin graphics, with varying results. Note that Strange Eons will not synthesize a bleed margin for transparent sheet images (i.e., if Sheet.isTransparent() is true).

        Overrides:
        getBleedMargin in class Sheet<DIY>
        Returns:
        the size of the bleed margin, in points (1 point = 1/72 inch)
        See Also:
        Sheet.hasCropMarks()
      • getFoldMarks

        public double[] getFoldMarks()
        Description copied from class: Sheet
        Returns an array that describes the extra fold marks that should appear on this face when it is placed in a deck. This method is only called if Sheet.hasFoldMarks() returns true. It should return an array of double values. Each fold mark to be added by the deck is described by a sequence of four doubles in the array. The first pair is the location of a start point for the fold mark (in x, y order). The location is relative to the width and height of the face, so for example the pair (0.5, 0) would start a fold mark in the center of the top edge. The second pair is a unit vector that describes the direction that the fold mark should extend from the start point. (Recall that a unit vector is a vector of length one, that is, sqrt(x2+y2) == 1.)

        Fold marks typically come in pairs, one on each side of the face. For example, the following fold mark array would indicate the face should be folded in half along the vertical axis by placing fold marks at the centers of the top and bottom edges:

        [0.5, 0,  0, -1,     0.5, 1,  0, 1]

        The base class returns null.

        Overrides:
        getFoldMarks in class Sheet<DIY>
        Returns:
        an array of quadruples that describe the location and angle of additional fold marks to be drawn around the component
      • hasFoldMarks

        public boolean hasFoldMarks()
        Description copied from class: Sheet
        Returns true if this sheet should have special fold marks added when printed.When this returns true one or more fold marks will be shown at locations determined by Sheet.getFoldMarks(). This can be used to produce complex 3D components that require assembly before use.

        Note that the fold marks produced by this method are completely independent of the marks that are sometimes generated automatically from crop marks (see Sheet.hasCropMarks()).

        The base class returns false.

        Overrides:
        hasFoldMarks in class Sheet<DIY>
        Returns:
        true if Sheet.getFoldMarks() should be consulted for the location of special fold marks
      • getPrintDimensions

        public PrintDimensions getPrintDimensions()
        Description copied from class: Sheet
        Return the printed size of the sheet, measured in points. The returned size will account for the current bleed margin settings.

        The base class implementation is only valid for fixed-size sheets. Variable-sized sheets must override this method to return the correct size.

        Overrides:
        getPrintDimensions in class Sheet<DIY>
        Returns:
        the dimensions of the bounding rectangle of this sheet when printed
      • getMarkerStyle

        public MarkerStyle getMarkerStyle()
        Description copied from class: Sheet
        If this sheet represents an embedded marker, returns the layout style of the marker. For regular sheets, this method returns null. (The base class returns null.)
        Overrides:
        getMarkerStyle in class Sheet<DIY>
        Returns:
        the token style of the embedded token, or null for standard sheets
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Sheet<DIY>