com.extentech.ExtenXLS.eventui
Class WorkBookModel

java.lang.Object
  extended by com.extentech.ExtenXLS.eventui.WorkBookModel

public class WorkBookModel
extends java.lang.Object

Model of a workbook that handles display-related logic. This class tracks the active sheet and cell and the current selection.


Constructor Summary
WorkBookModel()
          Creates a model of an empty workbook.
WorkBookModel(WorkBookHandle target)
          Creates a model of the given workbook.
WorkBookModel(WorkBookHandle target, int active)
          Creates a model of the given workbook with the given sheet active.
 
Method Summary
 void addActiveCellChangedListener(ActiveCellChangedListener listener)
           
 void addActiveSheetChangedListener(ActiveSheetChangedListener listener)
           
 void addSelectionChangedListener(SelectionChangedListener listener)
           
 void addStructureChangedListener(StructureChangedListener listener)
           
 void close()
          clear out object references in preparation for closing
 int convertColToModel(int index)
          Gets the workbook index of a column based on its view index.
 int convertColToView(int index)
          Gets the view index of a column based on its workbook index.
 int convertRowToModel(int index)
          Gets the workbook index of a row based on its view index.
 int convertRowToView(int index)
          Gets the view index of a row based on its workbook index.
 CellHandle getActiveCell()
          Returns the current active cell.
 int getActiveColumn()
           
 int getActiveRow()
           
 WorkSheetHandle getActiveSheet()
          Returns the current active sheet.
 java.lang.String getColLabel(int col)
          Returns the label for the given column.
 int getHeaderHeight()
          Gets the height of the column headers.
 int getHeaderWidth()
          Gets the width of the row headers.
 int getMaxCol()
          Gets the last column that will be displayed.
 int getMaxRow()
          Gets the last row that will be displayed.
 int getMinCol()
          Gets the first column that will be displayed.
 int getMinRow()
          Gets the first row that will be displayed.
 int getRowHeight(int index)
          Returns the height of the given row on the current sheet.
 java.lang.String getRowLabel(int row)
          Returns the label for the given row.
 double getScale()
          Gets the current scaling factor.
 CellRange getSelectedRange()
           
 CellRangeRef getSelectedRangeRef()
           
 WorkBookHandle getWorkBook()
          Returns the workbook this model wraps.
 boolean isEnableSelection()
           
 void removeActiveCellChangedListener(ActiveCellChangedListener listener)
           
 void removeActiveSheetChangedListener(ActiveSheetChangedListener listener)
           
 void removeSelectionChangedListener(SelectionChangedListener listener)
           
 void removeStructureChangedListener(StructureChangedListener listener)
           
 void setActiveCell(int row, int col)
           
 void setActiveSheet(int index)
          Sets the active sheet.
 void setColLabel(int col, java.lang.String label)
          Sets the label for a column.
 void setEnableSelection(boolean enable)
           
 void setHeaderHeight(int height)
          Sets the height of the column headers.
 void setHeaderWidth(int width)
          Sets the width of the row headers.
 void setMaxCol(int max)
          Sets the last column that will be displayed.
 void setMaxRow(int max)
          Sets the last row that will be displayed.
 void setMinCol(int min)
          Sets the first column that will be displayed.
 void setMinRow(int min)
          Sets the first row that will be displayed.
 void setRowLabel(int row, java.lang.String label)
          Sets the label for a row.
 void setScale(double scale)
          Sets the scaling factor.
 void setSelectedRange(CellRangeRef range)
          Sets the selection to the given range.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkBookModel

public WorkBookModel()
Creates a model of an empty workbook.


WorkBookModel

public WorkBookModel(WorkBookHandle target)
Creates a model of the given workbook. The active sheet will be determined by the workbook's default sheet setting. If there is no default sheet, the first sheet will be active.

Parameters:
target - the WorkBookHandle that should be modeled
Throws:
java.lang.IllegalArgumentException - if the given workbook is null

WorkBookModel

public WorkBookModel(WorkBookHandle target,
                     int active)
Creates a model of the given workbook with the given sheet active.

Parameters:
target - the WorkBookHandle that should be modeled
active - the index of the sheet that should be active on load
Throws:
java.lang.IllegalArgumentException - if the given workbook is null
java.lang.IndexOutOfBoundsException - if the given sheet does not exist
Method Detail

addActiveSheetChangedListener

public void addActiveSheetChangedListener(ActiveSheetChangedListener listener)

removeActiveSheetChangedListener

public void removeActiveSheetChangedListener(ActiveSheetChangedListener listener)

addSelectionChangedListener

public void addSelectionChangedListener(SelectionChangedListener listener)

removeSelectionChangedListener

public void removeSelectionChangedListener(SelectionChangedListener listener)

addActiveCellChangedListener

public void addActiveCellChangedListener(ActiveCellChangedListener listener)

removeActiveCellChangedListener

public void removeActiveCellChangedListener(ActiveCellChangedListener listener)

addStructureChangedListener

public void addStructureChangedListener(StructureChangedListener listener)

removeStructureChangedListener

public void removeStructureChangedListener(StructureChangedListener listener)

getActiveCell

public CellHandle getActiveCell()
Returns the current active cell.


getActiveRow

public int getActiveRow()

getActiveColumn

public int getActiveColumn()

getActiveSheet

public WorkSheetHandle getActiveSheet()
Returns the current active sheet.


getMaxRow

public int getMaxRow()
Gets the last row that will be displayed.

Returns:
the index of the last row that will be displayed

getMinRow

public int getMinRow()
Gets the first row that will be displayed.

Returns:
the index of the first row that will be displayed

getMaxCol

public int getMaxCol()
Gets the last column that will be displayed.

Returns:
the index of the last column that will be displayed

convertRowToModel

public int convertRowToModel(int index)
Gets the workbook index of a row based on its view index.

Throws:
java.lang.IndexOutOfBoundsException - if the given index is outside the viewable area of the workbook

convertRowToView

public int convertRowToView(int index)
Gets the view index of a row based on its workbook index.

Throws:
java.lang.IndexOutOfBoundsException - if the given index is outside the viewable area of the workbook

convertColToModel

public int convertColToModel(int index)
Gets the workbook index of a column based on its view index.

Throws:
java.lang.IndexOutOfBoundsException - if the given index is outside the viewable area of the workbook

convertColToView

public int convertColToView(int index)
Gets the view index of a column based on its workbook index.

Throws:
java.lang.IndexOutOfBoundsException - if the given index is outside the viewable area of the workbook

getMinCol

public int getMinCol()
Gets the first column that will be displayed.

Returns:
the index of the first column that will be displayed

getRowHeight

public int getRowHeight(int index)
Returns the height of the given row on the current sheet.

Parameters:
index - the index of the row whose height should be returned
Returns:
the height of the row in twips (1/20th points) or the default height if the row does not exist

getHeaderHeight

public int getHeaderHeight()
Gets the height of the column headers.

Returns:
the height of the column headers in pixels

getHeaderWidth

public int getHeaderWidth()
Gets the width of the row headers.

Returns:
the width of the row headers in pixels

getRowLabel

public java.lang.String getRowLabel(int row)
Returns the label for the given row.


getColLabel

public java.lang.String getColLabel(int col)
Returns the label for the given column.


getScale

public double getScale()
Gets the current scaling factor.


getSelectedRangeRef

public CellRangeRef getSelectedRangeRef()

getSelectedRange

public CellRange getSelectedRange()

getWorkBook

public WorkBookHandle getWorkBook()
Returns the workbook this model wraps.


isEnableSelection

public boolean isEnableSelection()

setEnableSelection

public void setEnableSelection(boolean enable)

setActiveCell

public void setActiveCell(int row,
                          int col)

setActiveSheet

public void setActiveSheet(int index)
Sets the active sheet.

Throws:
java.lang.IndexOutOfBoundsException - if the given sheet doesn't exist

setMaxRow

public void setMaxRow(int max)
Sets the last row that will be displayed.

Parameters:
max - the index of the last row that should be displayed

setMinRow

public void setMinRow(int min)
Sets the first row that will be displayed.

Parameters:
max - the index of the first row that should be displayed

setMaxCol

public void setMaxCol(int max)
Sets the last column that will be displayed.

Parameters:
max - the index of the last column that should be displayed

setMinCol

public void setMinCol(int min)
Sets the first column that will be displayed.

Parameters:
max - the index of the first column that should be displayed

setSelectedRange

public void setSelectedRange(CellRangeRef range)
Sets the selection to the given range. If the range is not qualified with a sheet it will be qualified with the active sheet. It will be resolved against the workbook if necessary.

Parameters:
range - the range that should become the selection
Throws:
java.lang.IllegalArgumentException - if the given range is not a valid selection for this workbook

setHeaderHeight

public void setHeaderHeight(int height)
Sets the height of the column headers.

Parameters:
height - the desired height in pixels

setHeaderWidth

public void setHeaderWidth(int width)
Sets the width of the row headers.

Parameters:
width - the desired width in pixels

setRowLabel

public void setRowLabel(int row,
                        java.lang.String label)
Sets the label for a row.


setColLabel

public void setColLabel(int col,
                        java.lang.String label)
Sets the label for a column.


setScale

public void setScale(double scale)
Sets the scaling factor.


close

public void close()
clear out object references in preparation for closing



Copyright © 2011 Extentech Inc. All Rights Reserved.