Class PlotCanvas

All Implemented Interfaces:
DataChangeListener, IRubberbanded, IToolBarListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, TableModelListener

See Also:
  • Field Details

  • Constructor Details

    • PlotCanvas

      public PlotCanvas(DataSet dataSet, String plotTitle, String xLabel, String yLabel)
      Create a plot canvas for plotting a dataset
      Parameters:
      dataSet - the dataset to plot. It might contain many curves
      plotTitle - the plot title
      xLabel - the x axis label
      yLabel - the y axis label
  • Method Details

    • getType

      public DataSetType getType()
      Get the DataSet type
      Returns:
      the data set type
    • getTitle

      public String getTitle()
      Get the plot title
      Returns:
      the plot title
    • getParameters

      public PlotParameters getParameters()
      Get the plot parameters
      Returns:
      the plot parameters
    • setParent

      public void setParent(Component parent)
      Set the parent component, probably a PlotPanel
      Parameters:
      parent - the optional parent component
    • setDataSet

      public void setDataSet(DataSet ds)
      Set a new data set for the canvas
      Parameters:
      ds - the new dataset
    • getDataSet

      public DataSet getDataSet()
      Get the underlying dataset
      Returns:
      the underlying dataset
    • getWorld

      public Rectangle2D.Double getWorld()
      Get the world boundary
      Returns:
      the world boundary
    • setWorldSystem

      public void setWorldSystem()
      Set the world system based on the dataset This is where the plot limits are set.
    • paintComponent

      public void paintComponent(Graphics g)
      Paint the canvas
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the graphics context
    • needsRedraw

      public void needsRedraw(boolean rescale)
      Data is being added, possibly very quickly, so lets schedule a redraw
      Parameters:
      rescale - if true the world system will also be rescaled
    • getActiveBounds

      public Rectangle getActiveBounds()
      Get the active plot area
      Returns:
      the active plot area
    • setAffineTransforms

      protected void setAffineTransforms()
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      The mouse has been dragged over the plot canvas
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      e - the mouseEvent
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      The mouse has moved over the plot canvas
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      e - the mouseEvent
    • getLocationString

      public String getLocationString()
      Get the last updated location string
      Returns:
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      The mouse has been clicked on the plot canvas
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      e - the mouseEvent
    • mousePressed

      public void mousePressed(MouseEvent e)
      The mouse has been pressed on plot canvas
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      e - the mouseEvent
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      The mouse has been released on plot canvas. A release comes before the click
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - the mouseEvent
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      The mouse has entered the area of the plot canvas
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - the mouseEvent
    • mouseExited

      public void mouseExited(MouseEvent e)
      The mouse has exited the area of the plot canvas
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - the mouseEvent
    • localToWorld

      public void localToWorld(Point pp, Point2D.Double wp)
      This converts a screen or pixel point to a world point.
      Parameters:
      pp - contains the local (screen-pixel) point.
      wp - will hold the resultant world point.
    • localToWorld

      public void localToWorld(Rectangle pr, Rectangle2D.Double wr)
      This converts a screen or pixel rectangle to a world rectangle.
      Parameters:
      pr - contains the local (screen-pixel) rectangle.
      wr - will hold the resultant world rectangle.
    • worldToLocal

      public void worldToLocal(Point pp, Point2D.Double wp)
      This converts a world point to a screen or pixel point.
      Parameters:
      pp - will hold the resultant local (screen-pixel) point.
      wp - contains world point.
    • worldToLocal

      public void worldToLocal(Rectangle r, Rectangle2D.Double wr)
    • doneRubberbanding

      public void doneRubberbanding()
      Description copied from interface: IRubberbanded
      This just signals that we are done rubber banding.
      Specified by:
      doneRubberbanding in interface IRubberbanded
    • recenterAtClick

      public void recenterAtClick(Point pp)
      Center the plot world at the click.
      Parameters:
      pp -
    • scale

      public void scale(double amount)
      Scale the canvas by a given amount
      Parameters:
      amount - the factor to scale by
    • buttonPressed

      public void buttonPressed(CommonToolBar toolbar, ToolBarButton button)
      Specified by:
      buttonPressed in interface IToolBarListener
    • doButtonAction

      public void doButtonAction(String command)
    • print

      public void print()
      Print
    • getSavePngFile

      public File getSavePngFile()
    • takePicture

      public void takePicture()
      Take a picture, sanve as png
    • toggleButtonActivated

      public void toggleButtonActivated(CommonToolBar toolbar, ToolBarToggleButton button)
      Specified by:
      toggleButtonActivated in interface IToolBarListener
    • showPreferencesEditor

      public void showPreferencesEditor()
      Show the plot preferences dialog
    • showDataEditor

      public void showDataEditor()
      Show the data editor
    • remoteFirePropertyChange

      public void remoteFirePropertyChange(String propName, Object oldValue, Object newValue)
      Used so another object can tell the plot canvas to fire a propert change event
      Parameters:
      propName -
      oldValue -
      newValue -
    • tableChanged

      public void tableChanged(TableModelEvent e)
      Specified by:
      tableChanged in interface TableModelListener
    • getPlotTicks

      public PlotTicks getPlotTicks()
      Get the canavas's plot ticks
      Returns:
      the plot ticks
    • getGradient

      public Gradient getGradient()
      Get the canvas's color gradient
      Returns:
      the color gradient
    • setSelectedToggle

      public void setSelectedToggle(String s)
      Set which toggle button is selected
    • dataSetChanged

      public void dataSetChanged(DataSet dataSet)
      Description copied from interface: DataChangeListener
      A data set changed
      Specified by:
      dataSetChanged in interface DataChangeListener
      Parameters:
      dataSet - the dataSet that changed