Package com.reportmill
Class RMViewer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.reportmill.RMViewer
- All Implemented Interfaces:
- RMDocument.DocListener,- ImageObserver,- MenuContainer,- Serializable
- Direct Known Subclasses:
- Gallery.GViewer,- RMEditor,- RMTrackballControl,- Scene3DTool.Scene3DControl
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(); JScrollPane scrollPane = new JScrollPane(viewer); myFrame.getContentPane().add(scrollPane, Border.CENTER); viewer.setDocument(new RMDocument(aSource));
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class javax.swing.JComponentJComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFieldsFields inherited from class javax.swing.JComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionconvertPointFromShape(RMPoint aPoint, RMShape aShape) Returns a point converted from the coordinate space of the given shape to viewer coords.convertPointToShape(Point2D aPoint, RMShape aShape) Returns a point converted from viewer coords to the coordinate space of the given shape.convertRectFromShape(RMRect aRect, RMShape aShape) Returns a rect converted from the coordinate space of the given shape to viewer coords.convertRectToShape(RMRect aRect, RMShape aShape) Returns a rect converted from viewer coords to the coordinate space of the given shape.voiddocShapeBoundsChanged(RMDocument aDoc, RMShape aShape) Doc listener method - called by editor when making bounds changes.voiddocShapeNeedsRepaint(RMDocument aDoc, RMShape aShape) Doc listener method - called before a shape makes a visual change.voiddocUndoerAddDirtyObject(RMDocument aDoc, RMObject anObj) Doc listener method - RMViewer ignores it, but RMEditor calls setUndoSelectedObjects.booleanReturns whether or not the gutter, page background & dropshadow get drawn.voidThis method repaints the total bounds of shapes that have previously been registered by shapeNeedsRepaint.Returns a java.awt.print.Book, suitable for AWT printing.Returns the dirty rect of shapes currently registered with shapeNeedsRepaint (and clears _dirtyShapes).Returns the RMDocument associated with this viewer.Returns the bounds of the viewer document.Returns filename associated with viewer's document (or null if the document didn't come from a file).Standard minimum size method.Returns the bounds of the viewer document's selected page.byteReturns the page layout of the viewer's document.Returns the optimal size of the viewer.intintReturns the rendering hings used to paint the view.Returns the currently selected page shape.intReturns the index of the current visiable document page.getShapeAtPoint(Point2D aPoint, boolean goDeep) Returns the first shape hit by the given point.Returns the object that is actually responsible for paining shapes in the viewer.booleanReturns whether changes to shapes cause repaints.getTransformFromShape(RMShape aShape) Returns the transform from given shape to viewer.Returns the undoer associated with the viewer's document.floatReturns the viewer's zoom factor (1 by default).voidmouseDragged(MouseEvent anEvent) Handle mouse dragged event.voidmouseMoved(MouseEvent anEvent) Handle mouse moved event.voidmousePressed(MouseEvent anEvent) Handle mouse pressed event.voidmouseReleased(MouseEvent anEvent) Handle mouse released event.voidpageBack()Selects the previous page.voidSelects the next page.voidOverrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.voidProvides a hook for subclasses to paint above standard viewer drawing.voidperformActionURLClick(String aURL) Viewer callback - called when shape with URL is clicked (opens URL).voidprint()This method tells the RMViewer to print by running the print dialog (configured to the default printer).voidThis method tells the RMViewer to print to the printer with the given printer name (use null for default printer).voidprint2()voidprotected voidprocessMouseEvent(MouseEvent anEvent) Handle mouse events.protected voidprocessMouseMotionEvent(MouseEvent anEvent) voidRequests a repaint for the area represented by the given rect.voidRuns a dialog panel to request a percentage zoom (which is then set with setZoomFactor).voidsetDocument(RMDocument aDoc) Sets the RMDocument associated with this viewer.voidsetPrintingDPI(int printingDPI) voidsetPrintingMode(int printingMode) voidsetSelectedPageIndex(int anIndex) Sets the page of viewer's document that is visible (by index).voidsetShapePainter(RMShapePainter aPainter) Sets the object that is actually responsible for paining shapes in the viewer.voidsetShapeRepaintEnabled(boolean aFlag) Sets whether changes to shapes cause repaints.voidsetZoomFactor(float aFactor) Sets the viewer's zoom factor (1 for 100%).voidSets the viewer's zoom to match the current screen resolutionvoidundoerAddChildToShape(RMShape aShape, RMShape aParent) Adds a child with undo registration in the viewer's documents's undoer (convenience).voidDisable's undo in the viewer's documents's undoer (convenience).voidEnable's undo in the viewer's documents's undoer (convenience).booleanReturns whether undos exist in the viewer's documents's undoer (convenience).voidundoerSetCoalesce(boolean aFlag) Turns on undo coalescing in the viewer's documents's undoer (convenience).voidundoerSetUndoTitle(String aTitle) Sets the title of the next registered undo in the viewer's documents's undoer (convenience).protected voidupdateShapeUnderStack(RMShape aShape, MouseEvent anEvent) The shape under stack should always be a stack of descendants that acceptEvents.voidSets the viewer's zoom to its previous value.Methods inherited from class javax.swing.JComponentaddAncestorListener, 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, 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, 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, updateUIMethods inherited from class java.awt.Containeradd, 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, validateTreeMethods inherited from class java.awt.Componentaction, 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
- 
Field Details- 
PRINT_MODE_VECTORpublic static final int PRINT_MODE_VECTOR- See Also:
 
