Class PencilDrawer

java.lang.Object
org.opensourcephysics.cabrillo.tracker.PencilDrawer

public class PencilDrawer extends Object
A PencilDrawer draws and manages PencilScenes for a TrackerPanel.
Author:
Douglas Brown
  • Field Details

    • frame

      protected TFrame frame
    • panelID

      protected Integer panelID
  • Method Details

    • getDrawer

      protected static PencilDrawer getDrawer(TrackerPanel panel)
      Gets the PencilDrawer for a specified TrackerPanel.
      Parameters:
      panel - the TrackerPanel
      Returns:
      the PencilDrawer
    • isDrawing

      public static boolean isDrawing(TrackerPanel panel)
      Determines if a TrackerPanel is actively drawing.
      Parameters:
      panel - the TrackerPanel
      Returns:
      true if drawing
    • hasDrawings

      public static boolean hasDrawings(TrackerPanel panel)
      Determines if any drawings or captions exist on a given TrackerPanel.
      Parameters:
      panel - the TrackerPanel
      Returns:
      true if drawings exist
    • dispose

      protected static void dispose(TrackerPanel panel)
      Disposes the PencilDrawer for a specified TrackerPanel.
      Parameters:
      panel - the TrackerPanel
    • areDrawingsVisible

      public boolean areDrawingsVisible()
      Determines if drawings (scenes) are visible.
      Returns:
      true if drawings are visible
    • setDrawingsVisible

      public void setDrawingsVisible(boolean vis, boolean andRepaint)
      Sets the visibility of all scenes.
      Parameters:
      vis - true to show all scenes
      andRepaint - TODO
    • addNewDrawingtoSelectedScene

      protected PencilDrawing addNewDrawingtoSelectedScene()
      Creates a drawing and adds it to the selected scene. If no scene is selected a new one is created.
      Returns:
      the newly added drawing
    • addDrawingtoSelectedScene

      protected PencilDrawing addDrawingtoSelectedScene(PencilDrawing drawing)
      Adds a drawing to the selected scene. If no scene is selected a new one is created.
      Parameters:
      drawing - the PencilDrawing to add
      Returns:
      the newly added drawing
    • getActiveDrawing

      protected PencilDrawing getActiveDrawing()
      Gets the active drawing, defined as the last one added. May return null.
      Returns:
      the active drawing
    • clearScenes

      protected void clearScenes(boolean andRepaint)
      Removes all scenes.
      Parameters:
      andRepaint - TODO
    • removeScene

      protected void removeScene(PencilScene scene)
      Removes a scene.
      Parameters:
      scene - the scene to remove
    • addScene

      protected void addScene(PencilScene scene)
      Adds a scene.
      Parameters:
      scene - the scene to add
    • addNewScene

      protected PencilScene addNewScene()
      Adds a new empty scene.
      Returns:
      the new scene
    • setScenes

      protected void setScenes(ArrayList<PencilScene> pencilScenes)
      Replaces all scenes with new ones.
      Parameters:
      pencilScenes - a list of scenes
    • getSelectedScene

      public PencilScene getSelectedScene()
      Gets the selected scene. May return null.
      Returns:
      the selected scene
    • getSceneAtFrame

      protected PencilScene getSceneAtFrame(int frame)
      Gets the scene at a given frame number. May return null.
      Parameters:
      frame - the frame number
      Returns:
      the earliest scene that starts at the frame or whose range includes the frame
    • getSceneWithCaption

      protected PencilScene getSceneWithCaption(PencilCaption caption)
      Gets the scene with a given caption. May return null.
      Parameters:
      caption - a PencilCaption
      Returns:
      the earliest scene with the caption, if any
    • getDrawingControl

      protected PencilControl getDrawingControl()
      Gets the drawing control for this PencilDrawer.
      Returns:
      the drawing control
    • getPencilCursor

      protected Cursor getPencilCursor()
      Gets the pencil cursor for drawing.
      Returns:
      a pencil cursor
    • handleMouseAction

      protected void handleMouseAction(MouseEvent e)
      Handles the drawing mouse actions.
      Parameters:
      e - the mouse event
    • dispose

      protected void dispose()
      Disposes of this drawer and associated PencilControl
    • refresh

      protected void refresh()
      Refreshes the PencilControl, if any, associated with this drawer.
    • finalize

      public void finalize()
      Overrides:
      finalize in class Object