com.steema.teechart.styles
Class CustomBar

java.lang.Object
  extended by com.steema.teechart.TeeBase
      extended by com.steema.teechart.styles.Series
          extended by com.steema.teechart.styles.CustomBar
All Implemented Interfaces:
ISeries, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Bar, HorizBar

public class CustomBar
extends Series

Title: CustomBar class

Description: Custom Bar Series.

Copyright (c) 2005-2008 by Steema Software SL. All Rights Reserved.

Company: Steema Software SL

See Also:
Serialized Form

Nested Class Summary
static interface CustomBar.BarStyleResolver
           
static class CustomBar.MarksLocation
           
 
Nested classes/interfaces inherited from class com.steema.teechart.styles.Series
Series.MarkTextResolver
 
Field Summary
protected  int barSizePercent
           
protected  boolean bDark3D
           
protected  boolean bUseOrigin
           
protected  int conePercent
           
protected  int customBarSize
           
protected  double dOrigin
           
protected  Rectangle iBarBounds
           
protected  int iBarSize
           
protected  MultiBars iMultiBar
           
protected  int iNumBars
           
protected  int iOrderPos
           
protected  int iPreviousCount
           
protected  boolean marksOnBar
           
protected  Color normalBarColor
           
protected  ChartPen pPen
           
 
Fields inherited from class com.steema.teechart.styles.Series
AUTODEPTH, AUTOZORDER, bActive, bBrush, bColorEach, calcVisiblePoints, colorMember, customMarkText, drawBetweenPoints, endZ, firstVisible, hasZValues, iColors, InternalUse, iNumSampleValues, iZOrder, labelMember, lastVisible, listenerList, mandatory, manualData, marks, middleZ, notMandatory, percentDecimal, percentFormat, sLabels, startZ, useAxis, useSeriesColor, valueFormat, vxValues, vyValues, yMandatory
 
Fields inherited from class com.steema.teechart.TeeBase
chart
 
Constructor Summary
CustomBar()
           
CustomBar(IBaseChart c)
           
 
Method Summary
protected  int applyBarOffset(int position)
           
 int barMargin()
          Returns side margin amount in pixels.
 void barRectangle(Color barColor, int aLeft, int aTop, int aRight, int aBottom)
          For internal use.
 void barRectangle(Color barColor, Rectangle r)
          For internal use.
protected  Rectangle calcBarBounds(int valueIndex)
           
 void calcFirstLastVisibleIndex()
           
protected  void calcFirstLastVisibleIndex(boolean recursive)
           
protected  int calcMarkLength(int valueIndex)
           
 void calcZOrder()
           
 int clicked(int x, int y)
          Returns the ValueIndex of the "clicked" point in the Series.
 void createSubGallery(Gallery addSubChart)
           
protected  void doBarGradient(int valueIndex, Rectangle rect)
           
 void doBeforeDrawChart()
           
protected  BarStyle doGetBarStyle(int valueIndex)
           
protected  void doGradient3D(int valueIndex, Point p0, Point p1)
           
protected  void drawLegendShape(IGraphics3D g, int valueIndex, Rectangle rect)
           
protected  void drawTickLine(int tickPos, BarStyle aStyle)
           
protected  void drawTickLines(int startPos, int endPos, BarStyle aStyle)
           
 boolean drawValuesForward()
          Returns whether Series draws its points in ascending/descending order.
 boolean getAutoMarkPosition()
          Repositions Marks on BarSeries to prevent overlapping.
 Rectangle getBarBounds()
          Coordinates of current Bar point being displayed.
