Class SummaryTable

All Implemented Interfaces:
EditableTableModel, PopupActivationListener, Serializable, Comparable, EventListener, ListSelectionListener, TableModel

public class SummaryTable extends RamAttributeStore
This class summarizes univariate statistics from a numeric exprerssion calculated from the input table. The information is summarized by a category expression, and is collected from records that match to a selection expression. The information may be summarized for a single period or for multiple periods.

SummaryTable objects can be created using the constructor or or the static createSummaryTable(ca.spatial.table.AttributeStore,java.lang.String,java.lang.String,java.lang.String,int,java.util.Observer) method. When using the constructor a summary table 'template' is created that does not yet contain any sampled data. This template is suitable to pass to a report constructor where it will be used to collect data on demand when the report is materialized. Use the getSnapshot(boolean) method in order to get a summarized data table from the template/

When the createSummaryTable(ca.spatial.table.AttributeStore, java.lang.String, java.lang.String, java.lang.String, int, java.util.Observer) method is used a snapshot will be taken of the state of the table when the summary is run. Use the SummaryTable.Snapshot.getParent() method to retrieve the template from the snaphot.

For example, the following will capture a summary table by LMU and planning period. The report will format the minimum harvest age value and present this as a table.


 at = new SummaryTable(control.getBlockTable(),
     "LMU",                     // The expression to categorize the data
     "TREATMENTAGE",            // Summarize TREATMENTAGE
     "CURRENTTREATMENT ne ''",  // Select harvest activities
      null,                     // Select all periods
 );
 // Take a snapshot and show the resulting data cube
 at.getSnapshot(false).showCube(true);
 
 categories5 = new Comparable[] {
   "A", 
   "CH", 
   "CP", 
   "HE", 
   "HO", 
   "LI", 
   "MI", 
   "N", 
   "SA", 
   "SOL", 
   "W"};

 report1 = new PeriodCategoryReport("minHarvAgeLMU", // filename
   "Minimum harvest age by LMU", // title
   "Age", // units
   attributeStore4, // attributeStore
   "", // reselectExpression
   Horizon.activeList, // periods
   false, // annualize
   "", // HTMLText
   false, // percent
   "Minimum", // valueExpression
   "Category", // categoryExpression
   categories5 // categories
 );
 report1.setNoChart(true);
 reportWriter.addReport(report1);
 
See Also:
Serialized Form
  • Constructor Details

    • SummaryTable

      public SummaryTable(AttributeStore as, String cat, String val, String select, int period) throws Exception
      Create a summary table for the values from a single planning period. The summary table will have one row for each unique value of the category expression. The row will contain the category expression and the sum of the value expression for each matching record.

      This constructor will create a SummaryTable definition but without the results. In order to capture the results obtain a snapshot using the getSnapshot(boolean) method. In order to automatically get a snapshot for the current values use one of the createSummaryTable(ca.spatial.table.AttributeStore, java.lang.String, java.lang.String, java.lang.String, int, java.util.Observer) methods.

      Parameters:
      as - The input attribute store to be summarized
      cat - The category expression. The output table will have one row for each unique value of the catgory expression.
      val - The value expression. The output table will sum the value expression for each unique category.
      period - The period to summarize
      Throws:
      Exception
    • SummaryTable

      public SummaryTable(AttributeStore as, String cat, String val, String select, int[] periods) throws Exception
      Create a summary table for the values from a list of planning periods. The summary table will have one row for each unique value of the category expression. The row will contain the category expression and the sum of the value expression for each matching record.

      This constructor will create a SummaryTable definition but without the results. In order to capture the results obtain a snapshot using the getSnapshot(boolean) method. In order to automatically get a snapshot for the current values use one of the createSummaryTable(ca.spatial.table.AttributeStore, java.lang.String, java.lang.String, java.lang.String, int, java.util.Observer) methods.

      Parameters:
      as - The input attribute store to be summarized
      cat - The category expression. The output table will have one row for each unique value of the catgory expression.
      val - The value expression. The output table will sum the value expression for each unique category.
      periods - The list of periods to summarize, or null to summarize all periods.
      Throws:
      Exception
  • Method Details

    • getParent

      public AttributeStore getParent()
    • getCacheParent

      public AttributeStore getCacheParent()
      Description copied from class: AttributeStore
      Return the parent data source from within a caching layer. In case the data source is not being cached then this will simply return itself.
      Overrides:
      getCacheParent in class AttributeStore
    • getCategory

      public String getCategory()
    • getValue

      public String getValue()
    • getReselect

      public String getReselect()
    • getPeriods

      public int[] getPeriods()
    • createSummaryTable

      public static AttributeStore createSummaryTable(AttributeStore as, String cat, String val, String select, int period, Observer progress) throws Exception
      Create a summary table for the values from a single planning period. The summary table will have one row for each unique value of the category expression. The row will contain the category expression and the sum of the value expression for each matching record.
      Parameters:
      as - The input attribute store to be summarized
      cat - The category expression. The output table will have one row for each unique value of the catgory expression.
      val - The value expression. The output table will sum the value expression for each unique category.
      period - The period to summarize
      progress - An optional Observer object to track the progress of the summary. This parameter may be null.
      Returns:
      Will return a SummaryTable with the results of the summary.
      Throws:
      Exception
    • createSummaryTable

      public static AttributeStore createSummaryTable(AttributeStore as, String cat, String val, String select, int[] periods, Observer progress) throws Exception
      Create a summary table for the selected planning peiords. The summary table will have one row for each unique value of the category expression. The row will contain the category expression and the sum of the value expression for each matching record.
      Parameters:
      as - The input attribute store to be summarized
      cat - The category expression. The output table will have one row for each unique value of the catgory expression.
      val - The value expression. The output table will sum the value expression for each unique category.
      periods - A list of periods to summarize. If null then summarize all periods.
      progress - An optional Observer object to track the progress of the summary. This parameter may be null.
      Returns:
      Will return a SummaryTable with the results of the summary.
      Throws:
      Exception
    • getSnapshot

      public AttributeStore getSnapshot(boolean useSelected)
      Get a snapshot of this summary definition. The queries will be run to compute the statistics in the underlying dataset. The results will be contained in the snapshot and will not change even if the underlying data set changes.
      Overrides:
      getSnapshot in class AttributeStore
      Parameters:
      useSelected - The calculations will only be computed on the selected records.
      Returns:
      This method will return a new shapshot that captures the state of the summary definition for the current data set.
    • getSnapshot

      public AttributeStore getSnapshot(boolean useSelected, Observer progress)
      Get a snapshot of this summary definition. The queries will be run to compute the statistics in the underlying dataset. The results will be contained in the snapshot and will not change even if the underlying data set changes.
      Overrides:
      getSnapshot in class AttributeStore
      Parameters:
      useSelected - The calculations will only be computed on the selected records.
      progress - A optional reference to an Observer that will be updated with the progress of the calculations.
      Returns:
      This method will return a new shapshot that captures the state of the summary definition for the current data set.