| •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.animation.value.AnimatedFloatList; |
| 29 |
import com.github.weisj.jsvg.animation.value.AnimatedPath; |
| 30 |
import com.github.weisj.jsvg.attributes.Animatable; |
| 31 |
import com.github.weisj.jsvg.attributes.Inherited; |
| 32 |
import com.github.weisj.jsvg.attributes.value.ConstantFloatList; |
| 33 |
import com.github.weisj.jsvg.attributes.value.ConstantValue; |
| 34 |
import com.github.weisj.jsvg.attributes.value.FloatListValue; |
| 35 |
import com.github.weisj.jsvg.geometry.*; |
| 36 |
import com.github.weisj.jsvg.parser.impl.AttributeNode; |
| 37 |
import com.github.weisj.jsvg.util.PathUtil; |
| 38 |
|
| 39 |
public abstract class AbstractPolyShape extends ShapeNode { |
| 40 |
|
| 41 |
@Override |
| 42 |
protected final @NotNull SVGShape buildShape(@NotNull AttributeNode attributeNode) { |
| 43 |
FloatListValue points = attributeNode.getFloatList("points", Inherited.NO, Animatable.YES); |
| 44 |
if (points instanceof AnimatedFloatList) { |
| 45 |
return new FillRuleAwareAWTSVGShape(new AnimatedPath((AnimatedFloatList) points, doClose())); |
| 46 |
} |
| 47 |
|
| 48 |
float[] pointsArray = ((ConstantFloatList) points).value(); |
| 49 |
if (pointsArray.length > 0) { |
| 50 |
return new FillRuleAwareAWTSVGShape( |
| 51 |
new ConstantValue<>(PathUtil.setPolyLine(null, pointsArray, doClose()))); |
| 52 |
} else { |
| 53 |
return new AWTSVGShape<>(new Rectangle()); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
protected abstract boolean doClose(); |
| 58 |
} |