protected  int getBarBoundsMidX()
           
 BarStyle getBarStyle()
          Defines the Bar shape used to draw Bars.
 ChartBrush getBrush()
          Defines the Brush used to fill Bars.
 int getConePercent()
          The apex size as percentage of the base.
 int getCustomBarWidth()
           
 boolean getDark3D()
          Darkens sides of bars to enhance 3D effect.
 int getDepthPercent()
          Determines the percent amount of bar size in "z" depth direction.
 Gradient getGradient()
          Defines the color Gradient used to fill the Bars.
 boolean getGradientRelative()
          Calculates Colors based on highest bar when Gradient is Visible.
 CustomBar.MarksLocation getMarksLocation()
           
 boolean getMarksOnBar()
           
 MultiBars getMultiBar()
          Determines how multiple BarSeries will be displayed in the same Chart.
 int getOffsetPercent()
          The Bar displacement as percentage of Bar size.
 double getOrigin()
          The common bottom value used for all Bar points.
 ChartPen getPen()
          Pen used to draw the Bar rectangles.
 boolean getSideMargins()
          Margin between Chart rectangle and Bars.
 int getStackGroup()
          Allows stacking independent Series within the same Chart, in series groups.
 ChartPen getTickLines()
          Pen used to draw "tick" lines across each bar.
 boolean getUseOrigin()
          Bars to be bottom aligned at the Origin method value.
 double getYOrigin()
          Obsolete.
protected  void internalApplyBarMargin(Margins margins)
           
protected  int internalCalcMarkLength(int valueIndex)
           
protected  boolean internalClicked(int valueIndex, Point point)
           
protected  int internalGetOriginPos(int valueIndex, int defaultOrigin)
           
protected  boolean isPointInChartRect(int valueIndex)
           
protected  int lastVisibleMark()
           
protected  double maxMandatoryValue(double value)
           
protected  double minMandatoryValue(double value)
           
protected  int numSampleValues()
           
 double pointOrigin(int valueIndex, boolean sumAll)
          For Internal Use.
 void prepareForGallery(boolean isEnabled)
           
 void removeBarStyleResolver()
           
 void setAutoMarkPosition(boolean value)
          Repositions Marks on BarSeries to prevent overlapping.
protected  void setBarSizePercent(int value)
           
 void setBarStyle(BarStyle value)
          Defines the Bar shape used to draw Bars.
 void setBarStyleResolver(CustomBar.BarStyleResolver resolver)
           
 void setChart(IBaseChart c)
          Chart associated with this object.
 void setConePercent(int value)
          Sets the apex size as a percentage of the base.
 void setCustomBarWidth(int value)
           
 void setDark3D(boolean value)
          Darkens sides of bars to enhance 3D effect.
 void setDepthPercent(int value)
          Determines the percent amount of bar size in "z" depth direction.
 void setGradientRelative(boolean value)
          Calculates Colors based on highest bar when Gradient is Visible.
 void setMarksLocation(CustomBar.MarksLocation value)
           
 void setMarksOnBar(boolean value)
           
 void setMultiBar(MultiBars value)
          Determines how multiple BarSeries will be displayed in the same Chart.
 void setOffsetPercent(int value)
          Sets the Bar displacement as percentage of Bar size.
 void setOrigin(double value)
          Sets the common bottom value used for all Bar points.
protected  void setPenBrushBar(Color barColor)
           
 void setSideMargins(boolean value)
          Sets a margin between Chart rectangle and Bars.
 void setStackGroup(int value)
          Allows stacking independent Series within the same Chart, in series groups.
 void setSubGallery(int index)
          Creates and prepares the index'th Series style to show at sub-gallery dialog.
 void setUseOrigin(boolean value)
          Allows Bars to be bottom aligned at the Origin method value.
 void setYOrigin(double value)
          Obsolete.
 void setZPositions()
           
protected  boolean shouldSerializeYOrigin()
           
