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 ClassesModifier and TypeClassDescriptionprivate static final class
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
FieldsModifier and TypeFieldDescriptionprivate HasContext
protected AttributeFontSpec
private boolean
protected LengthAdjust
private final List
<@NotNull TextSegment> protected Length
private Set
<VectorEffect> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptChild
(@Nullable 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) final void
addContent
(char[] content) void
appendTextShape
(@NotNull GlyphCursor cursor, @NotNull Path2D textShape, @NotNull RenderContext context) void
build
(@NotNull AttributeNode attributeNode) 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
protected abstract GlyphCursor
createLocalCursor
(@NotNull RenderContext context, @NotNull GlyphCursor current) protected void
private void
forEachSegment
(@NotNull RenderContext context, @NotNull BiConsumer<StringTextSegment, RenderContext> onStringTextSegment, @NotNull BiConsumer<TextSegment.RenderableSegment, RenderContext> onRenderableSegment) boolean
boolean
isVisible
(@NotNull RenderContext context) private @NotNull GlyphAdvancement
localGlyphAdvancement
(@NotNull RenderContext context, @NotNull GlyphCursor cursor) void
prepareSegmentForRendering
(@NotNull GlyphCursor cursor, @NotNull RenderContext context) protected final 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 Rectangle2D
untransformedElementBounds
(@NotNull RenderContext context, HasShape.Box box) @NotNull Set
<VectorEffect> 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 Details
-
segments
-
fontSpec
-
lengthAdjust
-
textLength
-
isVisible
private boolean isVisible -
context
-
vectorEffects
-
-
Constructor Details
-
TextContainer
TextContainer()
-
-
Method Details
-
build
- Specified by:
build
in interfaceSVGNode
- Overrides:
build
in classAbstractSVGNode
-
vectorEffects
- Specified by:
vectorEffects
in interfaceHasVectorEffects
-
contextDelegate
- Specified by:
contextDelegate
in interfaceHasContext.ByDelegate
-
acceptChild
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
- Specified by:
doAdd
in classBaseContainerNode<TextSegment>
-
addContent
public final void addContent(char[] content) - Specified by:
addContent
in interfaceSVGNode
- Overrides:
addContent
in classAbstractSVGNode
-
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 BiConsumer<StringTextSegment, RenderContext> onStringTextSegment, @NotNull @NotNull 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 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 Rectangle2D untransformedElementBounds(@NotNull @NotNull RenderContext context, HasShape.Box box) - Specified by:
untransformedElementBounds
in interfaceHasShape
-
isVisible
- Specified by:
isVisible
in interfaceRenderable
-