Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate


com.aspose.cells
Class Shape

java.lang.Object
  extended by com.aspose.cells.Shape
Direct Known Subclasses:
ArcShape, Button, ChartShape, CheckBox, ComboBox, Comment, GroupBox, GroupShape, Label, LineShape, ListBox, OleObject, OvalShape, Picture, RadioButton, RectangleShape, Spinner, TextBox

public class Shape
extends java.lang.Object

Common Shape Property.


Method Summary
 void addHyperlink(java.lang.String address)
          Adds a hyperlink to the mso drawing object.
 Characters[] getCharacters()
          Gets rich text formatting of this Shape.
 ShapeFill getFill()
          Gets a object that contains fill formatting properties for the specified shape.
 Font getFont()
          Gets the font of text in shape.
 GroupShape getGroup()
          get the GroupShape that this shape is in.
 int getHeight()
          Gets the height, in unit of pixel.
 double getHeightCM()
          Gets the height, in unit of centimeters.
 float getHeightInch()
          Gets the height, in unit of inches.
 int getHeightInChart()
          Gets the height, in units of 1/4000 of the chart area.
 Hyperlink getHyperlink()
          Gets a hyperlink from the mso drawing object.
 int getLeft()
          Gets the horizontal offset of shape from its left column, in unit of pixel.
 double getLeftCM()
          Gets the horizontal offset of shape from its left column, in unit of centimeters.
 float getLeftInch()
          Gets the horizontal offset of shape from its left column, in unit of inches.
 int getLeftInChart()
          Gets the horizontal offset of shape from its left column, in units of 1/4000 of the chart area.
 ShapeLine getLine()
          Gets a object that contains line formatting properties for the shape.
 java.lang.String getLinkedCell()
          Gets the linked cell of shape.
 int getLowerRightColumn()
          Gets the lower right column index.
 int getLowerRightRow()
          Gets the lower right row index.
 java.lang.String getName()
          Gets the name of this Shape.
 int getOrientation()
          Gets text orientation.
 int getPlacement()
          Gets the way the drawing obejct is attached to the cells below it.
 float getRotation()
          Gets rotation of shape
 java.lang.String getText()
          Gets the text in shape.
 int getTextHorizontalAlignment()
          Gets the text horizontal alignment.
 int getTextVerticalAlignment()
          Gets the text vertical alignment.
 int getTop()
          Gets the vertical offset of shape from its top row, in unit of pixel.
 double getTopCM()
          Gets the vertical offset of shape from its top row, in unit of centimeters.
 float getTopInch()
          Gets the vertical offset of shape from its top row, in unit of inches.
 int getTopInChart()
          Gets the vertical offset of shape from its top row, in units of 1/4000 of the chart area.
 short getType()
          Gets the shape type.
 int getUpperLeftColumn()
          Gets the upper left column index.
 int getUpperLeftRow()
          Gets the upper left row index.
 int getWidth()
          Gets the width, in unit of pixel.
 double getWidthCM()
          Gets the width, in unit of centimeters.
 float getWidthInch()
          Gets the width, in unit of inches.
 int getWidthInChart()
          Gets the widthx, in units of 1/4000 of the chart area.
 int getZOrderPosition()
          Gets the ZOrderPosition of Shape, 1 based.
 boolean hasLine()
          Indicates whether shape has border line.
 boolean isFilled()
          Indicates whether shape is filled.
 boolean isFlippedHorizontally()
          Checks whether shape is flipped horizontally.
 boolean isFlippedVertically()
          Checks whether shape is flipped vertically.
 boolean isLockAspectRatio()
          Indicates whether allow changes in aspect ratio.
 boolean isLocked()
          Check if the object is locked when the sheet is protected.
 boolean isPrintable()
          Check if the object is printable.
 void move(int startRow, int startColumn)
          Moves the shape to a specified location.
 void move(int startRow, int startColumn, int endRow, int endColumn)
          Moves the shape to a specified location and size.
 void moveToCenter(int startRow, int startColumn, int endRow, int endColumn)
          Moves the shape to the center of given cell range.
 void setCharacters(int startIndex, int length, Font font)
          Performs rich text formatting.
 void setFilled(boolean isFilled)
          Sets whether shape is filled.
 void setFlippedHorizontally(boolean flipped)
          Sets whether shape is flipped horizontally.
 void setFlippedVertically(boolean flipped)
          Sets whether shape is flipped vertically.
 void setFont(Font font)
          Sets the font of text in shape.
 void setHasLine(boolean hasLine)
          Sets whether shape has border line.
 void setHeight(int height)
          Sets the height, in unit of pixel.
 void setHeightCM(double height)
          Sets the height, in unit of centimeters.
 void setHeightInch(double height)
          Sets the height, in unit of inches.
 void setHeightInChart(int height)
          Sets the height, in units of 1/4000 of the chart area.
 void setLeft(int left)
          Deprecated. for shape in Chart, use setLeftInChart(int) instead; for shape in common sheet, use setLeftPositionInPixel(short, short) instead.
 void setLeftCM(double left)
          Sets the horizontal offset of shape from its left column, in unit of centimeters.
 void setLeftInch(double left)
          Sets the horizontal offset of shape from its left column, in unit of inches.
 void setLeftInChart(int left)
          Sets the horizontal offset of shape from its left column, in units of 1/4000 of the chart area.
 void setLeftPosition(short column, short offsetRatio)
          set left border position for shape.
 void setLeftPositionInPixel(short column, short offsetInPixel)
          set left border position for shape.
 void setLinkedCell(java.lang.String linkedCell)
          Sets the linked cell of shape.
 void setLockAspectRatio(boolean isLock)
          Sets whether allow changes in aspect ratio.
 void setLocked(boolean locked)
          Sets if the object is locked when the sheet is protected.
 void setName(java.lang.String name)
          Sets the name of this Shape.
 void setOrientation(int orientation)
          Sets text orientation.
 void setPlacement(byte placementType)
          Sets the way the drawing obejct is attached to the cells below it.
 void setPrintable(boolean printable)
          Sets if the object is printable
 void setRotation(float degree)
          Rotates the shape
 void setText(java.lang.String text)
          Sets the text in shape.
 void setTextHorizontalAlignment(int textAlignmentType)
          Sets the text horizontal alignment.
 void setTextVerticalAlignment(int textAlignmentType)
          Sets the text vertical alignment.
 void setTop(int top)
          Deprecated. for shape in Chart, use setTopInChart(int) instead; for shape in common sheet, use setTopPositionInPixel(int, short) instead.
 void setTopCM(double top)
          Sets the vertical offset of shape from its top row, in unit of centimeters.
 void setTopInch(double top)
          Sets the vertical offset of shape from its top row, in unit of inches.
 void setTopInChart(int top)
          Sets the vertical offset of shape from its top row, in units of 1/4000 of the chart area.
 void setTopPosition(int row, short offsetRatio)
          set top border position for shape.
 void setTopPositionInPixel(int row, short offsetInPixel)
          set top border position for shape.
 void setUpperLeftColumn(int column)
          Deprecated. replaced by setLeftPosition(short, short)
 void setUpperLeftRow(int row)
          Deprecated. replaced by setTopPosition(int, short)
 void setWidth(int width)
          Sets the width, in unit of pixel.
 void setWidthCM(double width)
          Sets the width, in unit of centimeters.
 void setWidthInch(double width)
          Sets the width, in unit of inches.
 void setWidthInChart(int width)
          Sets the width, in units of 1/4000 of the chart area.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Gets the name of this Shape.

