Package cz.vutbr.fit.layout.impl
Class DefaultContentRect
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultContentRect
-
- All Implemented Interfaces:
ContentRect,Rect
- Direct Known Subclasses:
DefaultTextChunk
public class DefaultContentRect extends Object implements ContentRect
A default ContentRect implementation which is not used in a tree. SeeDefaultTreeContentRectfor the tree node version.- Author:
- burgetr
-
-
Field Summary
-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Constructor Summary
Constructors Constructor Description DefaultContentRect()DefaultContentRect(ContentRect src)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUserAttribute(String name, Object value)Sets a user-defined attribute for the tree node.booleanequals(Object obj)ColorgetBackgroundColor()Obtains the background color of the area.byte[]getBackgroundImagePng()Gets the PNG image data of the background image if present.intgetBorderCount()Obtains the number of defined borders for the box.BordergetBorderStyle(Border.Side side)Obtains the properties of the box border at the given side.intgetBottomBorder()Obtains the bottom border width.RectangulargetBounds()Obtains the pixel position within in the page.intgetHeight()intgetId()Obtains a unique ID of the area within the page.intgetLeftBorder()Obtains the left border width.ContentLinegetLine()Returns the content line the area belongs to.org.eclipse.rdf4j.model.IRIgetPageIri()Obtains the IRI of the page this block belongs to.intgetRightBorder()Obtains the right border width.TextStylegetTextStyle()Gets the text style statistics of the content.intgetTopBorder()Obtains the top border width.<P> PgetUserAttribute(String name, Class<P> clazz)Obtains the user-defined attribute value assigned to the node.intgetWidth()intgetX1()intgetX2()intgetY1()intgetY2()booleanhasBackground()Checks whether the box has a background color or image.booleanhasBottomBorder()Checks whether the box has the bottom border defined.inthashCode()booleanhasLeftBorder()Checks whether the box has the left border defined.booleanhasRightBorder()Checks whether the box has right top border defined.booleanhasTopBorder()Checks whether the box has the top border defined.booleanisBackgroundSeparated()Checks whether the box is separated by background, i.e. its background color is not transparent and it is different from the ancestor background.voidmove(int xofs, int yofs)protected voidrecomputeTextStyle()Recomputes the text style after the style of some children has changed.voidsetBackgroundColor(Color backgroundColor)voidsetBackgroundImagePng(byte[] backgroundImagePng)voidsetBackgroundSeparated(boolean backgroundSeparated)Sets whether the box is separated by background.voidsetBorderStyle(Border.Side side, Border style)voidsetBounds(Rectangular bounds)Sets the pixel position within the page.voidsetId(int id)voidsetLine(ContentLine line)Assigns the content line to the area.voidsetPageIri(org.eclipse.rdf4j.model.IRI pageIri)voidsetTextStyle(TextStyle textStyle)
-
-
-
Constructor Detail
-
DefaultContentRect
public DefaultContentRect()
-
DefaultContentRect
public DefaultContentRect(ContentRect src)
-
-
Method Detail
-
getId
public int getId()
Description copied from interface:ContentRectObtains a unique ID of the area within the page.- Specified by:
getIdin interfaceContentRect- Returns:
- the area ID
-
setId
public void setId(int id)
-
getPageIri
public org.eclipse.rdf4j.model.IRI getPageIri()
Description copied from interface:ContentRectObtains the IRI of the page this block belongs to.- Specified by:
getPageIriin interfaceContentRect- Returns:
- the page IRI
-
setPageIri
public void setPageIri(org.eclipse.rdf4j.model.IRI pageIri)
-
getBackgroundColor
public Color getBackgroundColor()
Description copied from interface:ContentRectObtains the background color of the area.- Specified by:
getBackgroundColorin interfaceContentRect- Returns:
- A color or
nullfor transparent background
-
setBackgroundColor
public void setBackgroundColor(Color backgroundColor)
-
getBackgroundImagePng
public byte[] getBackgroundImagePng()
Description copied from interface:ContentRectGets the PNG image data of the background image if present. The image should have the same size as the content bounds.- Specified by:
getBackgroundImagePngin interfaceContentRect- Returns:
- the image data or
nullif no image is present in the background
-
hasBackground
public boolean hasBackground()
Description copied from interface:ContentRectChecks whether the box has a background color or image.- Specified by:
hasBackgroundin interfaceContentRect- Returns:
truewhen the box has a defined background color or image
-
setBackgroundImagePng
public void setBackgroundImagePng(byte[] backgroundImagePng)
-
isBackgroundSeparated
public boolean isBackgroundSeparated()
Description copied from interface:ContentRectChecks whether the box is separated by background, i.e. its background color is not transparent and it is different from the ancestor background.- Specified by:
isBackgroundSeparatedin interfaceContentRect- Returns:
truefor background-separated boxes
-
setBackgroundSeparated
public void setBackgroundSeparated(boolean backgroundSeparated)
Description copied from interface:ContentRectSets whether the box is separated by background. This is typically determined and set during the box tree construction.- Specified by:
setBackgroundSeparatedin interfaceContentRect
-
getTextStyle
public TextStyle getTextStyle()
Description copied from interface:ContentRectGets the text style statistics of the content.- Specified by:
getTextStylein interfaceContentRect- Returns:
- the text style statistics
-
recomputeTextStyle
protected void recomputeTextStyle()
Recomputes the text style after the style of some children has changed.
-
setTextStyle
public void setTextStyle(TextStyle textStyle)
-
getLine
public ContentLine getLine()
Description copied from interface:ContentRectReturns the content line the area belongs to.- Specified by:
getLinein interfaceContentRect- Returns:
- The content line or
nullwhen the area does not belong to any line
-
setLine
public void setLine(ContentLine line)
Description copied from interface:ContentRectAssigns the content line to the area.- Specified by:
setLinein interfaceContentRect- Parameters:
line- the content line to be assigned.
-
getTopBorder
public int getTopBorder()
Description copied from interface:ContentRectObtains the top border width.- Specified by:
getTopBorderin interfaceContentRect- Returns:
- the width of the border or 0 when there is no border
-
getBottomBorder
public int getBottomBorder()
Description copied from interface:ContentRectObtains the bottom border width.- Specified by:
getBottomBorderin interfaceContentRect- Returns:
- the width of the border or 0 when there is no border
-
getLeftBorder
public int getLeftBorder()
Description copied from interface:ContentRectObtains the left border width.- Specified by:
getLeftBorderin interfaceContentRect- Returns:
- the width of the border or 0 when there is no border
-
getRightBorder
public int getRightBorder()
Description copied from interface:ContentRectObtains the right border width.- Specified by:
getRightBorderin interfaceContentRect- Returns:
- the width of the border or 0 when there is no border
-
hasTopBorder
public boolean hasTopBorder()
Description copied from interface:ContentRectChecks whether the box has the top border defined.- Specified by:
hasTopBorderin interfaceContentRect- Returns:
trueif the box has a top border
-
hasBottomBorder
public boolean hasBottomBorder()
Description copied from interface:ContentRectChecks whether the box has the bottom border defined.- Specified by:
hasBottomBorderin interfaceContentRect- Returns:
trueif the box has a bottom border
-
hasLeftBorder
public boolean hasLeftBorder()
Description copied from interface:ContentRectChecks whether the box has the left border defined.- Specified by:
hasLeftBorderin interfaceContentRect- Returns:
trueif the box has a left border
-
hasRightBorder
public boolean hasRightBorder()
Description copied from interface:ContentRectChecks whether the box has right top border defined.- Specified by:
hasRightBorderin interfaceContentRect- Returns:
trueif the box has a right border
-
getBorderStyle
public Border getBorderStyle(Border.Side side)
Description copied from interface:ContentRectObtains the properties of the box border at the given side.- Specified by:
getBorderStylein interfaceContentRect- Parameters:
side- the border side.- Returns:
- the corresponding border properties.
-
setBorderStyle
public void setBorderStyle(Border.Side side, Border style)
-
getBounds
public Rectangular getBounds()
Description copied from interface:ContentRectObtains the pixel position within in the page.- Specified by:
getBoundsin interfaceContentRect- Returns:
- The rectangular pixel position.
-
setBounds
public void setBounds(Rectangular bounds)
Description copied from interface:ContentRectSets the pixel position within the page.- Specified by:
setBoundsin interfaceContentRect- Parameters:
bounds- the new position
-
getBorderCount
public int getBorderCount()
Description copied from interface:ContentRectObtains the number of defined borders for the box.- Specified by:
getBorderCountin interfaceContentRect- Returns:
- the number of defined borders (0..4)
-
getUserAttribute
public <P> P getUserAttribute(String name, Class<P> clazz)
Description copied from interface:ContentRectObtains the user-defined attribute value assigned to the node.- Specified by:
getUserAttributein interfaceContentRect- Parameters:
name- the attribute nameclazz- the class of the required attribute- Returns:
- an object of the given class representing the value of the attribute (application-specific)
or
nullwhen no such attribute is present.
-
addUserAttribute
public void addUserAttribute(String name, Object value)
Description copied from interface:ContentRectSets a user-defined attribute for the tree node. This allows to assign multiple attributes identified by their names.- Specified by:
addUserAttributein interfaceContentRect- Parameters:
name- the attribute namevalue- the attribute value
-
-