public class Chart
extends javax.swing.JComponent
implements java.awt.event.ActionListener
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Chart(ChartOwner chartOwner,
java.lang.String x_label,
java.lang.String y_label)
Constructor of the chart.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Event handler for this class.
|
int |
calculateXPosition(double x)
Calculates the x coordinate in pixels for the given x data value.
|
int |
calculateYPosition(double y)
Calculates the y coordinate in pixels for the given y data value.
|
void |
drawLine(java.awt.Color color,
double x1,
double y1,
double x2,
double y2)
Draws a line into the chart.
|
void |
drawLine(java.awt.Graphics g,
double x1,
double y1,
double x2,
double y2)
Draws a line into the chart.
|
void |
drawRect(java.awt.Graphics g,
double x1,
double y1,
double x2,
double y2)
Draws an unfilled rectangle into the chart.
|
void |
fillRect(java.awt.Graphics g,
double x1,
double y1,
double x2,
double y2)
Draws a filled rectangle into the chart.
|
void |
paint(java.awt.Graphics g)
This method is called automatically if the canvas has to be repaint.
|
void |
paintBackground(java.awt.Graphics g)
Draws the chart basics.
|
void |
processMouseEvent(java.awt.event.MouseEvent e)
Event handler for right-mouse-clicks onto the chart.
|
void |
setMax_x(double max_x)
Sets the maximum x value which appears in the data.
|
void |
setMax_y(double max_y)
Sets the maximum y value which appears in the data.
|
void |
setMin_x(double min_x)
Sets the minimum x value which appears in the data.
|
void |
setMin_y(double min_y)
Sets the minimum y value which appears in the data.
|
void |
setX_label(java.lang.String x_label)
Resets the legend (labeling) for the x axis.
|
void |
setY_label(java.lang.String y_label)
Resets the legend (labeling) for the y axis.
|
boolean |
testValue(double x,
double y)
Tests a new pair of values which appears in the data.
|
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateUI
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, 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, 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 Chart(ChartOwner chartOwner, java.lang.String x_label, java.lang.String y_label)
chartOwner
- The object which implements the drawChart() method.x_label
- The legend for the x axis.y_label
- The legend for the y axis.public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
g
- The specified Graphics context.public void paintBackground(java.awt.Graphics g)
g
- The specified Graphics context.public int calculateXPosition(double x)
x
- The x data value.public int calculateYPosition(double y)
y
- The y data value.public void drawLine(java.awt.Graphics g, double x1, double y1, double x2, double y2)
g
- The specified Graphics context.x1
- The x value of the starting coordinates.y1
- The y value of the starting coordinates.x2
- The x value of the ending coordinates.y2
- The x value of the ending coordinates.public void drawRect(java.awt.Graphics g, double x1, double y1, double x2, double y2)
g
- The specified Graphics context.x1
- The x value of the starting coordinates.y1
- The y value of the starting coordinates.x2
- The x value of the ending coordinates.y2
- The x value of the ending coordinates.public void fillRect(java.awt.Graphics g, double x1, double y1, double x2, double y2)
g
- The specified Graphics context.x1
- The x value of the starting coordinates.y1
- The y value of the starting coordinates.x2
- The x value of the ending coordinates.y2
- The x value of the ending coordinates.public void drawLine(java.awt.Color color, double x1, double y1, double x2, double y2)
color
- The color of the line.x1
- The x value of the starting coordinates.y1
- The y value of the starting coordinates.x2
- The x value of the ending coordinates.y2
- The x value of the ending coordinates.public boolean testValue(double x, double y)
x
- A new x value which shall be tested, if it is the new minmum or maximum.y
- A new y value which shall be tested, if it is the new minmum or maximum.public void setMax_y(double max_y)
max_y
- The maximum y value which appears in the data.public void setMax_x(double max_x)
max_x
- The maximum x value which appears in the data.public void setMin_x(double min_x)
min_x
- The minimum x value which appears in the data.public void setMin_y(double min_y)
min_y
- The minimum y value which appears in the data.public void setX_label(java.lang.String x_label)
x_label
- A new title for the x axis.public void setY_label(java.lang.String y_label)
y_label
- A new title for the y axis.public void processMouseEvent(java.awt.event.MouseEvent e)
processMouseEvent
in class javax.swing.JComponent
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener