public class RMViewer
extends javax.swing.JComponent
implements java.beans.PropertyChangeListener, javax.swing.Scrollable
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));
Modifier and Type | Class and 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 |
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and 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 |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
RMViewer()
Creates a new RMViewer with an empty document in it.
|
Modifier and Type | Method and 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(java.lang.Object aSource)
Sets the content from any source.
|
void |
setContent(RMParentShape aShape)
Sets the root shape that is the content of this viewer.
|
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.
|
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, 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
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
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, getPeer, 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, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String ZOOM_CHANGE
public static final int PRINT_MODE_VECTOR
public static final int PRINT_MODE_RASTER
public static final java.lang.String Content_Prop
public RMViewerShape getViewerShape()
protected RMViewerShape createViewerShape()
public RMParentShape getContent()
public void setContent(RMParentShape aShape)
public void setContent(java.lang.Object aSource)
@Nullable public RMDocument getDocument()
public WebURL getSourceURL()
public boolean isEditing()
public boolean isPreview()
public int getPageCount()
public RMParentShape getSelectedPage()
public int getSelectedPageIndex()
public void setSelectedPageIndex(int anIndex)
public void pageForward()
public void pageBack()
public void lastPage()
public void firstPage()
public void play()
public void stop()
public boolean getShown()
protected void setShown(boolean aValue)
protected void viewerShown()
protected void viewerHidden()
public RMRect getDocumentBounds()
public RMRect getPageBounds()
public RMShape getShapeAtPoint(java.awt.geom.Point2D aPoint, boolean goDeep)
public float getZoomFactor()
public void setZoomFactor(float aFactor)
protected void setZoomFactorImpl(float aFactor)
public RMViewer.ZoomMode getZoomMode()
public void setZoomMode(RMViewer.ZoomMode aZoomMode)
public boolean isZoomToFactor()
public float getlastZoomFactor()
public float getZoomFactor(RMViewer.ZoomMode aMode)
public void setZoomToFitFactor()
public java.awt.Rectangle getZoomFocusRect()
public float getZoomToActualSizeFactor()
public void zoomToggleLast()
public void runZoomPanel()
public void setBounds(int x, int y, int w, int h)
setBounds
in class java.awt.Component
public int getContentX()
public int getContentY()
public RMPoint convertPointFromShape(RMPoint aPoint, RMShape aShape)
public RMPoint convertPointToShape(java.awt.geom.Point2D aPoint, RMShape aShape)
public RMRect convertRectFromShape(RMRect aRect, RMShape aShape)
public RMRect convertRectToShape(RMRect aRect, RMShape aShape)
public java.awt.geom.AffineTransform getTransformFromShape(RMShape aShape)
public void repaint(java.awt.geom.Rectangle2D aRect)
public RMShapePainter getShapePainter(java.awt.Graphics2D aGr)
protected RMShapePainterJ2D createShapePainter(java.awt.Graphics2D aGr)
public boolean getDrawsBackground()
public void paintComponent(java.awt.Graphics aGraphics)
paintComponent
in class javax.swing.JComponent
protected void paintBackground(java.awt.Graphics2D aGrfx)
public RMViewerInputAdapter getInputAdapter()
public void setInputAdapter(RMViewerInputAdapter anInputAdapter)
protected RMViewerInputAdapter createInputAdapter()
protected void processMouseEvent(java.awt.event.MouseEvent anEvent)
processMouseEvent
in class javax.swing.JComponent
protected void processMouseMotionEvent(java.awt.event.MouseEvent anEvent)
processMouseMotionEvent
in class javax.swing.JComponent
protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent anEvent)
processMouseWheelEvent
in class java.awt.Component
protected void processKeyEvent(java.awt.event.KeyEvent anEvent)
processKeyEvent
in class javax.swing.JComponent
protected void mousePressed(java.awt.event.MouseEvent anEvent)
protected void mouseDragged(java.awt.event.MouseEvent anEvent)
protected void mouseReleased(java.awt.event.MouseEvent anEvent)
protected void mouseMoved(java.awt.event.MouseEvent anEvent)
public void performActionURLClick(java.lang.String aURL)
public RMShape getHoverShape(java.lang.String aString)
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
protected java.awt.Dimension getPrefSize()
protected java.awt.Dimension getPrefSize(float aScale)
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public RMUndoer getUndoer()
public void undoerSetUndoTitle(java.lang.String aTitle)
public boolean undoerHasUndos()
public boolean getShapeRepaintEnabled()
public void setShapeRepaintEnabled(boolean aFlag)
public void docShapeRepaint(RMShape aShape)
protected void flushShapeRepaints()
public RMRect getRepaintBoundsForShape(RMShape aShape)
public void propertyChange(java.beans.PropertyChangeEvent anEvent)
propertyChange
in interface java.beans.PropertyChangeListener
public RMShape getShape(java.lang.String aName)
public RMViewer.PhantomPane getPhantomPane()
public boolean getPaintFrameRate()
public void setPaintFrameRate(boolean aValue)
public void print() throws java.awt.print.PrinterException
java.awt.print.PrinterException
- Thrown when an error that causes the print job to abort occurs.
Modified in 7.8.0
public void print(java.lang.String aPrinterName, boolean runPanel) throws java.awt.print.PrinterException
aPrinterName
- The name returned by PrintServiceLookup.lookupPrintServices, or null for default printerrunPanel
- True if the print dialog should be shown.java.awt.print.PrinterException
- Thrown when an error that causes the print job to abort occurs.
Modified in 7.8.0
public int getPrintingMode()
public void setPrintingMode(int printingMode)
printingMode
- Allowable values are the constants PRINT_MODE_RASTER and PRINT_MODE_VECTOR. Other values will give
undefined results.public int getPrintingDPI()
public void setPrintingDPI(int printingDPI)
printingDPI
- Must be a positive integerpublic int getCopies()
public void setCopies(int copies)
copies
- Must be a positive integerpublic boolean isUseAutoLandscape()
public void setUseAutoLandscape(boolean useAutoLandscape)
public int getPageOrientation()
public void setPageOrientation(int pageOrientation)
public boolean isPrintBothSides()
public void setPrintBothSides(boolean printBothSides)
public boolean isCollate()
public void setCollate(boolean collate)
public java.awt.print.Book getBook(int orientation, java.awt.print.Paper paper)
Changes in 7.8.0: made the printable used based on printing mode