HSSFClientAnchorpublic class HSSFClientAnchor extends HSSFAnchor A client anchor is attached to an excel worksheet. It anchors against a
top-left and buttom-right cell. |
Fields Summary |
---|
short | col1 | int | row1 | short | col2 | int | row2 | int | anchorType |
Constructors Summary |
---|
public HSSFClientAnchor()Creates a new client anchor and defaults all the anchor positions to 0.
| public HSSFClientAnchor(int dx1, int dy1, int dx2, int dy2, short col1, int row1, short col2, int row2)Creates a new client anchor and sets the top-left and bottom-right
coordinates of the anchor.
super( dx1, dy1, dx2, dy2 );
checkRange(dx1, 0, 1023, "dx1");
checkRange(dx2, 0, 1023, "dx2");
checkRange(dy1, 0, 255, "dy1");
checkRange(dy2, 0, 255, "dy2");
checkRange(col1, 0, 255, "col1");
checkRange(col2, 0, 255, "col2");
checkRange(row1, 0, 255 * 256, "row1");
checkRange(row2, 0, 255 * 256, "row2");
this.col1 = col1;
this.row1 = row1;
this.col2 = col2;
this.row2 = row2;
|
Methods Summary |
---|
private void | checkRange(int value, int minRange, int maxRange, java.lang.String varName)
if (value < minRange || value > maxRange)
throw new IllegalArgumentException(varName + " must be between " + minRange + " and " + maxRange);
| public float | getAnchorHeightInPoints(org.apache.poi.hssf.usermodel.HSSFSheet sheet)Calculates the height of a client anchor in points.
int y1 = Math.min( getDy1(), getDy2() );
int y2 = Math.max( getDy1(), getDy2() );
int row1 = Math.min( getRow1(), getRow2() );
int row2 = Math.max( getRow1(), getRow2() );
float points = 0;
if (row1 == row2)
{
points = ((y2 - y1) / 256.0f) * getRowHeightInPoints(sheet, row2);
}
else
{
points += ((256.0f - y1) / 256.0f) * getRowHeightInPoints(sheet, row1);
for (int i = row1 + 1; i < row2; i++)
{
points += getRowHeightInPoints(sheet, i);
}
points += (y2 / 256.0f) * getRowHeightInPoints(sheet, row2);
}
return points;
| public int | getAnchorType()Gets the anchor type
0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
return anchorType;
| public short | getCol1()
return col1;
| public short | getCol2()
return col2;
| public int | getRow1()
return row1;
| public int | getRow2()
return row2;
| private float | getRowHeightInPoints(org.apache.poi.hssf.usermodel.HSSFSheet sheet, int rowNum)
HSSFRow row = sheet.getRow(rowNum);
if (row == null)
return sheet.getDefaultRowHeightInPoints();
else
return row.getHeightInPoints();
| public boolean | isHorizontallyFlipped()
if (col1 == col2)
return dx1 > dx2;
else
return col1 > col2;
| public boolean | isVerticallyFlipped()
if (row1 == row2)
return dy1 > dy2;
else
return row1 > row2;
| public void | setAnchor(short col1, int row1, int x1, int y1, short col2, int row2, int x2, int y2)Dets the top-left and bottom-right
coordinates of the anchor.
checkRange(dx1, 0, 1023, "dx1");
checkRange(dx2, 0, 1023, "dx2");
checkRange(dy1, 0, 255, "dy1");
checkRange(dy2, 0, 255, "dy2");
checkRange(col1, 0, 255, "col1");
checkRange(col2, 0, 255, "col2");
checkRange(row1, 0, 255 * 256, "row1");
checkRange(row2, 0, 255 * 256, "row2");
this.col1 = col1;
this.row1 = row1;
this.dx1 = x1;
this.dy1 = y1;
this.col2 = col2;
this.row2 = row2;
this.dx2 = x2;
this.dy2 = y2;
| public void | setAnchorType(int anchorType)Sets the anchor type
0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
this.anchorType = anchorType;
| public void | setCol1(short col1)
checkRange(col1, 0, 255, "col1");
this.col1 = col1;
| public void | setCol2(short col2)
checkRange(col2, 0, 255, "col2");
this.col2 = col2;
| public void | setRow1(int row1)
checkRange(row1, 0, 256 * 256, "row1");
this.row1 = row1;
| public void | setRow2(int row2)
checkRange(row2, 0, 256 * 256, "row2");
this.row2 = row2;
|
|