Returns:
name of Shape.

setName

public void setName(java.lang.String name)
Sets the name of this Shape.

Parameters:
name - the name to be set to Shape.

getZOrderPosition

public int getZOrderPosition()
Gets the ZOrderPosition of Shape, 1 based. Only takes count of those shapes that are not in group. For shapes in group, return their group's ZOrderPosition.

Returns:
ZOrderPosition of Shape.

getType

public short getType()
Gets the shape type.

Returns:
the shape type.
See Also:
MsoDrawingType

getFill

public ShapeFill getFill()
Gets a object that contains fill formatting properties for the specified shape.

Returns:
ShapeFill Object.

getLine

public ShapeLine getLine()
Gets a object that contains line formatting properties for the shape.

Returns:
ShapeLine Obejct.

isFilled

public boolean isFilled()
Indicates whether shape is filled.

Returns:
whether shape is filled.

setFilled

public void setFilled(boolean isFilled)
Sets whether shape is filled.

Parameters:
isFilled - whether shape is filled.

getHyperlink

public Hyperlink getHyperlink()
Gets a hyperlink from the mso drawing object.

Returns:
a hyperlink. Return null if the hyperlink has not bean set.

addHyperlink

public void addHyperlink(java.lang.String address)
Adds a hyperlink to the mso drawing object.

