mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
wip
This commit is contained in:
parent
8b03ff71b9
commit
fae0dfdf02
@ -173,8 +173,10 @@ public class SvgNanoParser implements Sprite {
|
||||
final HColor stroke = getTrueColor(strokeString, colorForMonochrome);
|
||||
ugs = ugs.apply(stroke);
|
||||
final String strokeWidth = extractData("stroke-width", s);
|
||||
if (strokeWidth != null)
|
||||
ugs = ugs.apply(new UStroke(Double.parseDouble(strokeWidth)));
|
||||
if (strokeWidth != null) {
|
||||
final double scale = ugs.getScale();
|
||||
ugs = ugs.apply(new UStroke(scale * Double.parseDouble(strokeWidth)));
|
||||
}
|
||||
|
||||
} else {
|
||||
final HColor fill = getTrueColor(fillString, colorForMonochrome);
|
||||
@ -234,6 +236,7 @@ public class SvgNanoParser implements Sprite {
|
||||
}
|
||||
|
||||
private void drawEllipse(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {
|
||||
final boolean debug = false;
|
||||
ugs = applyFill(ugs, s, colorForMonochrome);
|
||||
ugs = applyTransform(ugs, s);
|
||||
|
||||
@ -244,22 +247,31 @@ public class SvgNanoParser implements Sprite {
|
||||
|
||||
UPath path = new UPath();
|
||||
path.moveTo(0, ry);
|
||||
// path.lineTo(rx, 0);
|
||||
path.arcTo(rx, ry, 0, 0, 1, rx, 0);
|
||||
|
||||
// path.lineTo(2 * rx, ry);
|
||||
path.arcTo(rx, ry, 0, 0, 1, 2 * rx, ry);
|
||||
if (debug)
|
||||
path.lineTo(rx, 0);
|
||||
else
|
||||
path.arcTo(rx, ry, 0, 0, 1, rx, 0);
|
||||
|
||||
// path.lineTo(rx, 2 * ry);
|
||||
path.arcTo(rx, ry, 0, 0, 1, rx, 2 * ry);
|
||||
if (debug)
|
||||
path.lineTo(2 * rx, ry);
|
||||
else
|
||||
path.arcTo(rx, ry, 0, 0, 1, 2 * rx, ry);
|
||||
|
||||
// path.lineTo(0, ry);
|
||||
path.arcTo(rx, ry, 0, 0, 1, 0, ry);
|
||||
if (debug)
|
||||
path.lineTo(rx, 2 * ry);
|
||||
else
|
||||
path.arcTo(rx, ry, 0, 0, 1, rx, 2 * ry);
|
||||
|
||||
if (debug)
|
||||
path.lineTo(0, ry);
|
||||
else
|
||||
path.arcTo(rx, ry, 0, 0, 1, 0, ry);
|
||||
|
||||
path.closePath();
|
||||
|
||||
path = path.translate(cx - rx, cy - ry);
|
||||
path = path.affine(ugs.getAffineTransform(), ugs.getAngle());
|
||||
path = path.affine(ugs.getAffineTransform(), ugs.getAngle(), ugs.getScale());
|
||||
|
||||
ugs.draw(path);
|
||||
|
||||
|
@ -46,15 +46,17 @@ public class UGraphicWithScale {
|
||||
final private UGraphic ug;
|
||||
final private AffineTransform at;
|
||||
final private double angle;
|
||||
final private double scale;
|
||||
|
||||
public UGraphicWithScale(UGraphic ug, double scale) {
|
||||
this(ug, AffineTransform.getScaleInstance(scale, scale), 0);
|
||||
this(ug, AffineTransform.getScaleInstance(scale, scale), 0, scale);
|
||||
}
|
||||
|
||||
private UGraphicWithScale(UGraphic ug, AffineTransform at, double angle) {
|
||||
private UGraphicWithScale(UGraphic ug, AffineTransform at, double angle, double scale) {
|
||||
this.ug = ug;
|
||||
this.at = at;
|
||||
this.angle = angle;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public UGraphic getUg() {
|
||||
@ -62,13 +64,15 @@ public class UGraphicWithScale {
|
||||
}
|
||||
|
||||
public UGraphicWithScale apply(UChange change) {
|
||||
return new UGraphicWithScale(ug.apply(change), at, angle);
|
||||
return new UGraphicWithScale(ug.apply(change), at, angle, scale);
|
||||
}
|
||||
|
||||
public UGraphicWithScale applyScale(double changex, double changey) {
|
||||
if (changex != changey)
|
||||
throw new IllegalArgumentException();
|
||||
final AffineTransform copy = new AffineTransform(at);
|
||||
copy.scale(changex, changey);
|
||||
return new UGraphicWithScale(ug, copy, angle);
|
||||
return new UGraphicWithScale(ug, copy, angle, 1 * changex);
|
||||
}
|
||||
|
||||
public void draw(UShape shape) {
|
||||
@ -78,13 +82,13 @@ public class UGraphicWithScale {
|
||||
public UGraphicWithScale applyRotate(double delta_angle, double x, double y) {
|
||||
final AffineTransform copy = new AffineTransform(at);
|
||||
copy.rotate(delta_angle * Math.PI / 180, x, y);
|
||||
return new UGraphicWithScale(ug, copy, this.angle + delta_angle);
|
||||
return new UGraphicWithScale(ug, copy, this.angle + delta_angle, this.scale);
|
||||
}
|
||||
|
||||
public UGraphicWithScale applyTranslate(double x, double y) {
|
||||
final AffineTransform copy = new AffineTransform(at);
|
||||
copy.translate(x, y);
|
||||
return new UGraphicWithScale(ug, copy, angle);
|
||||
return new UGraphicWithScale(ug, copy, angle, this.scale);
|
||||
}
|
||||
|
||||
public AffineTransform getAffineTransform() {
|
||||
@ -94,11 +98,15 @@ public class UGraphicWithScale {
|
||||
public UGraphicWithScale applyMatrix(double v1, double v2, double v3, double v4, double v5, double v6) {
|
||||
final AffineTransform copy = new AffineTransform(at);
|
||||
copy.concatenate(new AffineTransform(new double[] { v1, v2, v3, v4, v5, v6 }));
|
||||
return new UGraphicWithScale(ug, copy, angle);
|
||||
return new UGraphicWithScale(ug, copy, angle, this.scale);
|
||||
}
|
||||
|
||||
public final double getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public double getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.StringLocated;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.baraye.IEntity;
|
||||
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandControl;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
@ -60,10 +61,9 @@ import net.sourceforge.plantuml.graphic.color.ColorType;
|
||||
import net.sourceforge.plantuml.json.Json.DefaultHandler;
|
||||
import net.sourceforge.plantuml.json.JsonParser;
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
|
||||
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
||||
|
||||
public class CommandCreateJson extends CommandMultilines2<AbstractClassOrObjectDiagram> {
|
||||
public class CommandCreateJson extends CommandMultilines2<AbstractEntityDiagram> {
|
||||
|
||||
public CommandCreateJson() {
|
||||
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH);
|
||||
@ -91,7 +91,7 @@ public class CommandCreateJson extends CommandMultilines2<AbstractClassOrObjectD
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeNow(AbstractClassOrObjectDiagram diagram, BlocLines lines)
|
||||
protected CommandExecutionResult executeNow(AbstractEntityDiagram diagram, BlocLines lines)
|
||||
throws NoSuchColorException {
|
||||
lines = lines.trim().removeEmptyLines();
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
|
||||
@ -141,7 +141,7 @@ public class CommandCreateJson extends CommandMultilines2<AbstractClassOrObjectD
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private IEntity executeArg0(AbstractClassOrObjectDiagram diagram, RegexResult line0) throws NoSuchColorException {
|
||||
private IEntity executeArg0(AbstractEntityDiagram diagram, RegexResult line0) throws NoSuchColorException {
|
||||
final String name = line0.get("NAME", 1);
|
||||
final Ident ident = diagram.buildLeafIdent(name);
|
||||
final Code code = diagram.V1972() ? ident : diagram.buildCode(name);
|
||||
|
@ -715,7 +715,7 @@ public class SvgGraphics {
|
||||
ensureVisible(coord[4] + x + 2 * deltaShadow, coord[5] + y + 2 * deltaShadow);
|
||||
} else if (type == USegmentType.SEG_ARCTO) {
|
||||
// A25,25 0,0 5,395,40
|
||||
sb.append("A" + format(coord[0]) + "," + format(coord[1]) + " " + formatBoolean(coord[2]) + " "
|
||||
sb.append("A" + format(coord[0]) + "," + format(coord[1]) + " " + format(coord[2]) + " "
|
||||
+ formatBoolean(coord[3]) + " " + formatBoolean(coord[4]) + " " + format(coord[5] + x) + ","
|
||||
+ format(coord[6] + y) + " ");
|
||||
ensureVisible(coord[5] + coord[0] + x + 2 * deltaShadow, coord[6] + coord[1] + y + 2 * deltaShadow);
|
||||
|
@ -102,10 +102,10 @@ public class UPath extends AbstractShadowable implements Iterable<USegment>, USh
|
||||
return result;
|
||||
}
|
||||
|
||||
public UPath affine(AffineTransform transform, double angle) {
|
||||
public UPath affine(AffineTransform transform, double angle, double scale) {
|
||||
final UPath result = new UPath(comment, codeLine);
|
||||
for (USegment seg : segments)
|
||||
result.addInternal(seg.affine(transform, angle));
|
||||
result.addInternal(seg.affine(transform, angle, scale));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -88,14 +88,16 @@ public class USegment {
|
||||
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
||||
}
|
||||
|
||||
public USegment affine(AffineTransform transform, double angle) {
|
||||
public USegment affine(AffineTransform transform, double angle, double scale) {
|
||||
if (pathType == USegmentType.SEG_ARCTO) {
|
||||
XPoint2D p1 = new XPoint2D(coord[5], coord[6]);
|
||||
|
||||
p1 = p1.transform(transform);
|
||||
return new USegment(
|
||||
new double[] { coord[0], coord[1], coord[2] + angle, coord[3], coord[4], p1.getX(), p1.getY() },
|
||||
pathType);
|
||||
|
||||
final double large_arc_flag = coord[3];
|
||||
final double sweep_flag = coord[4];
|
||||
return new USegment(new double[] { coord[0] * scale, coord[1] * scale, coord[2] + angle, large_arc_flag,
|
||||
sweep_flag, p1.getX(), p1.getY() }, pathType);
|
||||
}
|
||||
|
||||
if (coord.length != 2)
|
||||
|
@ -81,7 +81,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static int beta() {
|
||||
final int beta = 2;
|
||||
final int beta = 3;
|
||||
return beta;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user