com.steema.teechart.functions
Class Function

java.lang.Object
  extended by com.steema.teechart.TeeBase
      extended by com.steema.teechart.functions.Function
Direct Known Subclasses:
Add, ADX, Average, BaseTrend, Bollinger, CCI, CLV, CompressOHLC, Count, CrossPoints, Cumulative, CurveFitting, Custom, DownSampling, ExpMovAverage, High, HistogramFunction, Low, ManySeries, Moving, OBV, Perimeter, PVO, RootMeanSquare, SAR, Smoothing, StdDeviation, Variance

public class Function
extends TeeBase

Title: Function class

Description: Basic abstract function class. Examples of derived functions are: Add, Subtract, High, Low, Average and Count.

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

Company: Steema Software SL


Field Summary
protected  boolean canUsePeriod
           
protected  double dPeriod
           
 boolean HideSourceList
           
 boolean noSourceRequired
           
protected  Series series
           
 boolean SingleSource
           
protected  boolean updating
           
 
Fields inherited from class com.steema.teechart.TeeBase
chart, InternalUse
 
Constructor Summary
Function()
           
Function(IBaseChart c)
           
 
Method Summary
protected  void addFunctionXY(boolean yMandatorySource, double tmpX, double tmpY)
           
 void addPoints(java.util.Vector source)
          Gets all points from Source series, performs a function operation and stores results in ParentSeries.
 double calculate(Series source, int first, int last)
          Performs function operation on SourceSeries series.
protected  void calculateAllPoints(Series source, ValueList notMandatorySource)
           
protected  void calculateByPeriod(Series source, ValueList notMandatorySource)
           
 double calculateMany(java.util.Vector sourceSeries, int valueIndex)
          Performs function operation on list of series (SourceSeriesList).
protected  void calculatePeriod(Series source, double tmpX, int firstIndex, int lastIndex)
           
 void clear()
           
 void dispose()
           
protected  void doCalculation(Series source, ValueList notMandatorySource)
           
 java.lang.String getDescription()
          Gets descriptive text.
 double getPeriod()
          Controls how many points or X range will trigger a new point calculation.
 PeriodAlign getPeriodAlign()
          Controls where to place function calculations inside the full period space.
 PeriodStyle getPeriodStyle()
          Controls how the Period property is interpreted.
 Series getSeries()
          Returns the Series parent of Function.
static Function newInstance(java.lang.Class f)
           
protected  java.lang.Object readResolve()
           
 void recalculate()
          Performs a checkDataSource method call on parent Series.
 void setPeriod(double value)
           
 void setPeriodAlign(PeriodAlign value)
           
 void setPeriodStyle(PeriodStyle value)
           
 void setSeries(Series value)
           
protected  ValueList valueList(Series s)
           
 
Methods inherited from class com.steema.teechart.TeeBase
getChart, invalidate, setBooleanProperty, setChart, setColorProperty, setDoubleProperty, setIntegerProperty, setStringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dPeriod

protected double dPeriod

noSourceRequired

public transient boolean noSourceRequired

series

protected transient Series series

updating

protected transient boolean updating

canUsePeriod

protected transient boolean canUsePeriod

SingleSource

public transient boolean SingleSource

HideSourceList

public transient boolean HideSourceList
Constructor Detail

Function

public Function()

Function

public Function(IBaseChart c)
Method Detail

readResolve

protected java.lang.Object readResolve()

dispose

public void dispose()

newInstance

public static Function newInstance(java.lang.Class f)
                            throws java.lang.IllegalAccessException,
                                   java.lang.InstantiationException
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

getPeriod

public double getPeriod()
Controls how many points or X range will trigger a new point calculation.
Zero means all source points.
For example, Average function uses the Period property to calculate a new average point each time the "Period" number of points or X range is exceed.

NOTE: You may switch between number of points or X range by using the Function PeriodStyle property.
Default value: 0D

Returns:
double

setPeriod

public void setPeriod(double value)

getSeries

public Series getSeries()
Returns the Series parent of Function.
Run-time and read only.
The Series property returns the Series parent of this Function.
TChart uses Series to do the actual drawing.