protected  boolean subGalleryStack()
           
 
Methods inherited from class com.steema.teechart.styles.Series
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, addChartValue, added, addedValue, addNull, addNullXY, addSampleValues, addSeriesMouseListener, addSeriesPaintListener, addValues, assign, assignDispose, assignValues, associatedToAxis, beginUpdate, calcHorizMargins, calcPercentSt, calcPosValue, calculateMarkPosition, calcVerticalMargins, calcXPos, calcXPosValue, calcXSizeValue, calcYPos, calcYPosValue, calcYSizeValue, canAddRandomPoints, changeType, checkDataSource, checkMouse, checkOrder, checkOtherSeries, clear, clearLists, clicked, clone, cloneSeries, convertArray, countLegendItems, createNewSeries, createNewSeries, dataSourceArray, delete, delete, delete, dispose, doAfterDrawValues, doBeforeDrawValues, doClick, doClickPointer, doDoubleClick, draw, drawLegend, drawLegend, drawMark, drawMarks, drawMarksSeries, drawSeries, drawSeriesForward, drawValue, endUpdate, fillSampleValues, fillSampleValues, fireSeriesMouseEvent, fireSeriesPaint, firstDisplayed, galleryChanged3D, getActive, getAllowSinglePoint, getBitmapEditor, getColor, getColorEach, getColorMember, getColors, getCount, getCountLegendItems, getCursor, getCustomHorizAxis, getCustomVertAxis, getDataSource, getDefaultColor, getDefaultNullValue, getDepth, getDescription, getEndZ, getFields, getFirstVisible, getFunction, getHasZValues, getHorizAxis, getHorizontalAxis, getLabelMember, getLabels, getLastVisible, getLegendString, getMandatory, getMandatoryAxis, getMarks, getMarkText, getMarkValue, getMaxXValue, getMaxYValue, getMaxZValue, getMiddleZ, getMinXValue, getMinYValue, getMinZValue, getNotMandatory, getNumGallerySeries, getNumSampleValues, getOriginValue, getPercentFormat, getPoint, getSeriesColor, getShowInLegend, getStartZ, getTitle, getUseAxis, getValueColor, getValueFormat, getValueIndexSwapper, getValueList, getValueList, getValueMarkText, getValuesLists, getVertAxis, getVerticalAxis, getVisible, getXValues, getYMandatory, getYValueList, getYValues, getZOrder, hasClickEvents, hasDataSource, hasListenersOf, hasNoMandatoryValues, isNull, isValidSeriesSource, isValidSourceOf, lastDisplayed, legendItemColor, legendToValueIndex, maxMarkWidth, moreSameZOrder, mouseEvent, newFromType, onDisposing, prepareLegendCanvas, randomBounds, readResolve, recalcGetAxis, refreshSeries, removeMarkTextResolver, removeSeriesMouseListener, removeSeriesPaintListener, repaint, sameClass, setActive, setColor, setColorEach, setColorMember, setColors, setCursor, setCustomHorizAxis, setCustomHorizAxis, setCustomVertAxis, setCustomVertAxis, setDataSource, setDefaultNullValue, setDepth, setEndZ, setFunction, setHorizontal, setHorizontalAxis, setLabelMember, setLabels, setMarks, setMarkTextResolver, setMiddleZ, setNull, setNull, setPercentFormat, setSeriesColor, setShowInLegend, setStartZ, setTitle, setValueFormat, setValueList, setVerticalAxis, setVisible, setXValues, setYValues, setZOrder, sortByLabels, sortByLabels, swapValueIndex, titleOrName, toString, valuesListAdd, xScreenToValue, yScreenToValue
 
Methods inherited from class com.steema.teechart.TeeBase
getChart, invalidate, setBooleanProperty, setColorProperty, setDoubleProperty, setIntegerProperty, setStringProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.steema.teechart.styles.ISeries
getChart, invalidate
 

Field Detail

barSizePercent

protected int barSizePercent

conePercent

protected int conePercent

bDark3D

protected boolean bDark3D

iMultiBar

protected MultiBars iMultiBar

bUseOrigin

protected boolean bUseOrigin

marksOnBar

protected boolean marksOnBar

dOrigin

protected double dOrigin

pPen

protected ChartPen pPen

iBarBounds

protected Rectangle iBarBounds

iNumBars

protected int iNumBars

iOrderPos

protected int iOrderPos

iPreviousCount

protected int iPreviousCount

iBarSize

protected int iBarSize

customBarSize

protected int customBarSize

normalBarColor

protected Color normalBarColor
Constructor Detail

CustomBar

public CustomBar(IBaseChart c)

CustomBar

public CustomBar()
Method Detail

setBarStyleResolver

public void setBarStyleResolver(CustomBar.BarStyleResolver resolver)

removeBarStyleResolver

public void removeBarStyleResolver()

getMarksOnBar

public boolean getMarksOnBar()

setMarksOnBar

