Class CardFace

    • Field Detail

      • sheet

        protected transient Sheet<?> sheet
      • name

        protected transient java.lang.String name
    • Constructor Detail

      • CardFace

        public CardFace​(GameComponent component,
                        java.lang.String path,
                        int index)
        Create a CardFace for use in a deck.
        Parameters:
        component - the game component to get the faces from
        path - the path that the game component can be loaded from in future
        index - the index of the face of interest within the component
      • CardFace

        public CardFace​(java.lang.String name,
                        Sheet<?> face,
                        int index)
        Create a CardFace that can be used on a temporary deck. Temporary decks cannot be saved but can be printed.
        Parameters:
        name - the name to use for the face
        face - the sheet to display
        index - the index of the sheet in its source component
    • Method Detail

      • getFinishStyle

        public FinishStyle getFinishStyle()
        Description copied from interface: BleedMarginStyle
        Returns the finish style set on this item, or null if the deck default style should be used.
        Specified by:
        getFinishStyle in interface BleedMarginStyle
        Returns:
        the finish style to use
      • setFinishStyle

        public void setFinishStyle​(FinishStyle style)
        Description copied from interface: BleedMarginStyle
        Sets the edge finish style to use for this item, or null if the deck default option should be used.
        Specified by:
        setFinishStyle in interface BleedMarginStyle
        Parameters:
        style - the style to use
      • getBleedMarginWidth

        public double getBleedMarginWidth()
        Description copied from interface: BleedMarginStyle
        Returns the bleed margin width to use when the relevant finish option is selected.
        Specified by:
        getBleedMarginWidth in interface BleedMarginStyle
        Returns:
        the positive width in points
      • setBleedMarginWidth

        public void setBleedMarginWidth​(double widthInPoints)
        Description copied from interface: BleedMarginStyle
        Sets the bleed margin width to use when the relevant finish option is selected.
        Specified by:
        setBleedMarginWidth in interface BleedMarginStyle
        Parameters:
        widthInPoints - the positive bleed margin width
      • getFoldMarks

        public double[] getFoldMarks()
        Description copied from interface: PageItem
        Return an array of the relative positions and directions of extra fold marks for this item. These fold marks are in addition to any fold marks that are generated automatically based on the juxtaposition of CardFace items. They are intraitem fold marks that are added along the edges of some objects. For example, foldable tome leaves always have a fold mark along their spine, which runs vertically down the centre of the face.

        The returned array consists of two points for each mark in (x1,y1),(x2,y2) order. (x1,y1) is a point relative to the width and height of the card, e.g. 0.5, 0 is the center of the top edge. (x2,y2) is a unit vector that indicates the direction of the line that should be drawn from the first point. (This means that the direction of the fold mark line will be the same as that of the line segment from (0,0) to (x2, y2) and that Math.sqrt( x2*x2 + y2*y2 ) = 1.

        Returns null if there are no extra fold marks for this sheet.

        Specified by:
        getFoldMarks in interface PageItem
        Overrides:
        getFoldMarks in class AbstractItem
        Returns:
        an array of fold mark data in the format described above, or null if there are no extra fold marks
      • getBleedMargin

        public double getBleedMargin()
        Description copied from interface: PageItem
        Returns the bleed margin used for any automatic crop marks, in points.
        Specified by:
        getBleedMargin in interface PageItem
        Overrides:
        getBleedMargin in class AbstractItem
        Returns:
        the bleed margin for this item
      • getName

        public java.lang.String getName()
        Description copied from interface: PageItem
        Return the user-friendly short name of this item.
        Specified by:
        getName in interface PageItem
        Returns:
        a name that describes the card or its general kind
      • getSheetIndex

        public int getSheetIndex()
      • getSheet

        public Sheet<?> getSheet()
      • 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
      • renderImage

        protected java.awt.image.BufferedImage renderImage​(RenderTarget target,
                                                           double resolution)
        Description copied from class: AbstractRenderedItem
        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.

        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
      • getPath

        public java.lang.String getPath()
        Description copied from interface: DependentPageItem
        Returns the path to the external data source.
        Specified by:
        getPath in interface DependentPageItem
        Returns:
        the path to the data this item depends upon
      • setPath

        public void setPath​(java.lang.String path)
        Description copied from interface: DependentPageItem
        Set the path the external data source.
        Specified by:
        setPath in interface DependentPageItem
        Parameters:
        path - the path to the data this item depends upon
      • refresh

        public boolean refresh()
        Clears cached representation of the card face. The next time it is drawn, the sheet will be asked to redraw it from the component instance linked with the sheet. This is not suitable if the linked component needs to change (for example, if the file that the component is stored in is overwritten with a new component). In this case, see refresh(ca.cgjennings.apps.arkham.component.GameComponent).
        Specified by:
        refresh in interface DependentPageItem
        Returns:
        true if the refresh was successful
      • refresh

        public boolean refresh​(GameComponent component)
        Allows for optimized updates when the same component occurs many times in the same deck. The component passed in as a replacement must have a valid set of sheets in place.
        Parameters:
        component - the component to replace the existing one with
        Returns:
        true if the existing component was replaced
      • customizePopupMenu

        public void customizePopupMenu​(javax.swing.JPopupMenu menu,
                                       PageItem[] selection,
                                       boolean isSelectionFocus)
        Description copied from interface: PageItem
        Allows a page item the opportunity to customize the popup menu before it is displayed. When a popup menu is constructed for a page view, the items in the selection will be offered the opportunity to customize the menu. Generally, only the last item (if any) makes any changes.
        Specified by:
        customizePopupMenu in interface PageItem
        Overrides:
        customizePopupMenu in class AbstractItem
        Parameters:
        menu - the menu that will be displayed
        selection - the selected items; this should be considered read-only
        isSelectionFocus - if true, this is the last item in the selection
      • 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)
      • 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