public class Graph
extends javax.swing.JPanel
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Graph(java.lang.String title,
java.awt.Color backgroundColour,
java.awt.Color foregroundColour,
double minX,
double maxX,
double minY,
double maxY,
double minXLimit,
double maxXLimit,
double minYLimit,
double maxYLimit,
boolean mobileX,
boolean mobileY,
java.lang.String xAxisLabel,
java.lang.String yAxisLabel)
Full constructor for the graph.
|
Graph(java.lang.String title,
double minX,
double maxX,
double minY,
double maxY,
double minXLimit,
double maxXLimit,
double minYLimit,
double maxYLimit,
boolean mobileX,
boolean mobileY,
java.lang.String xAxisLabel,
java.lang.String yAxisLabel)
Constructor for graphg - using default background and foregrounds values.
|
Modifier and Type | Method and Description |
---|---|
void |
addSeries(GraphSeries graphSeries)
Adds a series to the graph.
|
double |
getMaxX()
Gets the maximum X value currently being shown on the graph.
|
double |
getMinX()
Gets the minimum X value currently being shown on the graph.
|
java.util.ArrayList<GraphSeries> |
getSeries()
Gets the list of series for this graph.
|
java.lang.String |
getTitle()
Gets the title being used for this graph.
|
java.lang.String |
getxAxisLabel()
Gets the X-axis label being used on this graph.
|
java.lang.String |
getyAxisLabel()
Gets the Y-axis label being used on this graph.
|
void |
initialise(java.lang.String title,
java.awt.Color backgroundColour,
java.awt.Color foregroundColour,
double minX,
double maxX,
double minY,
double maxY,
double minXLimit,
double maxXLimit,
double minYLimit,
double maxYLimit,
boolean mobileX,
boolean mobileY,
java.lang.String xAxisLabel,
java.lang.String yAxisLabel)
Initialise the graphs.
|
void |
makePointVisibleOnScreen(Point2D p)
Make the specified point visible on the graph.
|
void |
paintComponent(java.awt.Graphics g)
Main paint method.
|
void |
resetToBestSize()
Reset the size so the points fit in the graph to the edge.
|
void |
setForegroundColour(java.awt.Color foregroundColour)
Sets the foreground colour (axis and label colour).
|
void |
setMaxX(double maxX)
Set the current maximum X-axis value to be displayed.
|
void |
setMaxXLimit(double maxXLimit)
Set the limit of the maximum value to be shown on the X-axis.
|
void |
setMaxY(double maxY)
Set the current maximum Y-axis value to be displayed.
|
void |
setMaxYLimit(double maxYLimit)
Set the limit of the maximum value to be shown on the Y-axis.
|
void |
setMinX(double minX)
Set the current minimum X-axis value to be displayed.
|
void |
setMinXLimit(double minXLimit)
Set the limit of the minimum value to be shown on the X-axis.
|
void |
setMinY(double minY)
Set the current minimum Y-axis value to be displayed.
|
void |
setMinYLimit(double minYLimit)
Set the limit of the minimum value to be shown on the Y-axis.
|
void |
setMobileX(boolean mobileX)
Set the flag allowing the user to pan and zoom the X-axis.
|
void |
setMobileY(boolean mobileY)
Set the flag allowing the user to pan and zoom the Y-axis.
|
void |
setTitle(java.lang.String title)
Set the graph title.
|
void |
setXAxisLabel(java.lang.String xAxisLabel)
Set the X-axis label.
|
void |
setYAxisLabel(java.lang.String yAxisLabel)
Set the Y-axis label.
|
Point2D |
translate(Point2D xy,
boolean allowOffLimit)
Translate a XY position into screen coordinates.
|
Point2D |
untranslate(Point2D xy,
boolean allowOffLimit)
Untranslate a screen coordinate back to its X/Y value.
|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getPeer, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public Graph(java.lang.String title, double minX, double maxX, double minY, double maxY, double minXLimit, double maxXLimit, double minYLimit, double maxYLimit, boolean mobileX, boolean mobileY, java.lang.String xAxisLabel, java.lang.String yAxisLabel)
title
- The title of the graph.minX
- The initial minimum X value.maxX
- The initial maximum X value.minY
- The initial minimum Y value.maxY
- The initial maximum Y value.minXLimit
- The minimum limit of the X-axis range.maxXLimit
- The maximum limit of the X-axis range.minYLimit
- The minimum limit of the Y-axis range.maxYLimit
- The maximum limit of the Y-axis range.mobileX
- Whether the user should be able to pan and zoom on the X-axis.mobileY
- Whether the user should be able to pan and zoom on the Y-axis.xAxisLabel
- The label for the X-axis.yAxisLabel
- The label for the Y-axis.public Graph(java.lang.String title, java.awt.Color backgroundColour, java.awt.Color foregroundColour, double minX, double maxX, double minY, double maxY, double minXLimit, double maxXLimit, double minYLimit, double maxYLimit, boolean mobileX, boolean mobileY, java.lang.String xAxisLabel, java.lang.String yAxisLabel)
title
- The title of the graph.backgroundColour
- Colour for the background area.foregroundColour
- Colour for the foreground (axis and labels).minX
- The initial minimum X value.maxX
- The initial maximum X value.minY
- The initial minimum Y value.maxY
- The initial maximum Y value.minXLimit
- The minimum limit of the X-axis range.maxXLimit
- The maximum limit of the X-axis range.minYLimit
- The minimum limit of the Y-axis range.maxYLimit
- The maximum limit of the Y-axis range.mobileX
- Whether the user should be able to pan and zoom on the X-axis.mobileY
- Whether the user should be able to pan and zoom on the Y-axis.xAxisLabel
- The label for the X-axis.yAxisLabel
- The label for the Y-axis.public void initialise(java.lang.String title, java.awt.Color backgroundColour, java.awt.Color foregroundColour, double minX, double maxX, double minY, double maxY, double minXLimit, double maxXLimit, double minYLimit, double maxYLimit, boolean mobileX, boolean mobileY, java.lang.String xAxisLabel, java.lang.String yAxisLabel)
title
- The title of the graph.backgroundColour
- Colour for the background area.foregroundColour
- Colour for the foreground (axis and labels).minX
- The initial minimum X value.maxX
- The initial maximum X value.minY
- The initial minimum Y value.maxY
- The initial maximum Y value.minXLimit
- The minimum limit of the X-axis range.maxXLimit
- The maximum limit of the X-axis range.minYLimit
- The minimum limit of the Y-axis range.maxYLimit
- The maximum limit of the Y-axis range.mobileX
- Whether the user should be able to pan and zoom on the X-axis.mobileY
- Whether the user should be able to pan and zoom on the Y-axis.xAxisLabel
- The label for the X-axis.yAxisLabel
- The label for the Y-axis.public void addSeries(GraphSeries graphSeries)
graphSeries
- public void makePointVisibleOnScreen(Point2D p)
p
- public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public Point2D translate(Point2D xy, boolean allowOffLimit)
xy
- allowOffLimit
- public Point2D untranslate(Point2D xy, boolean allowOffLimit)
xy
- allowOffLimit
- public void setXAxisLabel(java.lang.String xAxisLabel)
xAxisLabel
- public void setYAxisLabel(java.lang.String yAxisLabel)
yAxisLabel
- public void setTitle(java.lang.String title)
title
- public void setMinX(double minX)
minX
- public void setMaxX(double maxX)
maxX
- public void setMinY(double minY)
maxX
- public void setMaxY(double maxY)
maxX
- public void setMinXLimit(double minXLimit)
minXLimit
- public void setMaxXLimit(double maxXLimit)
minXLimit
- public void setMinYLimit(double minYLimit)
minXLimit
- public void setMaxYLimit(double maxYLimit)
minXLimit
- public void setMobileX(boolean mobileX)
mobileX
- public void setMobileY(boolean mobileY)
mobileY
- public java.util.ArrayList<GraphSeries> getSeries()
public java.lang.String getxAxisLabel()
public java.lang.String getyAxisLabel()
public java.lang.String getTitle()
public void setForegroundColour(java.awt.Color foregroundColour)
foregroundColour
- public double getMinX()
public double getMaxX()
public void resetToBestSize()