Class Deck

    • Field Detail

      • PROPERTY_PAGE_ADDED

        public static final java.lang.String PROPERTY_PAGE_ADDED
        A property change that is fired with the page number when a page is added.
        See Also:
        Constant Field Values
      • PROPERTY_PAGE_REMOVED

        public static final java.lang.String PROPERTY_PAGE_REMOVED
        A property change that is fired with the page number when a page is removed.
        See Also:
        Constant Field Values
      • PROPERTY_PAGE_REORDERED

        public static final java.lang.String PROPERTY_PAGE_REORDERED
        A property change that is fired with the old and new page numbers when the page order changes.
        See Also:
        Constant Field Values
      • MAX_PAPER_SIZE

        public static final double MAX_PAPER_SIZE
        The maximum size for any dimension in a page format that is allowed in a deck. It is equal to 7200 points (100 inches, 81/3 feet, or 2.54 metres).
        See Also:
        Constant Field Values
      • RESELECT_GROUP

        public static final int RESELECT_GROUP
        The number of a selection group that is automatically populated with the previous selection when the selection is cleared. This allows the previous selection to be easily restored. This is the last group, and so is equal to NUM_SELECTION_GROUPS-1.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Deck

        public Deck()
        Creates a new, empty deck using the default paper size.
    • Method Detail

      • beginCompoundEdit

        public void beginCompoundEdit()
      • endCompoundEdit

        public void endCompoundEdit()
      • getPageCount

        public int getPageCount()
        Return the number of pages in this deck.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener pcl)
        Adds a PropertyChangeListener to the deck. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.
        Parameters:
        pcl - the listener to add
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener pcl)
        Removes a PropertyChangeListener from the deck. This removes a listener that was registered for all properties. If the listener was added more than once, it will be notified one less time after being removed. If the listener is null, or was never added, no exception is thrown and no action is taken.
        Parameters:
        pcl - the listener to remove
      • addNewPage

        public final Page addNewPage()
        Adds a new page to the end of this deck.
      • addNewPage

        public Page addNewPage​(int index)
        Adds a new page which will have the given page index. The newly created page will be made the active page and returned.
        Parameters:
        index - the page index, from 0 to getPageCount() inclusive
        Returns:
        the newly added blank page
      • removePage

        public void removePage​(int index)
        Removes the page at the specified page index.
        Parameters:
        index - the index of the page to remove
      • getPage

        public Page getPage​(int index)
        Returns the page with the specified index.
        Parameters:
        index - the index of the page to return
        Returns:
        the requested page
        See Also:
        getPageCount()
      • getSelectionPage

        public Page getSelectionPage()
        Returns the page that containing the currently selected page items, or null if there is no selection.
        Returns:
        the page containing
      • clearSelection

        public void clearSelection()
        Unselects all currently selected page items, if any.
      • addToSelection

        public void addToSelection​(PageItem item)
        Adds a page item to the current selection. If the new item is on a different page than the existing selection, the current selection is cleared first.
        Parameters:
        item - the item to add to the selection
      • removeFromSelection

        public void removeFromSelection​(PageItem item)
        Removes a page item from the current selection. Has no effect if the item is not selected.
        Parameters:
        item - the item to deselect
      • invertSelection

        public void invertSelection()
        Invert the set of selected page items on the page where the selection occurs. If there is no selection, all cards on the active page are selected.
      • storeSelectionInNumberedGroup

        public void storeSelectionInNumberedGroup​(int group)
        Stores the current selection in a numbered memory cell. There are guaranteed to be at least 10 general purpose cells available to the user.
        Parameters:
        group - the cell number to store the selection in
        Throws:
        java.lang.IndexOutOfBoundsException - if the group number is negative or equal to or greater than NUM_SELECTION_GROUPS
      • selectNumberedGroup

        public void selectNumberedGroup​(int groupNumber)
        Selects the specified numbered group. Numbered groups store selections in numbered memory cells as an aid to the user.
        Parameters:
        groupNumber - the index of the group
      • getSelectionGroupSize

        public int getSelectionGroupSize​(int group)
        Returns the number of items in the selection stored in the specified group.
        Parameters:
        group - the selection group number to measure
        Returns:
        the number of items in the selection group, or 0
      • setSelection

        public void setSelection​(PageItem item)
        Selects a single page item, clearing any existing selection.
        Parameters:
        item - the item to select
      • getSelection

        public PageItem[] getSelection()
        Returns the members of the current selection as a possibly empty array.
        Returns:
        the selected items
      • getSelectionSize

        public int getSelectionSize()
        Returns the number of currently selected cards.
        Returns:
        the selection size, or 0 if there is no selection
      • isSelected

        public boolean isSelected​(PageItem item)
        Returns true if the specified item is currently selected.
        Parameters:
        item - the item to test
        Returns:
        true if the item is in the current selection
      • deleteSelection

        public void deleteSelection()
        Deletes the items in the current selection.
      • selectAll

        public void selectAll​(Page page)
      • turnSelectionLeft

        public void turnSelectionLeft()
      • turnSelectionRight

        public void turnSelectionRight()
      • flipSelection

        public void flipSelection()
      • moveSelectionToFront

        public void moveSelectionToFront()
      • moveSelectionToBack

        public void moveSelectionToBack()
      • nudgeSelection

        public void nudgeSelection​(double dx,
                                   double dy)
      • groupSelection

        public void groupSelection()
        Group the selection into a single unit.
      • ungroupSelection

        public void ungroupSelection()
        Break any groups in the selection.
      • getSelectionRectangle

        public java.awt.geom.Rectangle2D.Double getSelectionRectangle()
      • reorderPage

        public void reorderPage​(int oldindex,
                                int newindex)
      • clone

        public Deck clone()
        Description copied from interface: GameComponent
        Returns a deep copy of this game component. The default clone implementation provided by super.clone() will return a shallow copy of the object. This will correctly clone all of this instance's fields that have primitive types. It is then up to you to clone any object fields where the field is not of an immutable type. Images used to store portraits, although not technically immutable, are treated as immutable by Strange Eons. So long as you also follow this convention, you can save memory by sharing the shallow copy of the image.

        Debugging tip: One operation that makes use of the clone() method is the Spin Off command. If you apply this command, make changes to the copied component, redraw the original component, and notice that changes in the copy have carried over to the original, then you are using a shallow copy rather than a deep copy. (That is, you are sharing a reference to the same mutable object rather than making a copy of the mutable object during the cloning.)

        Specified by:
        clone in interface GameComponent
        Overrides:
        clone in class java.lang.Object
        Returns:
        a deep copy of this component
      • getPublishersMarksEnabled

        public boolean getPublishersMarksEnabled()
        Returns whether publisher's marks are displayed for the deck.
        Returns:
        if true, publisher's marks will be generated for objects in the deck
      • setPublishersMarksEnabled

        public void setPublishersMarksEnabled​(boolean pubMarksEnabled)
        Sets whether publisher's marks are displayed for the deck.
        Parameters:
        pubMarksEnabled - if true, publisher's marks will be generated for objects in the deck
      • getPublishersMarkWidth

        public float getPublishersMarkWidth()
        Returns the width of publisher's marks when displayed for editing.
        Returns:
        the non-negative length, in points
        See Also:
        setPublishersMarkWidth(float)
      • setPublishersMarkWidth

        public void setPublishersMarkWidth​(float pubMarkWidth)
        Sets the width of publisher's marks when displayed for editing.
        Parameters:
        pubMarkWidth - the non-negative length, in points
        See Also:
        getPublishersMarkWidth()
      • getPublishersMarkPrintWidth

        public float getPublishersMarkPrintWidth()
        Returns the width of publisher's marks when printed.
        Returns:
        the non-negative length, in points
        See Also:
        setPublishersMarkPrintWidth(float)
      • setPublishersMarkPrintWidth

        public void setPublishersMarkPrintWidth​(float pubMarkWidth)
        Sets the width of publisher's marks when printed.
        Parameters:
        pubMarkWidth - the non-negative length, in points
        See Also:
        getPublishersMarkPrintWidth()
      • getPublishersMarkLength

        public double getPublishersMarkLength()
        Returns the length of publisher's marks.
        Returns:
        the non-negative length, in points
      • setPublishersMarkLength

        public void setPublishersMarkLength​(double pubMarkLength)
        Sets the length of publisher's marks when displayed for editing.
        Parameters:
        pubMarkLength - the non-negative length, in points
      • getPublishersMarkDistance

        public double getPublishersMarkDistance()
        Returns the size of the gap between deck objects and their publisher's marks.
        Returns:
        the distance, in points
      • setPublishersMarkDistance

        public void setPublishersMarkDistance​(double pubMarkDistance)
        Sets the size of the gap between deck objects and their publisher's marks.
        Parameters:
        pubMarkDistance - the non-negative distance, in points
      • setSaveFileHint

        public void setSaveFileHint​(java.io.File f)
        Sets a hint value that is saved with the deck in order to assist with locating linked files (such as game components used in the deck).
        Parameters:
        f - the file that the deck will be saved to
      • setName

        public void setName​(java.lang.String name)
      • getName

        public java.lang.String getName()
        Description copied from interface: GameComponent
        Returns the name of this component. This is not the name of the component type, but the name of the specific component. For example, a component that represents a game item would return the name of the item.
        Specified by:
        getName in interface GameComponent
        Returns:
        the component's name; possibly a shortened version of the full name
        See Also:
        GameComponent.getFullName()
      • hasChanged

        public boolean hasChanged()
        Description copied from interface: GameComponent
        Returns true if this component has been modified since the last call to hasChanged().
        Specified by:
        hasChanged in interface GameComponent
        Returns:
        true if the component has changed since this was last called
      • hasUnsavedChanges

        public boolean hasUnsavedChanges()
        Description copied from interface: GameComponent
        Returns the value of this component's unsaved changes flag.
        Specified by:
        hasUnsavedChanges in interface GameComponent
        Returns:
        true if this component has unsaved changes
      • clearAll

        public void clearAll()
        Description copied from interface: GameComponent
        Sets this component's content to an empty state. Typically, this is called from an editor when the user wishes to erase their work and start over.
        Specified by:
        clearAll in interface GameComponent
      • getSheetTitles

        public java.lang.String[] getSheetTitles()
        Returns an empty array, since decks do not have rendered sheets.
        Specified by:
        getSheetTitles in interface GameComponent
        Returns:
        an array of sheet titles matching the assigned sheets, or null if there are no sheets attached
        See Also:
        GameComponent.createDefaultSheets()
      • createDefaultSheets

        public Sheet<?>[] createDefaultSheets()
        This is not a valid operation for a Deck. Throws UnsupportedOperationException.
        Specified by:
        createDefaultSheets in interface GameComponent
        Returns:
        the newly created sheets
      • markSaved

        public void markSaved()
        Description copied from interface: GameComponent
        This method is called by the component's editor when the the component is saved to clear the component's unsaved changes flag.
        Specified by:
        markSaved in interface GameComponent
      • markChanged

        public final void markChanged​(int i)
        Description copied from interface: GameComponent
        Called to signal that changes have been made that require the ithe sheet to be redrawn. This is typically not called directly. Instead, calling a method like "setName" should check if the name being set is actually different, and if so then call this method for each sheet that may have changed as a result. Plug-ins that customize an existing component may also call this method as needed to reflect new features that they have added.

        Implementations of this method will typically call the Sheet.markChanged() method of the relevant sheet (unless the sheet set is null), set a flag for use by GameComponent.hasChanged(), and then call GameComponent.markUnsavedChanges().

        Specified by:
        markChanged in interface GameComponent
        Parameters:
        i - the index of the sheet that needs to be redrawn
      • setActivePage

        public void setActivePage​(Page pageToActivate)
        Changes the active page. The active page is the default target for commands that affect a particular page. When the deck is shown in a deck editor, the currently visible page and the active page are typically synchronized.
        Parameters:
        pageToActivate - the non-null page to activate
        See Also:
        getActivePage()
      • cut

        public void cut()
        Cuts the current selection, if any. The selection is removed from the deck and placed on the clipboard.
        See Also:
        copy(), paste()
      • copy

        public void copy()
        Copies the current selection to the clipboard.
        See Also:
        cut(), paste()
      • paste

        public void paste()
        Pastes a previously copied selection from the clipboard.
        See Also:
        cut(), copy()
      • centerSelectionOver

        public void centerSelectionOver​(double x,
                                        double y)
        Moves the selection so that it is centered over the point (x, y) (in document space).
        Parameters:
        x - the x-coordinate to center over
        y - the y-coordinate to center over
      • isDeckClipboardEmpty

        public static boolean isDeckClipboardEmpty()
        Returns whether the clipboard used for deck objects is empty. If empty, pasting will have no effect. The deck object clipboard is shared by all decks in the current instance of the application.
        Returns:
        true if the clipboard deck is empty
      • setPaperProperties

        public void setPaperProperties​(PaperProperties paper)
        Sets the paper format for pages in this deck. If page splitting is disabled, then this will also be the physical paper size for printing. When creating large objects, such as game boards, this will typically be set to a format matching the size of the physical object.
        Parameters:
        paper - the new paper format for deck pages
        Throws:
        java.lang.NullPointerException - if the paper format is null
        java.lang.IllegalArgumentException - if any paper measurement is larger than MAX_PAPER_SIZE
        See Also:
        getPaperProperties()
      • setPrinterPaperProperties

        public void setPrinterPaperProperties​(PaperProperties printerPaper)
        Sets the printed page format for the deck. If page splitting is enabled, then pages in the deck will be split into tiles sized for paper with this physical size. This value will be ignored unless page splitting is enabled.
        Parameters:
        printerPaper - the new paper format for printed pages
        Throws:
        java.lang.NullPointerException - if the paper format is null
        java.lang.IllegalArgumentException - if any paper measurement is larger than MAX_PAPER_SIZE
        See Also:
        getPrinterPaperProperties()
      • getPaperSizes

        public java.util.Set<PaperProperties> getPaperSizes()
        Returns a set of paper sizes that are appropriate for this deck at the current time. This will include all paper sizes that are registered for either all games or for the particular game associated with this deck in its settings (if any).
        Returns:
        a set of appropriate paper sizes for this deck
        See Also:
        setPaperProperties(ca.cgjennings.apps.arkham.deck.PaperProperties)
      • getPrinterPaperSizes

        public java.util.Set<PaperProperties> getPrinterPaperSizes()
        Returns a set of printer paper sizes that are appropriate for this deck at the current time. This set will include all physical paper sizes that are registered for either all games or for the particular game associated with this deck in its settings (if any).
        Returns:
        a set of appropriate physical paper sizes for this deck
        See Also:
        setPrinterPaperProperties(ca.cgjennings.apps.arkham.deck.PaperProperties)
      • isPaperSplitting

        public boolean isPaperSplitting()
        Returns whether paper splitting is enabled.
        Returns:
        true if tiling is enabled
        See Also:
        setPaperSplitting(boolean)
      • getSplitBorder

        public float getSplitBorder()
        Returns the size of the border that will be drawn around virtual pages when page splitting is enabled.
        Returns:
        the border size, in points
        See Also:
        setSplitBorder(float)
      • setSplitBorder

        public void setSplitBorder​(float splitBorder)
        Sets the size of the border that will be drawn round virtual pages, or 0 for no border.
        Parameters:
        splitBorder - the border size, or 0
        See Also:
        getSplitBorder(), setPaperSplitting(boolean)
      • getSplitBorderColor

        public java.awt.Color getSplitBorderColor()
        Returns the colour of the border that is drawn around virtual pages.
        Returns:
        the split border colour
        See Also:
        setSplitBorderColor(java.awt.Color)
      • setSplitBorderColor

        public void setSplitBorderColor​(java.awt.Color borderColor)
        Sets the colour of the border that is drawn around virtual pages.
        Parameters:
        borderColor - the split border colour; null is treated as black
        See Also:
        getSplitBorderColor(), setPaperSplitting(boolean)
      • 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
      • applyFinishStyleToItems

        public void applyFinishStyleToItems()
        Applies the current deck default finish options to all compatible items in the deck.
      • getComment

        public java.lang.String getComment()
        Description copied from interface: GameComponent
        Returns the design rationale comments associated with this component. If there are no comments, it should return an empty string.
        Specified by:
        getComment in interface GameComponent
        Returns:
        design comments supplied by the user of the component
      • setComment

        public void setComment​(java.lang.String comment)
        Sets the design rationale comment text associated with this deck.
        Parameters:
        comment - the new comment to set; null is treated as an empty string
      • getDefaultStyleApplicator

        public StyleApplicator getDefaultStyleApplicator()
        Returns the default item style applicator that will be used to apply a style to newly added deck items. The default style applicator for a deck is determined by the game associated with the deck.
        Returns:
        an applicator used to set the default style for new objects
      • getSettings

        public Settings getSettings()
        Description copied from interface: GameComponent
        Returns a Settings instance that will return this component's private settings. A component's private settings are saved along with the component when it is written to a file. This can be used to override the default settings for component (which are determined by the the shared game settings for the game associated with the component) as a way to "hack" existing component designs. It can also be used by the component itself to store arbitrary information. DIY components generally use the component's private settings to store the current user-configurable state of the component.

        Note that setting the key with the name Game.GAME_SETTING_KEY ("game") will change the parent scope of the private settings to the relevant game's settings for that game whose code matches the new value. (The initial value of this key is normally set on the component's half using the game code specified in the component's class map entry.)

        Specified by:
        getSettings in interface GameComponent
        Returns:
        the private settings that can be used to override settings for this component
      • isDeckLayoutSupported

        public static boolean isDeckLayoutSupported​(java.io.File f)
        Returns true if a given file represents a game component that can be placed in a deck. For recent file format versions, this can be determined without fully opening the file by examining its metadata. For older files, the component must first be read in. If for any reason the value cannot be read from the file, false is returned.
        Returns:
        returns true if the game component in the specified file can be placed in a deck
        See Also:
        GameComponent.isDeckLayoutSupported()
      • coreCheck

        public void coreCheck()
        Checks if all required libraries and extensions are installed. If a required library is not install This method is called when the component is read from a file, and possibly at other times

        This can safely be implemented as an empty method. However, implementing it correctly improves the user experience since they can be notified of which plug-ins they need to install to correctly use the component. In the case of a required but not installed library, the library can actually be downloaded and installed on demand and the component can then be successfully opened.

        For decks, the cores private setting is checked; if it it exists, its value is passed to validateCoreComponents.

        Specified by:
        coreCheck in interface GameComponent
        See Also:
        CoreComponents.validateCoreComponents(java.lang.Object)
      • convertFrom

        public void convertFrom​(ConversionSession session)
        Description copied from interface: GameComponent
        Called on a component that is being converted into another component type. Based on the conversion strategy, the old component may modify the new component directly, or modify the conversion context, or do nothing. This method is called before calling #convertTo(GameComponent, ConversionContext) on the target, and before any automatic conversion steps.
        Specified by:
        convertFrom in interface GameComponent
      • convertTo

        public void convertTo​(ConversionSession session)
        Description copied from interface: GameComponent
        Called on the replacement component when converting a component to another component type. Based on the conversion strategy, the new component may modify itself directly, or modify the conversion context, or do nothing. This method is called after calling #convertFrom(GameComponent, ConversionContext) on the source, but before any automatic conversion steps.
        Specified by:
        convertTo in interface GameComponent