net.sf.jett.model
Class Block

java.lang.Object
  extended by net.sf.jett.model.Block

public class Block
extends java.lang.Object

A Block object represents a rectangular block of Cells.

Author:
Randy Gettman

Nested Class Summary
static class Block.Direction
          Possible directionalities of the Block.
 
Constructor Summary
Block(Block parent, org.apache.poi.ss.usermodel.Cell tag)
          Construct a Block that coincides with the given Cell.
Block(Block parent, org.apache.poi.ss.usermodel.Cell startTag, org.apache.poi.ss.usermodel.Cell endTag)
          Construct a Block that lies in between the given start and end tags.
Block(Block parent, int left, int right, int top, int bottom)
          Construct a Block at the given boundary column and row numbers.
 
Method Summary
 void collapse()
          Collapses the block to zero size in columns and rows.
 void expand(int cols, int rows)
          Expands the block the given number of columns and rows.
 int getBottomRowNum()
          Returns the bottom row number (0-based).
 Block.Direction getDirection()
          Returns the specific Direction of this Block.
 int getLeftColNum()
          Returns the left column number (0-based).
 Block getParent()
          Returns this Block's parent Block.
 int getRightColNum()
          Returns the right column number (0-based).
 int getTopRowNum()
          Returns the top row number (0-based).
 void reactToGrowth(Block sibling, int colGrowth, int rowGrowth)
          When this Block is a copy, it may have to react to "sibling" Blocks when the "sibling" is processed first and it grows or shrinks during processing.
 void setDirection(Block.Direction dir)
          Sets the specific Direction of this Block.
 java.lang.String toString()
          Returns a String representation of this Block.
 void translate(int cols, int rows)
          Translates the block the given number of columns and rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Block

public Block(Block parent,
             org.apache.poi.ss.usermodel.Cell startTag,
             org.apache.poi.ss.usermodel.Cell endTag)
Construct a Block that lies in between the given start and end tags.

Parameters:
parent - The Block's parent.
startTag - The Cell containing the start tag.
endTag - The Cell containing the end tag.

Block

public Block(Block parent,
             org.apache.poi.ss.usermodel.Cell tag)
Construct a Block that coincides with the given Cell. This is used for bodiless tags.

Parameters:
parent - The Block's parent.
tag - The Cell containing the bodiless tag.

Block

public Block(Block parent,
             int left,
             int right,
             int top,
             int bottom)
Construct a Block at the given boundary column and row numbers.

Parameters:
parent - The Block's parent.
left - The left-most column number (0-based).
right - The right-most column index (0-based).
top - The top-most row number (0-based).
bottom - The bottom-most row number (0-based).
Method Detail

getLeftColNum

public int getLeftColNum()
Returns the left column number (0-based).

Returns:
The left column number.

getRightColNum

public int getRightColNum()
Returns the right column number (0-based).

Returns:
The right column number.

getTopRowNum

public int getTopRowNum()
Returns the top row number (0-based).

Returns:
The top row number.

getBottomRowNum

public int getBottomRowNum()
Returns the bottom row number (0-based).

Returns:
The bottom row number.

getDirection

public Block.Direction getDirection()
Returns the specific Direction of this Block.

Returns:
An enumerated type that determines the directionality of this Block.
See Also:
Block.Direction

setDirection

public void setDirection(Block.Direction dir)
Sets the specific Direction of this Block.

Parameters:
dir - An enumerated type that determines the directionality of this Block.
See Also:
Block.Direction

translate

public void translate(int cols,
                      int rows)
Translates the block the given number of columns and rows.

Parameters:
cols - The number of columns to move the block (can be negative).
rows - The number of rows to move the block (can be negative).

expand

public void expand(int cols,
                   int rows)
Expands the block the given number of columns and rows. The "left" and "top" properties are unchanged. The "bottom" property is changed.

Parameters:
cols - The number of columns to expand the block (can be negative).
rows - The number of rows to expand the block (can be negative).

collapse

public void collapse()
Collapses the block to zero size in columns and rows.

Since:
0.3.0

toString

public java.lang.String toString()
Returns a String representation of this Block.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this Block.

getParent

public Block getParent()
Returns this Block's parent Block.

Returns:
This Block's parent Block.

reactToGrowth

public void reactToGrowth(Block sibling,
                          int colGrowth,
                          int rowGrowth)
When this Block is a copy, it may have to react to "sibling" Blocks when the "sibling" is processed first and it grows or shrinks during processing. Here are the cases:
  1. Vertical direction. Expand to the right to match the sibling's column growth. Translate downward to move out of the way of the sibling Block.
  2. Horizontal direction. Translate to the right to move out of the way of the sibling Block. Expand downward to match the sibling's row growth.

Parameters:
sibling - The sibling Block that grew or shrank.
colGrowth - The number of columns the sibling Block grew (or shrank if negative).
rowGrowth - The number of rows the sibling Block grew (or shrank if negative).


Copyright © 2012-2013 Jett Team. All Rights Reserved.