|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
ciips.animation.Histogram
This is one example of the drawing object inheriting
java.awt.Panel
which can be added to the drawing panel
(DrawingPanel
).
Since DrawingPanel
is also an extension of panel,
this Histogram
panel has to be added to the drawing panel
by using the following statement (otherwise, the layout manager of
this class might interprete its dimension as null during the panel
initialization and nothing will show up):
Histogram histogram = new Histogram();
drawingPanel.setLayout(null);
drawingPanel.add(histogram);
...
histogram.setTitle("title");
histogram.setXLabel("x-axis label");
histogram.setYLabel("y-axis label");
histogram.setYMax(maxY);
histogram.setXMax(maxX);
histogram.setYStep(10);
histogram.setXStep(5);
histogram.reshape(x, y, width, height);
drawingPanel
is an instance of the class object
DrawingPanel
, which can be typically obtained from
the instance of AlgAnimFrame
, by calling the
getDrawingPanel()
method of the class.
e.g. in AlgThread
, the instance of AlgAnimFrame
is passed in as frame
. Therefore,
The
drawingPanel = frame.getDrawingPanel();
reshape
method is inherited from a parent class.
It is called to move the histogram to position (x, y)
and set the dimension of the histogram to width x height
.
DrawingPanel
,
AlgAnimFrame
,
Panel
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
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 | |
Histogram()
A constructor to this class which set the background of the panel to white, font to size 12 PLAIN courier, and initializes the title, x-axis label, y-axis label, etc. |
Method Summary | |
void |
draw(java.awt.Graphics g)
Same as paint() . |
int |
getX()
Get the left most position of the panel. |
int |
getY()
Get the top most position of the panel. |
void |
incValueX(int x)
Increment the Y value of vertical bar specified by the parameter. |
void |
init()
Initialize the histogram, removing all bars from the graph. |
void |
paint(java.awt.Graphics g)
Method to draw objects on the histogram panel. |
void |
setGrey(boolean on)
Set the grey attribute |
void |
setHighlight(boolean on)
Set the highlight attribute |
void |
setTitle(java.lang.String title)
Set a title for the histogram. |
void |
setValueXY(int x,
int y)
Set the Y value for the vertical bar at the specified X position. |
void |
setXLabel(java.lang.String xLabel)
Set a title for the x-axis. |
void |
setXMax(int xMax)
Set the maximum value for the x-axis of the histogram. |
void |
setXMin(int xMin)
Set the minimum value for the x-axis of the histogram. |
void |
setXStep(int step)
Set the incremental step for the x-axis of the histogram. |
void |
setYLabel(java.lang.String yLabel)
Set a title for the y-axis of the histogram. |
void |
setYMax(int yMax)
Set the maximum value for the y-axis of the histogram. |
void |
setYMin(int yMin)
Set the minimum value for the y-axis of the histogram. |
void |
setYStep(int step)
Set the incremental step for the y-axis. |
void |
update(java.awt.Graphics g)
This method is invoked when the repaint() method is called. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ciips.animation.DrawingObj |
move |
Constructor Detail |
public Histogram()
setBackground
method inherited. e.g.
Histogram histogram = new Histogram();
histogram.setBackground(Color.lightGray);
For detail of what color can be set, refer to
java.awt.Color
.
Method Detail |
public void init()
public int getX()
getX
in interface DrawingObj
public int getY()
getY
in interface DrawingObj
public void setTitle(java.lang.String title)
title
- The new title of the histogram.public void setXLabel(java.lang.String xLabel)
xLabel
- new title for the x-axis of the histogram.public void setYLabel(java.lang.String yLabel)
yLabel
- new title for the y-axis of the histogram.public void setYMax(int yMax)
yMax
- The maximum value for the y-axis of the histogram.public void setYStep(int step)
step
- The incremental step for the y-axis of the histogram.public void setYMin(int yMin)
yMin
- The new minimum value for the y-axis of the histogram.public void setXMax(int xMax)
xMax
- The maximum value for the x-axis of the histogram.public void setXStep(int step)
step
- The new incremental step for the x-axis of the histogram.setYStep(int)
public void setXMin(int xMin)
xMin
- The new minimum value for the x-axis of the histogram.public void setValueXY(int x, int y)
x
- The vertical bar at X = x
y
- The value of the vertical bar specified by the first parameter.public void incValueX(int x)
x
- Specifies the vertical bar at X = x.public void update(java.awt.Graphics g)
repaint()
method is called.
The update method is override here to eleminate flashing during
the updating of the histogram panel.
public void draw(java.awt.Graphics g)
paint()
. This method just calls the paint() method.
It must be defined here to implement the DrawingObj interface.
draw
in interface DrawingObj
g
- A reference to the graphical context.paint(java.awt.Graphics)
public void paint(java.awt.Graphics g)
public void setHighlight(boolean on)
DrawingObj
setHighlight
in interface DrawingObj
public void setGrey(boolean on)
DrawingObj
setGrey
in interface DrawingObj
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |