Interface PageItem

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  PageItem.SnapClass
      An enumeration of the general classes of items used to determine how an item will behave when snapped and what it can snap against.
      static class  PageItem.SnapTarget
      An enumeration of the algorithms used to determine the position of an item when it is snapped against another item.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ICON_SIZE  
      static int ORIENT_MIRROR_TURN_LEFT
      The orientation of flippable cards that are turned 90 degrees counter-clockwise and mirror imaged.
      static int ORIENT_MIRROR_TURN_RIGHT
      The orientation of flippable cards that are turned 90 degrees clockwise and mirror imaged.
      static int ORIENT_MIRROR_UPRIGHT
      The orientation of flippable cards that are mirror imaged.
      static int ORIENT_MIRROR_UPSIDEDOWN
      The orientation of flippable cards that are turned 180 and mirror imaged.
      static int ORIENT_TURN_LEFT
      The orientation of flippable cards that are turned 90 degrees counter-clockwise.
      static int ORIENT_TURN_RIGHT
      The orientation of flippable cards that are turned 90 degrees clockwise.
      static int ORIENT_UPRIGHT
      The orientation of flippable cards that are not turned or mirrored.
      static int ORIENT_UPSIDEDOWN
      The orientation of flippable cards that are turned 180 degrees.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      PageItem clone()
      Returns a new page item, using this item as a template.
      void customizePopupMenu​(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)
      Allows a page item the opportunity to customize the popup menu before it is displayed.
      double getBleedMargin()
      Returns the bleed margin used for any automatic crop marks, in points.
      java.util.EnumSet<PageItem.SnapClass> getClassesSnappedTo()
      Get the set of classes this card snaps against.
      java.lang.String getClientProperty​(java.lang.String propertyName)
      Returns the value of a client property of this page item, or null if the property is not defined.
      DragHandle[] getDragHandles()
      Returns an array of the custom DragHandles for this item.
      double[] getFoldMarks()
      Return an array of the relative positions and directions of extra fold marks for this item.
      Group getGroup()
      Returns the Group that this item belongs to, or null.
      double getHeight()
      Return the height of this item, in points.
      java.awt.geom.Point2D getLocation()
      Returns the location of this item as a Point2D.
      java.lang.String getName()
      Return the user-friendly short name of this item.
      int getOrientation()
      Return an the item's current orientation.
      java.awt.Shape getOutline()
      Return a Shape that corresponds to the outline of this item.
      Page getPage()
      Return the page that owns this item, or null if it has no parent.
      java.awt.geom.Rectangle2D.Double getRectangle()
      Return a rectangle of the bounds of this item.
      PageItem.SnapClass getSnapClass()
      Get the class this item counts as for snapping.
      PageItem.SnapTarget getSnapTarget()
      Get the snap target rule for this item.
      javax.swing.Icon getThumbnailIcon()
      Returns a small representative icon for this item.
      double getWidth()
      Return the width of this item, in points.
      double getX()
      Returns the current x-position of this card.
      double getY()
      Returns the current y-position of this card.
      boolean hasExteriorHandles()
      Returns true if this item has one or more drag handles that may lie outside of the item's bounding box.
      boolean hitTest​(java.awt.geom.Point2D point)
      Returns true if point is inside the visible bounds of this object.
      boolean isBleedMarginMarked()
      Returns true if this item should have crop marks added to it.
      boolean isHorizontal()
      Returns true if this is in a horizontal orientation (turned 90 degrees from normal).
      boolean isMirrored()
      Returns true if this item is mirror-imaged.
      boolean isSelectionLocked()
      Returns true if this item is locked against selection.
      boolean isTurned0DegreesFrom​(PageItem rhs)
      Returns true if this item has the same orientation rotation as another item.
      boolean isTurned180DegreesFrom​(PageItem rhs)
      Returns true if this item's orientation is turned 180 degrees relative to another item.
      boolean isTurned90DegreesFrom​(PageItem rhs)
      Returns true if this item's orientation is turned 90 degrees relative to another item.
      boolean isVertical()
      Returns true if card is in a vertical orientation.
      void paint​(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)
      Paint this item at its current location.
      void prepareToPaint​(RenderTarget target, double renderResolutionHint)
      Update any cached representations needed to paint this item at the specified settings.
      void putClientProperty​(java.lang.String propertyName, java.lang.String value)
      Sets a client property on this page item.
      void setClassesSnappedTo​(java.util.EnumSet<PageItem.SnapClass> snapClass)
      Set the set of classes this card snaps against.
      void setGroup​(Group g)
      Sets the Group for this item.
      void setLocation​(double x, double y)
      Set the location of this item.
      void setLocation​(java.awt.geom.Point2D loc)
      Set the location of this item.
      void setPage​(Page parent)
      Set the page which is the parent of this card, or null to clear its parent.
      void setSelectionLocked​(boolean lock)
      Set the state of the item's selection lock.
      void setSnapClass​(PageItem.SnapClass snapClass)
      Set the class this item counts as for snapping.
      void setSnapTarget​(PageItem.SnapTarget target)
      Set the snap target rule for this item.
      void setX​(double x)
      Set the x-location of this item.
      void setY​(double y)
      Set the y-location of this item.
    • Field Detail

      • ORIENT_UPRIGHT

        static final int ORIENT_UPRIGHT
        The orientation of flippable cards that are not turned or mirrored.
        See Also:
        Constant Field Values
      • ORIENT_TURN_LEFT

        static final int ORIENT_TURN_LEFT
        The orientation of flippable cards that are turned 90 degrees counter-clockwise.
        See Also:
        Constant Field Values
      • ORIENT_UPSIDEDOWN

        static final int ORIENT_UPSIDEDOWN
        The orientation of flippable cards that are turned 180 degrees.
        See Also:
        Constant Field Values
      • ORIENT_TURN_RIGHT

        static final int ORIENT_TURN_RIGHT
        The orientation of flippable cards that are turned 90 degrees clockwise.
        See Also:
        Constant Field Values
      • ORIENT_MIRROR_UPRIGHT

        static final int ORIENT_MIRROR_UPRIGHT
        The orientation of flippable cards that are mirror imaged.
        See Also:
        Constant Field Values
      • ORIENT_MIRROR_TURN_LEFT

        static final int ORIENT_MIRROR_TURN_LEFT
        The orientation of flippable cards that are turned 90 degrees counter-clockwise and mirror imaged.
        See Also:
        Constant Field Values
      • ORIENT_MIRROR_UPSIDEDOWN

        static final int ORIENT_MIRROR_UPSIDEDOWN
        The orientation of flippable cards that are turned 180 and mirror imaged.
        See Also:
        Constant Field Values
      • ORIENT_MIRROR_TURN_RIGHT

        static final int ORIENT_MIRROR_TURN_RIGHT
        The orientation of flippable cards that are turned 90 degrees clockwise and mirror imaged.
        See Also:
        Constant Field Values
    • Method Detail

      • clone

        PageItem clone()
        Returns a new page item, using this item as a template. The new item should generally be a deep copy, not sharing any objects with the original unless those objects are immutable. The deck editor absolutely relies on this method being implemented correctly! (For example, drag-and-drop and clipboard operations use clones to create copies of existing items.)
        Returns:
        a new copy of this page item
      • getFoldMarks

        double[] getFoldMarks()
        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.

        Returns:
        an array of fold mark data in the format described above, or null if there are no extra fold marks
      • getWidth

        double getWidth()
        Return the width of this item, in points.
        Returns:
        the item's width
      • getHeight

        double getHeight()
        Return the height of this item, in points.
        Returns:
        the item's height
      • getName

        java.lang.String getName()
        Return the user-friendly short name of this item.
        Returns:
        a name that describes the card or its general kind
      • getOrientation

        int getOrientation()
        Return an the item's current orientation. If the item does not implement FlippablePageItem, it should always return ORIENT_UPRIGHT.
        Returns:
        the item's orientation value
      • getPage

        Page getPage()
        Return the page that owns this item, or null if it has no parent.
        Returns:
        the page that this item is on
      • getRectangle

        java.awt.geom.Rectangle2D.Double getRectangle()
        Return a rectangle of the bounds of this item.
        Returns:
        a bounding rectangle for the item
      • getOutline

        java.awt.Shape getOutline()
        Return a Shape that corresponds to the outline of this item. In the simplest case, this can return the same result as getRectangle(). If precise geometry is available for the item, then this should return a more accurate bounding shape.
        Returns:
        the outline of this object
      • getDragHandles

        DragHandle[] getDragHandles()
        Returns an array of the custom DragHandles for this item. If the item has no handles, returns null.
        Returns:
        an array of drag handles for manipulating the object
      • getSnapClass

        PageItem.SnapClass getSnapClass()
        Get the class this item counts as for snapping.
        Returns:
        the snap class of this item
      • setSnapClass

        void setSnapClass​(PageItem.SnapClass snapClass)
        Set the class this item counts as for snapping.
        Parameters:
        snapClass - the new snap class for this item
      • getClassesSnappedTo

        java.util.EnumSet<PageItem.SnapClass> getClassesSnappedTo()
        Get the set of classes this card snaps against. The item will only snap to the kinds of objects that are included in this class.
        Returns:
        the snap classes that determine the objects that this item will snap against
      • setClassesSnappedTo

        void setClassesSnappedTo​(java.util.EnumSet<PageItem.SnapClass> snapClass)
        Set the set of classes this card snaps against.
        Parameters:
        snapClass - the snap classes that determine the objects that this item will snap against
      • getSnapTarget

        PageItem.SnapTarget getSnapTarget()
        Get the snap target rule for this item.
        Returns:
        the rule describing how this object snaps to other objects
      • setSnapTarget

        void setSnapTarget​(PageItem.SnapTarget target)
        Set the snap target rule for this item.
        Parameters:
        target - the rule describing how this object snaps to other objects
      • getThumbnailIcon

        javax.swing.Icon getThumbnailIcon()
        Returns a small representative icon for this item. The icon should be ICON_SIZE pixels wide and high.
      • getX

        double getX()
        Returns the current x-position of this card.
      • getY

        double getY()
        Returns the current y-position of this card.
      • isBleedMarginMarked

        boolean isBleedMarginMarked()
        Returns true if this item should have crop marks added to it. The crop marks will be placed getBleedMargin() points from the ends of each edge.
      • getBleedMargin

        double getBleedMargin()
        Returns the bleed margin used for any automatic crop marks, in points.
        Returns:
        the bleed margin for this item
      • hitTest

        boolean hitTest​(java.awt.geom.Point2D point)
        Returns true if point is inside the visible bounds of this object.
        Parameters:
        point - a point in document coordinates (points from the upper-left corner of the page)
        Returns:
        true if the point lies inside the bounds of the object
      • isHorizontal

        boolean isHorizontal()
        Returns true if this is in a horizontal orientation (turned 90 degrees from normal). If this is not a FlippablePageItem, it must return false.
      • isVertical

        boolean isVertical()
        Returns true if card is in a vertical orientation. If this is not a FlippablePageItem, it must return true.
      • isMirrored

        boolean isMirrored()
        Returns true if this item is mirror-imaged. If this is not a FlippablePageItem, it must return false.
      • isTurned0DegreesFrom

        boolean isTurned0DegreesFrom​(PageItem rhs)
        Returns true if this item has the same orientation rotation as another item.
      • isTurned180DegreesFrom

        boolean isTurned180DegreesFrom​(PageItem rhs)
        Returns true if this item's orientation is turned 180 degrees relative to another item.
      • isTurned90DegreesFrom

        boolean isTurned90DegreesFrom​(PageItem rhs)
        Returns true if this item's orientation is turned 90 degrees relative to another item.
      • paint

        void paint​(java.awt.Graphics2D g,
                   RenderTarget target,
                   double renderResolutionHint)
        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.
        Parameters:
        g - the graphics context to paint to
        target - the type of destination being drawn to
        renderResolutionHint - a source resolution hint
      • setPage

        void setPage​(Page parent)
        Set the page which is the parent of this card, or null to clear its parent. The Page class will set the parent automatically when a card is added or removed from it.
      • setX

        void setX​(double x)
        Set the x-location of this item.
        Parameters:
        x - the new x-location
      • setY

        void setY​(double y)
        Set the y-location of this item.
        Parameters:
        y - the new y-location
      • setLocation

        void setLocation​(double x,
                         double y)
        Set the location of this item.
        Parameters:
        x - the new x-location
        y - the new y-location
      • setLocation

        void setLocation​(java.awt.geom.Point2D loc)
        Set the location of this item.
        Parameters:
        loc - the new location
      • getLocation

        java.awt.geom.Point2D getLocation()
        Returns the location of this item as a Point2D.
        Returns:
        the location of this item on the page
      • setSelectionLocked

        void setSelectionLocked​(boolean lock)
        Set the state of the item's selection lock. Locked items cannot be selected or dragged.
        Parameters:
        lock - if true, prevent selecting or moving the item
      • isSelectionLocked

        boolean isSelectionLocked()
        Returns true if this item is locked against selection.
        Returns:
        true if the object is locked
      • customizePopupMenu

        void customizePopupMenu​(javax.swing.JPopupMenu menu,
                                PageItem[] selection,
                                boolean isSelectionFocus)
        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.
        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
      • getGroup

        Group getGroup()
        Returns the Group that this item belongs to, or null.
        Returns:
        the group the object is in, or null if it isn't in a group
      • hasExteriorHandles

        boolean hasExteriorHandles()
        Returns true if this item has one or more drag handles that may lie outside of the item's bounding box. The editor normally only tests handles that lie within the bounding box to see if the user has pointed at them; if this method returns true then the item's handles are always tested.
        Returns:
        true if some handles may be outside the bounding box
      • putClientProperty

        void putClientProperty​(java.lang.String propertyName,
                               java.lang.String value)
        Sets a client property on this page item. Client properties can be used by plug-ins to tag page items with plug-in specific data. Client properties are saved as part a deck save file. To delete a client property, use this method to set its value to null.
        Parameters:
        propertyName - the property name
        value - the value to associate with the property
        Throws:
        java.lang.NullPointerException - if the property name is null
      • getClientProperty

        java.lang.String getClientProperty​(java.lang.String propertyName)
        Returns the value of a client property of this page item, or null if the property is not defined.
        Parameters:
        propertyName - the property name
        Returns:
        the value associated with the property, or null
        Throws:
        java.lang.NullPointerException - if the property name is null