Package cz.vutbr.fit.layout.impl
Class DefaultTreeContentRect<T extends GenericTreeNode<T>>
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultTreeNode<T>
-
- cz.vutbr.fit.layout.impl.DefaultTreeContentRect<T>
-
- All Implemented Interfaces:
ContentRect
,GenericTreeNode<T>
,Rect
- Direct Known Subclasses:
DefaultArea
,DefaultBox
public class DefaultTreeContentRect<T extends GenericTreeNode<T>> extends DefaultTreeNode<T> implements ContentRect
A default ContentRect implementation that is a tree node at the same time. This class is usually not used directly; theDefaultBox
andDefaultArea
subclasses should be used instead.- Author:
- burgetr
-
-
Field Summary
-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeContentRect(Class<T> myType)
DefaultTreeContentRect(Class<T> myType, ContentRect src)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUserAttribute(String name, Object value)
Sets a user-defined attribute for the tree node.boolean
equals(Object obj)
Color
getBackgroundColor()
Obtains the background color of the area.byte[]
getBackgroundImagePng()
Gets the PNG image data of the background image if present.int
getBorderCount()
Obtains the number of defined borders for the box.Border
getBorderStyle(Border.Side side)
Obtains the properties of the box border at the given side.int
getBottomBorder()
Obtains the bottom border width.Rectangular
getBounds()
Obtains the pixel position within in the page.int
getHeight()
int
getId()
Obtains a unique ID of the area within the page.int
getLeftBorder()
Obtains the left border width.ContentLine
getLine()
Returns the content line the area belongs to.org.eclipse.rdf4j.model.IRI
getPageIri()
Obtains the IRI of the page this block belongs to.int
getRightBorder()
Obtains the right border width.TextStyle
getTextStyle()
Gets the text style statistics of the content.int
getTopBorder()
Obtains the top border width.<P> P
getUserAttribute(String name, Class<P> clazz)
Obtains the user-defined attribute value assigned to the node.int
getWidth()
int
getX1()
int
getX2()
int
getY1()
int
getY2()
boolean
hasBackground()
Checks whether the box has a background color or image.boolean
hasBottomBorder()
Checks whether the box has the bottom border defined.int
hashCode()
boolean
hasLeftBorder()
Checks whether the box has the left border defined.boolean
hasRightBorder()
Checks whether the box has right top border defined.boolean
hasTopBorder()
Checks whether the box has the top border defined.void
childrenChanged()
This method is called after some child nodes have been added or removed.boolean
isBackgroundSeparated()
Checks whether the box is separated by background, i.e. its background color is not transparent and it is different from the ancestor background.void
move(int xofs, int yofs)
protected void
recomputeTextStyle()
Recomputes the text style after the style of some children has changed.void
setBackgroundColor(Color backgroundColor)
void
setBackgroundImagePng(byte[] backgroundImagePng)
void
setBackgroundSeparated(boolean backgroundSeparated)
Sets whether the box is separated by background.void
setBorderStyle(Border.Side side, Border style)
void
setBounds(Rectangular bounds)
Sets the pixel position within the page.void
setId(int id)
void
setLine(ContentLine line)
Assigns the content line to the area.void
setPageIri(org.eclipse.rdf4j.model.IRI pageIri)
void
setTextStyle(TextStyle textStyle)
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultTreeNode
appendChild, appendChildren, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSibling, getParent, getPreviousSibling, getRoot, insertChild, isLeaf, isRoot, removeAllChildren, removeChild, removeChild, setParent, setRoot
-
-
-
-
Constructor Detail
-
DefaultTreeContentRect
public DefaultTreeContentRect(Class<T> myType, ContentRect src)
-
-
Method Detail
-
getId
public int getId()
Description copied from interface:ContentRect
Obtains a unique ID of the area within the page.- Specified by:
getId
in interfaceContentRect
- Returns:
- the area ID
-
setId
public void setId(int id)
-
getPageIri
public org.eclipse.rdf4j.model.IRI getPageIri()
Description copied from interface:ContentRect
Obtains the IRI of the page this block belongs to.- Specified by:
getPageIri
in interfaceContentRect
- Returns:
- the page IRI
-
setPageIri
public void setPageIri(org.eclipse.rdf4j.model.IRI pageIri)
-
getBackgroundColor
public Color getBackgroundColor()
Description copied from interface:ContentRect
Obtains the background color of the area.- Specified by:
getBackgroundColor
in interfaceContentRect
- Returns:
- A color or
null
for transparent background
-
setBackgroundColor
public void setBackgroundColor(Color backgroundColor)
-
getBackgroundImagePng
public byte[] getBackgroundImagePng()
Description copied from interface:ContentRect
Gets the PNG image data of the background image if present. The image should have the same size as the content bounds.- Specified by:
getBackgroundImagePng
in interfaceContentRect
- Returns:
- the image data or
null
if no image is present in the background
-
hasBackground
public boolean hasBackground()
Description copied from interface:ContentRect
Checks whether the box has a background color or image.- Specified by:
hasBackground
in interfaceContentRect
- Returns:
true
when the box has a defined background color or image
-
setBackgroundImagePng
public void setBackgroundImagePng(byte[] backgroundImagePng)
-
isBackgroundSeparated
public boolean isBackgroundSeparated()
Description copied from interface:ContentRect
Checks 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:
isBackgroundSeparated
in interfaceContentRect
- Returns:
true
for background-separated boxes
-
setBackgroundSeparated
public void setBackgroundSeparated(boolean backgroundSeparated)
Description copied from interface:ContentRect
Sets whether the box is separated by background. This is typically determined and set during the box tree construction.- Specified by:
setBackgroundSeparated
in interfaceContentRect
-
getTextStyle
public TextStyle getTextStyle()
Description copied from interface:ContentRect
Gets the text style statistics of the content.- Specified by:
getTextStyle
in 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:ContentRect
Returns the content line the area belongs to.- Specified by:
getLine
in interfaceContentRect
- Returns:
- The content line or
null
when the area does not belong to any line
-
setLine
public void setLine(ContentLine line)
Description copied from interface:ContentRect
Assigns the content line to the area.- Specified by:
setLine
in interfaceContentRect
- Parameters:
line
- the content line to be assigned.
-
getTopBorder
public int getTopBorder()
Description copied from interface:ContentRect
Obtains the top border width.- Specified by:
getTopBorder
in interfaceContentRect
- Returns:
- the width of the border or 0 when there is no border
-
getBottomBorder
public int getBottomBorder()
Description copied from interface:ContentRect
Obtains the bottom border width.- Specified by:
getBottomBorder
in interfaceContentRect
- Returns:
- the width of the border or 0 when there is no border
-
getLeftBorder
public int getLeftBorder()
Description copied from interface:ContentRect
Obtains the left border width.- Specified by:
getLeftBorder
in interfaceContentRect
- Returns:
- the width of the border or 0 when there is no border
-
getRightBorder
public int getRightBorder()
Description copied from interface:ContentRect
Obtains the right border width.- Specified by:
getRightBorder
in interfaceContentRect
- Returns:
- the width of the border or 0 when there is no border
-
hasTopBorder
public boolean hasTopBorder()
Description copied from interface:ContentRect
Checks whether the box has the top border defined.- Specified by:
hasTopBorder
in interfaceContentRect
- Returns:
true
if the box has a top border
-
hasBottomBorder
public boolean hasBottomBorder()
Description copied from interface:ContentRect
Checks whether the box has the bottom border defined.- Specified by:
hasBottomBorder
in interfaceContentRect
- Returns:
true
if the box has a bottom border
-
hasLeftBorder
public boolean hasLeftBorder()
Description copied from interface:ContentRect
Checks whether the box has the left border defined.- Specified by:
hasLeftBorder
in interfaceContentRect
- Returns:
true
if the box has a left border
-
hasRightBorder
public boolean hasRightBorder()
Description copied from interface:ContentRect
Checks whether the box has right top border defined.- Specified by:
hasRightBorder
in interfaceContentRect
- Returns:
true
if the box has a right border
-
getBorderStyle
public Border getBorderStyle(Border.Side side)
Description copied from interface:ContentRect
Obtains the properties of the box border at the given side.- Specified by:
getBorderStyle
in 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:ContentRect
Obtains the pixel position within in the page.- Specified by:
getBounds
in interfaceContentRect
- Returns:
- The rectangular pixel position.
-
setBounds
public void setBounds(Rectangular bounds)
Description copied from interface:ContentRect
Sets the pixel position within the page.- Specified by:
setBounds
in interfaceContentRect
- Parameters:
bounds
- the new position
-
getBorderCount
public int getBorderCount()
Description copied from interface:ContentRect
Obtains the number of defined borders for the box.- Specified by:
getBorderCount
in interfaceContentRect
- Returns:
- the number of defined borders (0..4)
-
getUserAttribute
public <P> P getUserAttribute(String name, Class<P> clazz)
Description copied from interface:ContentRect
Obtains the user-defined attribute value assigned to the node.- Specified by:
getUserAttribute
in 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
null
when no such attribute is present.
-
addUserAttribute
public void addUserAttribute(String name, Object value)
Description copied from interface:ContentRect
Sets a user-defined attribute for the tree node. This allows to assign multiple attributes identified by their names.- Specified by:
addUserAttribute
in interfaceContentRect
- Parameters:
name
- the attribute namevalue
- the attribute value
-
childrenChanged
public void childrenChanged()
Description copied from class:DefaultTreeNode
This method is called after some child nodes have been added or removed. Subclasses may override this method in order to update their own internal structures.- Specified by:
childrenChanged
in interfaceGenericTreeNode<T extends GenericTreeNode<T>>
- Overrides:
childrenChanged
in classDefaultTreeNode<T extends GenericTreeNode<T>>
-
-