Package org.apache.poi.hssf.usermodel
Class HSSFClientAnchor
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.HSSFAnchor
-
- org.apache.poi.hssf.usermodel.HSSFClientAnchor
-
- All Implemented Interfaces:
ChildAnchor,ClientAnchor
public final class HSSFClientAnchor extends HSSFAnchor implements ClientAnchor
A client anchor is attached to an excel worksheet. It anchors against a top-left and buttom-right cell.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.poi.ss.usermodel.ClientAnchor
ClientAnchor.AnchorType
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_COLstatic intMAX_ROW-
Fields inherited from class org.apache.poi.hssf.usermodel.HSSFAnchor
_isHorizontallyFlipped, _isVerticallyFlipped
-
-
Constructor Summary
Constructors Constructor Description HSSFClientAnchor()Creates a new client anchor and defaults all the anchor positions to 0.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.HSSFClientAnchor(EscherClientAnchorRecord escherClientAnchorRecord)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateEscherAnchor()booleanequals(Object obj)floatgetAnchorHeightInPoints(HSSFSheet sheet)Calculates the height of a client anchor in points.ClientAnchor.AnchorTypegetAnchorType()Gets the anchor type Changed from returning an int to an enum in POI 3.14 beta 1.shortgetCol1()Returns the column (0 based) of the first cell, or -1 if there is no top-left anchor cell.shortgetCol2()Returns the column (0 based) of the second cell, or -1 if there is no bottom-right anchor cell.intgetDx1()Returns the x coordinate within the first cell.intgetDx2()Returns the x coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELintgetDy1()Returns the y coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELintgetDy2()Sets the y coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELprotected EscherRecordgetEscherAnchor()intgetRow1()Returns the row (0 based) of the first cell, or -1 if there is no bottom-right anchor cell.intgetRow2()Returns the row (0 based) of the second cell, or -1 if there is no bottom-right anchor cell.inthashCode()booleanisHorizontallyFlipped()booleanisVerticallyFlipped()voidsetAnchor(short col1, int row1, int x1, int y1, short col2, int row2, int x2, int y2)Sets the top-left and bottom-right coordinates of the anchor.voidsetAnchorType(ClientAnchor.AnchorType anchorType)Sets the anchor typevoidsetCol1(int col1)Sets the column (0 based) of the first cell.voidsetCol1(short col1)voidsetCol2(int col2)Returns the column (0 based) of the second cell.voidsetCol2(short col2)voidsetDx1(int dx1)Sets the x coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELvoidsetDx2(int dx2)Sets the x coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELvoidsetDy1(int dy1)Sets the y coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELvoidsetDy2(int dy2)Sets the y coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXELvoidsetRow1(int row1)Returns the row (0 based) of the first cell.voidsetRow2(int row2)Returns the row (0 based) of the first cell.-
Methods inherited from class org.apache.poi.hssf.usermodel.HSSFAnchor
createAnchorFromEscher
-
-
-
-
Constructor Detail
-
HSSFClientAnchor
public HSSFClientAnchor(EscherClientAnchorRecord escherClientAnchorRecord)
-
HSSFClientAnchor
public HSSFClientAnchor()
Creates a new client anchor and defaults all the anchor positions to 0.
-
HSSFClientAnchor
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. Note: Microsoft Excel seems to sometimes disallow higher y1 than y2 or higher x1 than x2, you might need to reverse them and draw shapes vertically or horizontally flipped!- Parameters:
dx1- the x coordinate within the first cell.dy1- the y coordinate within the first cell.dx2- the x coordinate within the second cell.dy2- the y coordinate within the second cell.col1- the column (0 based) of the first cell.row1- the row (0 based) of the first cell.col2- the column (0 based) of the second cell.row2- the row (0 based) of the second cell.
-
-
Method Detail
-
getAnchorHeightInPoints
public float getAnchorHeightInPoints(HSSFSheet sheet)
Calculates the height of a client anchor in points.- Parameters:
sheet- the sheet the anchor will be attached to- Returns:
- the shape height.
-
getCol1
public short getCol1()
Description copied from interface:ClientAnchorReturns the column (0 based) of the first cell, or -1 if there is no top-left anchor cell. This is the case for absolute positioningClientAnchor.AnchorType.MOVE_AND_RESIZE- Specified by:
getCol1in interfaceClientAnchor- Returns:
- the column(0 based) of the first cell.
-
setCol1
public void setCol1(short col1)
- Parameters:
col1- the column(0 based) of the first cell.
-
setCol1
public void setCol1(int col1)
Description copied from interface:ClientAnchorSets the column (0 based) of the first cell.- Specified by:
setCol1in interfaceClientAnchor- Parameters:
col1- 0-based column of the first cell.
-
getCol2
public short getCol2()
Description copied from interface:ClientAnchorReturns the column (0 based) of the second cell, or -1 if there is no bottom-right anchor cell. This is the case for absolute positioning (ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE) and absolute sizing (ClientAnchor.AnchorType.MOVE_DONT_RESIZE.- Specified by:
getCol2in interfaceClientAnchor- Returns:
- the column(0 based) of the first cell.
-
setCol2
public void setCol2(short col2)
- Parameters:
col2- the column(0 based) of the second cell.
-
setCol2
public void setCol2(int col2)
Description copied from interface:ClientAnchorReturns the column (0 based) of the second cell.- Specified by:
setCol2in interfaceClientAnchor- Parameters:
col2- the column(0 based) of the second cell.
-
getRow1
public int getRow1()
Description copied from interface:ClientAnchorReturns the row (0 based) of the first cell, or -1 if there is no bottom-right anchor cell. This is the case for absolute positioning (ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE).- Specified by:
getRow1in interfaceClientAnchor- Returns:
- the row(0 based) of the first cell.
-
setRow1
public void setRow1(int row1)
Description copied from interface:ClientAnchorReturns the row (0 based) of the first cell.- Specified by:
setRow1in interfaceClientAnchor- Parameters:
row1- 0-based row of the first cell.
-
getRow2
public int getRow2()
Description copied from interface:ClientAnchorReturns the row (0 based) of the second cell, or -1 if there is no bottom-right anchor cell. This is the case for absolute positioning (ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE) and absolute sizing (ClientAnchor.AnchorType.MOVE_DONT_RESIZE.- Specified by:
getRow2in interfaceClientAnchor- Returns:
- the row(0 based) of the second cell.
-
setRow2
public void setRow2(int row2)
Description copied from interface:ClientAnchorReturns the row (0 based) of the first cell.- Specified by:
setRow2in interfaceClientAnchor- Parameters:
row2- the row(0 based) of the second cell.
-
setAnchor
public void setAnchor(short col1, int row1, int x1, int y1, short col2, int row2, int x2, int y2)Sets the top-left and bottom-right coordinates of the anchor. Note: Microsoft Excel seems to sometimes disallow higher y1 than y2 or higher x1 than x2, you might need to reverse them and draw shapes vertically or horizontally flipped!- Parameters:
x1- the x coordinate within the first cell.y1- the y coordinate within the first cell.x2- the x coordinate within the second cell.y2- the y coordinate within the second cell.col1- the column (0 based) of the first cell.row1- the row (0 based) of the first cell.col2- the column (0 based) of the second cell.row2- the row (0 based) of the second cell.
-
isHorizontallyFlipped
public boolean isHorizontallyFlipped()
- Specified by:
isHorizontallyFlippedin classHSSFAnchor- Returns:
- whether this shape is horizontally flipped
-
isVerticallyFlipped
public boolean isVerticallyFlipped()
- Specified by:
isVerticallyFlippedin classHSSFAnchor- Returns:
- whether this shape is vertically flipped
-
getEscherAnchor
protected EscherRecord getEscherAnchor()
- Specified by:
getEscherAnchorin classHSSFAnchor
-
createEscherAnchor
protected void createEscherAnchor()
- Specified by:
createEscherAnchorin classHSSFAnchor
-
getAnchorType
public ClientAnchor.AnchorType getAnchorType()
Gets the anchor type Changed from returning an int to an enum in POI 3.14 beta 1.- Specified by:
getAnchorTypein interfaceClientAnchor- Returns:
- the anchor type
-
setAnchorType
public void setAnchorType(ClientAnchor.AnchorType anchorType)
Sets the anchor type- Specified by:
setAnchorTypein interfaceClientAnchor- Parameters:
anchorType- the anchor type to set- Since:
- POI 3.14
-
getDx1
public int getDx1()
Description copied from interface:ClientAnchorReturns the x coordinate within the first cell. Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
getDx1in interfaceChildAnchor- Specified by:
getDx1in interfaceClientAnchor- Returns:
- the x coordinate within the first cell
-
setDx1
public void setDx1(int dx1)
Description copied from interface:ClientAnchorSets the x coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
setDx1in interfaceChildAnchor- Specified by:
setDx1in interfaceClientAnchor- Parameters:
dx1- the x coordinate within the first cell
-
getDy1
public int getDy1()
Description copied from interface:ClientAnchorReturns the y coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
getDy1in interfaceChildAnchor- Specified by:
getDy1in interfaceClientAnchor- Returns:
- the y coordinate within the first cell
-
setDy1
public void setDy1(int dy1)
Description copied from interface:ClientAnchorSets the y coordinate within the first cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
setDy1in interfaceChildAnchor- Specified by:
setDy1in interfaceClientAnchor- Parameters:
dy1- the y coordinate within the first cell
-
getDy2
public int getDy2()
Description copied from interface:ClientAnchorSets the y coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
getDy2in interfaceChildAnchor- Specified by:
getDy2in interfaceClientAnchor- Returns:
- the y coordinate within the second cell
-
setDy2
public void setDy2(int dy2)
Description copied from interface:ClientAnchorSets the y coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
setDy2in interfaceChildAnchor- Specified by:
setDy2in interfaceClientAnchor- Parameters:
dy2- the y coordinate within the second cell
-
getDx2
public int getDx2()
Description copied from interface:ClientAnchorReturns the x coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
getDx2in interfaceChildAnchor- Specified by:
getDx2in interfaceClientAnchor- Returns:
- the x coordinate within the second cell
-
setDx2
public void setDx2(int dx2)
Description copied from interface:ClientAnchorSets the x coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor ofUnits.EMU_PER_PIXEL- Specified by:
setDx2in interfaceChildAnchor- Specified by:
setDx2in interfaceClientAnchor- Parameters:
dx2- the x coordinate within the second cell
-
-