Class RMEditor

All Implemented Interfaces:
DeepChangeListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable

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

  • Constructor Details

    • RMEditor

      public RMEditor()
      Creates a new editor.
  • Method Details

    • getMainEditor

      public static RMEditor getMainEditor()
      Returns the editor that was most recently activated.
    • getEditorPane

      public RMEditorPane getEditorPane()
      Returns the editor pane for this editor, if there is one.
    • getViewerShape

      public RMEditorShape getViewerShape()
      Override to return as editor shape.
      Overrides:
      getViewerShape in class RMViewer
    • createViewerShape

      protected RMViewerShape createViewerShape()
      Creates the viewer shape.
      Overrides:
      createViewerShape in class RMViewer
    • isEditing

      public boolean isEditing()
      Returns whether viewer is really doing editing.
      Overrides:
      isEditing in class RMViewer
    • setEditing

      public void setEditing(boolean aFlag)
      Sets whether viewer is really doing editing.
    • getValueIsAdjusting

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

      protected RMShapePainterJ2D createShapePainter(Graphics2D aGr)
      Creates the object that is actually responsible for paining shapes in the viewer.
      Overrides:
      createShapePainter in class RMViewer
    • createDropTarget

      public DropTarget createDropTarget()
      Called to enabled drag and drop.
    • getTextEditor

      @Nullable 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(RMTextShape aText)
      Returns the text editor, primed for editing the given text shape.
    • setTextSelection

      protected void setTextSelection(int aStart, int anEnd)
      Called to notify the TextEditor has changed selection.
    • getShapesHelper

      public RMEditorShapes getShapesHelper()
      Returns the shapes helper.
    • createShapesHelper

      public RMEditorShapes createShapesHelper()
      Creates the shapes helper.
    • getSelectedShape

      @Nullable public RMShape getSelectedShape()
      Returns the first selected shape.
    • setSelectedShape

      public void setSelectedShape(RMShape aShape)
      Selects the given 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.
    • getSelectedShapes

      public List<RMShape> getSelectedShapes()
      Returns the selected shapes list.
    • setSelectedShapes

      public void setSelectedShapes(List<RMShape> theShapes)
      Selects the shapes in the given list.
    • addSelectedShape

      public void addSelectedShape(RMShape aShape)
      Add a shape to the selected shapes list and ensures the super selected is added as well on the first run.
    • removeSelectedShape

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

      @Nullable public RMShape getSuperSelectedShape()
      Returns the first super-selected shape.
    • getSuperSelectedParentShape

      public RMParentShape getSuperSelectedParentShape()
      Returns the first super selected shape, if parent shape.
    • setSuperSelectedShape

      public void setSuperSelectedShape(RMShape aShape)
      Super select a shape.
    • isSelected

      public boolean isSelected(RMShape aShape)
      Returns whether a given shape is selected in the editor.
    • isSuperSelected

      public boolean isSuperSelected(RMShape aShape)
      Returns whether a given shape is super-selected in the editor.
    • 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.
    • getSuperSelectedShapes

      public List<RMShape> getSuperSelectedShapes()
      Returns the super selected shape 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.
    • getSelectedOrSuperSelectedShape

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

      public List<RMShape> getSelectedOrSuperSelectedShapes()
      Returns the currently selected shapes or, if none, the super-selected shape in a list.
    • popSelection

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

      public RMRect getRepaintBoundsForShape(RMShape aShape)
      Overrides RMViewer implementation to account for selected shapes potentially having different bounds.
      Overrides:
      getRepaintBoundsForShape in class RMViewer
    • flushEditingChanges

      public void flushEditingChanges()
      This method finalizes any (potentially cached) changes in progress in the editor (like from text editing).
    • 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

      @Nullable public RMParentShape firstSuperSelectedShapeThatAcceptsChildren()
      Returns the first SuperSelectedShape that accepts children.
    • firstSuperSelectedShapeThatAcceptsChildrenSafe

      @Nullable public RMParentShape firstSuperSelectedShapeThatAcceptsChildrenSafe()
      Returns the first SuperSelectedShape that accepts children, or the currently selected page if N/A
    • firstSuperSelectedShapeThatAcceptsChildrenAtPoint

      public RMShape firstSuperSelectedShapeThatAcceptsChildrenAtPoint(RMPoint aPoint)
      Returns the first SuperSelected shape that accepts children at a given point.
    • 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<? extends RMShape> theShapes, RMParentShape 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 aPage, int anIndex)
      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 anIndex)
      Removes the document page at the given index.
    • getCurrentTool

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

      public void setCurrentTool(RMTool aTool)
      Tool method - sets the currently select tool to the given tool.
    • 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 anIndex)
      Override viewer method to reset selected shapes on page change.
      Overrides:
      setSelectedPageIndex in class RMViewer
    • getSelectedShapesBounds

      public RMRect getSelectedShapesBounds()
      Scrolls selected shapes to visible.
    • getZoomFocusRect

      public Rectangle getZoomFocusRect()
      Override to have zoom focus on selected shapes rect.
      Overrides:
      getZoomFocusRect in class RMViewer
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.
      Overrides:
      paintComponent in class RMViewer
    • createInputAdapter

      public RMViewerInputAdapter createInputAdapter()
      Creates an editor input adapter for viewer adapter.
      Overrides:
      createInputAdapter in class RMViewer
    • getEditorInputAdapter

      public RMEditorInputAdapter getEditorInputAdapter()
      Returns the even helper object.
    • processEvent

      protected void processEvent(AWTEvent e)
      Override to revalidate when ideal size changes.
      Overrides:
      processEvent in class Container
    • getPrefSize

      protected Dimension getPrefSize()
      Returns the ideal size of the viewer.
      Overrides:
      getPrefSize in class RMViewer
    • getToolTipText

      public String getToolTipText(MouseEvent anEvent)
      Returns a tool tip string by asking deepest shape's tool.
      Overrides:
      getToolTipText in class JComponent
    • getDataSource

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

      public void setDataSource(RMDataSource aDataSource)
      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.
    • setUndoSelection

      protected void setUndoSelection(Object aSelection)
      Sets the undo selection.
    • deepChange

      public void deepChange(PropertyChangeListener aShape, PropertyChangeEvent anEvent)
      Property change.
      Specified by:
      deepChange in interface DeepChangeListener
    • saveUndoerChanges

      protected void saveUndoerChanges()
      Saves Undo Changes.
    • saveUndoerChangesLater

      protected void saveUndoerChangesLater()
      Saves undo changes after a delay.