Diamond Control Suite 3.0

diamondedge.swing.grid
Class DsCellRange

java.lang.Object
  extended by diamondedge.swing.grid.DsCellRange
All Implemented Interfaces:
DsConstants, SwingConstants

public class DsCellRange
extends Object
implements DsConstants

A class which allows properties to be set accross a range of cells.

Warning: all methods except fillRows and fillColumns will re-order the values of the first row and column in the range. Most will re-order to go from top-left corner to the bottom-right corner.


Field Summary
static int SERIES_DAY
          all cells will be filled with a Date object whose day value increases by the given increment.
static int SERIES_DOUBLE
          all cells will be filled with an Integer object that increases by the given increment.
static int SERIES_INTEGER
          all cells will be filled with an Integer object that increases by the given increment.
static int SERIES_LONG
          all cells will be filled with an Integer object that increases by the given increment.
static int SERIES_MONTH
          all cells will be filled with a Date object whose month value increases by the given increment.
static int SERIES_SAME
          all cells will be filled with the same value.
static int SERIES_YEAR
          all cells will be filled with a Date object whose year value increases by the given increment.
 
Fields inherited from interface diamondedge.swing.DsConstants
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Method Summary
 void clear(boolean clearStyleOnly)
          Deletes all style properties in a DsCell and optionally the value for each cell in the range.
 boolean contains(int row, int col)
           
 void convertToGeneral()
          Attempts to convert the value of each cell into a Number, Boolean, Date in that order.
 void convertToNumber()
          Converts the value of each cell to a Number object.
 void fillColumns(int seriesType, double increment, boolean copyCellStyles)
          Sets the values and/or styles for the range of cells using values/styles in the firstRow and propagating them through their respective columns so that all values in the same column will have the value specified by the seriesType.
 void fillDown()
          Sets the values and styles for the range of cells using values/styles in the top-most row and propagating them through their respective columns so that all values in the same column will have the same value and style.
 void fillLeft()
          Sets the values and styles for the range of cells using values/styles in the left-most column and propagating them through their respective rows so that all values in the same row will have the same value and style.
 void fillRight()
          Sets the values and styles for the range of cells using values/styles in the left-most column and propagating them through their respective rows so that all values in the same row will have the same value and style.
 void fillRows(int seriesType, double increment, boolean copyCellStyles)
          Sets the values and/or styles for the range of cells using values/styles in the firstColumn and propagating them through their respective rows so that all values in the same row will have the value specified by the seriesType.
 void fillUp()
          Sets the values and styles for the range of cells using values/styles in the bottom-most row and propagating them through their respective columns so that all values in the same column will have the same value and style.
 DsCellRange find(Object searchFor, int matchType, int action)
          Finds a value in a cell or multiple cells.
 DsCellRange find(Object searchFor, int matchType, int action, int startRow, int startCol)
          Finds a value in a cell or multiple cells.
 String getClipString()
          Returns the cells formated into a tab delimited string.
 void justifyOrder()
          if firstRow > lastRow or firstColumn > lastColumn then their values are switched so the range is properly ordered from top-left corner to the bottom-right corner.
 void outline(Color color, int lineStyle, int lineWidth)
          Creates a line border around the entire perimeter of the range of cells with the given line width, style and color.
 void outline(Color color, int lineStyle, int lineWidth, int borderLines)
          Creates a line border around the perimeter of the range of cells with the given line width, style and color for each of the specified sides of the perimeter.
 void removeSpans()
          Removes all spans that are contained in or intersect with the cell range.
 void reOrder(boolean rowsTopToBottom, boolean columnsLeftToRight)
          if firstRow > lastRow or firstColumn > lastColumn then their values are switched so the range is properly ordered from top-left corner to the bottom-right corner.
 DsCellRange replace(Object searchFor, int matchType, Object replaceWith)
          Finds values in a cell or multiple cells and replaces the entire value with the value specified.
 void setBackground(Color c)
          Sets the background color for the range of cells.
 void setBorder(Border b)
          Sets a border that will be painted on the outside of each cell in the range.
 void setBorderLineColor(Color c)
          Sets a value which determines the color that line borders are drawn in.
 void setBorderLines(int val)
          Sets a value that determines which border lines that are drawn around the cell.
 void setBorderLineWidth(int val)
          Sets a value that determines the width of the lines that are drawn around each cell in the range.
 void setBorderStyle(int val)
          Sets a value that determines how the border is drawn for the range of cells.
 void setData(Object val)
          Sets a user defined object to be stored with each cell.
 void setEditable(boolean val)
          Determines whether the value for the range of cells can be edited by the user at run-time.
 void setFont(Font f)
          Sets the Font used to display the text for the range of cells.
 void setFontBold(boolean val)
          Sets the font for the range of cells to be a bold font.
 void setFontItalic(boolean val)
          Sets the font for the range of cells to be a Italic font.
 void setFontName(String val)
          Sets the font name for the range of cells.
 void setFontSize(int val)
          Sets the font size for the range of cells.
 void setFontStrikeThrough(boolean val)
          Sets the font for the range of cells to be a bold font.
 void setFontUnderline(int val)
          Sets the font for the range of cells to be a bold font.
 void setForeground(Color c)
          Sets the foreground color used to draw the text for the range of cells.
 void setFormat(Object val)
          Sets a value that determines how the text for each cell is formatted.
 void setHorizontalAlignment(int val)
          Sets the HorizontalAlignment for the range of cells.
 void setHorizontalTextPosition(int val)
          Sets the horizontal position of the text in relation to the icon.
 void setIcon(Icon icon)
          Sets icon this displayed of each cell in the range.
 void setNegativeNumberRed(boolean val)
          Sets a value for the range of cells that determines whether negative numbers are displayed in a red color.
 void setOpaque(boolean val)
          Sets a value for the range of cells that determines whether the background for the cell is painted.
 void setRotation(int val)
          Sets the rotation for the range of cells.
 void setShowGrid(boolean showGrid)
          Sets whether the table draws grid lines around cells.
 void setTextStyle(int val)
          Sets the TextStyle for the range of cells.
 void setValue(Object value)
          Sets the text contents/object for the range of cells.
 void setVerticalAlignment(int val)
          Sets the VerticalAlignment for the range of cells.
 void setVerticalTextPosition(int val)
          Sets the vertical position of the text in relation to the icon.
 void setWordWrap(boolean val)
          Sets the WordWrap for the range of cells.
 void spanCells()
          Makes the top left cell span across the space occupied by the cell range.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERIES_SAME