- 
PRINT_MODE_RASTERpublic static final int PRINT_MODE_RASTER- See Also:
 
- 
GridColor
- 
MarginColor
 
- 
- 
Constructor Details- 
RMViewerpublic RMViewer()Creates a new RMViewer with an empty document in it.
- 
RMViewerCreates a new RMViewer from the given source. aSource is used to get an RMDocument and can be many different things: String file path, File object, InputStream, byte array, URL or even an RMDocument.
 
- 
- 
Method Details- 
getPrintingModepublic int getPrintingMode()
- 
setPrintingModepublic void setPrintingMode(int printingMode) 
- 
getPrintingDPIpublic int getPrintingDPI()
- 
setPrintingDPIpublic void setPrintingDPI(int printingDPI) 
- 
getDocumentReturns the RMDocument associated with this viewer.
- 
setDocumentSets the RMDocument associated with this viewer.
- 
getSelectedPageReturns the currently selected page shape.
- 
getFilenameReturns filename associated with viewer's document (or null if the document didn't come from a file).
- 
getPageLayoutpublic byte getPageLayout()Returns the page layout of the viewer's document.
- 
getSelectedPageIndexpublic int getSelectedPageIndex()Returns the index of the current visiable document page.
- 
setSelectedPageIndexpublic void setSelectedPageIndex(int anIndex) Sets the page of viewer's document that is visible (by index).
- 
pageForwardpublic void pageForward()Selects the next page.
- 
pageBackpublic void pageBack()Selects the previous page.
- 
getDocumentBoundsReturns the bounds of the viewer document.
- 
getPageBoundsReturns the bounds of the viewer document's selected page.
- 
getShapeAtPointReturns the first shape hit by the given point.
- 
getZoomFactorpublic float getZoomFactor()Returns the viewer's zoom factor (1 by default).
- 
setZoomFactorpublic void setZoomFactor(float aFactor) Sets the viewer's zoom factor (1 for 100%).
- 
setZoomForScreenResolutionpublic void setZoomForScreenResolution()Sets the viewer's zoom to match the current screen resolution
- 
zoomToggleLastpublic void zoomToggleLast()Sets the viewer's zoom to its previous value.
- 
runZoomPanelpublic void runZoomPanel()Runs a dialog panel to request a percentage zoom (which is then set with setZoomFactor).
- 
convertPointFromShapeReturns a point converted from the coordinate space of the given shape to viewer coords.
- 
convertPointToShapeReturns a point converted from viewer coords to the coordinate space of the given shape.
- 
convertRectFromShapeReturns a rect converted from the coordinate space of the given shape to viewer coords.
- 
convertRectToShapeReturns a rect converted from viewer coords to the coordinate space of the given shape.
- 
getTransformFromShapeReturns the transform from given shape to viewer.
- 
repaintRequests a repaint for the area represented by the given rect.
- 
getShapePainterReturns the object that is actually responsible for paining shapes in the viewer.
- 
setShapePainterSets the object that is actually responsible for paining shapes in the viewer.
- 
getRenderingHintsReturns the rendering hings used to paint the view.
- 
drawsBackgroundpublic boolean drawsBackground()Returns whether or not the gutter, page background & dropshadow get drawn.
- 
paintComponentOverrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.- Overrides:
- paintComponentin class- JComponent
 
- 
paintComponentAboveProvides a hook for subclasses to paint above standard viewer drawing.
- 
processMouseEventHandle mouse events.- Overrides:
- processMouseEventin class- JComponent
 
- 
processMouseMotionEvent- Overrides:
- processMouseMotionEventin class- JComponent
 
- 
mousePressedHandle mouse pressed event.
- 
mouseDraggedHandle mouse dragged event.
- 
mouseReleasedHandle mouse released event.
- 
mouseMovedHandle mouse moved event.
- 
updateShapeUnderStackThe shape under stack should always be a stack of descendants that acceptEvents.
- 
performActionURLClickViewer callback - called when shape with URL is clicked (opens URL).
- 
getMinimumSizeStandard minimum size method.- Overrides:
- getMinimumSizein class- JComponent
 
- 
getPreferredSizeReturns the optimal size of the viewer.- Overrides:
- getPreferredSizein class- JComponent
 
- 
getUndoerReturns the undoer associated with the viewer's document.
- 
undoerSetUndoTitleSets the title of the next registered undo in the viewer's documents's undoer (convenience).
- 
undoerDisablepublic void undoerDisable()Disable's undo in the viewer's documents's undoer (convenience).
- 
undoerEnablepublic void undoerEnable()Enable's undo in the viewer's documents's undoer (convenience).
- 
undoerSetCoalescepublic void undoerSetCoalesce(boolean aFlag) Turns on undo coalescing in the viewer's documents's undoer (convenience).
- 
undoerHasUndospublic boolean undoerHasUndos()Returns whether undos exist in the viewer's documents's undoer (convenience).
- 
undoerAddChildToShapeAdds a child with undo registration in the viewer's documents's undoer (convenience).
- 
getShapeRepaintEnabledpublic boolean getShapeRepaintEnabled()Returns whether changes to shapes cause repaints.
- 
setShapeRepaintEnabledpublic void setShapeRepaintEnabled(boolean aFlag) Sets whether changes to shapes cause repaints.
- 
docShapeNeedsRepaintDoc 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.- Specified by:
- docShapeNeedsRepaintin interface- RMDocument.DocListener
 
- 
docShapeBoundsChangedDoc listener method - called by editor when making bounds changes.- Specified by:
- docShapeBoundsChangedin interface- RMDocument.DocListener
 
- 
docUndoerAddDirtyObjectDoc listener method - RMViewer ignores it, but RMEditor calls setUndoSelectedObjects.- Specified by:
- docUndoerAddDirtyObjectin interface- RMDocument.DocListener
 
- 
flushGraphicspublic void flushGraphics()This method repaints the total bounds of shapes that have previously been registered by shapeNeedsRepaint. This should only be used internally.
- 
getDirtyRectReturns the dirty rect of shapes currently registered with shapeNeedsRepaint (and clears _dirtyShapes).
- 
printpublic void print()This method tells the RMViewer to print by running the print dialog (configured to the default printer).
- 
printThis 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.
- 
print2public void print2()
- 
print2
- 
getBookReturns a java.awt.print.Book, suitable for AWT printing.
 
-