Package cz.vutbr.fit.layout.impl
Class DefaultArea
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultTreeNode<T>
-
- cz.vutbr.fit.layout.impl.DefaultTreeContentRect<Area>
-
- cz.vutbr.fit.layout.impl.DefaultArea
-
- All Implemented Interfaces:
Area
,ContentRect
,GenericTreeNode<Area>
,Rect
,Taggable
- Direct Known Subclasses:
RDFArea
public class DefaultArea extends DefaultTreeContentRect<Area> implements Area
Default generic Area implementation.- Author:
- burgetr
-
-
Field Summary
-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Constructor Summary
Constructors Constructor Description DefaultArea(Area src)
DefaultArea(Box box)
DefaultArea(Rectangular r)
DefaultArea(List<Box> boxList)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBox(Box box)
Adds a new box to the area.void
addTag(Tag tag, float support)
Adds a tag to this area.void
appendChild(Area child)
boolean
containsTag(Tag tag)
Tests whether the area or any of its direct child areas have the given tag.Area
copy()
Creates a copy of the area and makes it a next sibling of the source area.Area
createSuperArea(Rectangular gp, List<Area> selected, String name)
Creates a new subarea from a specified region of the area and moves the selected child nodes to the new area.protected AreaTopology
createTopology()
Creates a topology for this area.List<Box>
getAllBoxes()
Obtains all the boxes from this area and all the child areas.AreaTree
getAreaTree()
Obtains the tree the node belongs to.protected String
getBoxDescription(Box box)
Obtains a box description used as the default area name when the area is created from a box.List<Box>
getBoxes()
Returns a vector of boxes that are inside of this areaString
getBoxText()
Deprecated.Depracated in favor ofgetBoxText(BoxConcatenator)
.String
getBoxText(BoxConcatenator concat)
Returns the text string represented by a concatenation of all the boxes contained directly in this area (no subareas)Rectangular
getContentBounds()
Color
getEffectiveBackgroundColor()
Obtains the effective background color visible under the area.Rectangular
getGridPosition()
Gets the grid position of this area within the parent topology.int
getLevel()
Area grouping level.Tag
getMostSupportedTag()
Obtains the tag with the greatest support that is assigned to this area.String
getName()
Obtains the area name.Set<Tag>
getSupportedTags(float minSupport)
Obtains all the tags with the support greater or equal to the specified value.Map<Tag,Float>
getTags()
Obtains the set of tags assigned to the area.float
getTagSupport(Tag tag)
Obtains the support of the given tag assignmentString
getText()
Returns the complete text contained in this area and its sub areas concatenated using the default concatenator defined byConcatenators.getDefaultAreaConcatenator()
.String
getText(AreaConcatenator concatenator)
Returns the complete text contained in this area and its sub areas concatenated using the specified concatenator.String
getText(String separator)
Returns the complete text contained in this area and its sub area.AreaTopology
getTopology()
Returns the topology of this area.boolean
hasTag(Tag tag)
Tests whether the area has this tag.boolean
hasTag(Tag tag, float minSupport)
Tests whether the area has this tag with a support greater or equal to the specified value.void
childrenChanged()
This method is called after some child nodes have been added or removed.void
insertChild(Area child, int index)
void
insertParent(Area newParent, Area child)
Inserts a new area as a new parent of the given child area.protected void
invalidateTopology()
Marks the topology as dirty when the list of areas has been altered.boolean
isExplicitlySeparated()
When set to true, the area is considered to be separated from other areas explicitly, i.e. independently on its real borders or background.boolean
isHorizontalSeparator()
Checks whether the area can be interpreted as a horizontal separator.boolean
isReplaced()
Checks whether this area is formed by replaced boxes.boolean
isSeparator()
Checks whether the area can be interpreted as any kind of separator.boolean
isVerticalSeparator()
Checks whether the area can be interpreted as a vertical separator.void
move(int xofs, int yofs)
protected void
recomputeTextStyle()
Recomputes the average text style after some boxes or child areas have been added, removed or changed (e.g. added or removed boxes).void
removeAllTags(Collection<Tag> c)
Removes all tags that belong to the given collection.void
removeBox(Box box)
Removes the given box from the given area.void
removeBoxes(Collection<Box> box)
Removes the given boxes from the given area.void
removeTag(Tag tag)
Removes the specific tagvoid
setAreaTree(AreaTree areaTree)
void
setExplicitlySeparated(boolean explicitlySeparated)
When set to true, the area is considered to be separated from other areas explicitly, i.e. independently on its real borders or background.void
setGridPosition(Rectangular gp)
Sets the grid position of this area within the parent topology.void
setHorizontalSeparator(boolean hsep)
void
setLevel(int level)
Sets the area level.void
setName(String name)
Sets the name of the area.void
setVerticalSeparator(boolean vsep)
String
toString()
void
updateTopologies()
Updates the topologies of the child areas.-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultTreeContentRect
addUserAttribute, equals, getBackgroundColor, getBackgroundImagePng, getBorderCount, getBorderStyle, getBottomBorder, getBounds, getHeight, getId, getLeftBorder, getLine, getPageIri, getRightBorder, getTextStyle, getTopBorder, getUserAttribute, getWidth, getX1, getX2, getY1, getY2, hasBackground, hasBottomBorder, hashCode, hasLeftBorder, hasRightBorder, hasTopBorder, isBackgroundSeparated, setBackgroundColor, setBackgroundImagePng, setBackgroundSeparated, setBorderStyle, setBounds, setId, setLine, setPageIri, setTextStyle
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultTreeNode
appendChildren, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSibling, getParent, getPreviousSibling, getRoot, isLeaf, isRoot, removeAllChildren, removeChild, removeChild, setParent, setRoot
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cz.vutbr.fit.layout.model.Area
setBorderStyle
-
Methods inherited from interface cz.vutbr.fit.layout.model.ContentRect
addUserAttribute, getBackgroundColor, getBackgroundImagePng, getBorderCount, getBorderStyle, getBottomBorder, getBounds, getId, getLeftBorder, getLine, getPageIri, getRightBorder, getTextStyle, getTopBorder, getUserAttribute, hasBackground, hasBottomBorder, hasLeftBorder, hasRightBorder, hasTopBorder, isBackgroundSeparated, setBackgroundSeparated, setBounds, setLine
-
Methods inherited from interface cz.vutbr.fit.layout.model.GenericTreeNode
appendChildren, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSibling, getParent, getPreviousSibling, getRoot, isLeaf, isRoot, removeAllChildren, removeChild, removeChild, setParent, setRoot
-
-
-
-
Constructor Detail
-
DefaultArea
public DefaultArea(Rectangular r)
-
DefaultArea
public DefaultArea(Area src)
-
DefaultArea
public DefaultArea(Box box)
-
-
Method Detail
-
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<Area>
- Overrides:
childrenChanged
in classDefaultTreeContentRect<Area>
-
setName
public void setName(String name)
Sets the name of the area. The name is used when the area information is displayed usingtoString()
-
getName
public String getName()
Description copied from interface:Area
Obtains the area name.- Specified by:
getName
in interfaceArea
- Returns:
- the area name set previously using
Area.setName(String)
or a default name when nothing has been previously set.
-
getAreaTree
public AreaTree getAreaTree()
Description copied from interface:Area
Obtains the tree the node belongs to.- Specified by:
getAreaTree
in interfaceArea
- Returns:
- the tree or
null
when the node does not form part of any tree.
-
setAreaTree
public void setAreaTree(AreaTree areaTree)
- Specified by:
setAreaTree
in interfaceArea
-
getContentBounds
public Rectangular getContentBounds()
-
move
public void move(int xofs, int yofs)
- Specified by:
move
in interfaceRect
- Overrides:
move
in classDefaultTreeContentRect<Area>
-
getLevel
public int getLevel()
Description copied from interface:Area
Area grouping level. Area level 0 corresponds to the areas formed by boxes, greater numbers represent greater level of grouping (artificial areas).
-
setLevel
public void setLevel(int level)
Description copied from interface:Area
Sets the area level. Area level 0 corresponds to the areas formed by boxes, greater numbers represent greater level of grouping (artificial areas).
-
getTopology
public AreaTopology getTopology()
Description copied from interface:Area
Returns the topology of this area.- Specified by:
getTopology
in interfaceArea
- Returns:
- The area topology.
-
updateTopologies
public void updateTopologies()
Description copied from interface:Area
Updates the topologies of the child areas. This should be called when some nodes have been inserted, removed or changed in this area.- Specified by:
updateTopologies
in interfaceArea
-
createTopology
protected AreaTopology createTopology()
Creates a topology for this area. This method should be overriden when another topology implementation is used. By default, it returns the default grid-based topology. When another topology is used, theinvalidateTopology()
function should be overriden as well.- Returns:
- The created topology for this area
-
invalidateTopology
protected void invalidateTopology()
Marks the topology as dirty when the list of areas has been altered.
-
getEffectiveBackgroundColor
public Color getEffectiveBackgroundColor()
Description copied from interface:Area
Obtains the effective background color visible under the area.- Specified by:
getEffectiveBackgroundColor
in interfaceArea
- Returns:
- The background color.
-
appendChild
public void appendChild(Area child)
- Specified by:
appendChild
in interfaceGenericTreeNode<Area>
- Overrides:
appendChild
in classDefaultTreeNode<Area>
-
insertChild
public void insertChild(Area child, int index) throws IndexOutOfBoundsException
- Specified by:
insertChild
in interfaceGenericTreeNode<Area>
- Overrides:
insertChild
in classDefaultTreeNode<Area>
- Throws:
IndexOutOfBoundsException
-
getText
public String getText()
Description copied from interface:Area
Returns the complete text contained in this area and its sub areas concatenated using the default concatenator defined byConcatenators.getDefaultAreaConcatenator()
.
-
getText
public String getText(String separator)
Description copied from interface:Area
Returns the complete text contained in this area and its sub area. The individual areas are separated by the given string separator.
-
getText
public String getText(AreaConcatenator concatenator)
Description copied from interface:Area
Returns the complete text contained in this area and its sub areas concatenated using the specified concatenator.
-
isReplaced
public boolean isReplaced()
Description copied from interface:Area
Checks whether this area is formed by replaced boxes.- Specified by:
isReplaced
in interfaceArea
- Returns:
true
if the area contains replaced boxes only
-
addBox
public void addBox(Box box)
Description copied from interface:Area
Adds a new box to the area.
-
getAllBoxes
public List<Box> getAllBoxes()
Obtains all the boxes from this area and all the child areas.- Specified by:
getAllBoxes
in interfaceArea
- Returns:
- The list of boxes
-
getBoxText
public String getBoxText()
Deprecated.Depracated in favor ofgetBoxText(BoxConcatenator)
.Returns the text string represented by a concatenation of all the boxes contained directly in this area (no subareas)
-
getBoxText
public String getBoxText(BoxConcatenator concat)
Returns the text string represented by a concatenation of all the boxes contained directly in this area (no subareas)
-
removeBox
public void removeBox(Box box)
Removes the given box from the given area. This does not change the size of the area.- Parameters:
box
- the box to be removed
-
removeBoxes
public void removeBoxes(Collection<Box> box)
Removes the given boxes from the given area. This does not change the size of the area.- Parameters:
box
- the collection of boxes to be removed
-
addTag
public void addTag(Tag tag, float support)
Description copied from interface:Taggable
Adds a tag to this area. If the tag is already assigned to the area, the greater of the original and new support will be used.
-
hasTag
public boolean hasTag(Tag tag)
Description copied from interface:Taggable
Tests whether the area has this tag.
-
hasTag
public boolean hasTag(Tag tag, float minSupport)
Description copied from interface:Taggable
Tests whether the area has this tag with a support greater or equal to the specified value.
-
getSupportedTags
public Set<Tag> getSupportedTags(float minSupport)
Description copied from interface:Taggable
Obtains all the tags with the support greater or equal to the specified value.- Specified by:
getSupportedTags
in interfaceTaggable
- Parameters:
minSupport
- minimal required support- Returns:
- a set of tags with at least the minimal support (possibly empty)
-
getTagSupport
public float getTagSupport(Tag tag)
Description copied from interface:Taggable
Obtains the support of the given tag assignment- Specified by:
getTagSupport
in interfaceTaggable
- Parameters:
tag
- The tag to be tested- Returns:
- The support of the given tag in the range 0.0 to 1.0. Returns 0.0 when the tag is not assigned to this area.
-
getMostSupportedTag
public Tag getMostSupportedTag()
Description copied from interface:Taggable
Obtains the tag with the greatest support that is assigned to this area.- Specified by:
getMostSupportedTag
in interfaceTaggable
- Returns:
- The tag with the greatest support or
null
if there are no tags assigned to this area
-
removeAllTags
public void removeAllTags(Collection<Tag> c)
Removes all tags that belong to the given collection.- Parameters:
c
- A collection of tags to be removed.
-
removeTag
public void removeTag(Tag tag)
Removes the specific tag
-
containsTag
public boolean containsTag(Tag tag)
Tests whether the area or any of its direct child areas have the given tag.- Parameters:
tag
- the tag to be tested.- Returns:
true
if the area or its direct child areas have the given tag
-
setHorizontalSeparator
public void setHorizontalSeparator(boolean hsep)
-
isHorizontalSeparator
public boolean isHorizontalSeparator()
Description copied from interface:Area
Checks whether the area can be interpreted as a horizontal separator.- Specified by:
isHorizontalSeparator
in interfaceArea
- Returns:
true
when this area is a horizontal separator
-
setVerticalSeparator
public void setVerticalSeparator(boolean vsep)
-
isVerticalSeparator
public boolean isVerticalSeparator()
Description copied from interface:Area
Checks whether the area can be interpreted as a vertical separator.- Specified by:
isVerticalSeparator
in interfaceArea
- Returns:
true
when this area is a vertical separator
-
isSeparator
public boolean isSeparator()
Description copied from interface:Area
Checks whether the area can be interpreted as any kind of separator.- Specified by:
isSeparator
in interfaceArea
- Returns:
true
when this area is a separator
-
isExplicitlySeparated
public boolean isExplicitlySeparated()
Description copied from interface:Area
When set to true, the area is considered to be separated from other areas explicitly, i.e. independently on its real borders or background. This is usually used for some new superareas.- Specified by:
isExplicitlySeparated
in interfaceArea
- Returns:
true
, if the area is explicitly separated
-
setExplicitlySeparated
public void setExplicitlySeparated(boolean explicitlySeparated)
Description copied from interface:Area
When set to true, the area is considered to be separated from other areas explicitly, i.e. independently on its real borders or background. This is usually used for some new superareas.- Specified by:
setExplicitlySeparated
in interfaceArea
- Parameters:
explicitlySeparated
-true
, if the area should be explicitly separated
-
createSuperArea
public Area createSuperArea(Rectangular gp, List<Area> selected, String name)
Description copied from interface:Area
Creates a new subarea from a specified region of the area and moves the selected child nodes to the new area.- Specified by:
createSuperArea
in interfaceArea
- Parameters:
gp
- the subarea boundsselected
- nodes to be moved to the new areaname
- the name (identification) of the new area- Returns:
- the new AreaNode created in the tree or null, if nothing was created
-
insertParent
public void insertParent(Area newParent, Area child)
Description copied from interface:Area
Inserts a new area as a new parent of the given child area. The given area is replaced by the new parent and it becomes a child area of the parent.- Specified by:
insertParent
in interfaceArea
- Parameters:
newParent
- the new parent area (replacement)child
- the child area that should be replaced
-
copy
public Area copy()
Description copied from interface:Area
Creates a copy of the area and makes it a next sibling of the source area.
-
setGridPosition
public void setGridPosition(Rectangular gp)
Sets the grid position of this area within the parent topology.- Specified by:
setGridPosition
in interfaceArea
- Parameters:
gp
- the new grid position
-
getGridPosition
public Rectangular getGridPosition()
Gets the grid position of this area within the parent topology.- Specified by:
getGridPosition
in interfaceArea
- Returns:
- the grid position or a unit rectangle when there is no parent
-
getBoxDescription
protected String getBoxDescription(Box box)
Obtains a box description used as the default area name when the area is created from a box.- Parameters:
box
-- Returns:
-
recomputeTextStyle
protected void recomputeTextStyle()
Recomputes the average text style after some boxes or child areas have been added, removed or changed (e.g. added or removed boxes).- Overrides:
recomputeTextStyle
in classDefaultTreeContentRect<Area>
-
-