public static final int SERIES_SAME
all cells will be filled with the same value.

See Also:
Constant Field Values

SERIES_INTEGER

public static final int SERIES_INTEGER
all cells will be filled with an Integer object that increases by the given increment.

See Also:
Constant Field Values

SERIES_LONG

public static final int SERIES_LONG
all cells will be filled with an Integer object that increases by the given increment.

See Also:
Constant Field Values

SERIES_DOUBLE

public static final int SERIES_DOUBLE
all cells will be filled with an Integer object that increases by the given increment.

See Also:
Constant Field Values

SERIES_DAY

public static final int SERIES_DAY
all cells will be filled with a Date object whose day value increases by the given increment.

See Also:
Constant Field Values

SERIES_MONTH

public static final int SERIES_MONTH
all cells will be filled with a Date object whose month value increases by the given increment.

See Also:
Constant Field Values

SERIES_YEAR

public static final int SERIES_YEAR
all cells will be filled with a Date object whose year value increases by the given increment.

See Also:
Constant Field Values
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getClipString

public String getClipString()
Returns the cells formated into a tab delimited string.


contains

public boolean contains(int row,
                        int col)

justifyOrder

public void justifyOrder()
if firstRow > lastRow or firstColumn > lastColumn then their values are switched so the range is properly ordered from top-left corner to the bottom-right corner. All methods except the fill methods expect this order.


reOrder

public void reOrder(boolean rowsTopToBottom,
                    boolean columnsLeftToRight)
if firstRow > lastRow or firstColumn > lastColumn then their values are switched so the range is properly ordered from top-left corner to the bottom-right corner. All methods except the fill methods expect this order.


spanCells

public void spanCells()
Makes the top left cell span across the space occupied by the cell range.


removeSpans

public void removeSpans()
Removes all spans that are contained in or intersect with the cell range.


outline

public void outline(Color color,
                    int lineStyle,
                    int lineWidth)
