Package cz.vutbr.fit.layout.impl
Class DefaultTextChunk
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultContentRect
-
- cz.vutbr.fit.layout.impl.DefaultTextChunk
-
- All Implemented Interfaces:
ContentRect
,Rect
,Taggable
,TextChunk
- Direct Known Subclasses:
RDFTextChunk
public class DefaultTextChunk extends DefaultContentRect implements TextChunk
A default text chunk implementation.- Author:
- burgetr
-
-
Field Summary
-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Constructor Summary
Constructors Constructor Description DefaultTextChunk()
DefaultTextChunk(Rectangular r, Area sourceArea, Box sourceBox)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTag(Tag tag, float support)
Adds a tag to this area.protected void
copyStyle(Area src)
Color
getColor()
Gets the text color of the chunk.Color
getEffectiveBackgroundColor()
Gets the efficient background color of the chunk.String
getFontFamily()
Gets the font family of the chunk.ChunkSet
getChunkSet()
Gets the chunk set the chunk belongs to.Tag
getMostSupportedTag()
Obtains the tag with the greatest support that is assigned to this area.String
getName()
Gets a readable name of the chunk for listing purposes.Area
getSourceArea()
Gets the source area the chunk was extracted from.Box
getSourceBox()
Gets the source box the chunk was extracted from.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()
Gets the complete text of the chunk.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
removeAllTags(Collection<Tag> c)
Removes all tags that belong to the given collection.void
removeTag(Tag tag)
Removes the specific tagvoid
setColor(Color color)
void
setEffectiveBackgroundColor(Color effectiveBackgroundColor)
void
setFontFamily(String fontFamily)
void
setChunkSet(ChunkSet chunkSet)
void
setName(String name)
Sets a readable name of the chunk for listing purposes.void
setSourceArea(Area sourceArea)
void
setSourceBox(Box sourceBox)
void
setText(String text)
String
toString()
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultContentRect
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, move, recomputeTextStyle, setBackgroundColor, setBackgroundImagePng, setBackgroundSeparated, setBorderStyle, setBounds, setId, setLine, setPageIri, setTextStyle
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Constructor Detail
-
DefaultTextChunk
public DefaultTextChunk()
-
DefaultTextChunk
public DefaultTextChunk(Rectangular r, Area sourceArea, Box sourceBox)
-
-
Method Detail
-
getChunkSet
public ChunkSet getChunkSet()
Description copied from interface:TextChunk
Gets the chunk set the chunk belongs to.- Specified by:
getChunkSet
in interfaceTextChunk
- Returns:
- the chunk set or
null
when the chunk does not belong to any set.
-
setChunkSet
public void setChunkSet(ChunkSet chunkSet)
-
setText
public void setText(String text)
-
getText
public String getText()
Description copied from interface:TextChunk
Gets the complete text of the chunk.
-
getName
public String getName()
Description copied from interface:TextChunk
Gets a readable name of the chunk for listing purposes.
-
setName
public void setName(String name)
Description copied from interface:TextChunk
Sets a readable name of the chunk for listing purposes.
-
getSourceArea
public Area getSourceArea()
Description copied from interface:TextChunk
Gets the source area the chunk was extracted from.- Specified by:
getSourceArea
in interfaceTextChunk
- Returns:
- the source area
-
setSourceArea
public void setSourceArea(Area sourceArea)
-
getSourceBox
public Box getSourceBox()
Description copied from interface:TextChunk
Gets the source box the chunk was extracted from.- Specified by:
getSourceBox
in interfaceTextChunk
- Returns:
- the source box
-
setSourceBox
public void setSourceBox(Box sourceBox)
-
getFontFamily
public String getFontFamily()
Description copied from interface:TextChunk
Gets the font family of the chunk.- Specified by:
getFontFamily
in interfaceTextChunk
- Returns:
- the font family name
-
setFontFamily
public void setFontFamily(String fontFamily)
-
getColor
public Color getColor()
Description copied from interface:TextChunk
Gets the text color of the chunk.
-
setColor
public void setColor(Color color)
-
getEffectiveBackgroundColor
public Color getEffectiveBackgroundColor()
Description copied from interface:TextChunk
Gets the efficient background color of the chunk.- Specified by:
getEffectiveBackgroundColor
in interfaceTextChunk
- Returns:
- the background color or
nul
when transparent.
-
setEffectiveBackgroundColor
public void setEffectiveBackgroundColor(Color effectiveBackgroundColor)
-
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
-
copyStyle
protected void copyStyle(Area src)
-
-