public void setMarksOnBar(boolean value)

getMarksLocation

public CustomBar.MarksLocation getMarksLocation()

setMarksLocation

public void setMarksLocation(CustomBar.MarksLocation value)

getGradient

public Gradient getGradient()
Defines the color Gradient used to fill the Bars.
These can be filled with these three colors: StartColor, MidColor, EndColor. You can control the drawing output by setting the Direction method.
Use the Visible property to show / hide filling.

Example:


  barSeries = new Bar(myChart.getChart());
  barSeries.getMarks().setVisible(true);
  barSeries.fillSampleValues(6);
  barSeries.setColor(Color.RED);
  barSeries.setBarStyle(BarStyle.RECTGRADIENT);
  barSeries.getGradient().setDirection(GradientDirection.VERTICAL);
  barSeries.getGradient().setStartColor(Color.GREEN);
  barSeries.getGradient().setUseMiddle(false);
  barSeries.getGradient().setMiddleColor(Color.YELLOW);
 

Returns:
Gradient

getGradientRelative

public boolean getGradientRelative()
Calculates Colors based on highest bar when Gradient is Visible.
Default value: false

Returns:
boolean

setGradientRelative

public void setGradientRelative(boolean value)
Calculates Colors based on highest bar when Gradient is Visible.
Default value: false

Parameters:
value - boolean

getStackGroup

public int getStackGroup()
Allows stacking independent Series within the same Chart, in series groups.
Default value: 0

Returns:
int

setStackGroup

public void setStackGroup(int value)
Allows stacking independent Series within the same Chart, in series groups.
Default value: 0

Example:


 bar1Series.setStackGroup(0);
 bar2Series.setStackGroup(1);
 

Parameters:
value - int

setZPositions

public void setZPositions()
Overrides:
setZPositions in class Series

getDepthPercent

public int getDepthPercent()
Determines the percent amount of bar size in "z" depth direction. Default value: 100%

Returns:
int

setDepthPercent

public void setDepthPercent(int value)
Determines the percent amount of bar size in "z" depth direction. Default value: 100%

Example:


 series.setDepthPercent(50) ; // % of 3D depth
 

Parameters:
value - int

getDark3D

public boolean getDark3D()
Darkens sides of bars to enhance 3D effect.
This has effect only when Chart.Aspect.View3D is true. High color video modes (greater than 256 colors) will show dark colors much better than 256 or 16 color modes.
Default value: true

Returns:
boolean

setDark3D

public void setDark3D(boolean value)
Darkens sides of bars to enhance 3D effect.
Default value: true

Parameters:
value - boolean

prepareForGallery

public void prepareForGallery(boolean isEnabled)
Overrides:
prepareForGallery in class Series

setBarSizePercent

protected void setBarSizePercent(int value)

getSideMargins

public boolean getSideMargins()
Margin between Chart rectangle and Bars.
Default value: true

Returns:
boolean

setSideMargins

public void setSideMargins(boolean value)
Sets a margin between Chart rectangle and Bars.
Default value: true

Parameters:
value - boolean

shouldSerializeYOrigin

protected boolean shouldSerializeYOrigin()

getYOrigin

public double getYOrigin()
Obsolete. Please use CustomBar.Origin instead.

Returns:
double

setYOrigin

public void setYOrigin(double value)
Obsolete. Please use CustomBar.Origin instead.

Parameters:
value - double

getUseOrigin

public boolean getUseOrigin()
Bars to be bottom aligned at the Origin method value.
When false, the minimum of all Bar values is used as the Bar origins value.
When true, the Origin property is used as the start point for Bars.
Default value: true

Returns:
boolean

setUseOrigin

public void setUseOrigin(boolean value)
Allows Bars to be bottom aligned at the Origin method value.
Default value: true

Parameters:
value - boolean

getOrigin

public double getOrigin()
The common bottom value used for all Bar points.
UseOrigin must be true (the default) to use the Origin property.
Bars with a value bigger than Origin are drawn in one direction and Bars with a lower value are drawn in the opposite direction. This applies both to Bar series and HorizBar series classes.
Default value: 0

Returns:
double

