Class RMViewer

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.Scrollable
    Direct Known Subclasses:
    Gallery.GViewer, RMEditor, RMTrackballControl

    public class RMViewer
    extends javax.swing.JComponent
    implements java.beans.PropertyChangeListener, javax.swing.Scrollable
    The RMViewer class is a JComponent subclass that can be used in Swing applications to display and/or print an RMDocument.

    You might use it like this to simply print a document:

       new RMViewer(aDocument).print();
     

    Or you might want to allocate one and add it to a Swing component hierarchy:

       RMViewer viewer = new RMViewer(); viewer.setContent(new RMDocument(aSource));
       myFrame.getContentPane().add(new JScrollPane(viewer));
     
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RMViewer.PhantomPane
      A phantom component that resides in the viewer, that Swing JComponentShapes can attach to, to draw.
      protected class  RMViewer.RMVPrintable
      This inner class simply paints a requested page to a given Graphics object.
      static class  RMViewer.ZoomMode  
      • 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.lang.String Content_Prop  
      static int PRINT_MODE_RASTER  
      static int PRINT_MODE_VECTOR
      printingMode and printingDPI let us enhance RMViewer's builtin printing.
      static java.lang.String ZOOM_CHANGE  
      • 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
      RMViewer()
      Creates a new RMViewer with an empty document in it.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RMPoint convertPointFromShape​(RMPoint aPoint, RMShape aShape)
      Returns a point converted from the coordinate space of the given shape to viewer coords.
      RMPoint convertPointToShape​(java.awt.geom.Point2D aPoint, RMShape aShape)
      Returns a point converted from viewer coords to the coordinate space of the given shape.
      RMRect convertRectFromShape​(RMRect aRect, RMShape aShape)
      Returns a rect converted from the coordinate space of the given shape to viewer coords.
      RMRect convertRectToShape​(RMRect aRect, RMShape aShape)
      Returns a rect converted from viewer coords to the coordinate space of the given shape.
      protected RMViewerInputAdapter createInputAdapter()
      Creates a default input adapter.
      protected RMShapePainterJ2D createShapePainter​(java.awt.Graphics2D aGr)
      Creates the object that is actually responsible for paining shapes in the viewer.
      protected RMViewerShape createViewerShape()
      Creates the viewer shape.
      void docShapeRepaint​(RMShape aShape)
      Doc listener method - called before a shape makes a visual change.
      void firstPage()
      changes the selected page to the first page if the pageLayout is not of a continuous type.
      protected void flushShapeRepaints()
      This method repaints the total bounds of shapes that have previously been registered by shapeNeedsRepaint.
      java.awt.print.Book getBook​(int orientation, java.awt.print.Paper paper)
      Returns a java.awt.print.Book, suitable for AWT printing.
      RMParentShape getContent()
      Returns the root shape that is the content of this viewer.
      int getContentX()
      Returns the content shape's X location in viewer.
      int getContentY()
      Returns the content shape's Y location in viewer.
      int getCopies()  
      RMDocument getDocument()
      Returns the RMDocument associated with this viewer.
      RMRect getDocumentBounds()
      Returns the bounds of the viewer document.
      boolean getDrawsBackground()
      Returns whether or not the gutter, page background & drop shadow get drawn.
      RMShape getHoverShape​(java.lang.String aString)
      Returns a hover shape for given something.
      RMViewerInputAdapter getInputAdapter()
      Returns the input adapter for the viewer (handles mouse and keyboard input).
      float getlastZoomFactor()  
      RMRect getPageBounds()
      Returns the bounds of the viewer document's selected page.
      int getPageCount()
      Returns the page count.
      int getPageOrientation()  
      boolean getPaintFrameRate()
      Returns whether we paint frame rate.
      RMViewer.PhantomPane getPhantomPane()
      Returns the phantom pane (creating, if necessary).
      java.awt.Dimension getPreferredScrollableViewportSize()  
      java.awt.Dimension getPreferredSize()
      Returns the optimal size of the viewer.
      protected java.awt.Dimension getPrefSize()
      Returns the preferred size of the viewer ignoring ZoomFactor.
      protected java.awt.Dimension getPrefSize​(float aScale)
      Returns the preferred size of the viewer scaled to a given zoom factor.
      int getPrintingDPI()  
      int getPrintingMode()  
      RMRect getRepaintBoundsForShape​(RMShape aShape)
      Returns the bounds for a given shape in the viewer.
      int getScrollableBlockIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)  
      boolean getScrollableTracksViewportHeight()  
      boolean getScrollableTracksViewportWidth()
      Scrollable methods.
      int getScrollableUnitIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)  
      RMParentShape getSelectedPage()
      Returns the currently selected page shape.
      int getSelectedPageIndex()
      Returns the index of the current visible document page.
      RMShape getShape​(java.lang.String aName)
      Returns the document shape for given name.
      RMShape getShapeAtPoint​(java.awt.geom.Point2D aPoint, boolean goDeep)
      Returns the first shape hit by the given point.
      RMShapePainter getShapePainter​(java.awt.Graphics2D aGr)
      Returns the object that is actually responsible for paining shapes in the viewer.
      boolean getShapeRepaintEnabled()
      Returns whether changes to shapes cause repaints.
      boolean getShown()
      Returns whether viewer was shown.
      WebURL getSourceURL()
      Returns the source URL.
      java.awt.geom.AffineTransform getTransformFromShape​(RMShape aShape)
      Returns the transform from given shape to viewer.
      RMUndoer getUndoer()
      Returns the undoer associated with the viewer's document.
      RMViewerShape getViewerShape()
      Returns the viewer shape.
      float getZoomFactor()
      Returns the viewer's zoom factor (1 by default).
      float getZoomFactor​(RMViewer.ZoomMode aMode)
      Returns the zoom factor for the given mode at the current viewer size.
      java.awt.Rectangle getZoomFocusRect()
      Returns zoom focus rect (just the visible rect by default, but overriden by editor to return selected shapes rect).
      RMViewer.ZoomMode getZoomMode()
      Returns the ZoomMode (ZoomToFit, ZoomIfNeeded, ZoomToFactor).
      float getZoomToActualSizeFactor()
      Returns the zoom factor to view the document at actual size taking into account the current screen resolution.
      boolean isCollate()  
      boolean isEditing()
      Returns whether viewer is really doing editing.
      boolean isPreview()
      Returns whether editor is preview (or viewer) mode.
      boolean isPrintBothSides()  
      boolean isUseAutoLandscape()  
      boolean isZoomToFactor()
      Returns whether viewer is set to ZoomToFactor.
      void lastPage()
      changes the selected page to the last page if the pageLayout is not of a continuous type.
      protected void mouseDragged​(java.awt.event.MouseEvent anEvent)
      Handle mouse dragged event.
      protected void mouseMoved​(java.awt.event.MouseEvent anEvent)
      Handle mouse moved event.
      protected void mousePressed​(java.awt.event.MouseEvent anEvent)
      Handle mouse pressed event.
      protected void mouseReleased​(java.awt.event.MouseEvent anEvent)
      Handle mouse released event.
      void pageBack()
      Selects the previous page based on the page layout.
      void pageForward()
      Selects the next page based on the page layout.
      protected void paintBackground​(java.awt.Graphics2D aGrfx)
      Paints the background.
      void paintComponent​(java.awt.Graphics aGraphics)
      Overrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.
      void performActionURLClick​(java.lang.String aURL)
      Viewer callback - called when shape with URL is clicked (opens URL).
      void play()
      Starts any animation viewer might have.
      void print()
      This method tells the RMViewer to print by running the print dialog (configured to the default printer).
      void print​(java.lang.String aPrinterName, boolean runPanel)
      This method tells the RMViewer to print to the printer with the given printer name (use null for default printer).
      protected void processKeyEvent​(java.awt.event.KeyEvent anEvent)
      Handle key events.
      protected void processMouseEvent​(java.awt.event.MouseEvent anEvent)
      Handle mouse events.
      protected void processMouseMotionEvent​(java.awt.event.MouseEvent anEvent)
      Handle mouse motion events
      protected void processMouseWheelEvent​(java.awt.event.MouseWheelEvent anEvent)
      Handle mouse wheel events.
      void propertyChange​(java.beans.PropertyChangeEvent anEvent)
      PropertyChangeListener method - called by document.
      void repaint​(java.awt.geom.Rectangle2D aRect)
      Requests a repaint for the area represented by the given rect.
      void runZoomPanel()
      Runs a dialog panel to request a percentage zoom (which is then set with setZoomFactor).
      void setBounds​(int x, int y, int w, int h)
      Overrides to update ZoomFactor if dynamic.
      void setCollate​(boolean collate)  
      void setContent​(RMParentShape aShape)
      Sets the root shape that is the content of this viewer.
      void setContent​(java.lang.Object aSource)
      Sets the content from any source.
      void setCopies​(int copies)  
      void setInputAdapter​(RMViewerInputAdapter anInputAdapter)
      Sets the input adapter for the viewer (handles mouse and keyboard input).
      void setPageOrientation​(int pageOrientation)  
      void setPaintFrameRate​(boolean aValue)
      Sets whether we paint frame rate.
      void setPrintBothSides​(boolean printBothSides)  
      void setPrintingDPI​(int printingDPI)  
      void setPrintingMode​(int printingMode)  
      void setSelectedPageIndex​(int anIndex)
      Sets the page of viewer's document that is visible (by index).
      void setShapeRepaintEnabled​(boolean aFlag)
      Sets whether changes to shapes cause repaints.
      protected void setShown​(boolean aValue)
      Sets whether viewer was shown.
      void setUseAutoLandscape​(boolean useAutoLandscape)  
      void setZoomFactor​(float aFactor)
      Sets the viewer's zoom factor (1 for 100%).
      protected void setZoomFactorImpl​(float aFactor)
      Sets the viewer's zoom factor (1 for 100%) and mode.
      void setZoomMode​(RMViewer.ZoomMode aZoomMode)
      Sets the ZoomMode.
      void setZoomToFitFactor()
      Sets the zoom to fit factor, based on the current zoom mode.
      void stop()
      Stops any animation viewer might have.
      boolean undoerHasUndos()
      Returns whether undos exist in the viewer's documents's undoer (convenience).
      void undoerSetUndoTitle​(java.lang.String aTitle)
      Sets the title of the next registered undo in the viewer's documents's undoer (convenience).
      protected void viewerHidden()
      Called when viewer is hidden.
      protected void viewerShown()
      Called when viewer is shown.
      void zoomToggleLast()
      Sets the viewer's zoom to its previous value.
      • 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, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, 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

      • PRINT_MODE_VECTOR

        public static final int PRINT_MODE_VECTOR
        printingMode and printingDPI let us enhance RMViewer's builtin printing.
        Since:
        7.8.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • RMViewer

        public RMViewer()
        Creates a new RMViewer with an empty document in it.
    • Method Detail

      • getViewerShape

        public RMViewerShape getViewerShape()
        Returns the viewer shape.
      • createViewerShape

        protected RMViewerShape createViewerShape()
        Creates the viewer shape.
      • getContent

        public RMParentShape getContent()
        Returns the root shape that is the content of this viewer.
      • setContent

        public void setContent​(RMParentShape aShape)
        Sets the root shape that is the content of this viewer.
      • setContent

        public void setContent​(java.lang.Object aSource)
        Sets the content from any source.
      • getDocument

        @Nullable
        public RMDocument getDocument()
        Returns the RMDocument associated with this viewer.
      • getSourceURL

        public WebURL getSourceURL()
        Returns the source URL.
      • isEditing

        public boolean isEditing()
        Returns whether viewer is really doing editing.
      • isPreview

        public boolean isPreview()
        Returns whether editor is preview (or viewer) mode.
      • getPageCount

        public int getPageCount()
        Returns the page count.
      • getSelectedPage

        public RMParentShape getSelectedPage()
        Returns the currently selected page shape.
      • getSelectedPageIndex

        public int getSelectedPageIndex()
        Returns the index of the current visible document page.
      • setSelectedPageIndex

        public void setSelectedPageIndex​(int anIndex)
        Sets the page of viewer's document that is visible (by index).
      • pageForward

        public void pageForward()
        Selects the next page based on the page layout. This will adjust the increment for page changes based on the number of pages in the view resulting in stepping a view at a time when necessary.
      • pageBack

        public void pageBack()
        Selects the previous page based on the page layout. This will adjust the increment for page changes based on the number of pages in the view resulting in stepping a view at a time when necessary.
      • lastPage

        public void lastPage()
        changes the selected page to the last page if the pageLayout is not of a continuous type.
      • firstPage

        public void firstPage()
        changes the selected page to the first page if the pageLayout is not of a continuous type.
      • play

        public void play()
        Starts any animation viewer might have.
      • stop

        public void stop()
        Stops any animation viewer might have.
      • getShown

        public boolean getShown()
        Returns whether viewer was shown.
      • setShown

        protected void setShown​(boolean aValue)
        Sets whether viewer was shown.
      • viewerShown

        protected void viewerShown()
        Called when viewer is shown.
      • viewerHidden

        protected void viewerHidden()
        Called when viewer is hidden.
      • getDocumentBounds

        public RMRect getDocumentBounds()
        Returns the bounds of the viewer document.
      • getPageBounds

        public RMRect getPageBounds()
        Returns the bounds of the viewer document's selected page.
      • getShapeAtPoint

        public RMShape getShapeAtPoint​(java.awt.geom.Point2D aPoint,
                                       boolean goDeep)
        Returns the first shape hit by the given point.
      • getZoomFactor

        public float getZoomFactor()
        Returns the viewer's zoom factor (1 by default).
      • setZoomFactor

        public void setZoomFactor​(float aFactor)
        Sets the viewer's zoom factor (1 for 100%).
      • setZoomFactorImpl

        protected void setZoomFactorImpl​(float aFactor)
        Sets the viewer's zoom factor (1 for 100%) and mode.
      • getZoomMode

        public RMViewer.ZoomMode getZoomMode()
        Returns the ZoomMode (ZoomToFit, ZoomIfNeeded, ZoomToFactor).
      • setZoomMode

        public void setZoomMode​(RMViewer.ZoomMode aZoomMode)
        Sets the ZoomMode.
      • isZoomToFactor

        public boolean isZoomToFactor()
        Returns whether viewer is set to ZoomToFactor.
      • getlastZoomFactor

        public float getlastZoomFactor()
      • getZoomFactor

        public float getZoomFactor​(RMViewer.ZoomMode aMode)
        Returns the zoom factor for the given mode at the current viewer size.
      • setZoomToFitFactor

        public void setZoomToFitFactor()
        Sets the zoom to fit factor, based on the current zoom mode.
      • getZoomFocusRect

        public java.awt.Rectangle getZoomFocusRect()
        Returns zoom focus rect (just the visible rect by default, but overriden by editor to return selected shapes rect).
      • getZoomToActualSizeFactor

        public float getZoomToActualSizeFactor()
        Returns the zoom factor to view the document at actual size taking into account the current screen resolution.
      • zoomToggleLast

        public void zoomToggleLast()
        Sets the viewer's zoom to its previous value.
      • runZoomPanel

        public void runZoomPanel()
        Runs a dialog panel to request a percentage zoom (which is then set with setZoomFactor).
      • setBounds

        public void setBounds​(int x,
                              int y,
                              int w,
                              int h)
        Overrides to update ZoomFactor if dynamic.
        Overrides:
        setBounds in class java.awt.Component
      • getContentX

        public int getContentX()
        Returns the content shape's X location in viewer.
      • getContentY

        public int getContentY()
        Returns the content shape's Y location in viewer.
      • convertPointFromShape

        public RMPoint convertPointFromShape​(RMPoint aPoint,
                                             RMShape aShape)
        Returns a point converted from the coordinate space of the given shape to viewer coords.
      • convertPointToShape

        public RMPoint convertPointToShape​(java.awt.geom.Point2D aPoint,
                                           RMShape aShape)
        Returns a point converted from viewer coords to the coordinate space of the given shape.
      • convertRectFromShape

        public RMRect convertRectFromShape​(RMRect aRect,
                                           RMShape aShape)
        Returns a rect converted from the coordinate space of the given shape to viewer coords.
      • convertRectToShape

        public RMRect convertRectToShape​(RMRect aRect,
                                         RMShape aShape)
        Returns a rect converted from viewer coords to the coordinate space of the given shape.
      • getTransformFromShape

        public java.awt.geom.AffineTransform getTransformFromShape​(RMShape aShape)
        Returns the transform from given shape to viewer.
      • repaint

        public void repaint​(java.awt.geom.Rectangle2D aRect)
        Requests a repaint for the area represented by the given rect.
      • getShapePainter

        public RMShapePainter getShapePainter​(java.awt.Graphics2D aGr)
        Returns the object that is actually responsible for paining shapes in the viewer.
      • createShapePainter

        protected RMShapePainterJ2D createShapePainter​(java.awt.Graphics2D aGr)
        Creates the object that is actually responsible for paining shapes in the viewer.
      • getDrawsBackground

        public boolean getDrawsBackground()
        Returns whether or not the gutter, page background & drop shadow get drawn.
      • paintComponent

        public void paintComponent​(java.awt.Graphics aGraphics)
        Overrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.
        Overrides:
        paintComponent in class javax.swing.JComponent
      • paintBackground

        protected void paintBackground​(java.awt.Graphics2D aGrfx)
        Paints the background.
      • getInputAdapter

        public RMViewerInputAdapter getInputAdapter()
        Returns the input adapter for the viewer (handles mouse and keyboard input).
      • setInputAdapter

        public void setInputAdapter​(RMViewerInputAdapter anInputAdapter)
        Sets the input adapter for the viewer (handles mouse and keyboard input).
      • createInputAdapter

        protected RMViewerInputAdapter createInputAdapter()
        Creates a default input adapter.
      • processMouseEvent

        protected void processMouseEvent​(java.awt.event.MouseEvent anEvent)
        Handle mouse events.
        Overrides:
        processMouseEvent in class javax.swing.JComponent
      • processMouseMotionEvent

        protected void processMouseMotionEvent​(java.awt.event.MouseEvent anEvent)
        Handle mouse motion events
        Overrides:
        processMouseMotionEvent in class javax.swing.JComponent
      • processMouseWheelEvent

        protected void processMouseWheelEvent​(java.awt.event.MouseWheelEvent anEvent)
        Handle mouse wheel events.
        Overrides:
        processMouseWheelEvent in class java.awt.Component
      • processKeyEvent

        protected void processKeyEvent​(java.awt.event.KeyEvent anEvent)
        Handle key events.
        Overrides:
        processKeyEvent in class javax.swing.JComponent
      • mousePressed

        protected void mousePressed​(java.awt.event.MouseEvent anEvent)
        Handle mouse pressed event.
      • mouseDragged

        protected void mouseDragged​(java.awt.event.MouseEvent anEvent)
        Handle mouse dragged event.
      • mouseReleased

        protected void mouseReleased​(java.awt.event.MouseEvent anEvent)
        Handle mouse released event.
      • mouseMoved

        protected void mouseMoved​(java.awt.event.MouseEvent anEvent)
        Handle mouse moved event.
      • performActionURLClick

        public void performActionURLClick​(@Nonnull
                                          java.lang.String aURL)
        Viewer callback - called when shape with URL is clicked (opens URL).
      • getHoverShape

        public RMShape getHoverShape​(java.lang.String aString)
        Returns a hover shape for given something.
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Returns the optimal size of the viewer.
        Overrides:
        getPreferredSize in class javax.swing.JComponent
      • getPrefSize

        protected java.awt.Dimension getPrefSize()
        Returns the preferred size of the viewer ignoring ZoomFactor.
      • getPrefSize

        protected java.awt.Dimension getPrefSize​(float aScale)
        Returns the preferred size of the viewer scaled to a given zoom factor.
      • getScrollableTracksViewportWidth

        public boolean getScrollableTracksViewportWidth()
        Scrollable methods.
        Specified by:
        getScrollableTracksViewportWidth in interface javax.swing.Scrollable
      • getScrollableTracksViewportHeight

        public boolean getScrollableTracksViewportHeight()
        Specified by:
        getScrollableTracksViewportHeight in interface javax.swing.Scrollable
      • getScrollableBlockIncrement

        public int getScrollableBlockIncrement​(java.awt.Rectangle visibleRect,
                                               int orientation,
                                               int direction)
        Specified by:
        getScrollableBlockIncrement in interface javax.swing.Scrollable
      • getScrollableUnitIncrement

        public int getScrollableUnitIncrement​(java.awt.Rectangle visibleRect,
                                              int orientation,
                                              int direction)
        Specified by:
        getScrollableUnitIncrement in interface javax.swing.Scrollable
      • getPreferredScrollableViewportSize

        public java.awt.Dimension getPreferredScrollableViewportSize()
        Specified by:
        getPreferredScrollableViewportSize in interface javax.swing.Scrollable
      • getUndoer

        public RMUndoer getUndoer()
        Returns the undoer associated with the viewer's document.
      • undoerSetUndoTitle

        public void undoerSetUndoTitle​(java.lang.String aTitle)
        Sets the title of the next registered undo in the viewer's documents's undoer (convenience).
      • undoerHasUndos

        public boolean undoerHasUndos()
        Returns whether undos exist in the viewer's documents's undoer (convenience).
      • getShapeRepaintEnabled

        public boolean getShapeRepaintEnabled()
        Returns whether changes to shapes cause repaints.
      • setShapeRepaintEnabled

        public void setShapeRepaintEnabled​(boolean aFlag)
        Sets whether changes to shapes cause repaints.
      • docShapeRepaint

        public void docShapeRepaint​(RMShape aShape)
        Doc listener method - called before a shape makes a visual change. Provides a mechanism to efficiently repaint the portion of the viewer that currently displays a shape. Registers the area covered by the shape now and at event end, to efficiently repaint shapes in transition as well.
      • flushShapeRepaints

        protected void flushShapeRepaints()
        This method repaints the total bounds of shapes that have previously been registered by shapeNeedsRepaint. This should only be used internally.
      • getRepaintBoundsForShape

        public RMRect getRepaintBoundsForShape​(RMShape aShape)
        Returns the bounds for a given shape in the viewer. Subclasses can override this to account for things like different bounds for selected shapes.
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent anEvent)
        PropertyChangeListener method - called by document.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • getShape

        public RMShape getShape​(java.lang.String aName)
        Returns the document shape for given name.
      • getPhantomPane

        public RMViewer.PhantomPane getPhantomPane()
        Returns the phantom pane (creating, if necessary).
      • getPaintFrameRate

        public boolean getPaintFrameRate()
        Returns whether we paint frame rate.
      • setPaintFrameRate

        public void setPaintFrameRate​(boolean aValue)
        Sets whether we paint frame rate.
      • print

        public void print()
                   throws java.awt.print.PrinterException
        This method tells the RMViewer to print by running the print dialog (configured to the default printer).
        Throws:
        java.awt.print.PrinterException - Thrown when an error that causes the print job to abort occurs.

        Modified in 7.8.0

      • print

        public void print​(java.lang.String aPrinterName,
                          boolean runPanel)
                   throws java.awt.print.PrinterException
        This method tells the RMViewer to print to the printer with the given printer name (use null for default printer). It also offers an option to run the printer dialog.
        Parameters:
        aPrinterName - The name returned by PrintServiceLookup.lookupPrintServices, or null for default printer
        runPanel - True if the print dialog should be shown.
        Throws:
        java.awt.print.PrinterException - Thrown when an error that causes the print job to abort occurs.

        Modified in 7.8.0

      • getPrintingMode

        public int getPrintingMode()
        Since:
        7.8.0
      • setPrintingMode

        public void setPrintingMode​(int printingMode)
        Parameters:
        printingMode - Allowable values are the constants PRINT_MODE_RASTER and PRINT_MODE_VECTOR. Other values will give undefined results.
        Since:
        7.8.0
      • getPrintingDPI

        public int getPrintingDPI()
        Since:
        7.8.0
      • setPrintingDPI

        public void setPrintingDPI​(int printingDPI)
        Parameters:
        printingDPI - Must be a positive integer
        Since:
        7.8.0
      • getCopies

        public int getCopies()
        Since:
        7.8.0
      • setCopies

        public void setCopies​(int copies)
        Parameters:
        copies - Must be a positive integer
        Since:
        7.8.0
      • isUseAutoLandscape

        public boolean isUseAutoLandscape()
        Since:
        7.8.0
      • setUseAutoLandscape

        public void setUseAutoLandscape​(boolean useAutoLandscape)
        Since:
        7.8.0
      • getPageOrientation

        public int getPageOrientation()
        Since:
        7.8.0
      • setPageOrientation

        public void setPageOrientation​(int pageOrientation)
        Since:
        7.8.0
      • isPrintBothSides

        public boolean isPrintBothSides()
        Since:
        7.8.0
      • setPrintBothSides

        public void setPrintBothSides​(boolean printBothSides)
        Since:
        7.8.0
      • isCollate

        public boolean isCollate()
        Since:
        7.8.0
      • setCollate

        public void setCollate​(boolean collate)
        Since:
        7.8.0
      • getBook

        public java.awt.print.Book getBook​(int orientation,
                                           java.awt.print.Paper paper)
        Returns a java.awt.print.Book, suitable for AWT printing.

        Changes in 7.8.0: made the printable used based on printing mode