Creates a line border around the entire perimeter of the range of cells with the given line width, style and color. Valid values for lineStyle are:


outline

public void outline(Color color,
                    int lineStyle,
                    int lineWidth,
                    int borderLines)
Creates a line border around the perimeter of the range of cells with the given line width, style and color for each of the specified sides of the perimeter. Valid values for lineStyle are: Valid values borderLines are:


fillColumns

public void fillColumns(int seriesType,
                        double increment,
                        boolean copyCellStyles)
Sets the values and/or styles for the range of cells using values/styles in the firstRow and propagating them through their respective columns so that all values in the same column will have the value specified by the seriesType. Note: if you want to fill in a different order then you can re-order the current range.

Parameters:
seriesType - One of: SERIES_SAME, SERIES_INTEGER, SERIES_LONG, SERIES_DOUBLE, SERIES_DAY, SERIES_MONTH, SERIES_YEAR
increment - amount to increase the cell value from the preceeding cell
copyCellStyles - If true then all of the cell properties will be copied from the preceeding cell
See Also:
reOrder(boolean, boolean)

fillRows

public void fillRows(int seriesType,
                     double increment,
                     boolean copyCellStyles)
Sets the values and/or styles for the range of cells using values/styles in the firstColumn and propagating them through their respective rows so that all values in the same row will have the value specified by the seriesType. Note: if you want to fill in a different order then you can re-order the current range.

Parameters:
seriesType - One of: SERIES_SAME, SERIES_INTEGER, SERIES_LONG, SERIES_DOUBLE, SERIES_DAY, SERIES_MONTH, SERIES_YEAR
increment - amount to increase the cell value from the preceeding cell
copyCellStyles - If true then all of the cell properties will be copied from the preceeding cell
See Also:
reOrder(boolean, boolean)

fillDown

public void fillDown()
Sets the values and styles for the range of cells using values/styles in the top-most row and propagating them through their respective columns so that all values in the same column will have the same value and style.


fillUp

public void fillUp()
Sets the values and styles for the range of cells using values/styles in the bottom-most row and propagating them through their respective columns so that all values in the same column will have the same value and style.


fillRight

public void fillRight()
Sets the values and styles for the range of cells using values/styles in the left-most column and propagating them through their respective rows so that all values in the same row will have the same value and style.


fillLeft

public void fillLeft()
Sets the values and styles for the range of cells using values/styles in the left-most column and propagating them through their respective rows so that all values in the same row will have the same value and style.


setValue

public void setValue(Object value)
Sets the text contents/object for the range of cells.


setForeground

public void setForeground(Color c)
Sets the foreground color used to draw the text for the range of cells.

See Also:
DsCellProperties.setForeground(java.awt.Paint)

setBackground

public void setBackground(Color c)
Sets the background color for the range of cells.

See Also:
DsCellProperties.setBackground(java.awt.Paint)

setFont

public void setFont(Font f)
Sets the Font used to display the text for the range of cells.

See Also:
DsCellProperties.setFont(java.awt.Font)

setFontName

public void setFontName(String val)
Sets the font name for the range of cells.

See Also:
DsCellProperties.setFontName(java.lang.String)

setFontSize

public void setFontSize(int val)
Sets the font size for the range of cells.

See Also:
DsCellProperties.setFontSize(int)

setFontBold

public void setFontBold(boolean val)
Sets the font for the range of cells to be a bold font.

See Also:
DsCellProperties.setFontBold(boolean)

setFontItalic

public void setFontItalic(boolean val)
Sets the font for the range of cells to be a Italic font.

See Also:
DsCellProperties.setFontItalic(boolean)

setFontStrikeThrough

public void setFontStrikeThrough(boolean val)
Sets the font for the range of cells to be a bold font.

See Also:
DsCellProperties.setFontStrikeThrough(boolean)

setFontUnderline

public void setFontUnderline(int val)
Sets the font for the range of cells to be a bold font.

See Also:
DsCellProperties.setFont(java.awt.Font)

setNegativeNumberRed

public void setNegativeNumberRed(boolean val)
Sets a value for the range of cells that determines whether negative numbers are displayed in a red color. The value in the cell must be an instance of the Number class.

