mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
wip
This commit is contained in:
parent
03dbd4a848
commit
8b03ff71b9
@ -36,6 +36,7 @@
|
|||||||
package net.sourceforge.plantuml.creole.legacy;
|
package net.sourceforge.plantuml.creole.legacy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -111,7 +112,8 @@ public class StripeCode implements StripeRaw {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Neutron> getNeutrons() {
|
public List<Neutron> getNeutrons() {
|
||||||
throw new UnsupportedOperationException();
|
return Arrays.asList(Neutron.create(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import net.sourceforge.plantuml.ugraphic.UEllipse;
|
|||||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UImageSvg;
|
import net.sourceforge.plantuml.ugraphic.UImageSvg;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UText;
|
import net.sourceforge.plantuml.ugraphic.UText;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
@ -233,23 +234,35 @@ public class SvgNanoParser implements Sprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawEllipse(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {
|
private void drawEllipse(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {
|
||||||
|
|
||||||
ugs = applyFill(ugs, s, colorForMonochrome);
|
ugs = applyFill(ugs, s, colorForMonochrome);
|
||||||
ugs = applyTransform(ugs, s);
|
ugs = applyTransform(ugs, s);
|
||||||
|
|
||||||
final double scalex = ugs.getAffineTransform().getScaleX();
|
final double cx = Double.parseDouble(extractData("cx", s));
|
||||||
final double scaley = ugs.getAffineTransform().getScaleY();
|
final double cy = Double.parseDouble(extractData("cy", s));
|
||||||
|
final double rx = Double.parseDouble(extractData("rx", s));
|
||||||
|
final double ry = Double.parseDouble(extractData("ry", s));
|
||||||
|
|
||||||
final double deltax = ugs.getAffineTransform().getTranslateX();
|
UPath path = new UPath();
|
||||||
final double deltay = ugs.getAffineTransform().getTranslateY();
|
path.moveTo(0, ry);
|
||||||
|
// path.lineTo(rx, 0);
|
||||||
|
path.arcTo(rx, ry, 0, 0, 1, rx, 0);
|
||||||
|
|
||||||
final double cx = Double.parseDouble(extractData("cx", s)) * scalex;
|
// path.lineTo(2 * rx, ry);
|
||||||
final double cy = Double.parseDouble(extractData("cy", s)) * scaley;
|
path.arcTo(rx, ry, 0, 0, 1, 2 * rx, ry);
|
||||||
final double rx = Double.parseDouble(extractData("rx", s)) * scalex;
|
|
||||||
final double ry = Double.parseDouble(extractData("ry", s)) * scaley;
|
// path.lineTo(rx, 2 * ry);
|
||||||
|
path.arcTo(rx, ry, 0, 0, 1, rx, 2 * ry);
|
||||||
|
|
||||||
|
// path.lineTo(0, ry);
|
||||||
|
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());
|
||||||
|
|
||||||
|
ugs.draw(path);
|
||||||
|
|
||||||
final UTranslate translate = new UTranslate(deltax + cx - rx, deltay + cy - ry);
|
|
||||||
ugs.apply(translate).draw(new UEllipse(rx * 2, ry * 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawText(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {
|
private void drawText(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {
|
||||||
@ -320,7 +333,7 @@ public class SvgNanoParser implements Sprite {
|
|||||||
return ugs;
|
return ugs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphicWithScale applyRotate(UGraphicWithScale ugs, final String transform) {
|
private UGraphicWithScale applyRotate(UGraphicWithScale ugs, String transform) {
|
||||||
final Pattern p3 = Pattern.compile("rotate\\(([-.0-9]+)[ ,]+([-.0-9]+)[ ,]+([-.0-9]+)\\)");
|
final Pattern p3 = Pattern.compile("rotate\\(([-.0-9]+)[ ,]+([-.0-9]+)[ ,]+([-.0-9]+)\\)");
|
||||||
final Matcher m3 = p3.matcher(transform);
|
final Matcher m3 = p3.matcher(transform);
|
||||||
if (m3.find()) {
|
if (m3.find()) {
|
||||||
|
@ -45,14 +45,16 @@ public class UGraphicWithScale {
|
|||||||
|
|
||||||
final private UGraphic ug;
|
final private UGraphic ug;
|
||||||
final private AffineTransform at;
|
final private AffineTransform at;
|
||||||
|
final private double angle;
|
||||||
|
|
||||||
public UGraphicWithScale(UGraphic ug, double scale) {
|
public UGraphicWithScale(UGraphic ug, double scale) {
|
||||||
this(ug, AffineTransform.getScaleInstance(scale, scale));
|
this(ug, AffineTransform.getScaleInstance(scale, scale), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphicWithScale(UGraphic ug, AffineTransform at) {
|
private UGraphicWithScale(UGraphic ug, AffineTransform at, double angle) {
|
||||||
this.ug = ug;
|
this.ug = ug;
|
||||||
this.at = at;
|
this.at = at;
|
||||||
|
this.angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphic getUg() {
|
public UGraphic getUg() {
|
||||||
@ -60,29 +62,29 @@ public class UGraphicWithScale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicWithScale apply(UChange change) {
|
public UGraphicWithScale apply(UChange change) {
|
||||||
return new UGraphicWithScale(ug.apply(change), at);
|
return new UGraphicWithScale(ug.apply(change), at, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicWithScale applyScale(double changex, double changey) {
|
public UGraphicWithScale applyScale(double changex, double changey) {
|
||||||
final AffineTransform copy = new AffineTransform(at);
|
final AffineTransform copy = new AffineTransform(at);
|
||||||
copy.scale(changex, changey);
|
copy.scale(changex, changey);
|
||||||
return new UGraphicWithScale(ug, copy);
|
return new UGraphicWithScale(ug, copy, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(UShape shape) {
|
public void draw(UShape shape) {
|
||||||
ug.draw(shape);
|
ug.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicWithScale applyRotate(double angle, double x, double y) {
|
public UGraphicWithScale applyRotate(double delta_angle, double x, double y) {
|
||||||
final AffineTransform copy = new AffineTransform(at);
|
final AffineTransform copy = new AffineTransform(at);
|
||||||
copy.rotate(angle * Math.PI / 180, x, y);
|
copy.rotate(delta_angle * Math.PI / 180, x, y);
|
||||||
return new UGraphicWithScale(ug, copy);
|
return new UGraphicWithScale(ug, copy, this.angle + delta_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicWithScale applyTranslate(double x, double y) {
|
public UGraphicWithScale applyTranslate(double x, double y) {
|
||||||
final AffineTransform copy = new AffineTransform(at);
|
final AffineTransform copy = new AffineTransform(at);
|
||||||
copy.translate(x, y);
|
copy.translate(x, y);
|
||||||
return new UGraphicWithScale(ug, copy);
|
return new UGraphicWithScale(ug, copy, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AffineTransform getAffineTransform() {
|
public AffineTransform getAffineTransform() {
|
||||||
@ -92,7 +94,11 @@ public class UGraphicWithScale {
|
|||||||
public UGraphicWithScale applyMatrix(double v1, double v2, double v3, double v4, double v5, double v6) {
|
public UGraphicWithScale applyMatrix(double v1, double v2, double v3, double v4, double v5, double v6) {
|
||||||
final AffineTransform copy = new AffineTransform(at);
|
final AffineTransform copy = new AffineTransform(at);
|
||||||
copy.concatenate(new AffineTransform(new double[] { v1, v2, v3, v4, v5, v6 }));
|
copy.concatenate(new AffineTransform(new double[] { v1, v2, v3, v4, v5, v6 }));
|
||||||
return new UGraphicWithScale(ug, copy);
|
return new UGraphicWithScale(ug, copy, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getAngle() {
|
||||||
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,9 @@ import net.sourceforge.plantuml.tim.stdlib.IsLight;
|
|||||||
import net.sourceforge.plantuml.tim.stdlib.JsonKeyExists;
|
import net.sourceforge.plantuml.tim.stdlib.JsonKeyExists;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.Lighten;
|
import net.sourceforge.plantuml.tim.stdlib.Lighten;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.LoadJson;
|
import net.sourceforge.plantuml.tim.stdlib.LoadJson;
|
||||||
|
import net.sourceforge.plantuml.tim.stdlib.LogicalAnd;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.LogicalNot;
|
import net.sourceforge.plantuml.tim.stdlib.LogicalNot;
|
||||||
|
import net.sourceforge.plantuml.tim.stdlib.LogicalOr;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.Lower;
|
import net.sourceforge.plantuml.tim.stdlib.Lower;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.Newline;
|
import net.sourceforge.plantuml.tim.stdlib.Newline;
|
||||||
import net.sourceforge.plantuml.tim.stdlib.Now;
|
import net.sourceforge.plantuml.tim.stdlib.Now;
|
||||||
@ -193,6 +195,8 @@ public class TContext {
|
|||||||
functionsSet.addFunction(new SplitStr());
|
functionsSet.addFunction(new SplitStr());
|
||||||
functionsSet.addFunction(new JsonKeyExists());
|
functionsSet.addFunction(new JsonKeyExists());
|
||||||
functionsSet.addFunction(new Now());
|
functionsSet.addFunction(new Now());
|
||||||
|
functionsSet.addFunction(new LogicalAnd());
|
||||||
|
functionsSet.addFunction(new LogicalOr());
|
||||||
// %standard_exists_function
|
// %standard_exists_function
|
||||||
// %str_replace
|
// %str_replace
|
||||||
// !exit
|
// !exit
|
||||||
|
@ -51,7 +51,7 @@ import net.sourceforge.plantuml.tim.TMemory;
|
|||||||
public class ReversePolishInterpretor {
|
public class ReversePolishInterpretor {
|
||||||
|
|
||||||
private final TValue result;
|
private final TValue result;
|
||||||
private boolean trace = false;
|
private final boolean trace = false;
|
||||||
|
|
||||||
public ReversePolishInterpretor(TokenStack queue, Knowledge knowledge, TMemory memory, TContext context)
|
public ReversePolishInterpretor(TokenStack queue, Knowledge knowledge, TMemory memory, TContext context)
|
||||||
throws EaterException, EaterExceptionLocated {
|
throws EaterException, EaterExceptionLocated {
|
||||||
|
@ -115,7 +115,7 @@ public enum TokenType {
|
|||||||
if (lastToken == null)
|
if (lastToken == null)
|
||||||
return false;
|
return false;
|
||||||
final TokenType type = lastToken.getTokenType();
|
final TokenType type = lastToken.getTokenType();
|
||||||
if (type == TokenType.OPERATOR)
|
if (type == TokenType.OPERATOR || type == TokenType.OPEN_PAREN_MATH || type == TokenType.COMMA)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
68
src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java
Normal file
68
src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2023, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.tim.stdlib;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.LineLocation;
|
||||||
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||||
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
|
import net.sourceforge.plantuml.tim.expression.TValue;
|
||||||
|
|
||||||
|
public class LogicalAnd extends SimpleReturnFunction {
|
||||||
|
|
||||||
|
public TFunctionSignature getSignature() {
|
||||||
|
return new TFunctionSignature("%and", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||||
|
return nbArg >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||||
|
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||||
|
for (TValue v : values)
|
||||||
|
if (v.toBoolean() == false)
|
||||||
|
return TValue.fromBoolean(false);
|
||||||
|
|
||||||
|
return TValue.fromBoolean(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
68
src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java
Normal file
68
src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2023, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.tim.stdlib;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.LineLocation;
|
||||||
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||||
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
|
import net.sourceforge.plantuml.tim.expression.TValue;
|
||||||
|
|
||||||
|
public class LogicalOr extends SimpleReturnFunction {
|
||||||
|
|
||||||
|
public TFunctionSignature getSignature() {
|
||||||
|
return new TFunctionSignature("%or", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||||
|
return nbArg >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||||
|
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||||
|
for (TValue v : values)
|
||||||
|
if (v.toBoolean() == true)
|
||||||
|
return TValue.fromBoolean(true);
|
||||||
|
|
||||||
|
return TValue.fromBoolean(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.ugraphic;
|
package net.sourceforge.plantuml.ugraphic;
|
||||||
|
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -87,17 +88,25 @@ public class UPath extends AbstractShadowable implements Iterable<USegment>, USh
|
|||||||
|
|
||||||
public UPath translate(double dx, double dy) {
|
public UPath translate(double dx, double dy) {
|
||||||
final UPath result = new UPath(comment, codeLine);
|
final UPath result = new UPath(comment, codeLine);
|
||||||
for (USegment seg : segments) {
|
for (USegment seg : segments)
|
||||||
result.addInternal(seg.translate(dx, dy));
|
result.addInternal(seg.translate(dx, dy));
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UPath rotate(double theta) {
|
public UPath rotate(double theta) {
|
||||||
final UPath result = new UPath(comment, codeLine);
|
final UPath result = new UPath(comment, codeLine);
|
||||||
for (USegment seg : segments) {
|
for (USegment seg : segments)
|
||||||
result.addInternal(seg.rotate(theta));
|
result.addInternal(seg.rotate(theta));
|
||||||
}
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UPath affine(AffineTransform transform, double angle) {
|
||||||
|
final UPath result = new UPath(comment, codeLine);
|
||||||
|
for (USegment seg : segments)
|
||||||
|
result.addInternal(seg.affine(transform, angle));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,17 +64,23 @@ public class USegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public USegment translate(double dx, double dy) {
|
public USegment translate(double dx, double dy) {
|
||||||
if (coord.length != 2) {
|
|
||||||
|
if (pathType == USegmentType.SEG_ARCTO)
|
||||||
|
return new USegment(
|
||||||
|
new double[] { coord[0], coord[1], coord[2], coord[3], coord[4], coord[5] + dx, coord[6] + dy },
|
||||||
|
pathType);
|
||||||
|
|
||||||
|
if (coord.length != 2)
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
|
||||||
XPoint2D p1 = new XPoint2D(coord[0] + dx, coord[1] + dy);
|
XPoint2D p1 = new XPoint2D(coord[0] + dx, coord[1] + dy);
|
||||||
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public USegment rotate(double theta) {
|
public USegment rotate(double theta) {
|
||||||
if (coord.length != 2) {
|
if (coord.length != 2)
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
|
||||||
XPoint2D p1 = new XPoint2D(coord[0], coord[1]);
|
XPoint2D p1 = new XPoint2D(coord[0], coord[1]);
|
||||||
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
|
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
|
||||||
p1 = p1.transform(rotate);
|
p1 = p1.transform(rotate);
|
||||||
@ -82,4 +88,22 @@ public class USegment {
|
|||||||
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public USegment affine(AffineTransform transform, double angle) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coord.length != 2)
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
XPoint2D p1 = new XPoint2D(coord[0], coord[1]);
|
||||||
|
p1 = p1.transform(transform);
|
||||||
|
|
||||||
|
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import java.awt.geom.PathIterator;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public enum USegmentType {
|
public enum USegmentType {
|
||||||
|
|
||||||
|
|
||||||
SEG_MOVETO(PathIterator.SEG_MOVETO), //
|
SEG_MOVETO(PathIterator.SEG_MOVETO), //
|
||||||
SEG_LINETO(PathIterator.SEG_LINETO), //
|
SEG_LINETO(PathIterator.SEG_LINETO), //
|
||||||
@ -47,7 +46,7 @@ public enum USegmentType {
|
|||||||
SEG_CUBICTO(PathIterator.SEG_CUBICTO), //
|
SEG_CUBICTO(PathIterator.SEG_CUBICTO), //
|
||||||
SEG_CLOSE(PathIterator.SEG_CLOSE), //
|
SEG_CLOSE(PathIterator.SEG_CLOSE), //
|
||||||
SEG_ARCTO(4321);//
|
SEG_ARCTO(4321);//
|
||||||
|
|
||||||
final public static int SEG_ARCTO_VALUE = 4321;
|
final public static int SEG_ARCTO_VALUE = 4321;
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
@ -71,11 +70,10 @@ public enum USegmentType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static USegmentType getByCode(int code) {
|
public static USegmentType getByCode(int code) {
|
||||||
for (USegmentType p : EnumSet.allOf(USegmentType.class)) {
|
for (USegmentType p : EnumSet.allOf(USegmentType.class))
|
||||||
if (p.code == code) {
|
if (p.code == code)
|
||||||
return p;
|
return p;
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 1;
|
final int beta = 2;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user