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 voidaddBox(Box box)Adds a new box to the area.voidaddTag(Tag tag, float support)Adds a tag to this area.voidappendChild(Area child)booleancontainsTag(Tag tag)Tests whether the area or any of its direct child areas have the given tag.Areacopy()Creates a copy of the area and makes it a next sibling of the source area.AreacreateSuperArea(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 AreaTopologycreateTopology()Creates a topology for this area.List<Box>getAllBoxes()Obtains all the boxes from this area and all the child areas.AreaTreegetAreaTree()Obtains the tree the node belongs to.protected StringgetBoxDescription(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 areaStringgetBoxText()Deprecated.Depracated in favor ofgetBoxText(BoxConcatenator).StringgetBoxText(BoxConcatenator concat)Returns the text string represented by a concatenation of all the boxes contained directly in this area (no subareas)RectangulargetContentBounds()ColorgetEffectiveBackgroundColor()Obtains the effective background color visible under the area.RectangulargetGridPosition()Gets the grid position of this area within the parent topology.intgetLevel()Area grouping level.TaggetMostSupportedTag()Obtains the tag with the greatest support that is assigned to this area.StringgetName()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.floatgetTagSupport(Tag tag)Obtains the support of the given tag assignmentStringgetText()Returns the complete text contained in this area and its sub areas concatenated using the default concatenator defined byConcatenators.getDefaultAreaConcatenator().StringgetText(AreaConcatenator concatenator)Returns the complete text contained in this area and its sub areas concatenated using the specified concatenator.StringgetText(String separator)Returns the complete text contained in this area and its sub area.AreaTopologygetTopology()Returns the topology of this area.booleanhasTag(Tag tag)Tests whether the area has this tag.booleanhasTag(Tag tag, float minSupport)Tests whether the area has this tag with a support greater or equal to the specified value.voidchildrenChanged()This method is called after some child nodes have been added or removed.voidinsertChild(Area child, int index)voidinsertParent(Area newParent, Area child)Inserts a new area as a new parent of the given child area.protected voidinvalidateTopology()Marks the topology as dirty when the list of areas has been altered.booleanisExplicitlySeparated()When set to true, the area is considered to be separated from other areas explicitly, i.e. independently on its real borders or background.booleanisHorizontalSeparator()Checks whether the area can be interpreted as a horizontal separator.booleanisReplaced()Checks whether this area is formed by replaced boxes.booleanisSeparator()Checks whether the area can be interpreted as any kind of separator.booleanisVerticalSeparator()Checks whether the area can be interpreted as a vertical separator.voidmove(int xofs, int yofs)protected voidrecomputeTextStyle()Recomputes the average text style after some boxes or child areas have been added, removed or changed (e.g. added or removed boxes).voidremoveAllTags(Collection<Tag> c)Removes all tags that belong to the given collection.voidremoveBox(Box box)Removes the given box from the given area.voidremoveBoxes(Collection<Box> box)Removes the given boxes from the given area.voidremoveTag(Tag tag)Removes the specific tagvoidsetAreaTree(AreaTree areaTree)voidsetExplicitlySeparated(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.voidsetGridPosition(Rectangular gp)Sets the grid position of this area within the parent topology.voidsetHorizontalSeparator(boolean hsep)voidsetLevel(int level)Sets the area level.voidsetName(String name)Sets the name of the area.voidsetVerticalSeparator(boolean vsep)StringtoString()voidupdateTopologies()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:DefaultTreeNodeThis 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:
childrenChangedin interfaceGenericTreeNode<Area>- Overrides:
childrenChangedin 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:AreaObtains the area name.- Specified by:
getNamein 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:AreaObtains the tree the node belongs to.- Specified by:
getAreaTreein interfaceArea- Returns:
- the tree or
nullwhen the node does not form part of any tree.
-
setAreaTree
public void setAreaTree(AreaTree areaTree)
- Specified by:
setAreaTreein interfaceArea
-
getContentBounds
public Rectangular getContentBounds()
-
move
public void move(int xofs, int yofs)- Specified by:
movein interfaceRect- Overrides:
movein classDefaultTreeContentRect<Area>
-
getLevel
public int getLevel()
Description copied from interface:AreaArea 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:AreaSets 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:AreaReturns the topology of this area.- Specified by:
getTopologyin interfaceArea- Returns:
- The area topology.
-
updateTopologies
public void updateTopologies()
Description copied from interface:AreaUpdates the topologies of the child areas. This should be called when some nodes have been inserted, removed or changed in this area.- Specified by:
updateTopologiesin 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:AreaObtains the effective background color visible under the area.- Specified by:
getEffectiveBackgroundColorin interfaceArea- Returns:
- The background color.
-
appendChild
public void appendChild(Area child)
- Specified by:
appendChildin interfaceGenericTreeNode<Area>- Overrides:
appendChildin classDefaultTreeNode<Area>
-
insertChild
public void insertChild(Area child, int index) throws IndexOutOfBoundsException
- Specified by:
insertChildin interfaceGenericTreeNode<Area>- Overrides:
insertChildin classDefaultTreeNode<Area>- Throws:
IndexOutOfBoundsException
-
getText
public String getText()
Description copied from interface:AreaReturns 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:AreaReturns 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:AreaReturns the complete text contained in this area and its sub areas concatenated using the specified concatenator.
-
isReplaced
public boolean isReplaced()
Description copied from interface:AreaChecks whether this area is formed by replaced boxes.- Specified by:
isReplacedin interfaceArea- Returns:
trueif the area contains replaced boxes only
-
addBox
public void addBox(Box box)
Description copied from interface:AreaAdds 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:
getAllBoxesin 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:TaggableAdds 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:TaggableTests whether the area has this tag.
-
hasTag
public boolean hasTag(Tag tag, float minSupport)
Description copied from interface:TaggableTests 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:TaggableObtains all the tags with the support greater or equal to the specified value.- Specified by:
getSupportedTagsin 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:TaggableObtains the support of the given tag assignment- Specified by:
getTagSupportin 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:TaggableObtains the tag with the greatest support that is assigned to this area.- Specified by:
getMostSupportedTagin interfaceTaggable- Returns:
- The tag with the greatest support or
nullif 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:
trueif 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:AreaChecks whether the area can be interpreted as a horizontal separator.- Specified by:
isHorizontalSeparatorin interfaceArea- Returns:
truewhen this area is a horizontal separator
-
setVerticalSeparator
public void setVerticalSeparator(boolean vsep)
-
isVerticalSeparator
public boolean isVerticalSeparator()
Description copied from interface:AreaChecks whether the area can be interpreted as a vertical separator.- Specified by:
isVerticalSeparatorin interfaceArea- Returns:
truewhen this area is a vertical separator
-
isSeparator
public boolean isSeparator()
Description copied from interface:AreaChecks whether the area can be interpreted as any kind of separator.- Specified by:
isSeparatorin interfaceArea- Returns:
truewhen this area is a separator
-
isExplicitlySeparated
public boolean isExplicitlySeparated()
Description copied from interface:AreaWhen 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:
isExplicitlySeparatedin interfaceArea- Returns:
true, if the area is explicitly separated
-
setExplicitlySeparated
public void setExplicitlySeparated(boolean explicitlySeparated)
Description copied from interface:AreaWhen 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:
setExplicitlySeparatedin 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:AreaCreates a new subarea from a specified region of the area and moves the selected child nodes to the new area.- Specified by:
createSuperAreain 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:AreaInserts 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:
insertParentin interfaceArea- Parameters:
newParent- the new parent area (replacement)child- the child area that should be replaced
-
copy
public Area copy()
Description copied from interface:AreaCreates 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:
setGridPositionin interfaceArea- Parameters:
gp- the new grid position
-
getGridPosition
public Rectangular getGridPosition()
Gets the grid position of this area within the parent topology.- Specified by:
getGridPositionin 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:
recomputeTextStylein classDefaultTreeContentRect<Area>
-
-