Parameters:
address - address of this hyperlink.This parameter can't be empty.

hasLine

public boolean hasLine()
Indicates whether shape has border line.

Returns:
whether shape has border line.

setHasLine

public void setHasLine(boolean hasLine)
Sets whether shape has border line.

Parameters:
hasLine - whether shape has border line.

isFlippedHorizontally

public boolean isFlippedHorizontally()
Checks whether shape is flipped horizontally.

Returns:
whether shape is flipped horizontally.

setFlippedHorizontally

public void setFlippedHorizontally(boolean flipped)
Sets whether shape is flipped horizontally.

Parameters:
flipped - whether shape is flipped horizontally.

isFlippedVertically

public boolean isFlippedVertically()
Checks whether shape is flipped vertically.

Returns:
whether shape is flipped vertically.

setFlippedVertically

public void setFlippedVertically(boolean flipped)
Sets whether shape is flipped vertically.

Parameters:
flipped - whether shape is flipped vertically.

move

public void move(int startRow,
                 int startColumn,
                 int endRow,
                 int endColumn)
Moves the shape to a specified location and size.

Parameters:
startRow - row index of the top left cell.
startColumn - column index of the top left cell.
endRow - row index of the bottom right cell.
endColumn - column index of the bottom right cell.
Throws:
CellsException - if shape Object has bean removed.
java.lang.IllegalArgumentException - if row or column index is out of range.

move

public void move(int startRow,
                 int startColumn)
Moves the shape to a specified location.

Parameters:
startRow - row index of the top left cell.
startColumn - column index of the top left cell.
Throws:
CellsException - if shape Object has bean removed.
java.lang.IllegalArgumentException - if row or column index is out of range.

moveToCenter

public void moveToCenter(int startRow,
                         int startColumn,
                         int endRow,
                         int endColumn)
Moves the shape to the center of given cell range.

Parameters:
startRow - row index of the top left cell.
startColumn - column index of the top left cell.
endRow - row index of the bottom right cell.
endColumn - column index of the bottom right cell.

getUpperLeftColumn

public int getUpperLeftColumn()
Gets the upper left column index.

Returns:
the upper left column index.

setLeftPosition

public void setLeftPosition(short column,
                            short offsetRatio)
set left border position for shape.

Parameters:
column - column where the shape's left border is in
offsetRatio - ratio of the distance between shape's left border and column's left border to column's width. in unit of 1/1024, that is, valid value is between 0 and 1024(inclusive)

setTopPosition

public void setTopPosition(int row,
                           short offsetRatio)
set top border position for shape.

Parameters:
row - row where the shape's top border is in
offsetRatio - ratio of the distance between shape's top border and row's top border to row's height. in unit of 1/256, that is, valid value is between 0 and 256(inclusive)

setLeftPositionInPixel

public void setLeftPositionInPixel(short column,
                                   short offsetInPixel)
set left border position for shape.

Parameters:
column - column where the shape's left border is in
offsetInPixel - the distance between shape's left border and column's left border, in unit of pixel

setTopPositionInPixel

public void setTopPositionInPixel(int row,
                                  short offsetInPixel)
set top border position for shape.

Parameters:
row - row where the shape's top border is in
offsetInPixel - the distance between shape's top border and row's top border, in unit of pixel

setUpperLeftColumn

public void setUpperLeftColumn(int column)
Deprecated. replaced by setLeftPosition(short, short)

Sets the upper left column index.

