Class DrawingFrame

All Implemented Interfaces:
ClipboardOwner, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, AppFrame, Hidable
Direct Known Subclasses:
Complex2DFrame, ComplexPlotFrame, DisplayFrame, FFT2DFrame, FFTFrame, HistogramFrame, LatticeFrame, ParticleFrame, PlotFrame, RasterFrame, Scalar2DFrame, Vector2DFrame, VideoFrame

public class DrawingFrame extends OSPFrame implements ClipboardOwner
Drawing Frame: a frame that contains a drawing panel.
Version:
1.1
Author:
Wolfgang Christian
See Also:
  • Field Details

    • fileMenu

      protected JMenu fileMenu
    • editMenu

      protected JMenu editMenu
    • copyItem

      protected JMenuItem copyItem
    • pasteItem

      protected JMenuItem pasteItem
    • replaceItem

      protected JMenuItem replaceItem
    • drawingPanel

      protected DrawingPanel drawingPanel
    • customInspector

      protected Window customInspector
    • reply

      protected Tool reply
  • Constructor Details

    • DrawingFrame

      public DrawingFrame()
      DrawingFrame constructor that creates a default DrawingPanel. The default DrawingPanel is an InteractivePanel.
    • DrawingFrame

      public DrawingFrame(DrawingPanel drawingPanel)
      DrawingFrame constructor specifying the DrawingPanel that will be placed in the center of the content pane.
      Parameters:
      drawingPanel -
    • DrawingFrame

      public DrawingFrame(String title, DrawingPanel _drawingPanel)
      DrawingFrame constructor specifying the title and the DrawingPanel that will be placed in the center of the content pane.
      Parameters:
      title -
      _drawingPanel -
  • Method Details

    • render

      public void render()
      Renders the drawing panel if the frame is showing and not iconified.
      Overrides:
      render in class OSPFrame
    • invalidateImage

      public void invalidateImage()
      Invalidates image buffers if a drawing panel buffered.
      Overrides:
      invalidateImage in class OSPFrame
    • getDrawingPanel

      public DrawingPanel getDrawingPanel()
      Gets the drawing panel.
      Returns:
      the drawingPanel
    • setXLabel

      public void setXLabel(String label)
      Sets the label for the X (horizontal) axis.
      Parameters:
      label - the label
    • setYLabel

      public void setYLabel(String label)
      Sets the label for the Y (vertical) axis.
      Parameters:
      label - the label
    • setPolar

      public void setPolar(String plotTitle, double deltaR)
      Converts to polar coordinates.
      Parameters:
      plotTitle - String
      deltaR - double
    • setCartesian

      public void setCartesian(String xLabel, String yLabel, String plotTitle)
      Converts to cartesian coordinates.
      Parameters:
      xLabel - String
      yLabel - String
      plotTitle - String
    • limitAutoscaleX

      public void limitAutoscaleX(double floor, double ceil)
      Limits the xmin and xmax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil. Setting a floor or ceil value to Double.NaN<\code> will disable that limit.
      Parameters:
      floor - the xfloor value
      ceil - the xceil value
    • limitAutoscaleY

      public void limitAutoscaleY(double floor, double ceil)
      Limits ymin and ymax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil. Setting a floor or ceil value to Double.NaN<\code> will disable that limit.
      Parameters:
      floor - the yfloor value
      ceil - the yceil value
    • setAutoscaleX

      public void setAutoscaleX(boolean autoscale)
      Autoscale the drawing panel's x axis using min and max values. from measurable objects.
      Parameters:
      autoscale -
    • isAutoscaleX

      public boolean isAutoscaleX()
      Determines if the panel's x axis autoscale property is true.
      Returns:
      true<\code> if autoscaled.
    • setAutoscaleY

      public void setAutoscaleY(boolean autoscale)
      Autoscale the y axis using min and max values. from measurable objects.
      Parameters:
      autoscale -
    • isAutoscaleY

      public boolean isAutoscaleY()
      Determines if the y axis autoscale property is true.
      Returns:
      true<\code> if autoscaled.
    • setSquareAspect

      public void setSquareAspect(boolean isSquare)
      Sets the aspect ratio for horizontal to vertical to unity when true<\code>.
      Parameters:
      isSquare - boolean
    • setLogScale

      public void setLogScale(boolean logX, boolean logY)
      Sets Cartesian axes to log scale.
      Parameters:
      logX -
      logY -
    • setPixelsPerUnit

      public void setPixelsPerUnit(boolean enable, double xPixPerUnit, double yPixPerUnit)
      Sets the scale using pixels per unit.
      Parameters:
      enable - boolean enable fixed pixels per unit
      xPixPerUnit - double
      yPixPerUnit - double
    • setPreferredMinMax

      public void setPreferredMinMax(double xmin, double xmax, double ymin, double ymax)
      Sets the drawing panel's preferred scale.
      Parameters:
      xmin -
      xmax -
      ymin -
      ymax -
    • setPreferredMinMaxY

      public void setPreferredMinMaxY(double ymin, double ymax)
      Sets the drawing panel's preferred scale in the vertical direction.
      Parameters:
      ymin -
      ymax -
    • setPreferredMinMaxX

      public void setPreferredMinMaxX(double xmin, double xmax)
      Sets the drawing panel's preferred scale in the horizontal direction.
      Parameters:
      xmin - the minimum value
      xmax - the maximum value
    • clearDataAndRepaint

      public void clearDataAndRepaint()
      Clears data and repaints the drawing panel within this frame.
      Overrides:
      clearDataAndRepaint in class OSPFrame
    • clearDrawables

      public void clearDrawables()
      Clears Drawable objects added by the user from this frame.
    • addDrawable

      public void addDrawable(Drawable drawable)
      Adds a drawable object to the frame's drawing panel.
      Parameters:
      drawable -
    • replaceDrawable

      public void replaceDrawable(Drawable oldDrawable, Drawable newDrawable)
      Replaces a Drawable object with another Drawable.
      Parameters:
      oldDrawable - Drawable
      newDrawable - Drawable
    • removeDrawable

      public void removeDrawable(Drawable drawable)
      Removes a drawable object to the frame's drawing panel.
      Parameters:
      drawable -
    • setMessage

      public void setMessage(String msg)
      Shows a message in a yellow text box in the lower right hand corner.
      Parameters:
      msg -
    • setMessage

      public void setMessage(String msg, int location)
      Shows a message in a yellow text box at the given location. location 0=bottom left location 1=bottom right location 2=top right location 3=top left
      Parameters:
      msg -
      location -
    • getObjectOfClass

      public <T extends Drawable> ArrayList<T> getObjectOfClass(Class<T> c)
      Gets objects of a specific class from the drawing panel. Assignable subclasses are NOT returned. Interfaces CANNOT be specified. The same objects will be in the drawable list and the cloned list.
      Parameters:
      c - the class of the object
      Returns:
      the list
    • getDrawables

      public ArrayList<Drawable> getDrawables()
      Gets Drawable previously objects added by the user.
      Returns:
      the list
    • getDrawablesNoClone

      public ArrayList<Drawable> getDrawablesNoClone()
    • getAxes

      public DrawableAxes getAxes()
    • getDrawables

      public <T extends Drawable> ArrayList<T> getDrawables(Class<T> c)
      Gets Drawable objects added by the user of an assignable type. The list contains objects that are assignable from the class or interface.
      Parameters:
      c - the type of Drawable object
      Returns:
      the cloned list
      See Also:
    • getDrawablesExcept

      public <T extends Drawable> ArrayList<T> getDrawablesExcept(Class<T> c, Drawable except)
    • removeObjectsOfClass

      public <T extends Drawable> void removeObjectsOfClass(Class<T> c)
      Removes all objects of the given class from the drawable list. Assignable subclasses are NOT removed. Interfaces CANNOT be specified.
      Parameters:
      c - the class
    • setInteractiveMouseHandler

      public void setInteractiveMouseHandler(InteractiveMouseHandler handler)
      Sets the interactive mouse handler if the drawing panel is an interactive panel. Throws an invalid cast exception if the panel is not of the correct type.
      Parameters:
      handler - the mouse handler
    • setDrawingPanel

      public void setDrawingPanel(DrawingPanel _drawingPanel)
      Adds the drawing panel to the the frame. The panel is added to the center of the frame's content pane.
      Parameters:
      _drawingPanel -
    • setInteriorBackground

      public void setInteriorBackground(Color color)
      Sets the interior background color for the current drawing panel. The interior of a PlottingaPanel is the area inside the axes where is displayed. The interior of a DrawingPanel is the entire panel.
    • paint

      public void paint(Graphics g)
      This is a hack to fix a bug when the reload button is pressed in browsers running JDK 1.4.
      Overrides:
      paint in class Window
      Parameters:
      g -
    • setEnabledPaste

      public void setEnabledPaste(boolean enable)
      Enables the paste edit menu item.
      Parameters:
      enable - boolean
    • pasteAction

      protected void pasteAction(XMLControlElement control)
      Pastes drawables found in the specified xml control.
      Parameters:
      control - the xml control
    • setEnabledReplace

      public void setEnabledReplace(boolean enable)
      Enables the replace edit menu item.
      Parameters:
      enable - boolean
    • replaceAction

      public void replaceAction(XMLControlElement control)
      Replaces the drawables with the drawables found in the specified XML control.
      Parameters:
      control - XMLControlElement
    • copyAction

      protected void copyAction(XMLControlElement control)
      Copies objects found in the specified xml control.
      Parameters:
      control - the xml control
    • lostOwnership

      public void lostOwnership(Clipboard clipboard, Transferable contents)
      Implementation of ClipboardOwner interface. Override this method to receive notification that data copied to the clipboard has changed.
      Specified by:
      lostOwnership in interface ClipboardOwner
      Parameters:
      clipboard - Clipboard
      contents - Transferable
    • setEnabledCopy

      public void setEnabledCopy(boolean enable)
      Enables the copy edit menu item.
      Parameters:
      enable - boolean
    • refreshGUI

      protected void refreshGUI()
      Description copied from class: OSPFrame
      Refreshes the user interface in response to display changes such as Language.
      Overrides:
      refreshGUI in class OSPFrame
    • addMenuItems

      protected void addMenuItems()
      Adds Views menu items on the menu bar. Override this method to add custom menu items.
    • loadDisplayMenu

      protected JMenu loadDisplayMenu()
      Adds a Display menu to the menu bar.
      Overrides:
      loadDisplayMenu in class OSPFrame
    • loadToolsMenu

      protected JMenu loadToolsMenu()
      Adds a Tools menu to the menu bar.
      Overrides:
      loadToolsMenu in class OSPFrame
    • setCustomInspector

      public void setCustomInspector(Window w)
      Sets a custom properties inspector window.
      Parameters:
      w - the new inspector window
    • inspectXML

      public void inspectXML()
      Inspects the drawing frame by using an xml document tree.
    • saveXML

      public void saveXML()
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an XML.ObjectLoader to save and load data for this program.
      Returns:
      the object loader