| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.github.weisj.jsvg.nodes; |
| 23 |
|
| 24 |
import java.awt.geom.Point2D; |
| 25 |
|
| 26 |
import org.jetbrains.annotations.NotNull; |
| 27 |
|
| 28 |
import com.github.weisj.jsvg.attributes.Overflow; |
| 29 |
import com.github.weisj.jsvg.geometry.size.Length; |
| 30 |
import com.github.weisj.jsvg.nodes.container.CommonInnerViewContainer; |
| 31 |
import com.github.weisj.jsvg.nodes.filter.Filter; |
| 32 |
import com.github.weisj.jsvg.nodes.prototype.spec.Category; |
| 33 |
import com.github.weisj.jsvg.nodes.prototype.spec.ElementCategories; |
| 34 |
import com.github.weisj.jsvg.nodes.prototype.spec.PermittedContent; |
| 35 |
import com.github.weisj.jsvg.nodes.text.Text; |
| 36 |
import com.github.weisj.jsvg.parser.impl.AttributeNode; |
| 37 |
import com.github.weisj.jsvg.renderer.MeasureContext; |
| 38 |
|
| 39 |
@ElementCategories({Category.Container, Category.Structural}) |
| 40 |
@PermittedContent( |
| 41 |
categories = {Category.Animation, Category.Descriptive, Category.Shape, Category.Structural, Category.Gradient}, |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
anyOf = {Anchor.class, ClipPath.class, Filter.class, Image.class, Mask.class, Marker.class, Pattern.class, |
| 47 |
Style.class, Text.class, View.class} |
| 48 |
) |
| 49 |
public final class Symbol extends CommonInnerViewContainer { |
| 50 |
public static final String TAG = "symbol"; |
| 51 |
|
| 52 |
private Length refX; |
| 53 |
private Length refY; |
| 54 |
|
| 55 |
@Override |
| 56 |
public @NotNull String tagName() { |
| 57 |
return TAG; |
| 58 |
} |
| 59 |
|
| 60 |
@Override |
| 61 |
protected @NotNull Point2D anchorLocation(@NotNull MeasureContext context) { |
| 62 |
return new Point2D.Float(-refX.resolve(context), -refY.resolve(context)); |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
protected @NotNull Overflow defaultOverflow() { |
| 67 |
return Overflow.Hidden; |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public void build(@NotNull AttributeNode attributeNode) { |
| 72 |
super.build(attributeNode); |
| 73 |
refX = attributeNode.getHorizontalReferenceLengthFromKey("refX"); |
| 74 |
refY = attributeNode.getVerticalReferenceLengthFromKey("refY"); |
| 75 |
} |
| 76 |
|
| 77 |
@Override |
| 78 |
public boolean requiresInstantiation() { |
| 79 |
return true; |
| 80 |
} |
| 81 |
} |