See Also:
DsCellProperties.setNegativeNumberRed(boolean)

setOpaque

public void setOpaque(boolean val)
Sets a value for the range of cells that determines whether the background for the cell is painted.

See Also:
DsCellProperties.setOpaque(boolean)

setWordWrap

public void setWordWrap(boolean val)
Sets the WordWrap for the range of cells.

See Also:
DsCellProperties.setWordWrap(boolean)

setEditable

public void setEditable(boolean val)
Determines whether the value for the range of cells can be edited by the user at run-time.

See Also:
DsCellProperties.setEditable(boolean)

setHorizontalAlignment

public void setHorizontalAlignment(int val)
Sets the HorizontalAlignment for the range of cells.

See Also:
DsCellProperties.setHorizontalAlignment(int)

setVerticalAlignment

public void setVerticalAlignment(int val)
Sets the VerticalAlignment for the range of cells.

See Also:
DsCellProperties.setVerticalAlignment(int)

setTextStyle

public void setTextStyle(int val)
Sets the TextStyle for the range of cells.

See Also:
DsCellProperties.setTextStyle(int)

setRotation

public void setRotation(int val)
Sets the rotation for the range of cells.

See Also:
DsCellProperties.setRotation(int)

setShowGrid

public void setShowGrid(boolean showGrid)
Sets whether the table draws grid lines around cells. This is a convenience method that sets all BorderStyles to GRID_LINE and BorderLines to BORDER_OUTLINE or BORDER_NONE depending on whether the grid should be displayed.

See Also:
DsCellProperties.setBorderStyle(int), DsCellProperties.setBorderLines(int)

setBorderStyle

public void setBorderStyle(int val)
Sets a value that determines how the border is drawn for the range of cells.

See Also:
DsCellProperties.setBorderStyle(int)

setBorderLines

public void setBorderLines(int val)
Sets a value that determines which border lines that are drawn around the cell.

See Also:
DsCellProperties.setBorderLines(int)

setBorderLineWidth

public void setBorderLineWidth(int val)
Sets a value that determines the width of the lines that are drawn around each cell in the range. Maximum line width is 7.

See Also:
DsCellProperties.setBorderLineWidth(int)

setBorderLineColor

public void setBorderLineColor(Color c)
Sets a value which determines the color that line borders are drawn in. If null, then the Foreground color will be used.

See Also:
DsCellProperties.setBorderLineColor(java.awt.Paint)

setBorder

public void setBorder(Border b)
Sets a border that will be painted on the outside of each cell in the range. Any border specified in BorderStyle will be drawn on the inside.

See Also:
DsCellProperties.setBorder(int, int, java.awt.Paint)

setIcon

public void setIcon(Icon icon)
Sets icon this displayed of each cell in the range.

See Also:
DsCellProperties.setIcon(javax.swing.Icon)

setHorizontalTextPosition

public void setHorizontalTextPosition(int val)
Sets the horizontal position of the text in relation to the icon.

See Also:
DsCellProperties.setHorizontalTextPosition(int)

setVerticalTextPosition

public void setVerticalTextPosition(int val)
Sets the vertical position of the text in relation to the icon.

See Also:
DsCellProperties.setVerticalTextPosition(int)

setFormat

public void setFormat(Object val)
Sets a value that determines how the text for each cell is formatted. Should be an instance of Format or DefaultFormatter

See Also:
DsCellProperties.setFormat(java.lang.Object)

setData

public void setData(Object val)
Sets a user defined object to be stored with each cell. This can be any type of object. The value is never used internally.

See Also:
DsCell.setData(java.lang.Object)

clear

public void clear(boolean clearStyleOnly)
Deletes all style properties in a DsCell and optionally the value for each cell in the range.

Parameters:
clearStyleOnly - If true it does not alter the value for the cell. If false the cell value is also removed.

convertToNumber

public void convertToNumber()
Converts the value of each cell to a Number object. First tries to convert to an Integer then to a number using the following formats: integer, number, percent, currency.


convertToGeneral

public void convertToGeneral()
Attempts to convert the value of each cell into a Number, Boolean, Date in that order. If it cannot be converted then the original value is retained. Strings formatted according to the current locale for currencies and percents will be converted to Doubles.


find