setOrigin

public void setOrigin(double value)
Sets the common bottom value used for all Bar points.
Default value: 0

Parameters:
value - double

getAutoMarkPosition

public boolean getAutoMarkPosition()
Repositions Marks on BarSeries to prevent overlapping.
Marks are displaced to the top of the Bars to minimize the overlapping effect of Marks with long text or big font sizes.
When false, no checking is performed and all Marks are drawn at their Mark.ArrowLength distance to the top of the Bar.
Default value: false

Returns:
boolean

setAutoMarkPosition

public void setAutoMarkPosition(boolean value)
Repositions Marks on BarSeries to prevent overlapping.
Default value: false

Parameters:
value - boolean

getConePercent

public int getConePercent()
The apex size as percentage of the base.
Default value: 0

Returns:
int

setConePercent

public void setConePercent(int value)
Sets the apex size as a percentage of the base.
Default value: 0

Parameters:
value - int

getOffsetPercent

public int getOffsetPercent()
The Bar displacement as percentage of Bar size.
Displacement is horizontal for Bar series and vertical for HorizBar series. It can be used to create "overlayed" Bar charts. You can specify positive or negative values.
Default value: 0

Returns:
int

setOffsetPercent

public void setOffsetPercent(int value)
Sets the Bar displacement as percentage of Bar size.
Default value: 0

Parameters:
value - int

getBarStyle

public BarStyle getBarStyle()
Defines the Bar shape used to draw Bars.
Default value: BarStyle.Rectangle

Returns:
BarStyle

setBarStyle

public void setBarStyle(BarStyle value)
Defines the Bar shape used to draw Bars.
Default value: BarStyle.Rectangle

Parameters:
value - BarStyle

getBrush

public ChartBrush getBrush()
Defines the Brush used to fill Bars.
When BarBrush.Style is different than bsSolid, the Series.Color color is the background bar color.

Overrides:
getBrush in class Series
Returns:
ChartBrush

setChart

public void setChart(IBaseChart c)
Description copied from class: TeeBase
Chart associated with this object.

Specified by:
setChart in interface ISeries
Overrides:
setChart in class Series
Parameters:
c - IBaseChart

getMultiBar

public MultiBars getMultiBar()
Determines how multiple BarSeries will be displayed in the same Chart.
If you have more than one Bar series in the same Chart, then you can choose if they will be drawn side-by-side, back-to-front or Stacked.
Side-by-side means the Bar width will be divided by the number of Bar Series.
Default value: MultiBars.Side

Returns:
MultiBars

setMultiBar

public void setMultiBar(MultiBars value)
Determines how multiple BarSeries will be displayed in the same Chart.
Default value: MultiBars.Side

Parameters:
value - MultiBars

getPen

public ChartPen getPen()
Pen used to draw the Bar rectangles.
You can set BarPen.Visible = false to hide these lines.

Returns:
ChartPen

getTickLines

public ChartPen getTickLines()
Pen used to draw "tick" lines across each bar.

Returns:
ChartPen

getBarBounds

public Rectangle getBarBounds()
Coordinates of current Bar point being displayed.
Run-time and read-only.
This function returns an internal variable, that is calculated only when the Bar Series DrawValue method is called.
You should only use BarBounds in custom-derived series, after calling the "inherited DrawValue" method.

Returns:
Rectangle

getBarBoundsMidX

protected int getBarBoundsMidX()

doGetBarStyle

protected BarStyle doGetBarStyle(int valueIndex)

internalCalcMarkLength

protected int internalCalcMarkLength(int valueIndex)

doGradient3D

protected void doGradient3D(int valueIndex,
                            Point p0,
                            Point p1)

barRectangle

public void barRectangle(Color barColor,
                         Rectangle r)
For internal use.
Displays a Bar or HorizBar point using the parameter coordinates and the BarColor parameter.
It is internally called for each point in the Series.
The BarStyle property determines the type of graphical representation of every point (ie: Rectangle, Ellipse, Pyramid, etc).

Parameters:
barColor - Color
r - Rectangle

barRectangle

public void barRectangle(Color barColor,
                         int aLeft,
                         int aTop,
                         int aRight,
                         int aBottom)