Parameters:
column - the upper left column index .

getUpperLeftRow

public int getUpperLeftRow()
Gets the upper left row index.

Returns:
the upper left row index.

setUpperLeftRow

public void setUpperLeftRow(int row)
Deprecated. replaced by setTopPosition(int, short)

Sets the upper left row index.

Parameters:
row - the upper left row index.

getLowerRightRow

public int getLowerRightRow()
Gets the lower right row index.

Returns:
the lower right row index.

getLowerRightColumn

public int getLowerRightColumn()
Gets the lower right column index.

Returns:
the lower right column index.

getHeight

public int getHeight()
Gets the height, in unit of pixel.

Returns:
the height, in unit of pixel.

setHeight

public void setHeight(int height)
Sets the height, in unit of pixel.

Parameters:
height - the height, in unit of pixel.

getHeightInChart

public int getHeightInChart()
Gets the height, in units of 1/4000 of the chart area.

Returns:
the height, in units of 1/4000 of the chart area.

setHeightInChart

public void setHeightInChart(int height)
Sets the height, in units of 1/4000 of the chart area. This method only effects when the drawing object is in the chart.

Parameters:
height - the height, in units of 1/4000 of the chart area.
Throws:
java.lang.IllegalArgumentException - if height > 4000;

getHeightInch

public float getHeightInch()
Gets the height, in unit of inches.

Returns:
the height, in unit of inches.

setHeightInch

public void setHeightInch(double height)
Sets the height, in unit of inches.

Parameters:
height - the heigh, in unit of inches.

getHeightCM

public double getHeightCM()
Gets the height, in unit of centimeters.

Returns:
the height, in unit of centimeters.

setHeightCM

public void setHeightCM(double height)
Sets the height, in unit of centimeters.

Parameters:
height - the height, in unit of centimeters.

getWidth

public int getWidth()
Gets the width, in unit of pixel.

Returns:
the width, in unit of pixel.

setWidth

public void setWidth(int width)
Sets the width, in unit of pixel.

Parameters:
width - the width, in unit of pixel.

getWidthInChart

public int getWidthInChart()
Gets the widthx, in units of 1/4000 of the chart area.

Returns:
the width, in units of 1/4000 of the chart area.

setWidthInChart

public void setWidthInChart(int width)
Sets the width, in units of 1/4000 of the chart area. This method only effects when the drawing object is in the chart.

Parameters:
width - the width, in units of 1/4000 of the chart area.
Throws:
java.lang.IllegalArgumentException - if width > 4000;

getWidthInch

public float getWidthInch()
Gets the width, in unit of inches.

Returns:
the width, in unit of inches.

setWidthInch

public void setWidthInch(double width)
Sets the width, in unit of inches.

Parameters:
width - the width, in unit of inches.

getWidthCM

public double getWidthCM()
Gets the width, in unit of centimeters.

Returns:
the width, in unit of centimeters.

setWidthCM

public void setWidthCM(double width)
Sets the width, in unit of centimeters.

Parameters:
width - the width, in unit of centimeters.

getLeft

public int getLeft()
Gets the horizontal offset of shape from its left column, in unit of pixel. If shape is in Chart or Group, returns offset of shape from the left border of the Chart or Group.

Returns:
the horizontal offset of shape from its left column, in unit of pixel.

setLeft

public void setLeft(int left)
Deprecated. for shape in Chart, use setLeftInChart(int) instead; for shape in common sheet, use setLeftPositionInPixel(short, short) instead.

Sets the horizontal offset of shape from its left column, in unit of pixel.

Parameters:
left - the horizontal offset of shape from its left column, in unit of pixel.

getLeftInChart

public int getLeftInChart()
Gets the horizontal offset of shape from its left column, in units of 1/4000 of the chart area.

Returns:
the horizontal offset of shape from its left column, in units of 1/4000 of the chart area.

setLeftInChart

public void setLeftInChart(int left)
Sets the horizontal offset of shape from its left column, in units of 1/4000 of the chart area. This method only effects when the drawing object is in the chart.

Parameters:
left - the horizontal offset of shape from its left column, in units of 1/4000 of the chart area.
Throws:
java.lang.IllegalArgumentException - if left > 4000;

