1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-03 09:00:48 +00:00

Move UmlDiagram.animation to parent class (TitledDiagram).

This commit is contained in:
matthew16550 2021-03-10 05:41:49 +11:00
parent 568c2e3106
commit 4b4562ec35
3 changed files with 21 additions and 21 deletions

View File

@ -37,6 +37,8 @@ package net.sourceforge.plantuml;
import java.io.IOException;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.anim.AnimationDecoder;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -48,6 +50,8 @@ import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.StyleBuilder;
import javax.script.ScriptException;
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated {
public static final boolean FORCE_SMETANA = false;
@ -63,6 +67,8 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
private final SkinParam skinParam;
private Animation animation;
private final Pragma pragma = new Pragma();
public Pragma getPragma() {
@ -217,4 +223,18 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.same(10);
}
final public void setAnimation(Iterable<CharSequence> animationData) {
try {
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
this.animation = Animation.create(animationDecoder.decode());
} catch (ScriptException e) {
e.printStackTrace();
}
}
final public Animation getAnimation() {
return animation;
}
}

View File

@ -50,10 +50,6 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import javax.script.ScriptException;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.anim.AnimationDecoder;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.Diagram;
@ -96,8 +92,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
private int minwidth = Integer.MAX_VALUE;
private Animation animation;
public UmlDiagram(UmlDiagramType type) {
super(type);
}
@ -132,20 +126,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
throw new IllegalArgumentException();
}
final public void setAnimation(Iterable<CharSequence> animationData) {
try {
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
this.animation = Animation.create(animationDecoder.decode());
} catch (ScriptException e) {
e.printStackTrace();
}
}
final public Animation getAnimation() {
return animation;
}
public final boolean isHideUnlinkedData() {
return hideUnlinkedData;
}

View File

@ -129,7 +129,7 @@ public class ImageParameter {
this.fileFormatOption = fileFormatOption;
this.colorMapper = skinParam.getColorMapper();
this.useHandwritten = skinParam.handwritten();
this.animation = diagram instanceof UmlDiagram ? ((UmlDiagram) diagram).getAnimation() : null; // TODO move animation to TitledDiagram ?
this.animation = diagram.getAnimation();
this.dpiFactor = dpiFactor;
this.metadata = metadata;
this.warningOrError = warningOrError;