jsc.swt.plot2d
Class Histogram2D
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--jsc.swt.plot2d.PlotPanel
|
+--jsc.swt.plot2d.AxesPlot
|
+--jsc.swt.plot2d.Histogram2D
- All Implemented Interfaces:
- Accessible, Cloneable, ImageObserver, MenuContainer, Serializable
- public class Histogram2D
- extends AxesPlot
This class represents a histogram.
Antialiasing is turned off to improve drawing of the bars and text:
use setAntialiasing(true) if antialiasing is required.
- Version:
- 1.0
- Author:
- A. J. Bertie.
- See Also:
- Serialized Form
|
Field Summary |
static int |
FREQUENCY
Indicates histogram of raw frequencies. |
static int |
NORMALIZED
Indicates histogram of normalized frequencies.
|
static int |
RELATIVE
Indicates histogram of relative frequencies (proportions). |
|
Method Summary |
PlotObject |
addBars(FrequencyTable freq,
Color colour,
Paint paint,
Stroke stroke,
boolean filled)
Add a set of bars to the plot.
|
PlotObject |
addBars(FrequencyTable freq,
Color colour,
Stroke stroke)
Add a set of bars to the plot.
|
PlotObject |
addBars(FrequencyTable freq,
Paint paint)
Add a set of bars to the plot.
|
static int |
doaneBins(int n)
Returns a suitable number of class intervals for a histogram of sample size n.
|
int |
getType()
Returns the type of histogram: FREQUENCY, RELATIVE or NORMALIZED.
|
static int |
scottBins(int n)
Returns a suitable number of class intervals for a histogram of sample size n.
|
static double |
scottBinWidth(int n,
double sd)
Returns a suitable class interval width for a histogram of specified
sample size and sample standard deviation.
|
static double |
scottBinWidth(int n,
double min,
double max)
Returns a suitable class interval width for a histogram of specified
sample size and range of variate.
|
void |
setType(int type)
Set the type of histogram: FREQUENCY, RELATIVE or NORMALIZED.
|
| Methods inherited from class jsc.swt.plot2d.AxesPlot |
addVerticalLine, addVerticalLine, clone, copy, getHorizontalAxis, getTitle, getVerticalAxis, outsideAxes, paintComponent, rescaleHorizontal, rescaleVertical, setClipping, setPaintXaxis, setPaintYaxis, setTitle |
| Methods inherited from class jsc.swt.plot2d.PlotPanel |
addComponent, addComponent, addObject, addObjects, addRenderingHint, copyContents, copyPlot, ensureComponentCapacity, ensureObjectCapacity, getBufferedImage, getComponentBounds, getComponentBounds, getObject, getObject, getObjectCount, getObjectIndex, getObjects, getParHeight, getParWidth, getRenderingHints, getVirtualSpace, getVirtualTransform, isAntialiased, isEmpty, isTextAntialiased, merge, paintBackground, pixelToVirtual, pixelToVirtual, removeAll, removeAllComponents, removeAllObjects, removeComponent, removeLastComponent, removeLastObject, removeObject, removeObject, removeRenderingHint, setAntialiasing, setComponentBounds, setComponentBounds, setFocusColour, setObjectComposite, setTextAntialiasing, setVirtualSpace, setZoomable, setZoomBoxColour, setZoomBoxStroke, virtualToPixel, virtualToPixel, virtualToPixelHeight, virtualToPixelWidth, write, write |
| 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, paint, paintBorder, paintChildren, 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, 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 |
FREQUENCY
public static final int FREQUENCY
- Indicates histogram of raw frequencies.
- See Also:
- Constant Field Values
RELATIVE
public static final int RELATIVE
- Indicates histogram of relative frequencies (proportions).
- See Also:
- Constant Field Values
NORMALIZED
public static final int NORMALIZED
- Indicates histogram of normalized frequencies.
That is, a histogram in which the vertical scale
has been chosen such that the total area of the
bars equals unity.
- See Also:
- Constant Field Values
Histogram2D
public Histogram2D(String title,
AxisModel X,
AxisModel Y)
- Creates the histogram with given title and Axis objects.
- Parameters:
title - the title of the histogram.X - the horizontal axis of the histogram.Y - the vertical axis of the histogram.
addBars
public PlotObject addBars(FrequencyTable freq,
Paint paint)
- Add a set of bars to the plot.
The bar heights are proportional to the specified frequencies,
and drawn as a filled polygon using the specified paint style
(which can be a Color object).
The bar heights are calculated according to the current histogram
type, FREQUENCY (default), RELATIVE or NORMALIZED, which is set using
method setType().
Redraws the whole plot. Returns the PlotObject that was added to the plot.
- Parameters:
freq - the table of frequencies.paint - the paint style used to fill the bars.
- Returns:
- the object added to the plot.
addBars
public PlotObject addBars(FrequencyTable freq,
Color colour,
Stroke stroke)
- Add a set of bars to the plot.
The bar heights are proportional to the specified frequencies,
and their outline is drawn as a polygon using the specified graphical attributes.
The bar heights are calculated according to the current histogram
type, FREQUENCY (default), RELATIVE or NORMALIZED, which is set using
method setType().
Redraws the whole plot. Returns the PlotObject that was added to the plot.
- Parameters:
freq - the table of frequencies.colour - the colour of the bars.stroke - the stroke style to draw the outline of the bars.
- Returns:
- the object added to the plot.
addBars
public PlotObject addBars(FrequencyTable freq,
Color colour,
Paint paint,
Stroke stroke,
boolean filled)
- Add a set of bars to the plot.
The bar heights are proportional to the specified frequencies,
and drawn as a polygon using the specified graphical attributes.
The bar heights are calculated according to the current histogram
type, FREQUENCY (default), RELATIVE or NORMALIZED, which is set using
method setType().
If filled is true, the paint style (which can be a Color object) is used
to fill the polygon.
If filled is false, the outline of the polygon is drawn using the
colour and stroke style.
Redraws the whole plot. Returns the PlotObject that was added to the plot.
- Parameters:
freq - the table of frequencies.colour - the colour of the bars.paint - the paint style used to fill the bars.stroke - the stroke style to draw the outline of the bars.filled - if true, the bars are filled;
otherwise the outline of the bars is drawn.
- Returns:
- the object added to the plot.
doaneBins
public static int doaneBins(int n)
- Returns a suitable number of class intervals for a histogram of sample size n.
This method is more suitable for skewed data.
This uses the formula due to D.P.Doane(1976).
- Reference:
-
Doane,D.P.(1976) The American Statistician, Vol.30, 181-183.
- Parameters:
n - the number of observations.
- Returns:
- the number of bins.
- Throws:
IllegalArgumentException - if n less than 1.
getType
public int getType()
- Returns the type of histogram: FREQUENCY, RELATIVE or NORMALIZED.
- Returns:
- the type of histogram.
scottBins
public static int scottBins(int n)
- Returns a suitable number of class intervals for a histogram of sample size n.
This uses the formula due to D.W.Scott(1979).
- Reference:
-
Scott,D.W.(1979) Biometrika, Vol.66, 605-610.
- Parameters:
n - the number of observations.
- Returns:
- the number of bins.
- Throws:
IllegalArgumentException - if n less than 1.
scottBinWidth
public static double scottBinWidth(int n,
double sd)
- Returns a suitable class interval width for a histogram of specified
sample size and sample standard deviation.
This method is more suitable for normal data.
This uses the formula due to D.W.Scott(1979).
- Reference:
-
Scott,D.W.(1979) Biometrika, Vol.66, 605-610.
- Parameters:
n - the number of observations.sd - the sample standard deviation.
- Returns:
- the bin width.
- Throws:
IllegalArgumentException - if n less than 1 or sd not greater than zero.
scottBinWidth
public static double scottBinWidth(int n,
double min,
double max)
- Returns a suitable class interval width for a histogram of specified
sample size and range of variate.
This uses the formula due to D.W.Scott(1979).
- Reference:
-
Scott,D.W.(1979) Biometrika, Vol.66, 605-610.
- Parameters:
n - the number of observations.min - the minimum variate value.max - the maximum variate value.
- Returns:
- the bin width.
- Throws:
IllegalArgumentException - if n less than 1 or max not greater than min.
setType
public void setType(int type)
- Set the type of histogram: FREQUENCY, RELATIVE or NORMALIZED.
- Parameters:
type - the type of histogram.
- Throws:
IllegalArgumentException - if type is not valid.
Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005