getLeftInch

public float getLeftInch()
Gets the horizontal offset of shape from its left column, in unit of inches.

Returns:
the horizontal offset of shape from its left column, in unit of inches.

setLeftInch

public void setLeftInch(double left)
Sets the horizontal offset of shape from its left column, in unit of inches.

Parameters:
left - the horizontal offset of shape from its left column, in unit of inches.

getLeftCM

public double getLeftCM()
Gets the horizontal offset of shape from its left column, in unit of centimeters.

Returns:
the horizontal offset of shape from its left column, in unit of centimeters.

setLeftCM

public void setLeftCM(double left)
Sets the horizontal offset of shape from its left column, in unit of centimeters.

Parameters:
left - the horizontal offset of shape from its left column, in unit of centimeters.

getTop

public int getTop()
Gets the vertical offset of shape from its top row, in unit of pixel. If shape is in Chart or Group, returns the vertical offset of shape from the top border of Chart or Group.

Returns:
the vertical offset of shape from its top row, in unit of pixel.

setTop

public void setTop(int top)
Deprecated. for shape in Chart, use setTopInChart(int) instead; for shape in common sheet, use setTopPositionInPixel(int, short) instead.

Sets the vertical offset of shape from its top row, in unit of pixel.

Parameters:
top - the vertical offset of shape from its top row, in unit of pixel.

getTopInChart

public int getTopInChart()
Gets the vertical offset of shape from its top row, in units of 1/4000 of the chart area.

Returns:
the vertical offset of shape from its top row, in units of 1/4000 of the chart area.

setTopInChart

public void setTopInChart(int top)
Sets the vertical offset of shape from its top row, in units of 1/4000 of the chart area. This method only effects when the drawing object is in the chart.

Parameters:
top - the vertical offset of shape from its top row, in units of 1/4000 of the chart area.
Throws:
java.lang.IllegalArgumentException - if top > 4000;

getTopInch

public float getTopInch()
Gets the vertical offset of shape from its top row, in unit of inches.

Returns:
the vertical offset of shape from its top row, in unit of inches.

setTopInch

public void setTopInch(double top)
Sets the vertical offset of shape from its top row, in unit of inches.

Parameters:
top - the vertical offset of shape from its top row, in unit of inches.

getTopCM

public double getTopCM()
Gets the vertical offset of shape from its top row, in unit of centimeters.

Returns:
the vertical offset of shape from its top row, in unit of centimeters.

setTopCM

public void setTopCM(double top)
Sets the vertical offset of shape from its top row, in unit of centimeters.

Parameters:
top - the vertical offset of shape from its top row, in unit of centimeters.

getPlacement

public int getPlacement()
Gets the way the drawing obejct is attached to the cells below it.

Returns:
the way the drawing obejct is attached to the cells below it.
See Also:
setPlacement(byte)

setPlacement

public void setPlacement(byte placementType)
Sets the way the drawing obejct is attached to the cells below it.

Parameters:
placementType - the way the drawing obejct is attached to the cells below it. It could be one of the following values:
PlacementType.FREE_FLOATING
PlacementType.MOVE
PlacementType.MOVE_AND_SIZE
Throws:
java.lang.IllegalArgumentException - if placementType is not member of PlacementType

getGroup

public GroupShape getGroup()
get the GroupShape that this shape is in.

Returns:
the GroupShape that this shape is in. null if this shape is not in group

setRotation

public void setRotation(float degree)
Rotates the shape

Parameters:
degree - degree for rotate angle

getRotation

public float getRotation()
Gets rotation of shape

Returns:
degree for ratate angle

isLocked

public boolean isLocked()
Check if the object is locked when the sheet is protected.

Returns:
true if the object is locked, false if the object can be modified when the sheet is protected.

setLocked

public void setLocked(boolean locked)
Sets if the object is locked when the sheet is protected.

Parameters:
locked - true if the object is locked, false if the object can be modified when the sheet is protected.

isPrintable

public boolean isPrintable()
Check if the object is printable.

Returns:
true if the object is printable

setPrintable

