Package com.github.weisj.jsvg.nodes.text
Class TextContainer
- java.lang.Object
-
- com.github.weisj.jsvg.nodes.AbstractSVGNode
-
- com.github.weisj.jsvg.nodes.container.BaseContainerNode<TextSegment>
-
- com.github.weisj.jsvg.nodes.text.TextContainer
-
- All Implemented Interfaces:
Container<TextSegment>
,HasContext
,HasContext.ByDelegate
,HasFillRule
,HasFontContext
,HasFontRenderContext
,HasPaintContext
,HasShape
,HasVectorEffects
,Renderable
,SVGNode
,TextSegment
,TextSegment.RenderableSegment
- Direct Known Subclasses:
LinearTextContainer
,TextPath
abstract class TextContainer extends BaseContainerNode<TextSegment> implements TextSegment.RenderableSegment, HasShape, HasContext.ByDelegate, HasVectorEffects, Renderable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TextContainer.IntermediateTextMetrics
-
Nested classes/interfaces inherited from interface com.github.weisj.jsvg.nodes.prototype.HasContext
HasContext.ByDelegate
-
Nested classes/interfaces inherited from interface com.github.weisj.jsvg.nodes.prototype.HasShape
HasShape.Box
-
Nested classes/interfaces inherited from interface com.github.weisj.jsvg.nodes.text.TextSegment
TextSegment.RenderableSegment
-
Nested classes/interfaces inherited from interface com.github.weisj.jsvg.nodes.text.TextSegment.RenderableSegment
TextSegment.RenderableSegment.UseTextLengthForCalculation
-
-
Field Summary
Fields Modifier and Type Field Description private HasContext
context
protected AttributeFontSpec
fontSpec
private boolean
isVisible
protected LengthAdjust
lengthAdjust
private java.util.List<@NotNull TextSegment>
segments
protected Length
textLength
private java.util.Set<VectorEffect>
vectorEffects
-
Constructor Summary
Constructors Constructor Description TextContainer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptChild(@Nullable java.lang.String id, @NotNull SVGNode node)
Determine whether the container accepts thisSVGNode
as a child.private void
accumulateRenderableSegmentMetrics(@NotNull TextSegment.RenderableSegment segment, @NotNull TextContainer.IntermediateTextMetrics metrics, @NotNull RenderContext currentContext)
private void
accumulateSegmentMetrics(@NotNull TextContainer.IntermediateTextMetrics metrics, @NotNull StringTextSegment segment, @NotNull SVGFont font, float letterSpacing, int index)
void
addContent(char[] content)
void
appendTextShape(@NotNull GlyphCursor cursor, @NotNull java.awt.geom.Path2D textShape, @NotNull RenderContext context)
void
build(@NotNull AttributeNode attributeNode)
java.util.List<? extends @NotNull TextSegment>
children()
Return all children of this container.protected abstract void
cleanUpLocalCursor(@NotNull GlyphCursor current, @NotNull GlyphCursor local)
@NotNull TextMetrics
computeTextMetrics(@NotNull RenderContext context, @NotNull TextSegment.RenderableSegment.UseTextLengthForCalculation flag)
@NotNull HasContext
contextDelegate()
protected abstract GlyphCursor
createLocalCursor(@NotNull RenderContext context, @NotNull GlyphCursor current)
protected void
doAdd(@NotNull SVGNode node)
private void
forEachSegment(@NotNull RenderContext context, @NotNull java.util.function.BiConsumer<StringTextSegment,RenderContext> onStringTextSegment, @NotNull java.util.function.BiConsumer<TextSegment.RenderableSegment,RenderContext> onRenderableSegment)
boolean
hasFixedLength()
boolean
isVisible(@NotNull RenderContext context)
private @NotNull GlyphAdvancement
localGlyphAdvancement(@NotNull RenderContext context, @NotNull GlyphCursor cursor)
void
prepareSegmentForRendering(@NotNull GlyphCursor cursor, @NotNull RenderContext context)
protected void
renderSegment(@NotNull GlyphCursor cursor, @NotNull RenderContext context, @NotNull Output output)
void
renderSegmentWithoutLayout(@NotNull GlyphCursor cursor, @NotNull RenderContext context, @NotNull Output output)
private double
textAnchorOffset(@NotNull TextAnchor textAnchor, @NotNull GlyphCursor glyphCursor)
@NotNull java.awt.geom.Rectangle2D
untransformedElementBounds(@NotNull RenderContext context, HasShape.Box box)
@NotNull java.util.Set<VectorEffect>
vectorEffects()
-
Methods inherited from class com.github.weisj.jsvg.nodes.container.BaseContainerNode
addChild, isAcceptableType
-
Methods inherited from class com.github.weisj.jsvg.nodes.AbstractSVGNode
id, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.weisj.jsvg.nodes.prototype.Container
childrenOfType
-
Methods inherited from interface com.github.weisj.jsvg.nodes.prototype.HasContext.ByDelegate
fillRule, fontRenderContext, fontSpec, paintContext
-
Methods inherited from interface com.github.weisj.jsvg.nodes.prototype.HasShape
elementBounds, elementShape, untransformedElementShape
-
Methods inherited from interface com.github.weisj.jsvg.nodes.prototype.Renderable
parseIsVisible, render, requiresInstantiation, shouldEstablishChildContext
-
-
-
-
Field Detail
-
segments
private final java.util.List<@NotNull TextSegment> segments
-
fontSpec
protected AttributeFontSpec fontSpec
-
lengthAdjust
protected LengthAdjust lengthAdjust
-
textLength
protected Length textLength
-
isVisible
private boolean isVisible
-
context
private HasContext context
-
vectorEffects
private java.util.Set<VectorEffect> vectorEffects
-
-
Method Detail
-
build
@MustBeInvokedByOverriders public void build(@NotNull @NotNull AttributeNode attributeNode)
- Specified by:
build
in interfaceSVGNode
- Overrides:
build
in classAbstractSVGNode
-
vectorEffects
@NotNull public @NotNull java.util.Set<VectorEffect> vectorEffects()
- Specified by:
vectorEffects
in interfaceHasVectorEffects
-
contextDelegate
@NotNull public @NotNull HasContext contextDelegate()
- Specified by:
contextDelegate
in interfaceHasContext.ByDelegate
-
acceptChild
protected boolean acceptChild(@Nullable @Nullable java.lang.String id, @NotNull @NotNull SVGNode node)
Description copied from class:BaseContainerNode
Determine whether the container accepts thisSVGNode
as a child. By default, this will always report true but subclasses may choose to reject certain types of nodes.- Overrides:
acceptChild
in classBaseContainerNode<TextSegment>
- Parameters:
id
- the id of the nodenode
- the node itself- Returns:
- whether the node can be inserted as a child.
-
doAdd
protected void doAdd(@NotNull @NotNull SVGNode node)
- Specified by:
doAdd
in classBaseContainerNode<TextSegment>
-
addContent
public final void addContent(char[] content)
- Specified by:
addContent
in interfaceSVGNode
- Overrides:
addContent
in classAbstractSVGNode
-
children
public java.util.List<? extends @NotNull TextSegment> children()
Description copied from interface:Container
Return all children of this container. Note that the return type of this function internationally contains a wild card to make it a compilation error trying to modify it.- Specified by:
children
in interfaceContainer<TextSegment>
- Returns:
- the list of children.
-
createLocalCursor
protected abstract GlyphCursor createLocalCursor(@NotNull @NotNull RenderContext context, @NotNull @NotNull GlyphCursor current)
-
cleanUpLocalCursor
protected abstract void cleanUpLocalCursor(@NotNull @NotNull GlyphCursor current, @NotNull @NotNull GlyphCursor local)
-
renderSegment
protected final void renderSegment(@NotNull @NotNull GlyphCursor cursor, @NotNull @NotNull RenderContext context, @NotNull @NotNull Output output)
-
textAnchorOffset
private double textAnchorOffset(@NotNull @NotNull TextAnchor textAnchor, @NotNull @NotNull GlyphCursor glyphCursor)
-
forEachSegment
private void forEachSegment(@NotNull @NotNull RenderContext context, @NotNull @NotNull java.util.function.BiConsumer<StringTextSegment,RenderContext> onStringTextSegment, @NotNull @NotNull java.util.function.BiConsumer<TextSegment.RenderableSegment,RenderContext> onRenderableSegment)
-
computeTextMetrics
@NotNull public @NotNull TextMetrics computeTextMetrics(@NotNull @NotNull RenderContext context, @NotNull @NotNull TextSegment.RenderableSegment.UseTextLengthForCalculation flag)
- Specified by:
computeTextMetrics
in interfaceTextSegment.RenderableSegment
-
accumulateRenderableSegmentMetrics
private void accumulateRenderableSegmentMetrics(@NotNull @NotNull TextSegment.RenderableSegment segment, @NotNull @NotNull TextContainer.IntermediateTextMetrics metrics, @NotNull @NotNull RenderContext currentContext)
-
accumulateSegmentMetrics
private void accumulateSegmentMetrics(@NotNull @NotNull TextContainer.IntermediateTextMetrics metrics, @NotNull @NotNull StringTextSegment segment, @NotNull @NotNull SVGFont font, float letterSpacing, int index)
-
hasFixedLength
public boolean hasFixedLength()
- Specified by:
hasFixedLength
in interfaceTextSegment.RenderableSegment
-
renderSegmentWithoutLayout
public void renderSegmentWithoutLayout(@NotNull @NotNull GlyphCursor cursor, @NotNull @NotNull RenderContext context, @NotNull @NotNull Output output)
- Specified by:
renderSegmentWithoutLayout
in interfaceTextSegment.RenderableSegment
-
prepareSegmentForRendering
public void prepareSegmentForRendering(@NotNull @NotNull GlyphCursor cursor, @NotNull @NotNull RenderContext context)
- Specified by:
prepareSegmentForRendering
in interfaceTextSegment.RenderableSegment
-
appendTextShape
public void appendTextShape(@NotNull @NotNull GlyphCursor cursor, @NotNull @NotNull java.awt.geom.Path2D textShape, @NotNull @NotNull RenderContext context)
- Specified by:
appendTextShape
in interfaceTextSegment.RenderableSegment
-
localGlyphAdvancement
@NotNull private @NotNull GlyphAdvancement localGlyphAdvancement(@NotNull @NotNull RenderContext context, @NotNull @NotNull GlyphCursor cursor)
-
untransformedElementBounds
@NotNull public @NotNull java.awt.geom.Rectangle2D untransformedElementBounds(@NotNull @NotNull RenderContext context, HasShape.Box box)
- Specified by:
untransformedElementBounds
in interfaceHasShape
-
isVisible
public boolean isVisible(@NotNull @NotNull RenderContext context)
- Specified by:
isVisible
in interfaceRenderable
-
-