com.ihr.xbrl.om.table.layout

## Class XBRLTableLayout

- java.lang.Object
- - javax.swing.table.AbstractTableModel
  - - com.ihr.xbrl.om.table.layout.XBRLTableLayout

- All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

      public class XBRLTableLayout
      extends javax.swing.table.AbstractTableModel

  The table layout class contains an object model suitable for representation in a graphical view. It contains the effective breakdown for each axis and the headers (for rows and columns) also implements the elimination and expansion processes and resolves the relationship between data and the table cells. In the future, this class should implement a table model and other components to fully draw a table in the GUI
  Author:
    Ignacio
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLTableLayout(XBRLStructuralTable structuralTable)` Creates a new XBRLTableLayout from a structural table.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Cell` | `createCell(int newColNumber, int newRowNumber, CellHeader columnHeader, CellHeader rowHeader, CellHeader zHeader, java.util.TreeSet<java.lang.String> sortedTagSelectors)` Creates the cell.
    `void` | `createCells(org.jdom.Element tableElement)` Generates all table cells from the table model.
    `void` | `createHeaders(org.jdom.Element tableElement)` Generates the table headers for the entire table.
    `void` | `createModel(org.jdom.Element tableSet)` Generates the table layout model from the table content.
    `Aspect<?>` | `getAspectOnCell(CellHeader och)` Returns the aspect instance for the cell received in the parameter.
    `java.util.Iterator<Axis>` | `getAxis()` Returns an iterator on axis defined in this table.
    `Header` | `getAxisHeaderInfo(Axis axis)` Returns information about the axis collected while creating cells this contains all aspects in that axis and the set of distict values for each aspect.
    `Cell` | `getCellAt(int rowIndex, int columnIndex)` Access to the Cell object for specific rowIndex and columnIndex.
    `int` | `getColumnCount()`
    `EffectiveBreakdown` | `getEffectiveBreakdown(Axis axis, OpenAspectValueResolver externalResolver)` Returns (or computes and returns) the effective breakdown of all breakdowns in an axis from the structural model to the layout model.
    `FactsListClassifier` | `getFactsSelector()` Gets the facts selector.
    `XBRLItem` | `getItemAt(int rowIndex, int columnIndex)` Returns the XBRLItem for a specific cell indicated as a row and column if the cell contains a tuple, the result value is null.
    `int` | `getMissingAspects()` At the end of the table layout process, the table is explored for missing aspects.
    `int` | `getRowCount()`
    `CompanyKey` | `getSelectedCompany()` This method is required by the export to excel process but it shouldn't be here because a table might contains multiple companies in multiple rows.
    `XBRLStructuralTable` | `getStructuralTable()` Access to the table structural model.
    `java.util.Collection<CellHeader>` | `getTableHeadersRoots(Axis axis)` Access to the cell headers in the leftmost row or column.
    `java.util.Collection<XBRLFact>` | `getValueAt(int rowIndex, int columnIndex)`
    `int` | `getZLevel()` Access to the current value of the z level.
    `CellHeader` | `getZLevelCell(int zLevel)` Returns the CellHeader in the Z axis that corresponds with the indicated zLevel number.
    `int` | `getZLevels()` Returns the maximum ZLevel number for this table layout.
    `boolean` | `isAxisDefined(Axis axis)` Returns true if the table contains information for the axis indicated in the axis parameter.
    `boolean` | `isCellEditable(int rowIndex, int columnIndex)`
    `boolean` | `isOpen(Axis axis)` Returns true when on the axis indicated there is at least one open breakdown.
    `void` | `layout(XBRLFactsList factsSource, EditorSource editorSource, OpenAspectValueResolver externalResolver)` Prepares the table layout.
    `void` | `setZlevel(int zIndex)` Sets the current zLevel to the value indicated in the zIndex parameter.

    - ### Methods inherited from class javax.swing.table.AbstractTableModel

      `addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListener, setValueAt`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XBRLTableLayout

          public XBRLTableLayout(XBRLStructuralTable structuralTable)
                          throws XTValidationException,
                                 XFException

      Creates a new XBRLTableLayout from a structural table. This is just the constructor. The layout is generated later in a call to the layout method
      Parameters:
        `structuralTable` - the structural table
      Throws:
        `XTValidationException` - the XT validation exception
        `XFException` - the XF exception
      See Also:
        `layout(XBRLFactsList, EditorSource, OpenAspectValueResolver)`

  - ### Method Detail

    - #### getMissingAspects

          public int getMissingAspects()

      At the end of the table layout process, the table is explored for missing aspects. Actually the aspects explored are the Concept aspect, the Entity Identifier aspect and the Period aspect. If the aspect is not explicitly referenced in the table it is considered as an open aspect whose value will be provided by the GUI. At this time, the getMissingAspects() method returns a bitmap integer whose bits whose value is 1 means the aspect is missing.
      Returns:
        the missing aspects
      See Also:
        `CommonAspectRule`

    - #### layout

          public void layout(XBRLFactsList factsSource,
                    EditorSource editorSource,
                    OpenAspectValueResolver externalResolver)
                      throws XFException,
                             XTValidationException

      Prepares the table layout. This includes the expansion process and the process to prepare headers and cells The process might be fired when new values are added to the EditorSource in order to recreate the cells
      Parameters:
        `factsSource` - the source of facts for this layout. this is the same value used to build up this XBRLTableLayout instance
        `editorSource` - if this is not null, this must be an instance of the EditorSource interface that might provide extra values to open dimensions
        `externalResolver` - this this is not null, this class will be used to constrain the values of the selected dimensions in the Z axis
      Throws:
        `XFException` - the XF exception
        `XTValidationException` - the XT validation exception

    - #### getStructuralTable

          public XBRLStructuralTable getStructuralTable()

      Access to the table structural model.
      Returns:
        the structuralTable

    - #### getEffectiveBreakdown

          public EffectiveBreakdown getEffectiveBreakdown(Axis axis,
                                                 OpenAspectValueResolver externalResolver)

      Returns (or computes and returns) the effective breakdown of all breakdowns in an axis from the structural model to the layout model.
      Parameters:
        `axis` - the axis
        `externalResolver` - the external resolver
      Returns:
        the effective breakdown

    - #### getAxis

          public java.util.Iterator<Axis> getAxis()

      Returns an iterator on axis defined in this table. The iterator order is undefined
      Returns:
        the axis

    - #### isAxisDefined

          public boolean isAxisDefined(Axis axis)

      Returns true if the table contains information for the axis indicated in the axis parameter.
      Parameters:
        `axis` - the axis
      Returns:
        true, if is axis defined

    - #### isOpen

          public boolean isOpen(Axis axis)

      Returns true when on the axis indicated there is at least one open breakdown.
      Parameters:
        `axis` - the axis
      Returns:
        true, if is open

    - #### getAxisHeaderInfo

          public Header getAxisHeaderInfo(Axis axis)

      Returns information about the axis collected while creating cells this contains all aspects in that axis and the set of distict values for each aspect.
      Parameters:
        `axis` - the axis
      Returns:
        the axis header info

    - #### getTableHeadersRoots

          public java.util.Collection<CellHeader> getTableHeadersRoots(Axis axis)

      Access to the cell headers in the leftmost row or column. From this point it shall be possible to traverse CellHeaders using getChildren on the returned CellHeader
      Parameters:
        `axis` - the axis
      Returns:
        the table headers roots

    - #### createModel

          public void createModel(org.jdom.Element tableSet)
                           throws XTValidationException

      Generates the table layout model from the table content. This call generates the model for the entire layout. The parent node is the tableSet element.
      Parameters:
        `tableSet` - this is a jdom Element that must be a tableSet
      Throws:
        `XTValidationException` - the XT validation exception

    - #### createHeaders

          public void createHeaders(org.jdom.Element tableElement)
                             throws XTValidationException

      Generates the table headers for the entire table. This method could be called separately and this is why is is public. The parameter must be a JDom element node that is a table XML element.
      Parameters:
        `tableElement` - the table element
      Throws:
        `XTValidationException` - the XT validation exception

    - #### createCells

          public void createCells(org.jdom.Element tableElement)
                           throws XTValidationException

      Generates all table cells from the table model. This process follows the axis and generates cells for the entire table.
      Parameters:
        `tableElement` - the table element
      Throws:
        `XTValidationException` - the XT validation exception

    - #### createCell

          public Cell createCell(int newColNumber,
                        int newRowNumber,
                        CellHeader columnHeader,
                        CellHeader rowHeader,
                        CellHeader zHeader,
                        java.util.TreeSet<java.lang.String> sortedTagSelectors)
                          throws XTValidationException

      Creates the cell.
      Parameters:
        `newColNumber` - the new col number
        `newRowNumber` - the new row number
        `columnHeader` - the column header
        `rowHeader` - the row header
        `zHeader` - the z header
        `sortedTagSelectors` - the sorted tag selectors
      Returns:
        the cell
      Throws:
        `XTValidationException` - the XT validation exception

    - #### getAspectOnCell

          public Aspect<?> getAspectOnCell(CellHeader och)

      Returns the aspect instance for the cell received in the parameter.
      Parameters:
        `och` - the och
      Returns:
        the aspect on cell

    - #### getFactsSelector

          public FactsListClassifier getFactsSelector()

      Gets the facts selector.
      Returns:
        the facts selector

    - #### getZLevels

          public int getZLevels()

      Returns the maximum ZLevel number for this table layout. The first one is always 1, the range is between 1 and the value returned by this method inclusive. If this method returns 0 this means the table has no ZAxis, no rows and no columns defined.
      Returns:
        integer
      See Also:
        `getZLevel()`, `setZlevel(int)`

    - #### getZLevelCell

          public CellHeader getZLevelCell(int zLevel)

      Returns the CellHeader in the Z axis that corresponds with the indicated zLevel number.
      Parameters:
        `zLevel` - the z level
      Returns:
        the z level cell

    - #### getZLevel

          public int getZLevel()

      Access to the current value of the z level.
      Returns:
        integer value
      See Also:
        `getZLevels()`, `setZlevel(int)`

    - #### getRowCount

          public int getRowCount()

    - #### getColumnCount

          public int getColumnCount()

    - #### isCellEditable

          public boolean isCellEditable(int rowIndex,
                               int columnIndex)

      Specified by:
        `isCellEditable` in interface `javax.swing.table.TableModel`
      Overrides:
        `isCellEditable` in class `javax.swing.table.AbstractTableModel`

    - #### setZlevel

          public void setZlevel(int zIndex)

      Sets the current zLevel to the value indicated in the zIndex parameter. If the table layout contains multiple tables, this value establish the value of the z axis that selects the proper slice and applies to all calls to getCellAt, getItemAt and other methods that accepts row index and column index
      Parameters:
        `zIndex` - the new zlevel

    - #### getCellAt

          public Cell getCellAt(int rowIndex,
                       int columnIndex)

      Access to the Cell object for specific rowIndex and columnIndex.
      Parameters:
        `rowIndex` - the row index
        `columnIndex` - the column index
      Returns:
        the cell at

    - #### getValueAt

          public java.util.Collection<XBRLFact> getValueAt(int rowIndex,
                                                  int columnIndex)

    - #### getItemAt

          public XBRLItem getItemAt(int rowIndex,
                           int columnIndex)

      Returns the XBRLItem for a specific cell indicated as a row and column if the cell contains a tuple, the result value is null.
      Parameters:
        `rowIndex` - the row index
        `columnIndex` - the column index
      Returns:
        the item at

    - #### getSelectedCompany

          public CompanyKey getSelectedCompany()

      This method is required by the export to excel process but it shouldn't be here because a table might contains multiple companies in multiple rows.
      Returns:
        the selected company