Class PageView

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

    public final class PageView
    extends javax.swing.JComponent
    A view of a page of cards that forms part of a deck.
    Author:
    Chris Jennings
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.awt.Color ACTIVE_HANDLE  
      static java.awt.Color BORDER  
      static java.awt.Color CROP  
      static boolean DEBUG_DRAW
      If true, feedback about view performance will be printed at the top of the view.
      static java.awt.Color GRID  
      static java.awt.Color GRID_OUTLINE  
      static double HIGH_DPI  
      static java.awt.Color INACTIVE_HANDLE  
      static double LOW_DPI  
      static java.awt.Color MARGIN  
      static double MEDIUM_DPI  
      static java.awt.Color PAGE  
      static java.lang.String PAGE_VIEW_ACTION_KEY
      Common deck commands use this property key to determine which key they should be bound to in the page view.
      static java.awt.Color SELECTION  
      static java.awt.Color SELECTION_TAIL  
      static java.awt.Color SILHOUETTE  
      static java.awt.Color SILHOUETTE_OUTLINE  
      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      PageView()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addToSelection​(PageItem card)  
      void adjustZoomBySteps​(int ticks)
      Adjusts the zoom level of the view by a number of "ticks", as if the user had rotated a mouse wheel the specified number of steps.
      void centerOver​(double x, double y)  
      protected void clearOptionText()  
      java.awt.Point documentToView​(double x, double y)
      Returns the position within the view component for a given point in the page coordinates.
      java.awt.Rectangle documentToView​(java.awt.geom.Rectangle2D documentRectangle)
      Returns a rectangle in view coordinates that covers a rectangle in document coordinates.
      void ensureVisible​(java.awt.geom.Rectangle2D rectInDocumentSpace)
      Scrolls the view, if necessary, to make the specified rectangle visible.
      javax.swing.JLabel getOptionLabel()  
      Page getPage()  
      java.awt.geom.Point2D getViewLocation()  
      double getViewX()  
      double getViewY()  
      double getZoom()
      Returns the zoom factor of the view; this is a positive value where 1 represents 100% zoom.
      boolean isEditable()  
      boolean isSelected​(PageItem card)  
      void pageChangeEvent()  
      protected void paintComponent​(java.awt.Graphics g1)  
      void panView​(double dx, double dy)  
      void removeFromSelection​(PageItem card)  
      void repaint​(PageItem item)
      Repaints the part of the view covered by an item.
      void repaint​(java.awt.geom.Rectangle2D.Double rectangleInDocumentSpace)
      Repaints the area of the view that is covered by a rectangle in the document coordinate system.
      protected void setDefaultOptionText()  
      void setEditable​(boolean editable)  
      void setOptionLabel​(javax.swing.JLabel label)  
      protected void setOptionText​(java.lang.String s)  
      void setPage​(Page page)  
      void setScale​(double newScale)
      Changes the zoom factor to the specified level.
      void setSelection​(PageItem card)  
      void setViewLocation​(double x, double y)  
      protected void updateCursor​(java.awt.Point mousepos)  
      java.awt.geom.Point2D.Double viewToDocument​(int x, int y)
      Returns the position within the page for a given point in the view component.
      java.awt.geom.Rectangle2D.Double viewToDocument​(java.awt.Rectangle viewRectangle)
      Returns a rectangle in document coordinates that covers the same area of the document space as a rectangle in view coordinates covers in the view.
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEBUG_DRAW

        public static boolean DEBUG_DRAW
        If true, feedback about view performance will be printed at the top of the view. This is initially true only if the release type is DEVELOPMENT, but it can be changed at any time.
        See Also:
        StrangeEons.getReleaseType()
      • PAGE_VIEW_ACTION_KEY

        public static final java.lang.String PAGE_VIEW_ACTION_KEY
        Common deck commands use this property key to determine which key they should be bound to in the page view. They are commonly bound to simple keys that are unsuitable for use as global accelerators, like F for Move to Front.
        See Also:
        Constant Field Values
      • PAGE

        public static final java.awt.Color PAGE
      • BORDER

        public static final java.awt.Color BORDER
      • MARGIN

        public static final java.awt.Color MARGIN
      • GRID

        public static final java.awt.Color GRID
      • CROP

        public static final java.awt.Color CROP
      • INACTIVE_HANDLE

        public static final java.awt.Color INACTIVE_HANDLE
      • ACTIVE_HANDLE

        public static final java.awt.Color ACTIVE_HANDLE
      • GRID_OUTLINE

        public static final java.awt.Color GRID_OUTLINE
      • SELECTION

        public static final java.awt.Color SELECTION
      • SELECTION_TAIL

        public static final java.awt.Color SELECTION_TAIL
      • SILHOUETTE

        public static final java.awt.Color SILHOUETTE
      • SILHOUETTE_OUTLINE

        public static final java.awt.Color SILHOUETTE_OUTLINE
    • Constructor Detail

      • PageView

        public PageView()
    • Method Detail

      • updateCursor

        protected void updateCursor​(java.awt.Point mousepos)
      • repaint

        public void repaint​(PageItem item)
        Repaints the part of the view covered by an item.
        Parameters:
        item - the item that needs to be updated
      • repaint

        public void repaint​(java.awt.geom.Rectangle2D.Double rectangleInDocumentSpace)
        Repaints the area of the view that is covered by a rectangle in the document coordinate system. The area will be converted to the the view coordinate system, and if part of the rectangle is currently visible in the view then that part of the view will be repainted.
        Parameters:
        rectangleInDocumentSpace - the area of the document that needs repainting
      • paintComponent

        protected void paintComponent​(java.awt.Graphics g1)
        Overrides:
        paintComponent in class javax.swing.JComponent
      • addToSelection

        public void addToSelection​(PageItem card)
      • removeFromSelection

        public void removeFromSelection​(PageItem card)
      • setSelection

        public void setSelection​(PageItem card)
      • isSelected

        public boolean isSelected​(PageItem card)
      • adjustZoomBySteps

        public void adjustZoomBySteps​(int ticks)
        Adjusts the zoom level of the view by a number of "ticks", as if the user had rotated a mouse wheel the specified number of steps.
        Parameters:
        ticks - the number of ticks to adjust the zoom level by
      • getZoom

        public double getZoom()
        Returns the zoom factor of the view; this is a positive value where 1 represents 100% zoom.
        Returns:
        the scaling factor
      • setScale

        public void setScale​(double newScale)
        Changes the zoom factor to the specified level. If the zoom level is out of range, it will be clamped to the nearest acceptable value.
        Parameters:
        newScale - the new scale factor
      • centerOver

        public void centerOver​(double x,
                               double y)
      • setViewLocation

        public void setViewLocation​(double x,
                                    double y)
      • getViewLocation

        public java.awt.geom.Point2D getViewLocation()
      • getViewX

        public double getViewX()
      • getViewY

        public double getViewY()
      • panView

        public void panView​(double dx,
                            double dy)
      • getPage

        public Page getPage()
      • setPage

        public void setPage​(Page page)
      • ensureVisible

        public void ensureVisible​(java.awt.geom.Rectangle2D rectInDocumentSpace)
        Scrolls the view, if necessary, to make the specified rectangle visible. There is a limit to how much the view can be scrolled, as the view ensures that some edge of the page is always visible. Therefore, it is possible that the object will still not be visible after this is called.
        Parameters:
        rectInDocumentSpace - the rectangle to make visible, in document space (points from the upper-left corner of the page)
      • viewToDocument

        public java.awt.geom.Point2D.Double viewToDocument​(int x,
                                                           int y)
        Returns the position within the page for a given point in the view component.
        Parameters:
        x - the x-offset from the left edge of the component
        y - the y-offset from the top of the component
        Returns:
        the location of the point (x,y) in the document space
      • viewToDocument

        public java.awt.geom.Rectangle2D.Double viewToDocument​(java.awt.Rectangle viewRectangle)
        Returns a rectangle in document coordinates that covers the same area of the document space as a rectangle in view coordinates covers in the view.
        Parameters:
        viewRectangle - a rectangle in view coordinates
        Returns:
        the rectangle of document space covered by the view rectangle
      • documentToView

        public java.awt.Point documentToView​(double x,
                                             double y)
        Returns the position within the view component for a given point in the page coordinates.
        Parameters:
        x - the x-offset from the left edge of the page
        y - the y-offset from the top of the page
        Returns:
        the location of the point (x,y) in the view
      • documentToView

        public java.awt.Rectangle documentToView​(java.awt.geom.Rectangle2D documentRectangle)
        Returns a rectangle in view coordinates that covers a rectangle in document coordinates. Note that the returned rectangle is not restricted the visible part of the view.
        Parameters:
        documentRectangle - a rectangle in document space
        Returns:
        the rectangle of view space covered by the document rectangle
      • pageChangeEvent

        public void pageChangeEvent()
      • setOptionText

        protected void setOptionText​(java.lang.String s)
      • clearOptionText

        protected void clearOptionText()
      • setDefaultOptionText

        protected void setDefaultOptionText()
      • setOptionLabel

        public void setOptionLabel​(javax.swing.JLabel label)
      • getOptionLabel

        public javax.swing.JLabel getOptionLabel()
      • isEditable

        public boolean isEditable()
      • setEditable

        public void setEditable​(boolean editable)