|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Canvas
|
+--org.PingOO.DLAI.lib.graph.Graph2D
This is the main plotting class.
It partitions the canvas to contain the specified axes with the remaining space taken with the plotting region.
Axes are packed against the walls of the canvas.
The paint and update methods of this class handle all the drawing operations of the graph.
This means that independent components like Axis and DataSets must be registered with this class to be incorporated into the plot.
| Inner Class Summary | |
protected class |
Graph2D.Graph2DKeyListener
|
protected class |
Graph2D.LoadMessage
This is a separate thread that flashes a message on the Graph2D canvas that data is loading |
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
| Field Summary | |
protected java.util.Vector |
axis
A vector list of All the axes attached |
int |
borderBottom
The width of the border at the bottom of the canvas. |
int |
borderLeft
The width of the border at the left of the canvas. |
int |
borderRight
The width of the border at the right of the canvas. |
int |
borderTop
The width of the border at the top of the canvas. |
boolean |
clearAll
If set true (the default) the canvas will be set to the background color (erasing the plot) when the update method is called.
|
protected java.awt.Color |
DataBackground
The background color for the data window |
java.awt.Rectangle |
datarect
The rectangle that the data will be plotted within. |
protected java.util.Vector |
dataset
A vector list of All the DataSets attached |
private java.awt.Color |
DefaultBackground
Default Background Color |
protected java.awt.event.KeyListener |
defaultKeyListener
|
boolean |
drawgrid
If set true (the default) a grid will be drawn over the data window.
|
boolean |
drawzero
If set true (the default) a grid line will be drawn across the data window at the zeros of the innermost axes. |
boolean |
frame
If set true a frame will be drawn around the data window.
|
java.awt.Color |
framecolor
The color of the frame to be drawn |
java.awt.Color |
gridcolor
The color of the grid to be drawn |
TextLine |
lastText
Text to be painted Last onto the Graph Canvas. |
protected Graph2D.LoadMessage |
load_thread
The blinking "data loading" thread |
int |
loadingData
If this is greater than zero it means that data loading threads are active so the message "loading data" is flashed on the plot canvas. |
protected Markers |
markers
The markers that may have been loaded |
boolean |
paintAll
If set true (the default) everything associated with the plot will be drawn when the update method or paint method are called.
|
boolean |
square
Modify the position of the axis and the range of the axis so that the aspect ratio of the major tick marks are 1 and the plot is square on the screen |
java.awt.Color |
zerocolor
The color of the zero grid lines. |
| Fields inherited from class java.awt.Canvas |
base,
graphicsConfig,
nameCounter,
serialVersionUID |
| Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
| Constructor Summary | |
Graph2D()
|
|
| Method Summary | |
void |
attachAxis(Axis a)
Attaches a previously created Axis. |
void |
attachDataSet(DataSet d)
Attaches a DataSet to the graph. |
Axis |
createAxis(int position)
Creates and attaches an Axis to the graph. |
void |
detachAxes()
Detach All attached Axes. |
void |
detachAxis(Axis a)
Detach a previously attached Axis. |
void |
detachDataSet(DataSet d)
Detaches the DataSet from the class. |
void |
detachDataSets()
Detaches All the DataSets from the class. |
protected java.awt.Rectangle |
drawAxis(java.awt.Graphics g,
java.awt.Rectangle r)
Draw the Axis. |
protected void |
drawFrame(java.awt.Graphics g,
int x,
int y,
int width,
int height)
Draws a frame around the data area. |
void |
finishedloading()
Decrement the loading Data counter by one. |
protected java.awt.Rectangle |
ForceSquare(java.awt.Graphics g,
java.awt.Rectangle r)
Forces the plot to have an aspect ratio of 1 by forcing the axes to have the same range. |
protected java.awt.Rectangle |
getDataRectangle(java.awt.Graphics g,
java.awt.Rectangle r)
Calculates the rectangle occupied by the data. |
Markers |
getMarkers()
Get the markers |
double |
getXmax()
Gets the Maximum X value of all attached DataSets. |
double |
getXmin()
Gets the Minimum X value of all attached DataSets. |
double |
getYmax()
Gets the Maximum Y value of all attached DataSets. |
double |
getYmin()
Gets the Minimum Y value of all attached DataSets. |
DataSet |
loadDataSet(double[] data,
int n)
Loads and Attaches a DataSet from an array. |
DataSet |
loadFile(java.net.URL file)
Loads and Attaches a DataSet from a File. |
void |
loadmessage(java.lang.String s)
Change the message to be flashed on the canvas |
void |
paint(java.awt.Graphics g)
This paints the entire plot. |
void |
paintBeforeData(java.awt.Graphics g,
java.awt.Rectangle r)
A hook into the Graph2D.paint method. |
void |
paintFirst(java.awt.Graphics g,
java.awt.Rectangle r)
A hook into the Graph2D.paint method. |
void |
paintLast(java.awt.Graphics g,
java.awt.Rectangle r)
A hook into the Graph2D.paint method. |
void |
setDataBackground(java.awt.Color c)
Sets the background color for the data window. |
void |
setGraphBackground(java.awt.Color c)
Sets the background color for the entire canvas. |
void |
setMarkers(Markers m)
Set the markers for the plot. |
void |
startedloading()
Calling this method pauses the plot and displays a flashing message on the screen. |
void |
update(java.awt.Graphics g)
This method is called via the Graph2D.repaint() method. |
| Methods inherited from class java.awt.Canvas |
|
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
deliverEvent,
disable,
disableEvents,
dispatchEvent,
dispatchEventImpl,
doLayout,
enable,
enable,
enableEvents,
enableInputMethods,
eventEnabled,
firePropertyChange,
getAlignmentX,
getAlignmentY,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentAt,
getComponentAt,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getMaximumSize,
getMinimumSize,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getPreferredSize,
getSize,
getSize,
getToolkit,
getToolkitImpl,
getTreeLock,
getWidth,
getWindowForObject,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
initIDs,
inside,
invalidate,
isDisplayable,
isDoubleBuffered,
isEnabled,
isEnabledImpl,
isFocusTraversable,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
layout,
lightweightPrint,
list,
list,
list,
list,
list,
locate,
location,
lostFocus,
minimumSize,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
paramString,
postEvent,
preferredSize,
prepareImage,
prepareImage,
print,
printAll,
processComponentEvent,
processEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
readObject,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removeNotify,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setFont,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus,
validate,
writeObject |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
| Field Detail |
private java.awt.Color DefaultBackground
protected java.util.Vector axis
org.PingOO.DLAI.lib.graph.Graph2d#attachAxisprotected java.util.Vector dataset
org.PingOO.DLAI.lib.graph.Graph2d#attachDataSet,
DataSetprotected Markers markers
setMarkers(org.PingOO.DLAI.lib.graph.Markers)protected Graph2D.LoadMessage load_thread
startedloading()protected java.awt.Color DataBackground
public int loadingData
public int borderTop
public int borderBottom
public int borderLeft
public int borderRight
public boolean frame
true a frame will be drawn around the data window.
Any axes will overlay this frame.public java.awt.Color framecolor
public boolean drawgrid
true (the default) a grid will be drawn over the data window.
public java.awt.Color gridcolor
public boolean drawzero
true (the default) a grid line will be drawn across the data window at the zeros of the innermost axes.public java.awt.Color zerocolor
public java.awt.Rectangle datarect
public boolean clearAll
true (the default) the canvas will be set to the background color (erasing the plot) when the update method is called.
public boolean paintAll
true (the default) everything associated with the plot will be drawn when the update method or paint method are called.
public boolean square
public TextLine lastText
protected java.awt.event.KeyListener defaultKeyListener
| Constructor Detail |
public Graph2D()
| Method Detail |
public DataSet loadFile(java.net.URL file)
The data is assumed to consist (at this stage) 2 ASCII columns of numbers x, y.
As always blank lines are ignored and everything following # is ignored as a comment.
file - The URL of the data file to read.
public DataSet loadDataSet(double[] data,
int n)
The data is assumed to be stored in the form x, y, x, y, x, y, ...
A local copy of the data is made.
data - The data to be loaded in the form x, y, x, y, ...n - The number of (x,y) data points. This means that the minimum length of the data array is 2*n.public void attachDataSet(DataSet d)
public void detachDataSet(DataSet d)
d - The DataSet to detach.public void detachDataSets()
public Axis createAxis(int position)
Axis.TOP, Axis.BOTTOM, Axis.LEFT or Axis.RIGHT.position - Position of the axis in the drawing window.public void attachAxis(Axis a)
the - Axis to attach.public void detachAxis(Axis a)
the - Axis to dettach.public void detachAxes()
public double getXmax()
public double getYmax()
public double getXmin()
public double getYmin()
public void setMarkers(Markers m)
m - Marker class containing the defined markersMarkerspublic Markers getMarkers()
Markerspublic void setGraphBackground(java.awt.Color c)
c - The color to set the canvaspublic void setDataBackground(java.awt.Color c)
c - The color to set the data window.public void paint(java.awt.Graphics g)
g - Graphics state.
public void paintFirst(java.awt.Graphics g,
java.awt.Rectangle r)
g - Graphics stater - Rectangle containing the graph
public void paintBeforeData(java.awt.Graphics g,
java.awt.Rectangle r)
g - Graphics stater - Rectangle containing the data
public void paintLast(java.awt.Graphics g,
java.awt.Rectangle r)
g - Graphics stater - Rectangle containing the datapublic void update(java.awt.Graphics g)
public void startedloading()
finishedloading(),
loadmessage(java.lang.String),
Graph2D.LoadMessagepublic void finishedloading()
startedloading(),
loadmessage(java.lang.String),
Graph2D.LoadMessagepublic void loadmessage(java.lang.String s)
s - String contining the new message.startedloading(),
finishedloading(),
Graph2D.LoadMessage
protected java.awt.Rectangle ForceSquare(java.awt.Graphics g,
java.awt.Rectangle r)
g - r -
protected java.awt.Rectangle getDataRectangle(java.awt.Graphics g,
java.awt.Rectangle r)
protected java.awt.Rectangle drawAxis(java.awt.Graphics g,
java.awt.Rectangle r)
protected void drawFrame(java.awt.Graphics g,
int x,
int y,
int width,
int height)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||