com.endeca.navigation.charting
Class Grid

java.lang.Object
  extended by com.endeca.navigation.charting.Grid

public class Grid
extends Object

This class represents a grid (or multidimensional array) that is built from Endeca analytics data. The data is stored in a way that is convenient for building graphs, charts, or tables.

A Grid returns values based on one or more "axes". For example, suppose you have cross-tab data in the following form:

{ Name: Smith, Quarter: 1Q06, Sales: 3000 }
{ Name: Smith, Quarter: 2Q06, Sales: 4200 }
{ Name: Smith, Quarter: 3Q06, Sales: 4500 }
{ Name: Jones, Quarter: 1Q06, Sales: 1200 }
{ Name: Jones, Quarter: 2Q06, Sales: 1600 }
In this case, you create a Grid with 2 axisNames ("Name" and "Quarter") and with a valueName "Sales". The items in each axis (e.g., "Smith" and "3Q06") are called Labels, and are typically used as labels for the axes of a graph or table.

These Labels are also used to look up each value to display using the getValue method. In the example above, using getValue for the Labels "Smith" and "3Q06" would return "4500".


Constructor Summary
Grid(Iterator analytics, String valueName, List axisNames)
          Constructs a Grid from the specified Endeca analytics data.
Grid(Iterator analytics, String valueName, String axis)
          Convenience constructor for a one-axis Grid - same as passing in a List containing the strings.
Grid(Iterator analytics, String valueName, String axisOne, String axisTwo)
          Convenience constructor for a two-axis Grid - same as passing in a List containing the two strings.
 
Method Summary
 List getLabels(int axis)
          Returns the List of Labels for the specified axis.
 int getNumAxes()
          Returns the number of "axes" (that is, the number of labels) in the grid.
 Cell getValue(Label label)
          Convenience method - same as passing in a List containing the Label.
 Cell getValue(Label labelOne, Label labelTwo)
          Convenience method - same as passing in a List containing the two Labels.
 Cell getValue(List labels)
          Returns the value at the location indicated by the labels.
 void sortLabels(int axis, Comparator comparator)
          Causes the labels in the specified axis to be sorted by the specified comparator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grid

public Grid(Iterator analytics,
            String valueName,
            String axis)
Convenience constructor for a one-axis Grid - same as passing in a List containing the strings.


Grid

public Grid(Iterator analytics,
            String valueName,
            String axisOne,
            String axisTwo)
Convenience constructor for a two-axis Grid - same as passing in a List containing the two strings.


Grid

public Grid(Iterator analytics,
            String valueName,
            List axisNames)
Constructs a Grid from the specified Endeca analytics data.

Parameters:
analytics - The analytics results to use.
valueName - The name of the property or dimension that holds the value to chart.
axisNames - The names of the properties or dimensions that hold the labels of each "axis" of the grid.
Method Detail

sortLabels

public void sortLabels(int axis,
                       Comparator comparator)
Causes the labels in the specified axis to be sorted by the specified comparator. The next caller to getLabels(axis) will receive them in sorted order. The Comparator will be asked to compare Label objects.


getNumAxes

public int getNumAxes()
Returns the number of "axes" (that is, the number of labels) in the grid. This does not count the values as an axis. This value is equal to the number of label-lists available from getLabels().


getLabels

public List getLabels(int axis)
Returns the List of Labels for the specified axis.


getValue

public Cell getValue(Label label)
Convenience method - same as passing in a List containing the Label.


getValue

public Cell getValue(Label labelOne,
                     Label labelTwo)
Convenience method - same as passing in a List containing the two Labels.


getValue

public Cell getValue(List labels)
Returns the value at the location indicated by the labels.

Parameters:
labels - A List of Label objects.


© 2003, 2012 Oracle and/or its affiliates. All rights reserved.