Class JLChart

All Implemented Interfaces:
ActionListener, MouseListener, MouseMotionListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
AdvancedJLChart, AttributeMultiChart, DualNumberScalarChart, DualSpectrumImageViewer, MultiNumberSpectrumViewer, NonAttrNumberSpectrumViewer, NumberSpectrumItemTrend, NumberSpectrumStateBarChartViewer

A Class to handle 2D graphics plot.
Author:
JL Pons
See Also:
  • Field Details

    • LABEL_DOWN

      public static final int LABEL_DOWN
      Place label at the bottom of the chart
      See Also:
    • LABEL_UP

      public static final int LABEL_UP
      Place label at the top of the chart
      See Also:
    • LABEL_RIGHT

      public static final int LABEL_RIGHT
      Place label at the right of the chart
      See Also:
    • LABEL_LEFT

      public static final int LABEL_LEFT
      Place label at the left of the chart
      See Also:
    • LABEL_ROW

      public static final int LABEL_ROW
      Place label at the bottom of the chart and try to arrange them in rows
      See Also:
    • US_DATE_FORMAT

      public static final String US_DATE_FORMAT
      See Also:
    • FR_DATE_FORMAT

      public static final String FR_DATE_FORMAT
      See Also:
    • labelRect

      protected Vector<fr.esrf.tangoatk.widget.util.chart.LabelRect> labelRect
    • maxDisplayDuration

      protected double maxDisplayDuration
    • chartMenu

      protected JPopupMenu chartMenu
    • preferDialog

      protected boolean preferDialog
    • modalDialog

      protected boolean modalDialog
    • tableDialog

      protected JDialog tableDialog
    • dialogParent

      protected Window dialogParent
    • parentFrame

      protected JFrame parentFrame
    • lastSnapshotLocation

      protected String lastSnapshotLocation
    • lastDataFileLocation

      protected String lastDataFileLocation
    • lastFileFilter

      protected FileFilter lastFileFilter
    • noValueString

      protected String noValueString
  • Constructor Details

    • JLChart

      public JLChart()
      Graph constructor.
  • Method Details

    • getXAxis

      public JLAxis getXAxis()
      Return a handle to the x axis
      Returns:
      Axis handle
    • getY1Axis

      public JLAxis getY1Axis()
      Return a handle to the left y axis
      Returns:
      Axis handle
    • getY2Axis

      public JLAxis getY2Axis()
      Return a handle to the right y axis
      Returns:
      Axis handle
    • setXAxisOnBottom

      public void setXAxisOnBottom(boolean b)
      Sets weather x Axis is on bottom of screen or not
      Parameters:
      b - boolean to know weather x Axis is on bottom of screen or not
    • isXAxisOnBottom

      public boolean isXAxisOnBottom()
      tells weather x Axis is on bottom of screen or not
      Returns:
      [code]true[/code] if x Axis is on bottom of screen, [code]false[/code] otherwise
    • setHeaderFont

      public void setHeaderFont(Font f)
      Sets header font
      Parameters:
      f - Header font
      See Also:
    • getHeaderFont

      public Font getHeaderFont()
      Gets the header font
      Returns:
      Header font
      See Also:
    • setMargin

      public void setMargin(Dimension d)
      Sets component margin
      Parameters:
      d - Margin
      See Also:
    • getMargin

      public Dimension getMargin()
      Gets the current margin
      Returns:
      Margin
      See Also:
    • setBackground

      public void setBackground(Color c)
      Overrides:
      setBackground in class JComponent
    • setChartBackground

      public void setChartBackground(Color c)
      Sets the chart background (curve area)
      Parameters:
      c - Background color
    • getChartBackground

      public Color getChartBackground()
      Gets the chart background (curve area)
      Returns:
      Background color
    • setPaintAxisFirst

      public void setPaintAxisFirst(boolean b)
      Paints axis under curve when true
      Parameters:
      b - Painting order
    • isPaintAxisFirst

      public boolean isPaintAxisFirst()
      Return painting order between axis and curve
      Returns:
      true if axis are painted under curve
    • setHeaderVisible

      public void setHeaderVisible(boolean b)
      Displays or hides header.
      Parameters:
      b - true if the header is visible, false otherwise
      See Also:
    • isHeaderVisible

      public boolean isHeaderVisible()
      Returns:
      true if the header is visible, false otherwise a
    • setHeader

      public void setHeader(String s)
      Sets the header and displays it.
      Parameters:
      s - Graph header
      See Also:
    • getHeader

      public String getHeader()
      Gets the current header
      Returns:
      Graph header
      See Also:
    • setFrameParent

      public void setFrameParent(JFrame parent)
      Sets the JFrame that will receive the header as title.
      Parameters:
      parent - JFrame parent
    • setDisplayDuration

      public void setDisplayDuration(double v)
      Sets the display duration.This will garbage old data in all displayed data views. Garbaging occurs when addData is called.
      Parameters:
      v - Displauy duration (millisec). Pass Double.POSITIVE_INFINITY to disable.
      See Also:
    • getDisplayDuration

      public double getDisplayDuration()
      Gets the display duration.
      Returns:
      Display duration
      See Also:
    • getMaxDisplayDuration

      public double getMaxDisplayDuration()
      Gets the maximum allowed for a display duration
      Returns:
      Maximum allowed for a display duration
      See Also:
    • setMaxDisplayDuration

      public void setMaxDisplayDuration(double maxDisplayDuration)
      Sets the maximum allowed for a display duration
      Parameters:
      maxDisplayDuration - The maximum allowed for a display duration
      See Also:
    • setHeaderColor

      public void setHeaderColor(Color c)
      Sets the header color
      Parameters:
      c - Header color
    • getHeaderColor

      public Color getHeaderColor()
      Returns:
      the header color
    • setLabelVisible

      public void setLabelVisible(boolean b)
      Displays or hide labels.
      Parameters:
      b - true if labels are visible, false otherwise
      See Also:
    • isLabelVisible

      public boolean isLabelVisible()
      Determines wether labels are visivle or not.
      Returns:
      true if labels are visible, false otherwise
    • setLabelPlacement

      public void setLabelPlacement(int p)
      Set the label placement.
      Parameters:
      p - Placement
      See Also:
    • getLabelPlacement

      public int getLabelPlacement()
      Returns the current label placement.
      Returns:
      Label placement
      See Also:
    • setLabelFont

      public void setLabelFont(Font f)
      Sets the label font
      Parameters:
      f - Label font
    • getLabelFont

      public Font getLabelFont()
      Returns:
      the label font
      See Also:
    • showOptionDialog

      public void showOptionDialog()
      Display the global graph option dialog.
    • showDataOptionDialog

      public void showDataOptionDialog(JLDataView v)
      Display the data view option dialog.
      Parameters:
      v - Dataview
    • isZoomed

      public boolean isZoomed()
      Determines wether the graph is zoomed.
      Returns:
      true if the , false otherwise
    • enterZoom

      public void enterZoom()
      Enter zoom mode. This happens when you hold the left mouse button down and drag the mouse.
    • setJLChartListener

      public void setJLChartListener(IJLChartListener l)
      Set the specified JLChart Listener
      Parameters:
      l - JLChart listener. If set to null the listener will be removed.
    • addUserAction

      public void addUserAction(String name)
      Adds a user action. It will be available from the contextual chart menu. All JLChartActionListener are triggered when a user action is executed. Hint: If the action name starts with 'chk' , it will be displayed as check box menu item. Each time the chart menu is shown, a getActionState() is executed on all listener, if several listener handle the same action, the result will be a logical and of all results.
      Parameters:
      name - Action name
    • removeUserAction

      public void removeUserAction(String name)
      Removes a user action from chart menu.
      Parameters:
      name - Action name
    • autoScaleOnceX

      public void autoScaleOnceX()
      Autoscale once X Axis and disable auto scale
    • autoScaleOnceY1

      public void autoScaleOnceY1()
      Autoscale once Y1 Axis and disable auto scale
    • autoScaleOnceY2

      public void autoScaleOnceY2()
      Autoscale once Y2 Axis and disable auto scale
    • addJLChartActionListener

      public void addJLChartActionListener(IJLChartActionListener l)
      Add the specified JLChartAction listener to the list
      Parameters:
      l - Listener to add
    • exitZoom

      public void exitZoom()
      Exit zoom mode.
    • removeMenuItem

      public void removeMenuItem(int menu)
      Method to remove item of the contextual menu.
      Parameters:
      menu - Item to remove
      See Also:
    • addMenuItem

      public void addMenuItem(JMenuItem menu)
      Method to add item to the contextual menu.
      Parameters:
      menu - MenuItem to add
    • addSeparator

      public void addSeparator()
      Method to add a separator to the contextual menu.
    • removeJLChartActionListener

      public void removeJLChartActionListener(IJLChartActionListener l)
      Remove the specified JLChartAction Listener
      Parameters:
      l - Listener to remove
    • applyConfiguration

      public void applyConfiguration(CfFileReader f)
      Apply graph configuration. This includes all global settings. The CfFileReader object must have been filled by the caller.
      Parameters:
      f - Handle to CfFileReader object that contains global graph param
      See Also:
    • getConfiguration

      public String getConfiguration()
      Build a configuration string that can be write into a file and is compatible with CfFileReader.
      Returns:
      A string containing param.
      See Also:
    • getHelpString

      public String getHelpString()
      Returns:
      a string containing the configuration file help.
    • unselectAll

      public void unselectAll()
      Remove all dataview from the graph.
    • printGraph

      public void printGraph()
      Prints out this graph.
    • loadDataFile

      public void loadDataFile(String fileName)
      Loads a data file and add the corresponding data to Y1 axis
      Parameters:
      fileName - the full path of the data file
    • refreshTableSingle

      public void refreshTableSingle(JLDataView v)
    • showTableAll

      protected void showTableAll(Vector<JLDataView> views)
    • showTableAll

      protected void showTableAll()
    • showStatAll

      protected void showStatAll()
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Specified by:
      actionPerformed in interface ActionListener
    • paint

      public void paint(Graphics g)
      Paint the components. Use the repaint method to repaint the graph.
      Overrides:
      paint in class JComponent
      Parameters:
      g - Graphics object.
    • mouseWheelMoved

      public void mouseWheelMoved(MouseWheelEvent evt)
      Specified by:
      mouseWheelMoved in interface MouseWheelListener
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • buildPanelString

      public String[] buildPanelString(SearchInfo si)
    • showPanel

      public void showPanel(Graphics g, SearchInfo si)
      Display the value tooltip.
      Parameters:
      g - Graphics object
      si - SearchInfo structure.
      See Also:
    • showPanel

      public void showPanel(Graphics g, SearchInfo si, MouseEvent scrEvent)
    • garbageData

      public int garbageData(JLDataView v)
      Remove points that exceed displayDuration.
      Parameters:
      v - DataView containing points
      Returns:
      Number of deleted points
    • addData

      public void addData(JLDataView v, double x, double y)
      Add data to dataview , perform fast update when possible and garbage old data (if a display duration is specified).
      Parameters:
      v - The dataview
      x - x coordinates (real space)
      y - y coordinates (real space)
      See Also:
    • setTimePrecision

      public void setTimePrecision(int milliseconds)
      Sets the allowed margin to make a projection on a line on data show.
      Parameters:
      milliseconds - the margin, in milliseconds
    • getTimePrecision

      public int getTimePrecision()
      Returns the allowed margin to make a projection on a line on data show (default: 0).
      Returns:
      The allowed margin to make a projection on a line on data show (default: 0).
    • getNoValueString

      public String getNoValueString()
      Used with saveDataFile(). Returns the String used to represent "no data" (default : "").
      Returns:
      The String used to represent "no data"
    • setNoValueString

      public void setNoValueString(String noValueString)
      Used with saveDataFile(). Sets the String used to represent "no data" (default : "").
      Parameters:
      noValueString - The String used to represent "no data"
    • setPreferDialogForTable

      public void setPreferDialogForTable(boolean preferDialog, boolean modal)
      Sets if you prefer to use a JDialog with showTableXXX() methods instead of the classic JFrame
      Parameters:
      preferDialog - Prefer to have a dialog or not
      modal - The dialog should be modal or not
    • setParentForTableDialog

      public void setParentForTableDialog(Frame parent)
      Sets the parent that the "show table" dialog should have (in case you chose to have a dialog)
      Parameters:
      parent - The parent
      See Also:
    • setParentForTableDialog

      public void setParentForTableDialog(Dialog parent)
      Sets the parent that the "show table" dialog should have (in case you chose to have a dialog)
      Parameters:
      parent - The parent
      See Also:
    • removeDataView

      public void removeDataView(JLDataView view)
    • reset

      public void reset()
    • reset

      public void reset(boolean showConfirmDialog)
    • getUserActionMenuItem

      protected JMenuItem getUserActionMenuItem(String actionName)
    • isInRange

      public static boolean isInRange(double x, int NB)
    • main

      public static void main(String[] args)