Returns:
Series

setSeries

public void setSeries(Series value)

getPeriodStyle

public PeriodStyle getPeriodStyle()
Controls how the Period property is interpreted.
Either as number of points or as range.
Range means Period property is specified in a range of values.
Being able to define Period as a range can be very useful when using Date-Time series and when you want to express the Period of the function in a date-time step like OneMonth or OneDay.
So, for example you can now plot the monthly average of sales function just using a normal Average function on a date-time source series and setting the function period to one month :
{ Place a series1 and fill it with datetime data values at runtime (or from a database) }
series2.setFunction( new Average() );
series2.getFunction().setPeriodStyle( Range); series2.getFunction().setPeriod( DateTimeStep[ dtOneMonth ]); series2.setDataSource(series1);

This will result in several points, each one showing the average of each month of data in Series1.
It's mandatory that points in the source Series1 should be sorted by date when calculating functions on datetime periods.

The range can also be used for non-datetime series:

series2.setFunction( new Average() ) ;
series2.getFunction().setPeriodStyle(Range);
series2.getFunction().setPeriod(100);
series2.setDataSource(series1) ;
>br> This will calculate an average for each group of points inside every 100 interval.

(Points with X >=0, X<100 will be used to calculate the first average, points with X >=100, X<200 will be used to calculate the second average and so on... )
Notice this is different than calculating an average for every 100 points.
Default value: PeriodStyle.NumPoints

Returns:
PeriodStyle

setPeriodStyle

public void setPeriodStyle(PeriodStyle value)

getPeriodAlign

public PeriodAlign getPeriodAlign()
Controls where to place function calculations inside the full period space.
The position of calculation output points within range.
When the function Period is greater than zero (so it calculates by groups of points), the function results are added to the series by default at the center position of the Function Period. You can change this by setting PeriodAlign to

- First (function result will be added to series at start of each period),
- Center (function result will be added to series at center of each period)
- Last (function result will be added to series at end of each period)

Example

function1.setPeriodAlign(Center); // <-- by default is centered
The First and Last constants will plot calculations at the start and end X coordinates of each Period .
Default value: PeriodAlign.Centre

Returns:
PeriodAlign

setPeriodAlign

public void setPeriodAlign(PeriodAlign value)

addFunctionXY

protected void addFunctionXY(boolean yMandatorySource,
                             double tmpX,
                             double tmpY)

calculatePeriod

protected void calculatePeriod(Series source,
                               double tmpX,
                               int firstIndex,
                               int lastIndex)

calculate

public double calculate(Series source,
                        int first,
                        int last)
Performs function operation on SourceSeries series.
First and Last parameters are ValueIndex of first and last point used in calculation.
You can override Calculate function to perform customized calculation on one SourceSeries.

Parameters:
source - Series
first - int
last - int
Returns:
double

calculateMany

public double calculateMany(java.util.Vector sourceSeries,
                            int valueIndex)
Performs function operation on list of series (SourceSeriesList).
The ValueIndex parameter defines ValueIndex of point in each Series in list.
You can override CalculateMany function to perform customized calculation on list of SourceSeries.

Parameters:
sourceSeries - ArrayList
valueIndex - int
Returns:
double

calculateAllPoints

protected void calculateAllPoints(Series source,
                                  ValueList notMandatorySource)

calculateByPeriod

protected void calculateByPeriod(Series source,
                                 ValueList notMandatorySource)

getDescription

public java.lang.String getDescription()
Gets descriptive text.

Returns:
String

doCalculation

protected void doCalculation(Series source,
                             ValueList notMandatorySource)

valueList

protected ValueList valueList(Series s)

addPoints

public void addPoints(java.util.Vector source)
Gets all points from Source series, performs a function operation and stores results in ParentSeries.

Parameters:
source - ArrayList

recalculate

public void recalculate()
Performs a checkDataSource method call on parent Series.
Basically, all points in parent Series are recalculated.
The recalculating is performed only if internal updating flag is set to false.
To make sure updating is set to false, you can call Function endUpdate() method prior to calling Function recalculate.


clear

public void clear()