public void setPrintable(boolean printable)
Sets if the object is printable

Parameters:
printable - if the object is printable

isLockAspectRatio

public boolean isLockAspectRatio()
Indicates whether allow changes in aspect ratio.

Returns:
whether allow changes in aspect ratio.

setLockAspectRatio

public void setLockAspectRatio(boolean isLock)
Sets whether allow changes in aspect ratio.

Parameters:
isLock - whether allow changes in aspect ratio.

getFont

public Font getFont()
Gets the font of text in shape.

Returns:
the font of text in shape.
Throws:
CellsException - if shape has been removed.

setFont

public void setFont(Font font)
Sets the font of text in shape.

Parameters:
font - the font of text in shape.
Throws:
CellsException - if shape has been removed.

getText

public java.lang.String getText()
Gets the text in shape.

Returns:
the text in shape.
Throws:
CellsException - if shape has been removed.

setText

public void setText(java.lang.String text)
Sets the text in shape.

Parameters:
text - the text in shape.
Throws:
CellsException - if shape has been removed.

getCharacters

public Characters[] getCharacters()
Gets rich text formatting of this Shape.

Returns:
rich text formatting of this Shape. If this Shape does not contains text, return null.
Throws:
CellsException - if shape has been removed.

setCharacters

public void setCharacters(int startIndex,
                          int length,
                          Font font)
Performs rich text formatting.

Parameters:
startIndex - start index.
length - character counts. If length is negative, all characters after the start index are formatted. If length is 0, no characters is formatted.
font - font for the specified range. It can be null which means shape's font is used.
Throws:
CellsException - if shape has been removed.

getLinkedCell

public java.lang.String getLinkedCell()
Gets the linked cell of shape.

Returns:
the linked cell.
Throws:
CellsException - if shape has been removed.

setLinkedCell

public void setLinkedCell(java.lang.String linkedCell)
Sets the linked cell of shape.

Parameters:
linkedCell - the linked cell.
Throws:
CellsException - if shape has been removed.

getTextHorizontalAlignment

public int getTextHorizontalAlignment()
Gets the text horizontal alignment.

Returns:
the text horizontal alignment.
Throws:
CellsException - if shape has been removed.
See Also:
setTextHorizontalAlignment(int)

setTextHorizontalAlignment

public void setTextHorizontalAlignment(int textAlignmentType)
Sets the text horizontal alignment.

Parameters:
textAlignmentType - the text horizontal alignment. It could be one of the following values:
TextAlignmentType.LEFT
TextAlignmentType.CENTER
TextAlignmentType.RIGHT
TextAlignmentType.JUSTIFY
TextAlignmentType.DISTRIBUTED
Throws:
CellsException - if shape has been removed.
java.lang.IllegalArgumentException - if text alignment type is invalid.

getTextVerticalAlignment

public int getTextVerticalAlignment()
Gets the text vertical alignment.

Returns:
the text vertical alignment of text.
Throws:
CellsException - if shape has been removed.
See Also:
setTextVerticalAlignment(int)

setTextVerticalAlignment

public void setTextVerticalAlignment(int textAlignmentType)
Sets the text vertical alignment.

Parameters:
textAlignmentType - the text vertical alignment. It could be one of the following values:
TextAlignmentType.TOP
TextAlignmentType.CENTER
TextAlignmentType.BOTTOM
TextAlignmentType.JUSTIFY
TextAlignmentType.DISTRIBUTED
Throws:
CellsException - if shape has been removed.
java.lang.IllegalArgumentException - if text alignment type is invalid.

getOrientation

public int getOrientation()
Gets text orientation.

Returns:
text orientation.
Throws:
CellsException - if shape has been removed.
See Also:
setOrientation(int)

setOrientation

public void setOrientation(int orientation)
Sets text orientation. It could be one of the following values:
MsoTextOrientation.NO_ROTATED
MsoTextOrientation.TOP_TO_BOTTOM
MsoTextOrientation.UPWARD
MsoTextOrientation.DOWNWARD

Throws:
java.lang.IllegalArgumentException - if rotation is one of MsoTextOrientation constants.
CellsException - if shape has been removed.