public DsCellRange find(Object searchFor,
                        int matchType,
                        int action)
Finds a value in a cell or multiple cells. If the searchFor value is a Number, BigDecimal or Date then a numerical or date comparison will be used for FIND_EQUALS, FIND_GTE and FIND_LTE.

Parameters:
searchFor - Object to find.
matchType - One of:
  • FIND_STRING - case insensitive search of a string that is equal to the toString() of the cell value
  • FIND_PREFIX - case insensitive search of a string that matches the first part of the cell value's toString()
  • FIND_REGEX - cell value whose toString() matches the given regular expression
  • FIND_EQUALS - cell value that is equal to the given value. For strings this is case sensitive.
  • FIND_NE - cell value that is not equal to the given value. For strings this is case sensitive.
  • FIND_GTE - cell value that is greater than or equal to the given value
  • FIND_LTE - cell value that is less than or equal to the given value
  • FIND_GT - cell value that is greater than the given value
  • FIND_LT - cell value that is less than the given value
  • FIND_ALL - Search all cells. Otherwise search is stopped on the first match. Should be OR'ed in with one of the above values
action - One of: SELECT_NONE, SELECT_CELL, SELECT_ROW
Returns:
a DsCellRange that is the smallest rectangular range that includes all of the matched cells.

find

public DsCellRange find(Object searchFor,
                        int matchType,
                        int action,
                        int startRow,
                        int startCol)
Finds a value in a cell or multiple cells. If the searchFor value is a Number, BigDecimal or Date then a numerical or date comparison will be used for FIND_EQUALS, FIND_GTE and FIND_LTE. To search in reverse order, create a DsCellRange with the last row as the first argument for example:
grid.getCells( grid.getRowCount() - 1, grid.getColumnCount() -1, 0, 0 );

Parameters:
searchFor - Object to find.
matchType - One of:
  • FIND_STRING - case insensitive search of a string that is equal to the toString() of the cell value
  • FIND_PREFIX - case insensitive search of a string that matches the first part of the cell value's toString()
  • FIND_REGEX - cell value whose toString() matches the given regular expression
  • FIND_EQUALS - cell value that is equal to the given value. For strings this is case sensitive.
  • FIND_NE - cell value that is not equal to the given value. For strings this is case sensitive.
  • FIND_GTE - cell value that is greater than or equal to the given value
  • FIND_LTE - cell value that is less than or equal to the given value
  • FIND_GT - cell value that is greater than the given value
  • FIND_LT - cell value that is less than the given value
  • FIND_ALL - Search all cells. Otherwise search is stopped on the first match. Should be OR'ed in with one of the above values
action - One of: SELECT_NONE, SELECT_CELL, SELECT_ROW
startRow - row to begin search from. -1 means start with first row in range otherwise it must be a valid row within the range.
startCol - column to begin search from. -1 means start with first column in range.
Returns:
a DsCellRange that is the smallest rectangular range that includes all of the matched cells.

replace

public DsCellRange replace(Object searchFor,
                           int matchType,
                           Object replaceWith)
Finds values in a cell or multiple cells and replaces the entire value with the value specified. If the searchFor value is a Number, BigDecimal or Date then a numerical or date comparison will be used for FIND_EQUALS, FIND_GTE and FIND_LTE.

Parameters:
searchFor - Object to find.
matchType - One of:
  • FIND_STRING - case insensitive search of a string that is equal to the toString() of the cell value
  • FIND_PREFIX - case insensitive search of a string that matches the first part of the cell value's toString()
  • FIND_REGEX - cell value whose toString() matches the given regular expression
  • FIND_EQUALS - cell value that is equal to the given value. For strings this is case sensitive.
  • FIND_NE - cell value that is not equal to the given value. For strings this is case sensitive.
  • FIND_GTE - cell value that is greater than or equal to the given value
  • FIND_LTE - cell value that is less than or equal to the given value
  • FIND_GT - cell value that is greater than the given value
  • FIND_LT - cell value that is less than the given value
  • FIND_ALL - Search all cells. Otherwise search is stopped on the first match. Should be OR'ed in with one of the above values
replaceWith - the new value for each cell that is found
Returns:
a DsCellRange that is the smallest rectangular range that includes all of the matched cells.

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.