public class ChartPanel
extends javax.swing.JPanel
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 |
---|
ChartPanel(ChartOwner chartOwner,
java.lang.String name,
java.lang.String x_label,
java.lang.String y_label)
Constructor of the chart panel.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Event handler for the items in the context menu.
|
void |
addLegend(java.lang.String text)
Adds a new legend item at the bottom of the panel in a new color.
|
static java.awt.Color |
color(int i)
Returns the colors used to draw charts.
|
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)
Paints the panel and all of its components.
|
void |
processMouseEvent(java.awt.event.MouseEvent e)
Event handler for right-mouse-clicks onto the chart.
|
void |
redrawChart()
Forces the chart to repaint.
|
void |
saveAs(java.lang.String title)
Saves the chart (including title and legend) as an image file.
|
void |
scale()
Rescales the size of the header font.
|
void |
set_xlabel(java.lang.String x_label)
Resets the legend (labeling) for the x axis.
|
void |
set_ylabel(java.lang.String y_label)
Resets the legend (labeling) for the y axis.
|
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.
|
boolean |
testValue(double x,
double y)
Tests a new pair of values which appears in the data.
|
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, 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 ChartPanel(ChartOwner chartOwner, java.lang.String name, java.lang.String x_label, java.lang.String y_label)
chartOwner
- The object which implements the drawChart() method.name
- Title of the chart.x_label
- The labeling for the x axis.y_label
- The labeling for the y axis.public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
public void scale()
public void redrawChart()
public void addLegend(java.lang.String text)
text
- The labeling of the legend item.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_x(double max_x)
max_x
- The maximum x value which appears in the data.public void setMax_y(double max_y)
max_y
- The maximum y 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 set_xlabel(java.lang.String x_label)
x_label
- A new title for the x axis.public void set_ylabel(java.lang.String y_label)
y_label
- A new title for the y axis.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 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
public void saveAs(java.lang.String title)
title
- public static java.awt.Color color(int i)
i
- The index number of the color you want.