Class RMEditor

All Implemented Interfaces:
RMDocument.DocListener, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
RBEditor, RMRptEditor

public class RMEditor extends RMViewer
This class subclasses RMViewer to support RMDocument editing.
See Also:
  • Constructor Details

    • RMEditor

      public RMEditor()
      Creates a new editor.
    • RMEditor

      public RMEditor(Object aSource)
      Creates an editor initialized with a document from aSource (String(path), File, InputStream, bytes, etc.).
  • Method Details

    • mainEditor

      public static RMEditor mainEditor()
      Returns the editor that was most recently used.
    • setDocument

      public void setDocument(RMDocument aDoc)
      Overrides viewer method to add an undoer to document.
      Overrides:
      setDocument in class RMViewer
    • isPreview

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

      public void setPreview(boolean doPreview)
      Sets whether editor should be in preview (or viewer) mode.
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
      Returns whether the editor is in a state of constant change, like during a mouse drag loop.
    • getFileExtension

      public String getFileExtension()
      Returns extension for editor document.
    • getFileDescription

      public String getFileDescription()
      Returns the description for the editor document for use in open/save panels.
    • getWindow

      public Window getWindow()
      Returns the window ancestor that the editor component resides in.
    • getDragAndDrop

      public void getDragAndDrop()
      Called to enabled drag and drop.
    • getTextEditor

      public RMEditorTextEditor getTextEditor()
      Returns the text editor (or null if not editing).
    • getTextEditor

      public RMEditorTextEditor getTextEditor(boolean evenIfNotActive)
      Returns the text editor (even if not editing).
    • getTextEditor

      public RMEditorTextEditor getTextEditor(RMText aText)
      Returns the text editor, primed for editing the given text shape.
    • getSelectedShapeCount

      public int getSelectedShapeCount()
      Returns the number of selected shapes.
    • getSelectedShape

      public RMShape getSelectedShape(int anIndex)
      Returns the selected shape at the given index.
    • getSelectedShape

      public RMShape getSelectedShape()
      Returns the first selected shape.
    • getSelectedShapes

      public List getSelectedShapes()
      Returns the selected shapes list.
    • getSuperSelectedShapeCount

      public int getSuperSelectedShapeCount()
      Returns the number of super-selected shapes.
    • getSuperSelectedShape

      public RMShape getSuperSelectedShape(int anIndex)
      Returns the super-selected shape at the given index.
    • getSuperSelectedShape

      public RMShape getSuperSelectedShape()
      Returns the first super-selected shape.
    • getSuperSelectedShapes

      public List getSuperSelectedShapes()
      Returns the super selected shape list.
    • getSelectedOrSuperSelectedShape

      public RMShape getSelectedOrSuperSelectedShape()
      Returns the currently selected shape or, if none, the super-selected shape.
    • getSelectedShapesOrSuperSelectedShape

      public List getSelectedShapesOrSuperSelectedShape()
      Returns the currentlys elected shapes or, if none, the super-selected shape in a list.
    • getSelectedOrSuperSelectedShapeCount

      public int getSelectedOrSuperSelectedShapeCount()
      Returns the number of currently selected shapes or simply 1, if a shape is super-selected.
    • getSelectedOrSuperSelectedShape

      public RMShape getSelectedOrSuperSelectedShape(int anIndex)
      Returns the currently selected shape at the given index, or the super-selected shape.
    • selectShape

      public void selectShape(RMShape aShape)
      Selects the given shape.
    • selectShapes

      public void selectShapes(List shapes)
      Selects the shapes in the given list.
    • addShapeToSelectedShapes

      public void addShapeToSelectedShapes(RMShape aShape)
      Add a shape to the selected shapes list.
    • removeShapeFromSelectedShapes

      public void removeShapeFromSelectedShapes(RMShape aShape)
      Remove a shape from the selected shapes list.
    • superSelectShape

      public void superSelectShape(RMShape aShape)
      Super select a shape.
    • superSelect

      public void superSelect()
      SuperSelect currently selected shape.
    • flushEditingChanges

      public void flushEditingChanges()
      This method finalizes any (potentially cached) changes in progress in the editor (like from text editing).
    • popSelection

      public void popSelection()
      Un-SuperSelect currently super selected shape.
    • getShapeAtPoint

      public RMShape getShapeAtPoint(Point2D aPoint)
      Returns first shape hit by point given in View coords.
    • getChildShapeAtPoint

      public RMShape getChildShapeAtPoint(RMShape aShape, RMPoint aPoint)
      Returns the child of the given shape hit by the given point.
    • firstSuperSelectedShapeThatAcceptsChildren

      public RMShape firstSuperSelectedShapeThatAcceptsChildren()
      Returns the first SuperSelectedShape that accepts children.
    • firstSuperSelectedShapeThatAcceptsChildrenAtPoint

      public RMShape firstSuperSelectedShapeThatAcceptsChildrenAtPoint(RMPoint aPoint)
      Returns the first SuperSelected shape that accepts children at a given point.
    • firstSuperSelectedShapeThatAcceptsChildrenOrChildrenSuperSelectImmediately

      public RMShape firstSuperSelectedShapeThatAcceptsChildrenOrChildrenSuperSelectImmediately()
      Returns the first super selected shape that accepts children or whose children super select immediately.
    • cut

      public void cut()
      Standard clipboard cut functionality.
    • copy

      public void copy()
      Standard clipboard copy functionality.
    • paste

      public void paste()
      Standard clipbard paste functionality.
    • selectAll

      public void selectAll()
      Causes all the children of the current super selected shape to become selected.
    • delete

      public void delete()
      Deletes all the currently selected shapes.
    • addShapesToShape

      public void addShapesToShape(List shapes, RMShape aShape, boolean withCorrection)
      Adds shapes as children to given shape.
    • addPage

      public void addPage()
      Adds a page to the document after current page.
    • addPagePrevious

      public void addPagePrevious()
      Adds a page to the document before current page.
    • addPage

      public void addPage(RMPage page, int index)
      Adds a given page to the current document at the given index.
    • removePage

      public void removePage()
      Removes current page from document.
    • removePage

      public void removePage(int index)
      Removes the document page at the given index.
    • getCurrentTool

      public Tool getCurrentTool()
      Tool method - returns the currently selected tool.
    • setCurrentTool

      public void setCurrentTool(Tool aTool)
      Tool method - sets the currently select tool to the given tool.
    • setCurrentTool

      public void setCurrentTool(int anIndex)
      Tool method - sets the currently selected tool to the specific Tool's core tool at the given index.
    • isCurrentToolSelectTool

      public boolean isCurrentToolSelectTool()
      Returns whether the select tool is currently selected.
    • setCurrentToolToSelectTool

      public void setCurrentToolToSelectTool()
      Sets the current tool to the select tool.
    • isCurrentToolSelectToolAndSelecting

      public boolean isCurrentToolSelectToolAndSelecting()
      Tool method - Returns whether the select tool is currently selected and if it's currently being used to select.
    • resetCurrentTool

      public void resetCurrentTool()
      Resets the currently selected tool.
    • setSelectedPageIndex

      public void setSelectedPageIndex(int index)
      Override viewer method to reset selected shapes on page change.
      Overrides:
      setSelectedPageIndex in class RMViewer
    • setZoomFactor

      public void setZoomFactor(float aFactor)
      Overrides viewer method to focus zoomed region on selected shapes.
      Overrides:
      setZoomFactor in class RMViewer
    • getEditorShapePainter

      public RMEditorShapePainter getEditorShapePainter()
      Returns the shape painter (which is actually an editor shape painter).
    • paintComponentAbove

      public void paintComponentAbove(Graphics2D g2)
      RMEditor drawing.
      Overrides:
      paintComponentAbove in class RMViewer
    • paintViewportAbove

      public void paintViewportAbove(Graphics2D g2, JViewport aViewport)
      Paints editor stuff in viewport, so that it's independent of scroll.
    • getEvents

      public RMEditorEvents getEvents()
      Returns the even helper object.
    • mouseMoved

      public void mouseMoved(MouseEvent anEvent)
      Handle mouse moved event.
      Overrides:
      mouseMoved in class RMViewer
    • mousePressed

      public void mousePressed(MouseEvent anEvent)
      Handle mouse pressed event.
      Overrides:
      mousePressed in class RMViewer
    • mouseDragged

      public void mouseDragged(MouseEvent anEvent)
      Handle mouse dragged event.
      Overrides:
      mouseDragged in class RMViewer
    • mouseReleased

      public void mouseReleased(MouseEvent anEvent)
      Handle mouse released event.
      Overrides:
      mouseReleased in class RMViewer
    • processKeyEvent

      protected void processKeyEvent(KeyEvent e)
      Handle key events.
      Overrides:
      processKeyEvent in class JComponent
    • processKeyEventSuper

      protected void processKeyEventSuper(KeyEvent e)
      Handle key event super - so RMEditorEvents can get at default behavior.
    • isManagingFocus

      public boolean isManagingFocus()
      This gives us tab events, but seems to be deprecated.
      Overrides:
      isManagingFocus in class JComponent
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides viewer method to ensure editor is always at least 575x300.
      Overrides:
      getPreferredSize in class RMViewer
    • getDataSource

      public RMDataSource getDataSource()
      Returns the datasource associated with the editor's document.
    • setDataSource

      public void setDataSource(Object aSource)
      Sets the datasource associated with the editor's document.
    • getDataSourceDataset

      public Object getDataSourceDataset()
      Returns the sample dataset from the document's datasource.
    • undo

      public void undo()
      Called to undo the last edit operation in the editor.
    • redo

      public void redo()
      Called to redo the last undo operation in the editor.
    • docUndoerAddDirtyObject

      public void docUndoerAddDirtyObject(RMDocument aDoc, RMObject anObj)
      Doc listener method - RMViewer ignores it, but RMEditor calls setUndoSelectedObjects.
      Specified by:
      docUndoerAddDirtyObject in interface RMDocument.DocListener
      Overrides:
      docUndoerAddDirtyObject in class RMViewer
    • getArchiverClassMap

      public Map getArchiverClassMap()
      Returns the Map of tags and classes to be used for unarchiving document shapes.