Class JLChart
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
fr.esrf.tangoatk.widget.util.chart.JLChart
- All Implemented Interfaces:
ActionListener,MouseListener,MouseMotionListener,MouseWheelListener,ImageObserver,MenuContainer,Serializable,EventListener
- Direct Known Subclasses:
AdvancedJLChart,AttributeMultiChart,DualNumberScalarChart,DualSpectrumImageViewer,MultiNumberSpectrumViewer,NonAttrNumberSpectrumViewer,NumberSpectrumItemTrend,NumberSpectrumStateBarChartViewer
public class JLChart
extends JComponent
implements MouseWheelListener, MouseListener, MouseMotionListener, ActionListener
A Class to handle 2D graphics plot.
- Author:
- JL Pons
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JPopupMenuprotected Windowstatic final Stringstatic final intPlace label at the bottom of the chartstatic final intPlace label at the left of the chartstatic final intPlace label at the right of the chartstatic final intPlace label at the bottom of the chart and try to arrange them in rowsstatic final intPlace label at the top of the chartprotected Vector<fr.esrf.tangoatk.widget.util.chart.LabelRect>protected Stringprotected FileFilterprotected Stringprotected doublestatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected booleanprotected Stringprotected JFrameprotected booleanprotected JDialogstatic final StringFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddData(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).voidAdd the specified JLChartAction listener to the listvoidaddMenuItem(JMenuItem menu) Method to add item to the contextual menu.voidMethod to add a separator to the contextual menu.voidaddUserAction(String name) Adds a user action.voidApply graph configuration.voidAutoscale once X Axis and disable auto scalevoidAutoscale once Y1 Axis and disable auto scalevoidAutoscale once Y2 Axis and disable auto scaleString[]voidEnter zoom mode.voidexitZoom()Exit zoom mode.intRemove points that exceed displayDuration.Gets the chart background (curve area)Build a configuration string that can be write into a file and is compatible with CfFileReader.doubleGets the display duration.Gets the current headerGets the header fontintReturns the current label placement.Gets the current margindoubleGets the maximum allowed for a display durationUsed with saveDataFile().intReturns the allowed margin to make a projection on a line on data show (default: 0).protected JMenuItemgetUserActionMenuItem(String actionName) getXAxis()Return a handle to the x axisReturn a handle to the left y axisReturn a handle to the right y axisbooleanstatic booleanisInRange(double x, int NB) booleanDetermines wether labels are visivle or not.booleanReturn painting order between axis and curvebooleantells weather x Axis is on bottom of screen or notbooleanisZoomed()Determines wether the graph is zoomed.voidloadDataFile(String fileName) Loads a data file and add the corresponding data to Y1 axisstatic voidvoidvoidvoidvoidvoidvoidvoidvoidvoidPaint the components.voidPrints out this graph.voidvoidremoveDataView(JLDataView view) voidRemove the specified JLChartAction ListenervoidremoveMenuItem(int menu) Method to remove item of the contextual menu.voidremoveUserAction(String name) Removes a user action from chart menu.voidreset()voidreset(boolean showConfirmDialog) voidvoidSets the chart background (curve area)voidsetDisplayDuration(double v) Sets the display duration.This will garbage old data in all displayed data views.voidsetFrameParent(JFrame parent) Sets the JFrame that will receive the header as title.voidSets the header and displays it.voidSets the header colorvoidSets header fontvoidsetHeaderVisible(boolean b) Displays or hides header.voidSet the specified JLChart ListenervoidsetLabelFont(Font f) Sets the label fontvoidsetLabelPlacement(int p) Set the label placement.voidsetLabelVisible(boolean b) Displays or hide labels.voidSets component marginvoidsetMaxDisplayDuration(double maxDisplayDuration) Sets the maximum allowed for a display durationvoidsetNoValueString(String noValueString) Used with saveDataFile().voidsetPaintAxisFirst(boolean b) Paints axis under curve when truevoidsetParentForTableDialog(Dialog parent) Sets the parent that the "show table" dialog should have (in case you chose to have a dialog)voidsetParentForTableDialog(Frame parent) Sets the parent that the "show table" dialog should have (in case you chose to have a dialog)voidsetPreferDialogForTable(boolean preferDialog, boolean modal) Sets if you prefer to use a JDialog with showTableXXX() methods instead of the classic JFramevoidsetTimePrecision(int milliseconds) Sets the allowed margin to make a projection on a line on data show.voidsetXAxisOnBottom(boolean b) Sets weather x Axis is on bottom of screen or notvoidDisplay the data view option dialog.voidDisplay the global graph option dialog.voidshowPanel(Graphics g, SearchInfo si) Display the value tooltip.voidshowPanel(Graphics g, SearchInfo si, MouseEvent scrEvent) protected voidprotected voidprotected voidshowTableAll(Vector<JLDataView> views) voidRemove all dataview from the graph.Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
LABEL_DOWN
public static final int LABEL_DOWNPlace label at the bottom of the chart- See Also:
-
LABEL_UP
public static final int LABEL_UPPlace label at the top of the chart- See Also:
-
LABEL_RIGHT
public static final int LABEL_RIGHTPlace label at the right of the chart- See Also:
-
LABEL_LEFT
public static final int LABEL_LEFTPlace label at the left of the chart- See Also:
-
LABEL_ROW
public static final int LABEL_ROWPlace label at the bottom of the chart and try to arrange them in rows- See Also:
-
MENU_CHARTPROP
public static final int MENU_CHARTPROP- See Also:
-
MENU_DVPROP
public static final int MENU_DVPROP- See Also:
-
MENU_TABLE
public static final int MENU_TABLE- See Also:
-
MENU_DATASAVE
public static final int MENU_DATASAVE- See Also:
-
MENU_PRINT
public static final int MENU_PRINT- See Also:
-
MENU_STAT
public static final int MENU_STAT- See Also:
-
MENU_DATALOAD
public static final int MENU_DATALOAD- See Also:
-
US_DATE_FORMAT
- See Also:
-
FR_DATE_FORMAT
- See Also:
-
labelRect
-
maxDisplayDuration
protected double maxDisplayDuration -
chartMenu
-
preferDialog
protected boolean preferDialog -
modalDialog
protected boolean modalDialog -
tableDialog
-
dialogParent
-
parentFrame
-
lastSnapshotLocation
-
lastDataFileLocation
-
lastFileFilter
-
noValueString
-
-
Constructor Details
-
JLChart
public JLChart()Graph constructor.
-
-
Method Details
-
getXAxis
Return a handle to the x axis- Returns:
- Axis handle
-
getY1Axis
Return a handle to the left y axis- Returns:
- Axis handle
-
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
Sets header font- Parameters:
f- Header font- See Also:
-
getHeaderFont
Gets the header font- Returns:
- Header font
- See Also:
-
setMargin
Sets component margin- Parameters:
d- Margin- See Also:
-
getMargin
Gets the current margin- Returns:
- Margin
- See Also:
-
setBackground
- Overrides:
setBackgroundin classJComponent
-
setChartBackground
Sets the chart background (curve area)- Parameters:
c- Background 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
Sets the header and displays it.- Parameters:
s- Graph header- See Also:
-
getHeader
Gets the current header- Returns:
- Graph header
- See Also:
-
setFrameParent
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
Sets the header color- Parameters:
c- Header 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
Sets the label font- Parameters:
f- Label font
-
getLabelFont
- Returns:
- the label font
- See Also:
-
showOptionDialog
public void showOptionDialog()Display the global graph option dialog. -
showDataOptionDialog
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
Set the specified JLChart Listener- Parameters:
l- JLChart listener. If set to null the listener will be removed.
-
addUserAction
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
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
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
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
Remove the specified JLChartAction Listener- Parameters:
l- Listener to remove
-
applyConfiguration
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
Build a configuration string that can be write into a file and is compatible with CfFileReader.- Returns:
- A string containing param.
- See Also:
-
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
Loads a data file and add the corresponding data to Y1 axis- Parameters:
fileName- the full path of the data file
-
refreshTableSingle
-
showTableAll
-
showTableAll
protected void showTableAll() -
showStatAll
protected void showStatAll() -
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
paint
Paint the components. Use the repaint method to repaint the graph.- Overrides:
paintin classJComponent- Parameters:
g- Graphics object.
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
buildPanelString
-
showPanel
Display the value tooltip.- Parameters:
g- Graphics objectsi- SearchInfo structure.- See Also:
-
showPanel
-
garbageData
Remove points that exceed displayDuration.- Parameters:
v- DataView containing points- Returns:
- Number of deleted points
-
addData
Add data to dataview , perform fast update when possible and garbage old data (if a display duration is specified).- Parameters:
v- The dataviewx- 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
Used with saveDataFile(). Returns the String used to represent "no data" (default : "").- Returns:
- The String used to represent "no data"
-
setNoValueString
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 notmodal- The dialog should be modal or not
-
setParentForTableDialog
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
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
-
reset
public void reset() -
reset
public void reset(boolean showConfirmDialog) -
getUserActionMenuItem
-
isInRange
public static boolean isInRange(double x, int NB) -
main
-