|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Canvas multigraph.DoubleBufferedCanvas multigraph.Plotter
A Plotter
is a DoubleBufferedCanvas
that
has the following additional functionality:
PlotPoint
objects
in addition to the usual Graphics
object drawing
methods.
PlotFrame
objects representing
nested coordinate systems in the canvas:
devicePixelFrame
is the system cooresponding to
raw device pixel coordinates --- in which (0,0)
is the upper left corner
pixelFrame
is the same as devicePixelFrame
except
that (0,0) is at the lower left corner and y increases
upward across the canvas
marginFrame
defines a rectangle set inside pixelFrame
by given top, bottom, left, and right margin amounts.
The default margin amounts are hardcoded but these may
be changed by calling setMargins()
. marginFrame
coordinates are in terms of pixels
(i.e. a 1x1 box in the marginFrame
system is
exactly one pixel), but marginFrame
is
offset so that (0,0) is inset from the lower left
corner of pixelFrame
by (leftMargin
,bottomMargin
).
Plotter
* methods).
paint
method that erases the background to white
and draws a light grey rectangle around the marginFrame
. Subclasses
can override this method to provide more specific rendering.
PlotFrame
,
PlotPoint
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.awt.Canvas |
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
protected int |
bottomMargin
The bottom margin amount, in pixels. |
protected PlotFrame |
devicePixelFrame
A PlotFrame representing pixel coordinates for this canvas. |
protected int |
lastMouseX
The x coordinate [in devicePixelFrame space] of the last mouse event |
protected int |
lastMouseY
The y coordinate [in devicePixelFrame space] of the last mouse event |
protected int |
leftMargin
The left margin amount, in pixels. |
protected PlotFrame |
marginFrame
A PlotFrame defining a rectangle set inside pixelFrame by given top, bottom, left, and right margin
amounts. |
protected int |
mouseBaseX
The x coordinate [in devicePixelFrame space] of the last mousePressed
event. |
protected int |
mouseBaseY
The x coordinate [in devicePixelFrame space] of the last mousePressed
event. |
protected PlotFrame |
pixelFrame
A PlotFrame whose coordinates are the same as for devicePixelFrame
except that the y axis is inverted: (0,0) is the lower left corner. |
protected int |
rightMargin
The right margin amount, in pixels. |
protected int |
topMargin
The top margin amount, in pixels. |
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 | |
Plotter(int pixelWidth,
int pixelHeight)
Create a new plotter object having the given width and height, in pixels. |
Method Summary | |
void |
drawLine(java.awt.Graphics g,
PlotPoint p1,
PlotPoint p2)
Draw a line connecting two points. |
void |
drawRect(java.awt.Graphics g,
PlotPoint upperLeft,
double width,
double height)
Draw a rectangle specified by its upper left corner, and width and height (in pixels, but specified as doubles). |
void |
drawRect(java.awt.Graphics g,
PlotPoint upperLeft,
int width,
int height)
Draw a rectangle specified by its upper left corner, and width and height (in pixels). |
void |
drawRect(java.awt.Graphics g,
PlotPoint lowerLeft,
PlotPoint upperRight)
Draw a rectangle specified by its lower left and upper right corners. |
void |
drawString(java.awt.Graphics g,
PlotPoint base,
java.lang.String label)
Draw a string at a given location. |
void |
fillArc(java.awt.Graphics g,
PlotPoint p1,
int width,
int height,
int a1,
int a2)
Draw a filled arc. |
void |
fillCircle(java.awt.Graphics g,
PlotPoint p1,
int radius)
|
void |
fillPolygon(java.awt.Graphics g,
PlotPoint[] vertices)
Draw a filled polygon specified by an array of vertices. |
void |
fillQuad(java.awt.Graphics g,
PlotPoint a,
PlotPoint b,
PlotPoint c,
PlotPoint d)
Draw a filled quadrilateral specified by its 4 vertices. |
void |
fillRect(java.awt.Graphics g,
PlotPoint upperLeft,
double width,
double height)
Draw a filled rectangle specified by its upper left corner, and width and height (in pixels, but specified as doubles). |
void |
fillRect(java.awt.Graphics g,
PlotPoint upperLeft,
int width,
int height)
Draw a filled rectangle specified by its upper left corner, and width and height (in pixels). |
void |
fillRect(java.awt.Graphics g,
PlotPoint lowerLeft,
PlotPoint upperRight)
Draw a filled rectangle specified by its lower left and upper right corners. |
void |
fillRectDefinite(java.awt.Graphics g,
PlotPoint lowerLeft,
PlotPoint upperRight)
Draw a filled rectangle specified by its lower left and upper right corners, rounding the width and height of the rectangle up to 1 pixel if either would otherwise be 0. |
void |
fillRectLLDefinite(java.awt.Graphics g,
PlotPoint lowerLeft,
int width,
int height)
Draw a filled rectangle specified by its lower left corner and width and height in pixels, rounding the width and height of the rectangle up to 1 pixel if either would otherwise be 0. |
PlotFrame |
getPixelFrame()
Returns the pixelFrame for this Plotter object. |
protected void |
keyReleased(int modifiers,
char key)
Process a keyReleased event; the Plotter's
handler calls this whenever a keyReleased event occurs. |
protected void |
keyTyped(int modifiers,
char key)
Process a keyTyped event; the Plotter's
handler calls this whenever a keyTyped event occurs. |
protected void |
mouseDragged(int modifiers,
int x,
int y)
Process a mouseDragged event; the Plotter's
handler calls this whenever a mouseDragged event occurs. |
protected void |
mouseMoved(int modifiers,
int x,
int y)
Process a mouseMoved event; the Plotter's
handler calls this whenever a mouseMoved event occurs. |
protected void |
mousePressed(int modifiers,
int x,
int y)
Process a mousePressed event; the Plotter's
handler calls this whenever a mousePressed event occurs. |
protected void |
mouseReleased(int modifiers,
int x,
int y)
Process a mouseReleased event; the Plotter's
handler calls this whenever a mouseReleased event occurs. |
void |
paint(java.awt.Graphics g)
Erase the background to white (unless renderClear
has been called since the last call to paint ),
and draw a light grey rectangle
around the marginFrame . |
protected void |
renderClear(java.awt.Graphics g)
Erase the background to white. |
void |
setMargins(int leftMargin,
int rightMargin,
int topMargin,
int bottomMargin)
Sets the margins by which marginFrame is inset from
pixelFrame . |
Methods inherited from class multigraph.DoubleBufferedCanvas |
getMaximumSize, getMinimumSize, getPreferredSize, update |
Methods inherited from class java.awt.Canvas |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected PlotFrame devicePixelFrame
PlotFrame
representing pixel coordinates for this canvas.
These coordinates are the same as the coordinates for the underlying
java.awt.Canvas
object; (0,0) is in the upper left corner
and y increases downward across the canvas.
protected PlotFrame pixelFrame
PlotFrame
whose coordinates are the same as for devicePixelFrame
except that the y axis is inverted: (0,0) is the lower left corner.
protected PlotFrame marginFrame
PlotFrame
defining a rectangle set inside pixelFrame
by given top, bottom, left, and right margin
amounts. The default margin amounts are hardcoded but these
may be changed by calling setMargins()
. marginFrame
coordinates are in
terms of pixels (i.e. a 1x1 box in the marginFrame
system is exactly one pixel), but marginFrame
is
offset so that (0,0) is inset from the lower left corner of
pixelFrame
by (leftMargin
,bottomMargin
).
protected int leftMargin
protected int rightMargin
protected int topMargin
protected int bottomMargin
protected int lastMouseX
devicePixelFrame
space] of the last mouse event
protected int lastMouseY
devicePixelFrame
space] of the last mouse event
protected int mouseBaseX
devicePixelFrame
space] of the last mousePressed
event.
protected int mouseBaseY
devicePixelFrame
space] of the last mousePressed
event.
Constructor Detail |
public Plotter(int pixelWidth, int pixelHeight)
Method Detail |
public PlotFrame getPixelFrame()
pixelFrame
for this Plotter
object.
public void setMargins(int leftMargin, int rightMargin, int topMargin, int bottomMargin)
marginFrame
is inset from
pixelFrame
. Margin values are measured in pixels. If
any of the margin values passed in is negative, the
corresponding margin value is left unchanged. Calling
setMargins
causes marginFrame
to be
recomputed in terms of the new settings.
public void paint(java.awt.Graphics g)
renderClear
has been called since the last call to paint
),
and draw a light grey rectangle
around the marginFrame
. Subclasses can override this
method to provide their own rendering.
protected void renderClear(java.awt.Graphics g)
paint
so that subclasses
whose paint
implementation needs to draw
something after the background is cleared but
before the grey marginFrame
rectangle is drawn can do
so by calling renderClear
first, doing whatever intermediate
drawing is needed, and then calling paint
.
public void drawRect(java.awt.Graphics g, PlotPoint upperLeft, int width, int height)
public void drawRect(java.awt.Graphics g, PlotPoint upperLeft, double width, double height)
public void drawRect(java.awt.Graphics g, PlotPoint lowerLeft, PlotPoint upperRight)
public void fillRect(java.awt.Graphics g, PlotPoint upperLeft, int width, int height)
public void fillRect(java.awt.Graphics g, PlotPoint upperLeft, double width, double height)
public void fillRect(java.awt.Graphics g, PlotPoint lowerLeft, PlotPoint upperRight)
public void fillRectDefinite(java.awt.Graphics g, PlotPoint lowerLeft, PlotPoint upperRight)
public void fillRectLLDefinite(java.awt.Graphics g, PlotPoint lowerLeft, int width, int height)
public void fillQuad(java.awt.Graphics g, PlotPoint a, PlotPoint b, PlotPoint c, PlotPoint d)
public void drawLine(java.awt.Graphics g, PlotPoint p1, PlotPoint p2)
public void fillArc(java.awt.Graphics g, PlotPoint p1, int width, int height, int a1, int a2)
public void fillCircle(java.awt.Graphics g, PlotPoint p1, int radius)
public void fillPolygon(java.awt.Graphics g, PlotPoint[] vertices)
public void drawString(java.awt.Graphics g, PlotPoint base, java.lang.String label)
protected void mousePressed(int modifiers, int x, int y)
Plotter's
handler calls this whenever a mousePressed event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()x
- The x coordinate (in devicePixelFrame
space)
of the event.y
- The y coordinate (in devicePixelFrame
space)
of the event.protected void mouseReleased(int modifiers, int x, int y)
Plotter's
handler calls this whenever a mouseReleased event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()x
- The x coordinate (in devicePixelFrame
space)
of the event.y
- The y coordinate (in devicePixelFrame
space)
of the event.protected void mouseMoved(int modifiers, int x, int y)
Plotter's
handler calls this whenever a mouseMoved event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()x
- The x coordinate (in devicePixelFrame
space)
of the event.y
- The y coordinate (in devicePixelFrame
space)
of the event.protected void mouseDragged(int modifiers, int x, int y)
Plotter's
handler calls this whenever a mouseDragged event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()x
- The x coordinate (in devicePixelFrame
space)
of the event.y
- The y coordinate (in devicePixelFrame
space)
of the event.protected void keyTyped(int modifiers, char key)
Plotter's
handler calls this whenever a keyTyped event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()key
- The key that was typed.protected void keyReleased(int modifiers, char key)
Plotter's
handler calls this whenever a keyReleased event occurs.
modifiers
- The event modifier mask returned
by java.awt.event.InputEvent.getModifiers()key
- The key that was released.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |