|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--com.objectplanet.chart.Chart
|
+--com.objectplanet.chart.BarChart
This bar chart component enables you to add a bar chart to your java
applications with just a few lines of code.
A simple bar chart can be created with the following code:
See here for a list of parameters to
set for the bar chart.
BarChart chart = new BarChart(5);
long[] values = new long[] {100, 200, 300, 400, 500};
chart.setSampleValues(values);
A chart with the legend turned on, multicolor set, and displayed in 3D can be
created with the following code:
BarChart chart = new BarChart(5);
long[] values = new long[] {100, 200, 300, 400, 500};
chart.setSampleValues(values);
chart.setMultiColorOn(true);
chart.setLegendOn(true);
chart.set3DModeOn(true);
| Nested Class Summary |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
static int |
SIDE_BY_SIDE_BARS
Use side-by-side bars in multiple series charts; setBarType() |
static int |
STACKED_BARS
Use stacked bars in multiple series charts; setBarType() |
| Fields inherited from class com.objectplanet.chart.Chart |
BELOW, BELOW_AND_FLOATING, BOTTOM, chartData, FLOATING, HORIZONTAL, INSIDE, LEFT, OUTSIDE, overlayCharts, RIGHT, STATIC, TARGET_LINE_ID_AND_VALUE_LABEL, TARGET_LINE_ID_LABEL, TARGET_LINE_NO_LABEL, TARGET_LINE_VALUE_LABEL, TOP, VERTICAL, visibleSamples |
| 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 | |
BarChart()
Creates a bar chart with 1 series, 1 sample and a range of 100. |
|
BarChart(int count)
Creates a bar chart with the given number of samples and default range. |
|
BarChart(int count,
double range)
Creates a bar chart with the given number of bars and range. |
|
BarChart(int sampleCount,
double range,
double lowerRange)
Creates a bar chart with the given number of bars and range. |
|
BarChart(int seriesCount,
int sampleCount,
double range,
double lowerRange)
Creates a bar chart with the given number of series and bars and range. |
|
| Method Summary | |
protected void |
calculateChartData(java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
Calculates the position and size of each bar in the chart. |
com.objectplanet.chart.ChartSample |
checkSelection(java.awt.Point point)
This method is called when the user releases the mouse and checks if the given point is inside a bar or a legend label. |
java.lang.String[] |
getBarLabels()
Gets the bar labels. |
int |
getBarLabelStyle()
Gets the current bar label style. |
int |
getBarType()
Gets the current bar type in multiple series charts. |
double |
getBarWidth()
Gets the relative width of each bar. |
java.awt.Rectangle |
getGraphBounds()
Calculates the bounding rectangle of the graph itself, based on which features are on and how they are configured. |
int |
getgridAlignment()
Gets the bar alignment. |
java.lang.String[] |
getLegendLabels()
Gets the legend labels. |
int |
getValueLabelStyle()
Gets the current value label style. |
int |
getValuePosition(double value)
Gets the position in the chart of the specified value. |
boolean |
isAutoLabelSpacingOn()
Gets the state of the automatic label spacing. |
boolean |
isBarLabelsOn()
Checks if the bar labels are turned on. |
boolean |
isBarOutlineOn()
Checks if the bar outline is turned on or off. |
boolean |
isMultiColorOn()
Checks if the multicolor mode is turned on. |
boolean |
isMultiSeriesOn()
Checks if the chart is in multi series mode. |
void |
render(java.awt.Graphics g)
Renders the bar chart according to the current chart attributes and which charts features are turned on or off. |
protected void |
renderData(java.awt.Graphics g,
java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
Renders the bars and the value labels. |
void |
reset()
Resets the chart data and features. |
void |
setAutoLabelSpacingOn(boolean on)
Turns on or off automatic bar label spacing. |
void |
setBarAlignment(int alignment)
Sets the bar alignment. |
void |
setBarLabels(java.lang.String[] labels)
Sets the bar labels. |
void |
setBarLabelsOn(boolean on)
Turns on or off the bar labels. |
void |
setBarLabelStyle(int style)
Sets the bar label style. |
void |
setBarOutlineColor(java.awt.Color color)
Sets the color used for the bar outline. |
void |
setBarOutlineOn(boolean on)
Turns on or off the bar outline. |
void |
setBarType(int type)
Sets the bar type in multiple series charts. |
void |
setBarWidth(double width)
Sets the relative width of each bar. |
void |
setMultiColorOn(boolean on)
Turns on or off multi-color bar display. |
void |
setMultiSeriesOn(boolean state)
Makes the chart behave like it does when it has multiple data series, even if it has only one. |
void |
setValueLabelStyle(int style)
Sets the value label style. |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, 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, printAll, processComponentEvent, 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, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int SIDE_BY_SIDE_BARS
public static final int STACKED_BARS
| Constructor Detail |
public BarChart()
public BarChart(int count)
count - The number of bars for the chart.
public BarChart(int count,
double range)
count - The number of bars for the chart.range - The initial range of the chart.
public BarChart(int sampleCount,
double range,
double lowerRange)
sampleCount - The number of bars for the chart.range - The initial upper range of the chart.lowerRange - The initial lower range of the chart.
public BarChart(int seriesCount,
int sampleCount,
double range,
double lowerRange)
seriesCount - The number of data series in the chart.sampleCount - The number of sample in the chart.range - The initial upper range of the chart.lowerRange - The initial lower range of the chart.| Method Detail |
protected void calculateChartData(java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
calculateChartData in class Chartgrid - The chart grid bounds.dataBounds - The data bounds.public com.objectplanet.chart.ChartSample checkSelection(java.awt.Point point)
checkSelection in class Chartpoint - The point clicked on.
public java.lang.String[] getBarLabels()
public int getBarLabelStyle()
setBarLabelStyle(int)public int getBarType()
public double getBarWidth()
setBarWidth(double)public java.awt.Rectangle getGraphBounds()
getGraphBounds in class Chartpublic int getgridAlignment()
setBarAlignment(int)public java.lang.String[] getLegendLabels()
getLegendLabels in class ChartChart.setLegendLabels(java.lang.String[])public int getValueLabelStyle()
public int getValuePosition(double value)
value - The value to find the position for.
public boolean isAutoLabelSpacingOn()
setAutoLabelSpacingOn(boolean)public boolean isBarLabelsOn()
public boolean isBarOutlineOn()
public boolean isMultiColorOn()
public boolean isMultiSeriesOn()
setMultiSeriesOn(boolean)public void render(java.awt.Graphics g)
render in class Chartg - The graphics context used to paint with.Chart.paint(java.awt.Graphics)
protected void renderData(java.awt.Graphics g,
java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
renderData in class Chartg - The graphics context used to paint with.grid - The grid bounds to paint within.dataBounds - The scrolled data bounds to calculate the bars from.public void reset()
reset in class Chartpublic void setAutoLabelSpacingOn(boolean on)
on - True for on, false for off.public void setBarAlignment(int alignment)
alignment - HORIZONTAL or VERTICAL.
java.lang.IllegalArgumentException - If the alignment is not valid.public void setBarLabels(java.lang.String[] labels)
labels - The labels, or null for default behavior.setBarLabelsOn(boolean),
Chart.setSampleLabels(java.lang.String[])public void setBarLabelsOn(boolean on)
on - True if the bar labels should be displayed.Chart.setSampleLabel(int, java.lang.String)public void setBarLabelStyle(int style)
style - BELOW, FLOATING, BELOW_AND_FLOATING.public void setBarOutlineColor(java.awt.Color color)
color - The color to set.public void setBarOutlineOn(boolean on)
on - True if on, false for off.public void setBarType(int type)
type - STACKED_BARS or SIDE_BY_SIDE_BARS.
java.lang.IllegalArgumentException - If the type is not valid.public void setBarWidth(double width)
width - The width fraction to use (0.0 to 1.0).public void setMultiColorOn(boolean on)
on - True for multi-color, false for single-color.public void setMultiSeriesOn(boolean state)
state - True for on, false for off.public void setValueLabelStyle(int style)
style - INSIDE, OUTSIDE, FLOATING.
java.lang.IllegalArgumentException - If the style is invalid.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||