|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Canvas
com.singularsys.jepexamples.applets.AbstractCanvas
public abstract class AbstractCanvas
An abstract base class providing scaling and double buffering support for Canvas components. Scaling is such that the position of the origin on the screen does not change. Has methods for clearing background, painting axis, grid, scales and elapse time.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Canvas |
|---|
java.awt.Canvas.AccessibleAWTCanvas |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected java.awt.Color |
axisColor
Color for axis |
protected java.awt.Color |
bgColor
Color for background |
protected double |
cenX
|
protected double |
cenY
|
protected int |
defaultOffX
|
protected int |
defaultOffY
|
protected double |
defaultScaleX
Default scale values, set in constructor used in reset |
protected double |
defaultScaleY
Default scale values, set in constructor used in reset |
protected java.awt.Dimension |
dimensions
Dimensions of the canvas |
protected java.awt.Color |
gridColor
Color for grid |
protected java.awt.Color |
labelColor
Color for labels |
protected java.awt.Font |
labelFont
|
protected java.awt.Point |
lastpos
|
protected int |
offX
Offset of the graph in absolute coords |
protected int |
offY
Offset of the graph in absolute coords |
protected java.awt.PopupMenu |
popup
A popup menu |
protected java.awt.Font |
scaleFont
|
protected double |
scaleX
Scaling of the graph in x and y directions |
protected double |
scaleY
Scaling of the graph in x and y directions |
protected boolean |
showGrid
Whether to show calculation times |
protected boolean |
showScale
Whether to show scales |
protected boolean |
showTime
Whether to show calculation times |
protected java.awt.image.BufferStrategy |
strategy
BufferStratergy to use |
| 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 | |
|---|---|
AbstractCanvas()
Constructor using 1 for scaling and 0 for offset. |
|
AbstractCanvas(double sx,
double sy,
int offx,
int offy)
Constructor specifying the default values for scaling and offset. |
|
| Method Summary | |
|---|---|
protected void |
center()
|
protected int |
clipX(int xAbsolute)
Clip screen X values to lie within screen |
protected int |
clipY(int yAbsolute)
Clip screen Y values to lie within screen |
void |
componentHidden(java.awt.event.ComponentEvent e)
|
void |
componentMoved(java.awt.event.ComponentEvent e)
|
void |
componentResized(java.awt.event.ComponentEvent e)
|
void |
componentShown(java.awt.event.ComponentEvent e)
|
abstract void |
dump()
Dump textual representation to System.out |
int |
getOffX()
|
int |
getOffY()
|
java.awt.PopupMenu |
getPopup()
A pop-up menu which subclasses can add items to. |
double |
getScaleX()
|
double |
getScaleY()
|
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
|
void |
paint(java.awt.Graphics g)
Provides double buffering support and calls paintCanvas. |
protected void |
paintAxes(java.awt.Graphics g)
Paints the axes for the graph. |
protected void |
paintCanvas(java.awt.Graphics g)
Paint the canvas. |
protected abstract void |
paintCurve(java.awt.Graphics g)
Paint the curve |
protected void |
paintGrid(java.awt.Graphics g)
|
protected void |
paintScale(java.awt.Graphics g)
|
protected void |
paintTime(java.awt.Graphics g,
long t1,
long t2)
Paints the elapse time |
protected void |
paintWhite(java.awt.Graphics g)
Fills the background with white. |
protected void |
rescaled()
Called when scale, or offset changed Default action is to call repaint |
void |
reset()
|
void |
resetCanvas()
|
protected void |
resized()
Called when canvas sized changes Default action is to call repaint |
void |
setOffset(int offX,
int offY)
|
void |
setScale(double scX,
double scY)
|
void |
shiftCanvas(int xdiff,
int ydiff)
|
void |
update(java.awt.Graphics g)
Just calls paint. |
protected int |
xAbsolute(double xRelative)
Translates from scaled coordinates to screen coordinates. |
protected double |
xRelative(int xAbsolute)
Translates from screen coordinates to scaled coordinates. |
protected int |
yAbsolute(double yRelative)
Translates from scaled coordinates to screen coordinates. |
protected double |
yRelative(int yAbsolute)
Translates from screen coordinates to scaled coordinates. |
void |
zoomCanvas(double amount)
Zoom the canvas. |
| 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, 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, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, setMaximumSize, setMinimumSize, setName, setPreferredSize, 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 java.awt.Color bgColor
protected java.awt.Color labelColor
protected java.awt.Color axisColor
protected java.awt.Color gridColor
protected java.awt.Font scaleFont
protected java.awt.Font labelFont
protected double cenX
protected double cenY
protected double scaleX
protected double scaleY
protected int offX
protected int offY
protected double defaultScaleX
protected double defaultScaleY
protected int defaultOffX
protected int defaultOffY
protected java.awt.Dimension dimensions
protected java.awt.image.BufferStrategy strategy
protected java.awt.PopupMenu popup
protected boolean showScale
protected boolean showGrid
protected boolean showTime
protected java.awt.Point lastpos
| Constructor Detail |
|---|
public AbstractCanvas()
public AbstractCanvas(double sx,
double sy,
int offx,
int offy)
sx - sy - offx - offy - | Method Detail |
|---|
protected void center()
public abstract void dump()
protected void rescaled()
protected void resized()
protected int clipX(int xAbsolute)
protected int clipY(int yAbsolute)
protected int xAbsolute(double xRelative)
protected int yAbsolute(double yRelative)
protected double xRelative(int xAbsolute)
protected double yRelative(int yAbsolute)
public double getScaleX()
public double getScaleY()
public void setScale(double scX,
double scY)
public int getOffX()
public int getOffY()
public void setOffset(int offX,
int offY)
public void reset()
public void resetCanvas()
public void zoomCanvas(double amount)
amount -
public void shiftCanvas(int xdiff,
int ydiff)
public java.awt.PopupMenu getPopup()
public void update(java.awt.Graphics g)
update in class java.awt.Canvaspublic void paint(java.awt.Graphics g)
paint in class java.awt.CanvaspaintCanvas(Graphics)protected void paintCanvas(java.awt.Graphics g)
g - the graphics objectprotected abstract void paintCurve(java.awt.Graphics g)
g -
protected void paintTime(java.awt.Graphics g,
long t1,
long t2)
g - t1 - start time in nano-secs.t2 - end time in nano-secs.protected void paintWhite(java.awt.Graphics g)
protected void paintAxes(java.awt.Graphics g)
protected void paintScale(java.awt.Graphics g)
protected void paintGrid(java.awt.Graphics g)
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden in interface java.awt.event.ComponentListenerpublic void componentMoved(java.awt.event.ComponentEvent e)
componentMoved in interface java.awt.event.ComponentListenerpublic void componentShown(java.awt.event.ComponentEvent e)
componentShown in interface java.awt.event.ComponentListenerpublic void componentResized(java.awt.event.ComponentEvent e)
componentResized in interface java.awt.event.ComponentListenerpublic void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved in interface java.awt.event.MouseWheelListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListenerpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||