Class JaxoCanvas

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable, JaxoCanvasComponent, JaxoDrawingArea, JaxoLocalized

public final class JaxoCanvas extends AbstractJaxoCanvas
An instance of the canvas: responsible for all the painting.
Since:
2.0
See Also:
  • Constructor Details

    • JaxoCanvas

      public JaxoCanvas(ActionListener listener)
      Constructs a new canvas.
      Parameters:
      listener - An ActionListener to receive events from the Canvas.
  • Method Details

    • markImageInvalid

      public void markImageInvalid(Rectangle boundingBox)
      Mark the specified region as invalid. Currently this is also synchronous.
      Parameters:
      boundingBox - The region to update. May be null in which case the whole image is marked for update.
    • refresh

      public void refresh()
      Refresh the canvas. This should basically clean up any drawing operation and repaint the drawing area.
    • setCanvasGraph

      public void setCanvasGraph(JaxoGraph value)
      Sets the current graph. Also clears the hovering object.
      Specified by:
      setCanvasGraph in interface JaxoDrawingArea
      Overrides:
      setCanvasGraph in class AbstractJaxoCanvas
      Parameters:
      value - The graph to be set.
    • paintComponent

      protected void paintComponent(Graphics g)
      Paint the Canvas.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - The graphics context to paint to.
    • printComponent

      protected void printComponent(Graphics gr)
      Print the Canvas.
      Overrides:
      printComponent in class JComponent
      Parameters:
      gr - The graphics context to print to.
    • rebuildImage

      protected void rebuildImage()
      Build a new off-screen image. This should only be needed for resizing the canvas.
      Specified by:
      rebuildImage in class AbstractJaxoCanvas
    • revalidateCanvas

      protected void revalidateCanvas()
      Resets the preferred size of the canvas.
      Specified by:
      revalidateCanvas in class AbstractJaxoCanvas
    • deleteMarkedObjects

      protected void deleteMarkedObjects()
      Deletes all 'marked' objects from the drawing area and the current canvas graph.
      Specified by:
      deleteMarkedObjects in class AbstractJaxoCanvas
    • pasteFromClipboard

      public void pasteFromClipboard()
      Paste the objects currently on the clipboard.
    • ungroupMarkedObjects

      public void ungroupMarkedObjects()
      Ungroup all marked objects. This is not recursive, only one level is resolved.
    • ungroupSelectedObject

      public void ungroupSelectedObject()
      If the selected object is a group, ungroup it.
    • groupMarkedObjects

      public void groupMarkedObjects()
      Groups the currently marked objects.
    • updateMode

      public void updateMode(int mode)
      Resets canvas parameters for the given mode. Sets the cursor, and determines whether to draw visualAid and handles.
      Specified by:
      updateMode in class AbstractJaxoCanvas
      Parameters:
      mode - The mode to adjust to.
    • clear

      public void clear()
      Clears the drawing area.
    • moveSelection

      public void moveSelection(boolean backGround)
      Moves the currently selected objects into either fore- or background.
      Parameters:
      backGround - True for moving into background, false for foreground.
    • editNearestObject

      public void editNearestObject(Point p)
      Determine the closest object to the given point and bring up an edit panel for it.
      Parameters:
      p - the test point
    • initiateEdit

      public void initiateEdit(Point p)
      Start an edit action at a given point.
      Parameters:
      p - the point associated with the edit action.
    • continueEdit

      public void continueEdit(Point p, Point last)
      Continue an edit actione that has been initiated before.
      Parameters:
      p - the point on this drawing area associated with the edit action.
      last - the last recorded action point, or null if none.
    • finalizeEdit

      public void finalizeEdit()
      Finalize a user input action.
    • updatePointsAid

      public void updatePointsAid(Point p)
      Updates the visual aid that is painted for objects in click-move mode.
      Parameters:
      p - the current location of the cursor.
    • initiateSelect

      public void initiateSelect(Point p)
      Start a select action.
      Parameters:
      p - the point where the select action was started.
    • continueSelect

      public void continueSelect(Point p)
      Carry on a select action that was started previously.
      Parameters:
      p - the current point of the select action.
    • finalizeSelect

      public void finalizeSelect(Point p)
      End a select action.
      Parameters:
      p - the point where the select action was finished.