|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--iglu.polka.PLineGraph
Draw 2D data sets. These sets are implemented by GraphData2D. This graph adds itself as a data change listener on all added data sets and redraws itself whenever some of its data is changed. Various options for controlling appearance are included, but many more could be added.
GraphData2D
,
Serialized FormField Summary | |
private double |
closestDistance
distance to the closes point from the mouse |
private OrderedPoint2D |
closestPoint
the closes point if it's turned on |
private boolean |
drawAxes
Should be axes be drawn. |
private java.awt.Color |
graphcolor
Color of the graph |
private boolean |
highlightClosest
|
private double |
highX
High end of the X range. |
private double |
highY
High end of the y range. |
(package private) java.awt.Insets |
insets
The spaces around the edge of the JLabel where we can't draw. |
private java.util.LinkedList |
lines
The lines in the graph. |
private double |
lowX
Low end of the X range. |
private double |
lowY
The low end of the Y range. |
private double |
pixelDist
|
private boolean |
pointTracking
|
(package private) double |
xScale
How to transform the x points to pixel values. |
(package private) double |
yScale
How to transform the y values to pixel values. |
Fields inherited from class javax.swing.JPanel |
|
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
PLineGraph(double lowX,
double highX,
double lowY,
double highY)
Creates new PLineGraph |
Method Summary | |
void |
addLine(GraphData2D gd)
add a new line to the graph. |
void |
clearLines()
Erase all the points and their labels. |
protected OrderedPoint2D |
closestScreenPoint(GraphData2D gd,
int x,
int y)
|
private int |
drawableX(double x)
Change a point X value to a pixel X value. |
private int |
drawableY(double y)
Change a point Y value to a pixel Y value. |
void |
enableHighlightClosestPoint()
|
void |
enablePointTracking(double nPixelDist)
install the listeners so that the graph keeps track of the closest point to the mouse, and its distance |
double |
getClosestDistance()
|
OrderedPoint2D |
getClosestPoint()
|
java.awt.Color |
getColor()
Get the background color |
static void |
main(java.lang.String[] argv)
Draws a simple three point graph. |
void |
paint(java.awt.Graphics g)
Draws the graph. |
protected void |
paintALine(GraphData2D gd,
java.awt.Graphics g)
Draws one dataset. |
void |
removeLine(GraphData2D gd)
|
void |
setColor(java.awt.Color nc)
Set the background color |
void |
setDomain(double lowX,
double highX)
Set the X values for the graph. |
void |
setDrawAxes(boolean drawAxes)
Sets whether the axes are drawn. |
void |
setRange(double lowY,
double highY)
Set the Y values for the graph. |
double |
virtualX(int x)
Returns the virtual value of X, given a drawable X |
double |
virtualY(int y)
Returns the virtual value of Y, given a drawable Y |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private double lowY
private double highY
private double lowX
private double highX
private boolean drawAxes
private java.awt.Color graphcolor
private java.util.LinkedList lines
private OrderedPoint2D closestPoint
private double closestDistance
private boolean pointTracking
private boolean highlightClosest
private double pixelDist
java.awt.Insets insets
double xScale
double yScale
Constructor Detail |
public PLineGraph(double lowX, double highX, double lowY, double highY)
lowX
- highX
- lowY
- highY
- Method Detail |
public void setColor(java.awt.Color nc)
public java.awt.Color getColor()
public void setRange(double lowY, double highY)
lowY
- highY
- public void setDomain(double lowX, double highX)
lowX
- highX
- public void clearLines()
public void removeLine(GraphData2D gd)
public void addLine(GraphData2D gd)
gd
- public void setDrawAxes(boolean drawAxes)
drawAxes
- public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
g
- protected void paintALine(GraphData2D gd, java.awt.Graphics g)
gd
- g
- private int drawableX(double x)
x
- public double virtualX(int x)
private int drawableY(double y)
y
- public double virtualY(int y)
public void enablePointTracking(double nPixelDist)
public void enableHighlightClosestPoint()
protected OrderedPoint2D closestScreenPoint(GraphData2D gd, int x, int y)
public OrderedPoint2D getClosestPoint()
public double getClosestDistance()
public static void main(java.lang.String[] argv)
argv
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |