Abstract Classes & Interfaces

OVERVIEW

This chapter describes the functions that are defined in the Perspective abstract interface. If you use any of these interfaces, your application must implement these functions in the format described in this chapter.

NumberFormatCallBack Class

The NumberFormatCallBack class defines the following static variables and methods:

//Axis Label
public final static int AXIS_LABEL = 0;
// Pie Label
public final static int PIE_LABEL = 1;
// Pie Total
public final static int PIE_TOTAL = 2;
// Data Label
public final static int DATA_LABEL = 3;
// Value Display in Tooltip
public final static int TOOLTIP_VALUE = 4;
// Data Label for HiLo Volume 
public final static int DATA_LABEL_HILO_VOL = 5;

The NumberFormatCallback class represents an abstract interface to an object that formats the numbers in a Perspective for Java chart. To use this class, do the following:

You may also use:

The following methods can be used to view information that is set by the reserved setState() method:

protected int getSeries();
protected int getGroup();
protected int getLabelType();
protected int getAxisLabelOrdinalPosition();
protected boolean isAxisLabel();
protected boolean isX1AxisLabel();
protected boolean isY1AxisLabel();
protected boolean isY2AxisLabel();
protected boolean isY3AxisLabel();
protected boolean isY4AxisLabel();
protected boolean isY5AxisLabel();

init()

This method is used to initialize a Perspective instance for the NumberFormatCallback interface.

SYNTAX:

void init (Perspective
aPerspectiveInstance)

INPUT:

aPerspectiveInstance; a Perspective Instance

RETURN:

void;

EXAMPLE:

public void init (Perspective aPerspectiveInstance)
{
    m_Perspective = aPerspectiveInstance;
}

ALSO SEE:

toString(), getNumberFormatCallBack(), isNumberFormatCallBack(), setNumberFormatCallBack()

toString()

This function converts the double value identified by dVal to a string using a user-defined criteria. This function must be created by your NumberFormatCallback interface to format numeric labels as required by your application.

SYNTAX:

String toString (double dVal)

INPUT:

dVal; a double value

RETURN:

String; string equivalent of dVal

ALSO SEE:

getNumberFormatCallBack(), isNumberFormatCallBack(), setNumberFormatCallBack()

Example NumberFormatCallback Interface

The following example program shows a simple implementation of the NumberFormatCallback interface:

import tdg.NumberFormatCallBack;
/* The PfjNumberFormatCallback class. * Class PfjNumberFormatCallback extends the * Perspective 
   NumberFormatCallBack class */
public class PfjNumberFormatCallback extends NumberFormatCallBack
{
     // PfjNumberFormatCallback PUBLIC MEMBER FUNCTIONS
        public String toString (double dVal)
        {
             String labelType;
             String resultValue;
             String axisValue;
             String dataValue;
             switch (getLabelType())
             { // switch on labelType
                  case AXIS_LABEL: labelType = "Axis";
                  break;
                  case PIE_LABEL: labelType = "Slice";
                  break;
                  case PIE_TOTAL: labelType = "PieT";
                  break;
                  case DATA_LABEL: labelType = "Data";
                  break;
                  case TOOLTIP_VALUE: labelType = "ToolTip";
                  break;
                  default: labelType = "BadLabelType";
                  System.out.println (
                       "Undefined LabelType = " + getLabelType() + "Value = " + dVal                   );                   break;              } // switch on labelType              if (isAxisLabel())              {                   if (isY1AxisLabel())                        axisValue = "Y1" + ";" + getAxisLabelOrdinalPosition();                   else if (isY2AxisLabel())                        axisValue = "Y2" + ";" + getAxisLabelOrdinalPosition();                   else if (isX1AxisLabel())                        axisValue = "X1" + ";" + getAxisLabelOrdinalPosition();                   else                        axisValue = "BadAxis";              }              else                   axisValue = "NA";              if (dVal > 1 || dVal == 0)                   dataValue = new Double (dVal).toString();              else              {                   dataValue=new Integer ((int) (dVal * 100 + .5)).toString() + "%";                   resultValue=labelType + ";" + getSeries() +";" + getGroup() + ";" + axisValue + ":" + dataValue;                   return resultValue;              }      } } // PfjNumberFormatCallback

TDGDataCallbackIF Interface

This interface defines a group of methods that can be used to get and set data in a chart when the setDataFromCallBack() method is used to slave chart data to an arbitrary Java Object.

/* Establish the label for the specified column. */
public abstract String columnLabel (int c);
/* Return the number of columns. */
public abstract int getColumns();
/* Establish the label for the specified row. */
public abstract String rowLabel (int r);
/* Return the number of rows. */
public abstract int getRows();

/*** Get the contents of the specified cell.
 * Note that any type of Object can be returned.
 * Perspective will interpret the Object type as a String
 * or Double.**/

public abstract Object getValue (int r, int c);

These methods are identical to the methods defined in the TDGDataGrid interface.

TDGDataGrid Interface

TDGDataGrid is an abstract interface. It defines a series of methods that you must implement into an object. The TDGDataGrid interface represents an abstract data model that is one way of preparing data for graphing. Use these methods to enable this interface.

You may also use getDataGridCallback() to get the TDGDataGrid interface defined by setDataFromDataGrid()

The TDGDataGrid interface defines the following methods that must be implemented by your application if you choose to use this interface:

NOTE: TDGPreScaleIF is an optional callback interface that users with large datasets may implement in their existing data callbacks (TDGDataGrid) to expedite processing of data. See the TDGPreScaleIF interface below for details.

columnLabel()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object.This method is used to establish column labels/headings for the column specified by the input parameter c. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String columnLabel (int c)

INPUT:

c; a column number

RETURN:

String; Column label at column c.

ALSO SEE:

setDataFromDataGrid()

getColumns()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This method is used to get the number of columns in the chart. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract int getColumns();

INPUT:

None

RETURN:

int; The number of columns in the chart.

ALSO SEE:

setDataFromDataGrid()

getFootnote()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object.This function is used to establish the chart footnote. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getFootnote();

INPUT:

None

RETURN:

String; The chart footnote string.

ALSO SEE:

setDataFromDataGrid()

getO1AxisTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This function is used to establish the chart O1-axis title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getO1AxisTitle();

INPUT:

None

RETURN:

String; O1-Axis title string.

ALSO SEE:

setDataFromDataGrid()

getO2AxisTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This function is used to establish the chart O2-axis title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getO2AxisTitle();

INPUT:

None

RETURN:

String; O2-Axis title string.

ALSO SEE:

setDataFromDataGrid()

getRows()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This method is used to get the number of rows in the chart. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract int
getRows();

INPUT:

None

RETURN:

int; The number of rows in the chart.

ALSO SEE:

setDataFromDataGrid()

getSubtitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This function is used to establish the chart subtitle. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getSubtitle();

INPUT:

None

RETURN:

String; Chart subtitle string.

ALSO SEE:

setDataFromDataGrid()

getTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This function is used to establish the chart title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getTitle();

INPUT:

None

RETURN:

String; Chart title string.

ALSO SEE:

setDataFromDataGrid()

getValue()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e., setDataFromDataGrid()), this method must be implemented by your application in an object. This function gets the contents of the specified cell (at row (r), column (c)). Note that any type of Object can be returned. Perspective will interpret the Object type as a String or Double. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract Object getValue (int r, int c)

INPUT:

r; row number

INPUT:

c; column number

RETURN:

Object; Chart Data at row (r), column (c)

ALSO SEE:

setDataFromDataGrid()

getX1AxisTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This function is used to establish the chart X1-axis title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getX1AxisTitle()

INPUT:

None

RETURN:

String; The X1-Axis Title String

ALSO SEE:

setDataFromDataGrid()

getY1AxisTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This function is used to establish the chart Y1-axis title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getY1AxisTitle()

INPUT:

None

RETURN:

String; The Y1-Axis Title String

ALSO SEE:

setDataFromDataGrid()

getY2AxisTitle()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This function is used to establish the chart Y2-axis title. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String getY2AxisTitle()

INPUT:

None

RETURN:

String; The Y2-Axis Title String

ALSO SEE:

setDataFromDataGrid()

isDirty()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This function is used to determine if data in the chart has changed: TRUE = data has changed, FALSE = data has not changed. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract boolean isDirty();

INPUT:

None

RETURN:

boolean; true = Chart data has changed, false = Chart data has not changed

ALSO SEE:

setDataFromDataGrid()

rowLabel()

This is a required method for the TDGDataGrid object. If you use TDGDataGrid (i.e.g, setDataFromDataGrid(), this method must be implemented by your application in an object. This method is used to establish row labels/headings for the row specified by the input parameter r. The syntax shows the format in which this method must be implemented by your application.

SYNTAX:

public abstract String rowLabel (int r)

INPUT:

r; a row number

RETURN:

String; Row label at row r.

ALSO SEE:

setDataFromDataGrid()

TDGDataGridPieBar Interface

This interface defines a method to get the title string from a Pie-Bar chart.

getPieBarLabel()

This method establishes the chart title in a Pie-Bar chart.

SYNTAX:

java.lang.String getPieBarLabel()

INPUT:

None

RETURN:

String; chart title

TDGListener Interface

The addPerspectiveListener() method creates an instance of an abstract class or interface to catch high-level events defined by the Perspective for Java integration. This method also tells the charting engine to notify the perspectiveEvent() method defined in the TDGListener interface when a Perspective event occurs.

perspectiveEvent()

The perspectiveEvent() method will be called with an event object when an Perspective event occurs. The perspectiveEvent() must be included and defined in the object identified by addPerspectiveListener(). The definition of the perspectiveEvent() method should indicate handling of events that are reported by the charting engine.

SYNTAX:

void perspectiveEvent (TDGEvent e);

INPUT:

e: A location to store the event. On return, it will be set to the perspective event. Event codes and methods for getting event information are defined in the TDGEvent class.

RETURN:

void;

EXAMPLE:

See FullMetalListener() in Appendix C

ALSO SEE:

addPerspectiveListener()

TDGEvent Class

This class defines the following static variables and methods that can be used by a Perspective listener interface to get information. The following event codes are defined in this class:

// The lowest event ID allowed in Perspective JavaCHART world.
public final static int TDG_FIRST_EVENT_ID=AWTEvent.RESERVED_ID_MAX+ 1959;

// The highest event ID allowed in Perspective JavaCHART world.
public final static int TDG_LAST_EVENT_ID = TDG_FIRST_EVENT_ID + 1959;

// Perspective selection changed.
public static final int TDG_SELECTION_CHANGED  = TDG_FIRST_EVENT_ID + 1;

// Apply color change to current selection, if any.
public static final int TDG_APPLY_COLOR = TDG_FIRST_EVENT_ID + 2;

// Notify Listeners that Preset has changed.
public static final int TDG_3DPRESET_CHANGED = TDG_FIRST_EVENT_ID + 3;

// Notify Listeners that GraphType has changed.
public static final int TDG_GRAPHTYPE_CHANGED = TDG_FIRST_EVENT_ID + 4;

// Notify Listeners that CALC has been performed.
public static final int TDG_CALC_PERFORMED = TDG_FIRST_EVENT_ID + 5;

// Notify Listeners that Editing State has been toggled.
public static final int TDG_EDITOR_STATE_TOGGLE = TDG_FIRST_EVENT_ID + 6;

// Notify Listeners that Mouse Pressed.
public static final int TDG_MOUSE_PRESSED = TDG_FIRST_EVENT_ID + 7;

// Notify Listeners that Mouse Dragged.
public static final int TDG_MOUSE_DRAGGED = TDG_FIRST_EVENT_ID + 8;

// Notify Listeners that Mouse Released.
public static final int TDG_MOUSE_RELEASED = TDG_FIRST_EVENT_ID + 9;

// Notify Listeners that Mouse Moved.
public static final int TDG_MOUSE_MOVED = TDG_FIRST_EVENT_ID + 10;

// Notify Listeners that Key Pressed.
public static final int TDG_KEY_PRESSED = TDG_FIRST_EVENT_ID + 11;

// Notify Listeners that Key Released.
public static final int TDG_KEY_RELEASED = TDG_FIRST_EVENT_ID + 12;

// Notify Listeners that Key Typed.
public static final int TDG_KEY_TYPED = TDG_FIRST_EVENT_ID + 13;

// Notify Listeners that Mouse Exited.
public static final int TDG_MOUSE_EXITED = TDG_FIRST_EVENT_ID + 14;

// Notify Listeners that Mouse Entered.
public static final int TDG_MOUSE_ENTERED = TDG_FIRST_EVENT_ID + 15;

// Notify Listeners that Mouse Clicked.
public static final int TDG_MOUSE_CLICKED =T DG_FIRST_EVENT_ID + 16;

// Notify Listeners that there is not enough data
public static final int TDG_NOT_ENOUGH_DATA  = TDG_FIRST_EVENT_ID + 17;

//Notify Listeners the mouse is over a resize handle.
public static final int TDG_RESIZE_HANDLE_CHANGED = TDG_FIRST_EVENT_ID + 18;

// Notify Listeners the mouse is over a resize handle.
public static final int TDG_ACCESS_UPDATED = TDG_FIRST_EVENT_ID + 19;

// Notify Listeners that a negative value has been identified and will not be used
public static final int TDG_NEGATIVE_VALUE = TDG_FIRST_EVENT_ID + 20;

// Notify Listeners that all the data is zero
public static final int TDG_ALL_DATA_ZERO = TDG_FIRST_EVENT_ID + 21;

// Notify Listeners that a stock chart's high data is less than it's low
public static final int TDG_STOCK_HIGH_LT_LOW_VALUE = TDG_FIRST_EVENT_ID + 22;

// Notify Listeners that a pareto chart's data contains a zero
value
public static final int TDG_PARETO_ZERO_VALUE = TDG_FIRST_EVENT_ID + 23;

// Notify Listeners that O1Labels overlap
public static final int TDG_O1LABELS_OVERLAP = TDG_FIRST_EVENT_ID + 24;

// Notify Listeners that a pareto chart's data contains a negative value
public static final int TDG_PARETO_NEGATIVE_VALUE = TDG_FIRST_EVENT_ID + 25;

// Notify Listeners that a pareto chart's data contains a negative value
public static final int TDG_PARETO_NEGATIVE_VALUE = TDG_FIRST_EVENT_ID + 25;

// Notify Listeners a stock chart's value is out of range
public static final int TDG_STOCK_OPEN_OR_CLOSE_OUT_OF_RANGE = TDG_FIRST_EVENT_ID + 26;

// Number of"columns" (rows if SeriesAreRows == false) is NOT an even multiple of
the number of groups. Could indicate that the data is not suitable for the data format of the graphtype.
public static final int TDG_PARTIAL_GROUP = TDG_FIRST_EVENT_ID + 27;

// There is one group of data. but markers are turned off and to display a line or area
would require 2 or more columns.
public static final int TDG_TOO_FEW_GROUPS_FOR_LINE = TDG_FIRST_EVENT_ID + 28;

// All data values in all rows assigned to one of the two or more Y axes in a multi-Y axis graph are null.
public static final int TDG_ALL_AXIS_DATA_ZERO = TDG_FIRST_EVENT_ID + 29;

// All data values in all rows assigned to one of the two or more Y axes in a multi-Y axis graph are null.
public static final int TDG_COLUMN_DATA_ALL_NULL = TDG_FIRST_EVENT_ID + 30;


// Negative or nullminimum scale invalid for a logarithmic scale.
public static final int INVALID_MINIMUM_SCALE_LOG = TDG_FIRST_EVENT_ID + 31;

// Zero data value 
public static final int TDG_ZERO_DATA = TDG_FIRST_EVENT_ID + 32;

// Null data value for Pie or Percent
public static final int TDG_NULL_DATA_VALUE = TDG_FIRST_EVENT_ID + 33;

// Reserved for internal/Acumen use
public static final int TDG_DATA_CHANGED = TDG_FIRST_EVENT_ID + 34;

The following public methods are defined in the TDGEvent class:

CONSTRUCTOR:

/**
* Constructs a TDGEvent object with the specified source
* Perspective and type.
* @param source the Perspective where the event originated
* @param id the event type
*/
public TDGEvent (Object source, int id, Object dataObject) {
        super (source);
        m_id = id;
        m_dataObject = dataObject;
}

getSource()

This method returns the source where this event originated.

SYNTAX:

public Object getSource()

INPUT:

None

RETURN:

Object: source where this event originated

getID()

This method returns the ID associated with this event.

SYNTAX:

public int getID()

INPUT:

None

RETURN:

int; ID associated with this event.

getDataObject()

This method returns the dataObject associated with this event.

SYNTAX:

public Object getDataObject()

INPUT:

None

RETURN:

Object: dataObject associated with this event

getDescription()

This method returns a description string associated with this event.

SYNTAX:

public String getDescription()

INPUT:

None

RETURN:

String; description string associated with this event.

TDGNestedLabel Interface

The TDGNestedLabel Interface defines the following methods:

Perspective supports nested/multi-dimensional labels on the O1 axis with these properties and methods:

Use the following procedures to implement the nested labels interface:

  1. You must create your own version of the nested labels callback. It must implement all of the abstract methods defined in the TDGNestedLabel interface.
  2. Register the callback with the setO1LabelCallback() method. Example:
m_chart.setO1LabelCallback (TDGNestedLabel cb);
  1. Enable the NestedLabel property. Example:
m_chart.setNestedLabels (true);

Perspective includes a simple example of nested labels in the TDGTestNestedGroupsLabels class. The example class can be enabled by setting the NestedLabels properrty to true.

getAllLabels()

This method gets all the labels at the specified level (for batch autofitting).

SYNTAX:

public abstract Vector getAllLabels (int nLevel);

INPUT:

nLevel; Level to get the labels from.

RETURN:

Vector; Vector of String objects.

getLabel()

This method gets the string specified by the group and level. If nLevel is zero, the group label is returned. If nLevel is 1, its immediate parent in the hierarchy, etc. is returned.

SYNTAX:

public abstract String getLabel (int nGroup, int nLevel);

INPUT:

nGroup; a group number.

nLevel; a multi-dimensional label level

RETURN:

String; the label at nGroup, nLevel

getLabelGrouping()

This method gets the number of labels grouped at the level specified by the group and level.

SYNTAX:

public abstract int getLabelGrouping (int nGroup, int nLevel);

INPUT:

nGroup; a group number.

nLevel; a multi-dimensional label level

RETURN:

int; Number of labels grouped at nGroup, nLevel

getNumLabelsOnLevel()

This method returns an integer value that identifies how many labels there are on a given level.

SYNTAX:

public abstract int getNumLabelsOnLevel (int nLevel);

INPUT:

nLevel; a multi-dimensional label level

RETURN:

int; Number of labels on nLevel

getNumLevels()

This method returns an integer value that defines the number levels of nested-labels.

SYNTAX:

public abstract int getNumLevels();

INPUT:

None

RETURN:

int; Number of nested label levels.

Example TDGNestedLabels Implementation

package tdg;
import java.util.Vector;
public class TDGTestNestedGroupLabels3 implements TDGNestedLabel
{
     protected Perspectivem_Perspective;
     protected String[][]m_Labels = {
          { "Q1", "Q2","Q3", "Q4", "Q5", "Q6", "Q7","Q8" },
          { "1997", "1998"},
          { "Total" }
     };
     /** Constructor. **/
     public TDGTestNestedGroupLabels3 (Perspective perspective)
     {
          m_Perspective = perspective;
     }
     /* How many nested levels of labels are there? */
     public int getNumLevels()
     {
          return m_Labels.length;
     }
     /* How many labels are there on this level? */
     public int getNumLabelsOnLevel (int nLevel)
     {
          int nLabels;
          switch (nLevel)
          {
               case 0: nLabels = 8;
               break;
               case 1: nLabels = 2;
               break;
               case 2:
               default: nLabels = 1;
               break;
          }
     return nLabels;
     }

/**
 * Get all the labels at the specified level (for batch
 * autofitting). Returns a Vector of String objects.
 **/

public Vector getAllLabels (int nLevel)
{
     Assert.assert3D ((nLevel >= 0) && (nLevel < m_Labels.length));
     intnLabels = getNumLabelsOnLevel (nLevel);
     VectorvLabels = new Vector (nLabels);
     StringsLabel;
     for (int i = 0; i<nLabels; i++)
     {
          sLabel = getLabel (i, nLevel);
          if (sLabel != null)vLabels.addElement (sLabel);
     }
     return vLabels;
}

/**
 * Get the string specified by the group and level;
 * if nLevel is 0, the group label, if nLevel is 1, its
 * immediate parent in the hierarchy, etc.
 **/

public String getLabel (int nGroup, int nLevel)
{
     String sLabel = m_Labels[nLevel][nGroup];
     return sLabel;
}

/**
 * Get the number of labels grouped at
this level
 * specified by the group and level.
 **/

public int getLabelGrouping (int nGroup, int nLevel)
{
     int nGrouping;
     switch (nLevel)
     {
          case 0:
               nGrouping = 4;
               break;
          case 1:
               nGrouping = 2;
               break;
          case 2:
          default:
               nGrouping = 1;
               break;
     }
   
return nGrouping;
} 

TDGPreScaleIF Interface

TDGPreScaleIF is an optional callback interface that users with large datasets may implement in their existing data callbacks (TDGDataGrid) to expedite processing of data. There are 2 methods in the interface:

getScaleMaximum()

Based on the axis and scaling parameters, you may decide at runtime NOT to handle this call and choose to throw an Exception. If the call to the callback method results in an exception, Perspective for Java will catch the exception and do the scaling.

SYNTAX:

public double getScaleMaximum (int nAxis,int scaling) throws Exception

INPUT:

nAxis; an integer that identifies an axis

scaling; an integer that identifies the type of scaling

SCALING_ABSOLUTE
SCALING_STACKED
SCALING_PERCENT
SCALING_HIST
SCALING_WATERFALL

RETURN:

double; maximum value to calculate scaling

EXAMPLE:

public double getScaleMaximum (int nAxis, int nScaling) throws Exception
{
    // Stacked,Percent,Histogram scaling too complex, let PFJ do it!
    if (nScaling == TDGPreScaleIF.SCALING_ABSOLUTE)  return max;
    else throw new Exception ("Sorry, I don't understand this scaling: " + nScaling);
}

ALSO SEE:

getScaleMinimum()

getScaleMinimum()

Based on the axis and scaling parameters, you may decide at runtime NOT to handle this call and choose to throw an Exception. If the call to the callback method results in an exception, Perspective for Java will catch the exception and do the scaling.

SYNTAX:

public double getScaleMinimum (int nAxis, int scaling) throws Exception

INPUT:

nAxis; an integer that identifies an axis

scaling; an integer that identifies the type of scaling

SCALING_ABSOLUTE
SCALING_STACKED
SCALING_PERCENT
SCALING_HIST
SCALING_WATERFALL

RETURN:

double; minimum value to calculate scaling

EXAMPLE:

public double getScaleMinimum (int nAxis, int nScaling)throws Exception
{
    // Stacked,Percent,Histogram scaling too complex,
    // let PFJ do it!
    if  (nScaling == TDGPreScaleIF.SCALING_ABSOLUTE)
         return min;
    else
         throw new Exception ("Sorry, I don't understand this scaling: " + nScaling);
}

ALSO SEE:

getScaleMaximum()

Example Implementation of TDGPreScaleIF

The following code shows an example implementation of this interface.

EXAMPLE:

package tdg;
import tdg.data.in.TDGDataGrid;
import tdg.data.in.TDGPreScaleIF;
import java.util.Random;
public class LargeDefaultData implements TDGDataGrid, TDGPreScaleIF
{
  static final int SMALL_DATASET = 10;
  static final int LARGE_DATASET = 1000;
  boolean isDirtyFlag = false;
  double[][] testdata = new double[LARGE_DATASET] [SMALL_DATASET];
  Object data[][];
  String[] rowLabels = new String[LARGE_DATASET];
  String[] colLabels = {"1", "2", "3", "4", "5", "6","7","8", "9", "10"};
  int numCols = SMALL_DATASET;
  int numRows = LARGE_DATASET;
  double value;
  double min = Double.MAX_VALUE;
  double max = -Double.MAX_VALUE;
  Random randNum = new Random (1000);
  public LargeDefaultData()
  {   // Row Labels.
      for (int i=0;i<numRows;i++)rowLabels[i]="" +  (i+1); // Load Data.
      data = new Object[numRows][numCols];
      for (int row = 0; row < numRows; row++)
      {
           for (int col = 0; col < numCols; col++)
           {
                value = randNum.nextDouble() * 100;
                data[row][col] = new Double (value);
                // For dataformats with more than one
                // numeric axis, e.g. scatter, we
                // need to check which axis "value" 
                // was associated with.
                if  (value < min)min = value;
                if  (value > max)max = value;
          }
      }
  }
  public String getTitle() { return "Performance Test Title"; }
  public String getSubtitle() { return ""; }
  public String getFootnote() { return ""; }
  public String getX1AxisTitle() { return ""; }
  public String getY1AxisTitle() { return ""; }
  public String getO1AxisTitle() { return ""; }
  public String getO2AxisTitle() { return ""; }
  public String getY2AxisTitle() { return ""; }
  public String columnLabel (int x){return colLabels[x];}

  public int getColumns() { return numCols; }
  public String rowLabel (int x) {return rowLabels[x];}
  public int getRows() { return numRows; }
  public Object getValue (int row, int col) { return data[row][col]; }
  public boolean isDirty() { return isDirtyFlag; }

  // Needed for TDGPreScaleIF interface to speed PFJ scale calculations

  public double getScaleMinimum (int nAxis,int nScaling)throws Exception
  {
       // Stacked,Percent,Histogram scaling too complex, let PFJ do it!
       if  (nScaling == TDGPreScaleIF.SCALING_ABSOLUTE)
            return min;
       else
            throw new Exception ("Sorry, I don't understand this scaling: " + nScaling);
  }

  public double getScaleMaximum (int nAxis,int nScaling)throws Exception
  {
       // Stacked,Percent,Histogram scaling too, complex let PFJ do it!
       if  (nScaling == TDGPreScaleIF.SCALING_ABSOLUTE)
            return max;
       else
            throw new Exception ("Sorry, I don't  understand this scaling: " + nScaling);
  }
}

ToolTipCallback Interface

This interface defines a dynamic callback function to produce a tooltip:

getDynamicToolTip()

This function is a dynamic callback to produce a tooltip. When this method is called, your application should provide a very fast method that returns the proper string for the object in question.

SYNTAX:

String getDynamicToolTip (tdg.TDGMouseState aMouseState,boolean UserOrDeveloper)

INPUT:

aMouseState; an object of class TDGMouseState which provides all the information about the object for which the tooltip is being generated.

UserOrDeveloper; true = Developer information, false = User information

RETURN:

String; tooltip result string.

NOTES:

getDynamicToolTip() is defined in the ToolTipCallBack interface.

EXAMPLE:

public class TestToolTipCallBack implements ToolTipCallBack
{
    public String getDynamicToolTip (
        TDGMouseState aMouseState,
        boolean UserOrDeveloper
    )

    {
        String strReturn;
        // MACROS that are expanded in a CUSTOM Tool Tip
        // Examples:
        // [ON] is ([OID])[R]Instance # [OIN][R]
    

        /*
        // MACROS for formatting
        static final String RETURN_MACRO = "[R]";// A CR
        // MACROS for OBJECTS and OBJECT IDS
        static final String OBJECT_NAME_MACRO = "[ON]";
        static final String OBJECT_DESCRIPTION_MACRO = "[OD]";
        static final String OBJECT_ID_MACRO = "[OID]";
        static final String OBJECT_INSTANCE_MACRO = "[OIN]";
        static final String SERIES_LABEL_MACRO = "[SL]";
        static final String GROUP_LABEL_MACRO = "[GL]";
        // MACROS for VALUES
        static final String CUMULATIVE_STACKED_VALUE_MACRO = "[CUMSTKV]";
        static final String CUMULATIVE_PERCENTAGE_VALUE_MACRO = "[CUMPCTV]";
        static final String PIE_PERCENTAGE_VALUE_MACRO = "[PIEPCTV]";
        static final String HILO_HIGH_VALUE_MACRO = "[HV]";
        static final String HILO_LOW_VALUE_MACRO = "[LV]";
        static final String HILO_OPEN_VALUE_MACRO = "[OV]";
        static final String HILO_CLOSE_VALUE_MACRO = "[CV]";
        static final String HILO_VOLUME_VALUE_MACRO = "[VV]";
        static final String X_VALUE_MACRO = "[XV]";
        static final String Y_VALUE_MACRO = "[YV]";
        static final String Z_VALUE_MACRO = "[ZV]";
        */

        strReturn = "Element ID is (" + aMouseState.getElementObjectID() + ")[R]";
        strReturn += "Series = [SL][R]";
        strReturn += "Group = [GL][R]";
        strReturn += "Cumulative Stacked = [CUMSTKV][R]";
        strReturn += "Cumulative Percentage = [CUMPCTV][R]";
        strReturn += "Pie Percentage = [PIEPCTV][R]";
        strReturn += "High = [HV][R]";
        strReturn += "Low = [LV][R]";
        strReturn += "Open = [OV][R]";
        strReturn += "Close = [CV][R]";
        strReturn += "Volume = [VV][R]";
        strReturn += "X Value = [XV][R]";
        strReturn += "Y Value = [YV][R]";
        strReturn += "Z Value = [ZV][R]";
        return strReturn;
    } 
}

ALSO SEE:

setDynamicToolTip()

TDGError

TDGError is the root error event class for all perspective-level error events. An error listener defined by addErrorListener() may obtain error codes using the methods defined in this class. The following error codes are defined in TDGError:

// The lowest error ID allowed in Perspective for Java
public final static int TDG_FIRST_ERROR_ID = AWTEvent.RESERVED_ID_MAX + 1959;

// The highest error IDallowed in Perspective for Java
public final static int TDG_LAST_ERROR_ID = TDG_FIRST_ERROR_ID + 1959;

// Scale minimum largerthat scale maximum.
public static final int SCALE_INVERTED = TDG_FIRST_ERROR_ID + 1;

// Negative axis step.
public static final int NEGATIVE_AXIS_STEP = TDG_FIRST_ERROR_ID + 2;

// Step larger than range.
public static final int AXIS_STEP_LARGE = TDG_FIRST_ERROR_ID + 3;

// Step too small.
public static final int AXIS_STEP_SMALL = TDG_FIRST_ERROR_ID + 4;

// Negative or null minimum scale invalid for a logarithmic scale.
public static final int INVALID_MINIMUM_SCALE_LOG = TDG_FIRST_ERROR_ID + 5;

// Negative or null maximum scale invalid for a logarithmic scale.
public static final int INVALID_MAXIMUM_SCALE_LOG = TDG_FIRST_ERROR_ID + 6;

// Scale minimum and maximum are equal.
public static final int MINIMUM_MAXIMUM_SCALE_EQUAL=TDG_FIRST_ERROR_ID+
7;

// Negative axis minor step.
public static final int NEGATIVE_AXIS_MINOR_STEP = TDG_FIRST_ERROR_ID + 8;

// Minor step larger than range.
public static final int MINOR_STEP_LARGE = TDG_FIRST_ERROR_ID + 9;

// Minor step too small.
public static final int MINOR_STEP_SMALL = TDG_FIRST_ERROR_ID + 10;

// Empty Cell.
public static final int EMPTY_CELL = TDG_FIRST_ERROR_ID + 11;

// Messages from FTP Session.
public static final int FTP_MESSAGES = TDG_FIRST_ERROR_ID + 12;

// Calc Moving Average.
public static final int CALC_MOVING_AVERAGE = TDG_FIRST_ERROR_ID + 13; 

// Unknown Axis.
public static final int UNKNOWN_AXIS = TDG_FIRST_ERROR_ID + 14;

// Property Normalization.
public static final int PROPERTY_NORMALIZATION = TDG_FIRST_ERROR_ID + 15; 

// Invalid GraphType Change Occurred.
public static final int GRAPHTYPE_CHANGE_ATTEMPTED = TDG_FIRST_ERROR_ID + 16;

// Notify Listeners of interesting information. Primarily to enhance use of TDGLoadSave.
public static final int TDG_GENERAL_MESSAGE = TDG_FIRST_ERROR_ID + 17;

// Failed to write chart to a stream or file.
public static final int WRITE_ERROR = TDG_FIRST_ERROR_ID + 18;

// Failed to read from a stream or file.
public static final int READ_ERROR = TDG_FIRST_ERROR_ID + 19;

// Error accessing Texture URL from the look of the graph
public static final int TEXTUREURLNOTFOUND_ERROR = TDG_FIRST_ERROR_ID + 20;

The following methods are defined in TDGError.

TDGError()

This method creates a TDGError object with the specified source Perspective and type.

SYNTAX:

public TDGError (Object source, int id, String Explanation, Object errorObject)

INPUT:

source; the Perspective where the error originated

id; error ID

Explanation; error text string

errorObject; error object

getSource()

This method is defined in the TDGError class. It returns the source where this error originated.

SYNTAX:

public Object getSource()

INPUT:

None

RETURN:

Object: the source where this error originated.

getID()

This method is defined in the TDGError class. It returns an ID associated this error.

SYNTAX:

public int getID()

INPUT:

None

RETURN:

int; error ID

getExplanation()

This method is defined in the TDGError class. It returns a string the described this error.

SYNTAX:

public String getExplanation()

INPUT:

None

RETURN:

String; a text string that describes the error code

getErrorObject()

This method is defined in the TDGError class. It returns the data object associated with this error.

SYNTAX:

public Object getErrorObject()

INPUT:

None

Return

Object; data object associated with this error.