| •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.*; |
| 25 |
|
| 26 |
import org.jetbrains.annotations.NotNull; |
| 27 |
|
| 28 |
import com.github.weisj.jsvg.attributes.FillRule; |
| 29 |
import com.github.weisj.jsvg.geometry.AWTSVGShape; |
| 30 |
import com.github.weisj.jsvg.geometry.SVGShape; |
| 31 |
import com.github.weisj.jsvg.nodes.prototype.spec.Category; |
| 32 |
import com.github.weisj.jsvg.nodes.prototype.spec.ElementCategories; |
| 33 |
import com.github.weisj.jsvg.nodes.prototype.spec.PermittedContent; |
| 34 |
import com.github.weisj.jsvg.parser.impl.AttributeNode; |
| 35 |
import com.github.weisj.jsvg.util.PathUtil; |
| 36 |
|
| 37 |
@ElementCategories({Category.Graphic, Category.Shape}) |
| 38 |
@PermittedContent(categories = {Category.Animation, Category.Descriptive}) |
| 39 |
public final class Path extends ShapeNode { |
| 40 |
public static final String TAG = "path"; |
| 41 |
|
| 42 |
@Override |
| 43 |
public @NotNull String tagName() { |
| 44 |
return TAG; |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
protected @NotNull SVGShape buildShape(@NotNull AttributeNode attributeNode) { |
| 49 |
String pathValue = attributeNode.getValue("d"); |
| 50 |
if (pathValue == null) return new AWTSVGShape<>(new Rectangle()); |
| 51 |
return PathUtil.parseFromPathData(pathValue, FillRule.Nonzero); |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
protected boolean shouldPaintStartEndMarkersInMiddle() { |
| 56 |
return false; |
| 57 |
} |
| 58 |
} |