For internal use.
Displays a Bar or HorizBar point using the parameter coordinates and the BarColor parameter.
It is internally called for each point in the Series.
The BarStyle property determines the type of graphical representation of every point (ie: Rectangle, Ellipse, Pyramid, etc).

Parameters:
barColor - Color
aLeft - int
aTop - int
aRight - int
aBottom - int

doBarGradient

protected void doBarGradient(int valueIndex,
                             Rectangle rect)

getCustomBarWidth

public int getCustomBarWidth()

setCustomBarWidth

public void setCustomBarWidth(int value)

barMargin

public int barMargin()
Returns side margin amount in pixels.

Returns:
int

internalApplyBarMargin

protected void internalApplyBarMargin(Margins margins)

calcBarBounds

protected Rectangle calcBarBounds(int valueIndex)

isPointInChartRect

protected boolean isPointInChartRect(int valueIndex)
Overrides:
isPointInChartRect in class Series

calcFirstLastVisibleIndex

protected void calcFirstLastVisibleIndex(boolean recursive)

calcFirstLastVisibleIndex

public void calcFirstLastVisibleIndex()
Specified by:
calcFirstLastVisibleIndex in interface ISeries
Overrides:
calcFirstLastVisibleIndex in class Series

lastVisibleMark

protected int lastVisibleMark()
Overrides:
lastVisibleMark in class Series

internalGetOriginPos

protected int internalGetOriginPos(int valueIndex,
                                   int defaultOrigin)

maxMandatoryValue

protected double maxMandatoryValue(double value)

pointOrigin

public double pointOrigin(int valueIndex,
                          boolean sumAll)
For Internal Use.
The PointOrigin function returns the summed values of more than one Series point.
It's only used by Series types with Stacked or Stacked 100% styles such as BarSeries, HorizBar series and Area series.

Parameters:
valueIndex - int
sumAll - boolean
Returns:
double

minMandatoryValue

protected double minMandatoryValue(double value)

calcZOrder

public void calcZOrder()
Overrides:
calcZOrder in class Series

doBeforeDrawChart

public void doBeforeDrawChart()
Overrides:
doBeforeDrawChart in class Series

drawTickLine

protected void drawTickLine(int tickPos,
                            BarStyle aStyle)

drawTickLines

protected void drawTickLines(int startPos,
                             int endPos,
                             BarStyle aStyle)

drawLegendShape

protected void drawLegendShape(IGraphics3D g,
                               int valueIndex,
                               Rectangle rect)
Overrides:
drawLegendShape in class Series

drawValuesForward

public boolean drawValuesForward()
Description copied from class: Series
Returns whether Series draws its points in ascending/descending order.
Some Series need to draw their points in descending order (starting from the last point to the first) depending on certain situations. For example, when the horizontal axis Inverted property is True.

Overrides:
drawValuesForward in class Series
Returns:
boolean true if values in this series are displayed forward, from 0 to Count-1.

applyBarOffset

protected int applyBarOffset(int position)

calcMarkLength

protected int calcMarkLength(int valueIndex)

internalClicked

protected boolean internalClicked(int valueIndex,
                                  Point point)

clicked

public int clicked(int x,
                   int y)
Returns the ValueIndex of the "clicked" point in the Series.
Clicked means the X and Y coordinates are in the point screen region bounds. If no point is "touched", Clicked returns -1

Specified by:
clicked in interface ISeries
Overrides:
clicked in class Series
Parameters:
x - int
y - int
Returns:
int

numSampleValues

protected int numSampleValues()
Overrides:
numSampleValues in class Series

setPenBrushBar

protected void setPenBrushBar(Color barColor)

subGalleryStack

protected boolean subGalleryStack()

createSubGallery

public void createSubGallery(Gallery addSubChart)
Overrides:
createSubGallery in class Series

setSubGallery

public void setSubGallery(int index)
Description copied from class: Series
Creates and prepares the index'th Series style to show at sub-gallery dialog.

Specified by:
setSubGallery in interface ISeries
Overrides:
setSubGallery in class Series
Parameters:
index - int