public class RMViewer extends javax.swing.JComponent implements RMDocument.DocListener
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(); JScrollPane scrollPane = new JScrollPane(viewer); myFrame.getContentPane().add(scrollPane, Border.CENTER); viewer.setDocument(new RMDocument(aSource));
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
GridColor |
static java.awt.Color |
MarginColor |
static int |
PRINT_MODE_RASTER |
static int |
PRINT_MODE_VECTOR |
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.
|
RMViewer(java.lang.Object aSource)
Creates a new RMViewer from the given source.
|
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.
|
void |
docShapeBoundsChanged(RMDocument aDoc,
RMShape aShape)
Doc listener method - called by editor when making bounds changes.
|
void |
docShapeNeedsRepaint(RMDocument aDoc,
RMShape aShape)
Doc listener method - called before a shape makes a visual change.
|
void |
docUndoerAddDirtyObject(RMDocument aDoc,
RMObject anObj)
Doc listener method - RMViewer ignores it, but RMEditor calls setUndoSelectedObjects.
|
boolean |
drawsBackground()
Returns whether or not the gutter, page background & dropshadow get drawn.
|
void |
flushGraphics()
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.
|
RMRect |
getDirtyRect()
Returns the dirty rect of shapes currently registered with shapeNeedsRepaint (and clears _dirtyShapes).
|
RMDocument |
getDocument()
Returns the RMDocument associated with this viewer.
|
RMRect |
getDocumentBounds()
Returns the bounds of the viewer document.
|
java.lang.String |
getFilename()
Returns filename associated with viewer's document (or null if the document didn't come from a file).
|
java.awt.Dimension |
getMinimumSize()
Standard minimum size method.
|
RMRect |
getPageBounds()
Returns the bounds of the viewer document's selected page.
|
byte |
getPageLayout()
Returns the page layout of the viewer's document.
|
java.awt.Dimension |
getPreferredSize()
Returns the optimal size of the viewer.
|
int |
getPrintingDPI() |
int |
getPrintingMode() |
java.awt.RenderingHints |
getRenderingHints()
Returns the rendering hings used to paint the view.
|
RMShape |
getSelectedPage()
Returns the currently selected page shape.
|
int |
getSelectedPageIndex()
Returns the index of the current visiable document page.
|
RMShape |
getShapeAtPoint(java.awt.geom.Point2D aPoint,
boolean goDeep)
Returns the first shape hit by the given point.
|
RMShapePainter |
getShapePainter()
Returns the object that is actually responsible for paining shapes in the viewer.
|
boolean |
getShapeRepaintEnabled()
Returns whether changes to shapes cause repaints.
|
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.
|
float |
getZoomFactor()
Returns the viewer's zoom factor (1 by default).
|
void |
mouseDragged(java.awt.event.MouseEvent anEvent)
Handle mouse dragged event.
|
void |
mouseMoved(java.awt.event.MouseEvent anEvent)
Handle mouse moved event.
|
void |
mousePressed(java.awt.event.MouseEvent anEvent)
Handle mouse pressed event.
|
void |
mouseReleased(java.awt.event.MouseEvent anEvent)
Handle mouse released event.
|
void |
pageBack()
Selects the previous page.
|
void |
pageForward()
Selects the next page.
|
void |
paintComponent(java.awt.Graphics g)
Overrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.
|
void |
paintComponentAbove(java.awt.Graphics2D g)
Provides a hook for subclasses to paint above standard viewer drawing.
|
void |
performActionURLClick(java.lang.String aURL)
Viewer callback - called when shape with URL is clicked (opens URL).
|
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).
|
void |
print2() |
void |
print2(java.lang.String aPrinterName,
boolean runPanel) |
protected void |
processMouseEvent(java.awt.event.MouseEvent anEvent)
Handle mouse events.
|
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent anEvent) |
void |
repaint(RMRect 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 |
setDocument(RMDocument aDoc)
Sets the RMDocument associated with this viewer.
|
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 |
setShapePainter(RMShapePainter aPainter)
Sets the object that is actually responsible for paining shapes in the viewer.
|
void |
setShapeRepaintEnabled(boolean aFlag)
Sets whether changes to shapes cause repaints.
|
void |
setZoomFactor(float aFactor)
Sets the viewer's zoom factor (1 for 100%).
|
void |
setZoomForScreenResolution()
Sets the viewer's zoom to match the current screen resolution
|
void |
undoerAddChildToShape(RMShape aShape,
RMShape aParent)
Adds a child with undo registration in the viewer's documents's undoer (convenience).
|
void |
undoerDisable()
Disable's undo in the viewer's documents's undoer (convenience).
|
void |
undoerEnable()
Enable's undo in the viewer's documents's undoer (convenience).
|
boolean |
undoerHasUndos()
Returns whether undos exist in the viewer's documents's undoer (convenience).
|
void |
undoerSetCoalesce(boolean aFlag)
Turns on undo coalescing 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 |
updateShapeUnderStack(RMShape aShape,
java.awt.event.MouseEvent anEvent)
The shape under stack should always be a stack of descendants that acceptEvents.
|
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, 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, processKeyEvent, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int PRINT_MODE_VECTOR
public static final int PRINT_MODE_RASTER
public static java.awt.Color GridColor
public static java.awt.Color MarginColor
public RMViewer()
public RMViewer(java.lang.Object aSource)
public int getPrintingMode()
public void setPrintingMode(int printingMode)
public int getPrintingDPI()
public void setPrintingDPI(int printingDPI)
public RMDocument getDocument()
public void setDocument(RMDocument aDoc)
public RMShape getSelectedPage()
public java.lang.String getFilename()
public byte getPageLayout()
public int getSelectedPageIndex()
public void setSelectedPageIndex(int anIndex)
public void pageForward()
public void pageBack()
public RMRect getDocumentBounds()
public RMRect getPageBounds()
public RMShape getShapeAtPoint(java.awt.geom.Point2D aPoint, boolean goDeep)
public float getZoomFactor()
public void setZoomFactor(float aFactor)
public void setZoomForScreenResolution()
public void zoomToggleLast()
public void runZoomPanel()
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(RMRect aRect)
public RMShapePainter getShapePainter()
public void setShapePainter(RMShapePainter aPainter)
public java.awt.RenderingHints getRenderingHints()
public boolean drawsBackground()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void paintComponentAbove(java.awt.Graphics2D g)
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
public void mousePressed(java.awt.event.MouseEvent anEvent)
public void mouseDragged(java.awt.event.MouseEvent anEvent)
public void mouseReleased(java.awt.event.MouseEvent anEvent)
public void mouseMoved(java.awt.event.MouseEvent anEvent)
protected void updateShapeUnderStack(RMShape aShape, java.awt.event.MouseEvent anEvent)
public void performActionURLClick(java.lang.String aURL)
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public RMUndoer getUndoer()
public void undoerSetUndoTitle(java.lang.String aTitle)
public void undoerDisable()
public void undoerEnable()
public void undoerSetCoalesce(boolean aFlag)
public boolean undoerHasUndos()
public void undoerAddChildToShape(RMShape aShape, RMShape aParent)
public boolean getShapeRepaintEnabled()
public void setShapeRepaintEnabled(boolean aFlag)
public void docShapeNeedsRepaint(RMDocument aDoc, RMShape aShape)
docShapeNeedsRepaint
in interface RMDocument.DocListener
public void docShapeBoundsChanged(RMDocument aDoc, RMShape aShape)
docShapeBoundsChanged
in interface RMDocument.DocListener
public void docUndoerAddDirtyObject(RMDocument aDoc, RMObject anObj)
docUndoerAddDirtyObject
in interface RMDocument.DocListener
public void flushGraphics()
public RMRect getDirtyRect()
public void print()
public void print(java.lang.String aPrinterName, boolean runPanel)
public void print2()
public void print2(java.lang.String aPrinterName, boolean runPanel)
public java.awt.print.Book getBook(int orientation, java.awt.print.Paper paper)