mirror of
https://github.com/octoleo/plantuml.git
synced 2024-06-06 10:20:54 +00:00
wip
This commit is contained in:
parent
9ab898fe1b
commit
b2afe9c916
|
@ -50,6 +50,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.api.ThemeStyle;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
|
@ -215,20 +216,18 @@ public class SkinParam implements ISkinParam {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static final Pattern patternCleanUnderscoreDot = Pattern.compile("_|\\.");
|
||||
private static final Pattern patternCleanSequence = Pattern.compile("sequence(participant|actor)");
|
||||
private static final Pattern patternCleanArrow = Pattern.compile("(activity|class|component|object|sequence|state|usecase)arrow");
|
||||
private static final Pattern patternCleanAlign = Pattern.compile("align$");
|
||||
|
||||
List<String> cleanForKeySlow(String key) {
|
||||
key = StringUtils.trin(StringUtils.goLowerCase(key));
|
||||
key = key.replaceAll("_|\\.", "");
|
||||
// key = replaceSmart(key, "partition", "package");
|
||||
key = replaceSmart(key, "sequenceparticipant", "participant");
|
||||
key = replaceSmart(key, "sequenceactor", "actor");
|
||||
key = key.replaceAll("activityarrow", "arrow");
|
||||
key = key.replaceAll("objectarrow", "arrow");
|
||||
key = key.replaceAll("classarrow", "arrow");
|
||||
key = key.replaceAll("componentarrow", "arrow");
|
||||
key = key.replaceAll("statearrow", "arrow");
|
||||
key = key.replaceAll("usecasearrow", "arrow");
|
||||
key = key.replaceAll("sequencearrow", "arrow");
|
||||
key = key.replaceAll("align$", "alignment");
|
||||
key = patternCleanUnderscoreDot.matcher(key).replaceAll("");
|
||||
key = patternCleanSequence.matcher(key).replaceAll("$1");
|
||||
key = patternCleanArrow.matcher(key).replaceAll("arrow");
|
||||
key = patternCleanAlign.matcher(key).replaceAll("alignment");
|
||||
|
||||
final Matcher2 mm = stereoPattern.matcher(key);
|
||||
final List<String> result = new ArrayList<>();
|
||||
while (mm.find()) {
|
||||
|
@ -241,13 +240,6 @@ public class SkinParam implements ISkinParam {
|
|||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
private static String replaceSmart(String s, String src, String target) {
|
||||
if (s.contains(src) == false) {
|
||||
return s;
|
||||
}
|
||||
return s.replaceAll(src, target);
|
||||
}
|
||||
|
||||
public HColor getHyperlinkColor() {
|
||||
final HColor result = getHtmlColor(ColorParam.hyperlink, null, false);
|
||||
if (result == null)
|
||||
|
|
|
@ -83,6 +83,7 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
|
|||
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
|
||||
import net.sourceforge.plantuml.ugraphic.comp.SlotFinder;
|
||||
import net.sourceforge.plantuml.utils.MathUtils;
|
||||
|
@ -301,7 +302,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable
|
|||
|
||||
final double xpos = swimlane.getTranslate().getDx() + swimlane.getMinMax().getMinX();
|
||||
final HColor back = swimlane.getColors().getColor(ColorType.BACK);
|
||||
if (back != null) {
|
||||
if (HColors.isTransparent(back) == false) {
|
||||
final LaneDivider divider2 = dividers.get(i + 1);
|
||||
final UGraphic background = ug.apply(back.bg()).apply(back)
|
||||
.apply(UTranslate.dx(xpos - divider1.getX2()));
|
||||
|
|
|
@ -104,8 +104,8 @@ public class FtileCircleStop extends AbstractFtile {
|
|||
// if (skinParam().shadowing(null)) {
|
||||
// circleSmall.setDeltaShadow(3);
|
||||
// }
|
||||
ug.apply(HColors.middle(borderColor, backColor)).apply(borderColor.bg()).apply(new UTranslate(delta, delta))
|
||||
.draw(circleSmall);
|
||||
final HColor middle = HColors.middle(borderColor, backColor);
|
||||
ug.apply(middle).apply(borderColor.bg()).apply(new UTranslate(delta, delta)).draw(circleSmall);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -144,10 +144,10 @@ public class AffineTransformation {
|
|||
MinMax result = MinMax.getEmpty(false);
|
||||
final AffineTransform tmp = getAffineTransform(rect);
|
||||
|
||||
result = result.addPoint(new XPoint2D(0, 0).getTransform(tmp));
|
||||
result = result.addPoint(new XPoint2D(0, rect.getHeight()).getTransform(tmp));
|
||||
result = result.addPoint(new XPoint2D(rect.getWidth(), 0).getTransform(tmp));
|
||||
result = result.addPoint(new XPoint2D(rect.getWidth(), rect.getHeight()).getTransform(tmp));
|
||||
result = result.addPoint(new XPoint2D(0, 0).transform(tmp));
|
||||
result = result.addPoint(new XPoint2D(0, rect.getHeight()).transform(tmp));
|
||||
result = result.addPoint(new XPoint2D(rect.getWidth(), 0).transform(tmp));
|
||||
result = result.addPoint(new XPoint2D(rect.getWidth(), rect.getHeight()).transform(tmp));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ public class XCubicCurve2D implements XShape {
|
|||
public double x2;
|
||||
public double y2;
|
||||
|
||||
public XCubicCurve2D() {
|
||||
this(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public XCubicCurve2D(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2,
|
||||
double y2) {
|
||||
this.x1 = x1;
|
||||
|
@ -123,8 +127,24 @@ public class XCubicCurve2D implements XShape {
|
|||
}
|
||||
|
||||
public double getFlatnessSq() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return Math.max(XLine2D.ptSegDistSq(x1, y1, x2, y2, ctrlx1, ctrly1),
|
||||
XLine2D.ptSegDistSq(x1, y1, x2, y2, ctrlx2, ctrly2));
|
||||
}
|
||||
|
||||
public double getFlatness() {
|
||||
return getFlatness(getX1(), getY1(), getCtrlX1(), getCtrlY1(), getCtrlX2(), getCtrlY2(), getX2(), getY2());
|
||||
}
|
||||
|
||||
private static double getFlatness(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2,
|
||||
double x2, double y2) {
|
||||
return Math.sqrt(getFlatnessSq(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2));
|
||||
}
|
||||
|
||||
private static double getFlatnessSq(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2,
|
||||
double x2, double y2) {
|
||||
return Math.max(XLine2D.ptSegDistSq(x1, y1, x2, y2, ctrlx1, ctrly1),
|
||||
XLine2D.ptSegDistSq(x1, y1, x2, y2, ctrlx2, ctrly2));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ import net.sourceforge.plantuml.awt.XShape;
|
|||
|
||||
public class XLine2D implements XShape {
|
||||
|
||||
public double x1;
|
||||
public double y1;
|
||||
public double x2;
|
||||
public double y2;
|
||||
final public double x1;
|
||||
final public double y1;
|
||||
final public double x2;
|
||||
final public double y2;
|
||||
|
||||
public XLine2D() {
|
||||
this(0, 0, 0, 0);
|
||||
|
@ -21,6 +21,12 @@ public class XLine2D implements XShape {
|
|||
|
||||
}
|
||||
|
||||
public XPoint2D getMiddle() {
|
||||
final double mx = (this.x1 + this.x2) / 2;
|
||||
final double my = (this.y1 + this.y2) / 2;
|
||||
return new XPoint2D(mx, my);
|
||||
}
|
||||
|
||||
public XLine2D(XPoint2D p1, XPoint2D p2) {
|
||||
this(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
|
@ -49,4 +55,78 @@ public class XLine2D implements XShape {
|
|||
return new XPoint2D(x2, y2);
|
||||
}
|
||||
|
||||
public XLine2D withPoint1(XPoint2D other) {
|
||||
return new XLine2D(other.x, other.y, x2, y2);
|
||||
}
|
||||
|
||||
public XLine2D withPoint2(XPoint2D other) {
|
||||
return new XLine2D(x1, y1, other.x, other.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the square of the distance from a point to a line segment. The
|
||||
* distance measured is the distance between the specified point and the closest
|
||||
* point between the specified end points. If the specified point intersects the
|
||||
* line segment in between the end points, this method returns 0.0.
|
||||
*
|
||||
* @param x1 the X coordinate of the start point of the specified line segment
|
||||
* @param y1 the Y coordinate of the start point of the specified line segment
|
||||
* @param x2 the X coordinate of the end point of the specified line segment
|
||||
* @param y2 the Y coordinate of the end point of the specified line segment
|
||||
* @param px the X coordinate of the specified point being measured against the
|
||||
* specified line segment
|
||||
* @param py the Y coordinate of the specified point being measured against the
|
||||
* specified line segment
|
||||
* @return a double value that is the square of the distance from the specified
|
||||
* point to the specified line segment.
|
||||
* @see #ptLineDistSq(double, double, double, double, double, double)
|
||||
* @since 1.2
|
||||
*/
|
||||
public static double ptSegDistSq(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
// Adjust vectors relative to x1,y1
|
||||
// x2,y2 becomes relative vector from x1,y1 to end of segment
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
// px,py becomes relative vector from x1,y1 to test point
|
||||
px -= x1;
|
||||
py -= y1;
|
||||
double dotprod = px * x2 + py * y2;
|
||||
double projlenSq;
|
||||
if (dotprod <= 0.0) {
|
||||
// px,py is on the side of x1,y1 away from x2,y2
|
||||
// distance to segment is length of px,py vector
|
||||
// "length of its (clipped) projection" is now 0.0
|
||||
projlenSq = 0.0;
|
||||
} else {
|
||||
// switch to backwards vectors relative to x2,y2
|
||||
// x2,y2 are already the negative of x1,y1=>x2,y2
|
||||
// to get px,py to be the negative of px,py=>x2,y2
|
||||
// the dot product of two negated vectors is the same
|
||||
// as the dot product of the two normal vectors
|
||||
px = x2 - px;
|
||||
py = y2 - py;
|
||||
dotprod = px * x2 + py * y2;
|
||||
if (dotprod <= 0.0) {
|
||||
// px,py is on the side of x2,y2 away from x1,y1
|
||||
// distance to segment is length of (backwards) px,py vector
|
||||
// "length of its (clipped) projection" is now 0.0
|
||||
projlenSq = 0.0;
|
||||
} else {
|
||||
// px,py is between x1,y1 and x2,y2
|
||||
// dotprod is the length of the px,py vector
|
||||
// projected on the x2,y2=>x1,y1 vector times the
|
||||
// length of the x2,y2=>x1,y1 vector
|
||||
projlenSq = dotprod * dotprod / (x2 * x2 + y2 * y2);
|
||||
}
|
||||
}
|
||||
// Distance to line is now the length of the relative point
|
||||
// vector minus the length of its projection onto the line
|
||||
// (which is zero if the projection falls outside the range
|
||||
// of the line segment).
|
||||
double lenSq = px * px + py * py - projlenSq;
|
||||
if (lenSq < 0) {
|
||||
lenSq = 0;
|
||||
}
|
||||
return lenSq;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.awt.geom.Point2D;
|
|||
|
||||
public class XPoint2D {
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
final public double x;
|
||||
final public double y;
|
||||
|
||||
public XPoint2D() {
|
||||
this(0, 0);
|
||||
|
@ -33,10 +33,6 @@ public class XPoint2D {
|
|||
return new Double(x).hashCode() + new Double(y).hashCode();
|
||||
}
|
||||
|
||||
public XPoint2D(Point2D pt) {
|
||||
this(pt.getX(), pt.getY());
|
||||
}
|
||||
|
||||
public final double getX() {
|
||||
return x;
|
||||
}
|
||||
|
@ -69,32 +65,18 @@ public class XPoint2D {
|
|||
return Math.sqrt(px * px + py * py);
|
||||
}
|
||||
|
||||
public void setLocation(double px, double py) {
|
||||
this.x = px;
|
||||
this.y = py;
|
||||
}
|
||||
|
||||
public XPoint2D move(double dx, double dy) {
|
||||
return new XPoint2D(x + dx, y + dy);
|
||||
|
||||
}
|
||||
|
||||
public void transform(AffineTransform rotate) {
|
||||
public XPoint2D transform(AffineTransform rotate) {
|
||||
final Point2D.Double tmp = new Point2D.Double(x, y);
|
||||
rotate.transform(tmp, tmp);
|
||||
this.x = tmp.x;
|
||||
this.y = tmp.y;
|
||||
|
||||
return new XPoint2D(tmp.x, tmp.y);
|
||||
}
|
||||
|
||||
public XPoint2D getTransform(AffineTransform rotate) {
|
||||
final Point2D.Double tmp = new Point2D.Double(x, y);
|
||||
rotate.transform(tmp, tmp);
|
||||
return new XPoint2D(tmp);
|
||||
}
|
||||
|
||||
public Point2D toLegacy() {
|
||||
return new Point2D.Double(x, y);
|
||||
public XPoint2D move(XPoint2D delta) {
|
||||
return new XPoint2D(delta.x, delta.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,4 +70,10 @@ public class XRectangle2D implements XShape {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean contains(double xp, double yp) {
|
||||
if (width <= 0 || height <= 0)
|
||||
throw new IllegalStateException();
|
||||
return xp >= getMinX() && xp < getMaxX() && yp >= getMinY() && yp < getMaxY();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.braille;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
|
||||
|
@ -141,18 +141,18 @@ public class BrailleGrid {
|
|||
}
|
||||
|
||||
public void drawDotPath(double x, double y, DotPath shape) {
|
||||
for (CubicCurve2D.Double bez : shape.getBeziers()) {
|
||||
for (XCubicCurve2D bez : shape.getBeziers()) {
|
||||
drawCubic(x, y, bez);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCubic(double x, double y, CubicCurve2D.Double bez) {
|
||||
drawPointInternal(x, y, new XPoint2D(bez.getP1()));
|
||||
drawPointInternal(x, y, new XPoint2D(bez.getP2()));
|
||||
private void drawCubic(double x, double y, XCubicCurve2D bez) {
|
||||
drawPointInternal(x, y, bez.getP1());
|
||||
drawPointInternal(x, y, bez.getP2());
|
||||
if (bez.getP1().distance(bez.getP2()) > quanta) {
|
||||
final CubicCurve2D.Double part1 = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double part2 = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D part1 = new XCubicCurve2D();
|
||||
final XCubicCurve2D part2 = new XCubicCurve2D();
|
||||
bez.subdivide(part1, part2);
|
||||
drawCubic(x, y, part1);
|
||||
drawCubic(x, y, part2);
|
||||
|
|
|
@ -39,12 +39,13 @@ import net.sourceforge.plantuml.posimo.DotPath;
|
|||
import net.sourceforge.plantuml.ugraphic.UDriver;
|
||||
import net.sourceforge.plantuml.ugraphic.UParam;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class DriverDotPathBraille implements UDriver<DotPath, BrailleGrid> {
|
||||
|
||||
public void draw(DotPath shape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) {
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false)
|
||||
grid.drawDotPath(x, y, shape);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
|
|||
import net.sourceforge.plantuml.ugraphic.UText;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorScheme;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
import net.sourceforge.plantuml.utils.CharHidder;
|
||||
|
||||
public final class AtomText extends AbstractAtom implements Atom {
|
||||
|
@ -141,18 +140,13 @@ public final class AtomText extends AbstractAtom implements Atom {
|
|||
}
|
||||
HColor textColor = fontConfiguration.getColor();
|
||||
FontConfiguration useFontConfiguration = fontConfiguration;
|
||||
if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) {
|
||||
textColor = ug.getParam().getBackcolor().opposite();
|
||||
useFontConfiguration = fontConfiguration.changeColor(textColor);
|
||||
}
|
||||
if (textColor instanceof HColorScheme) {
|
||||
HColor backcolor = ug.getParam().getBackcolor();
|
||||
if (backcolor == null)
|
||||
backcolor = ug.getDefaultBackground();
|
||||
|
||||
textColor = ((HColorScheme) textColor).getAppropriateColor(backcolor);
|
||||
useFontConfiguration = fontConfiguration.changeColor(textColor);
|
||||
}
|
||||
HColor backcolor = ug.getParam().getBackcolor();
|
||||
if (HColors.isTransparent(backcolor))
|
||||
backcolor = ug.getDefaultBackground();
|
||||
|
||||
textColor = textColor.getAppropriateColor(backcolor);
|
||||
useFontConfiguration = fontConfiguration.changeColor(textColor);
|
||||
|
||||
if (marginLeft != AtomTextUtils.ZERO)
|
||||
ug = ug.apply(UTranslate.dx(marginLeft.getDouble(ug.getStringBounder())));
|
||||
|
|
|
@ -46,47 +46,48 @@ public class HideOrShow2 {
|
|||
}
|
||||
|
||||
private boolean isApplyable(ILeaf leaf) {
|
||||
if (what.startsWith("$")) {
|
||||
if (what.startsWith("$"))
|
||||
return isApplyableTag(leaf, what.substring(1));
|
||||
}
|
||||
if (what.startsWith("<<") && what.endsWith(">>")) {
|
||||
|
||||
if (what.startsWith("<<") && what.endsWith(">>"))
|
||||
return isApplyableStereotype(leaf, what.substring(2, what.length() - 2).trim());
|
||||
}
|
||||
if (what.equalsIgnoreCase("@unlinked")) {
|
||||
|
||||
if (isAboutUnlinked())
|
||||
return isApplyableUnlinked(leaf);
|
||||
}
|
||||
|
||||
final String fullName = leaf.getCodeGetName();
|
||||
// System.err.println("fullName=" + fullName);
|
||||
return match(fullName, what);
|
||||
}
|
||||
|
||||
public boolean isAboutUnlinked() {
|
||||
return what.equalsIgnoreCase("@unlinked");
|
||||
}
|
||||
|
||||
private boolean isApplyableUnlinked(ILeaf leaf) {
|
||||
if (leaf.isAloneAndUnlinked()) {
|
||||
if (leaf.isAloneAndUnlinked())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isApplyableStereotype(ILeaf leaf, String pattern) {
|
||||
final Stereotype stereotype = leaf.getStereotype();
|
||||
if (stereotype == null) {
|
||||
if (stereotype == null)
|
||||
return false;
|
||||
}
|
||||
for (String label : stereotype.getMultipleLabels()) {
|
||||
if (match(label, pattern)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
for (String label : stereotype.getMultipleLabels())
|
||||
if (match(label, pattern))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isApplyableTag(ILeaf leaf, String pattern) {
|
||||
for (Stereotag tag : leaf.stereotags()) {
|
||||
if (match(tag.getName(), pattern)) {
|
||||
for (Stereotag tag : leaf.stereotags())
|
||||
if (match(tag.getName(), pattern))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,9 +109,9 @@ public class HideOrShow2 {
|
|||
}
|
||||
|
||||
public boolean apply(boolean hidden, ILeaf leaf) {
|
||||
if (isApplyable(leaf)) {
|
||||
if (isApplyable(leaf))
|
||||
return !show;
|
||||
}
|
||||
|
||||
return hidden;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,9 +122,9 @@ public final class EntityFactory {
|
|||
folder.setUSymbol(symbol);
|
||||
folder.setStereotype(g.getStereotype());
|
||||
folder.setColors(g.getColors());
|
||||
if (g.getUrl99() != null)
|
||||
if (g.getUrl99() != null)
|
||||
folder.addUrl(g.getUrl99());
|
||||
|
||||
|
||||
// if (UseStyle.useBetaStyle()) {
|
||||
// // System.err.println("Backcolor ?");
|
||||
// } else {
|
||||
|
@ -144,16 +144,15 @@ public final class EntityFactory {
|
|||
final Set<Ident> known = new HashSet<>(groups2.keySet());
|
||||
known.removeAll(hiddenBecauseOfIntrication);
|
||||
String sep = namespaceSeparator.getNamespaceSeparator();
|
||||
if (sep == null) {
|
||||
if (sep == null)
|
||||
sep = ".";
|
||||
}
|
||||
for (int check = ident.size() - 1; check > 0; check--) {
|
||||
if (known.contains(ident.getPrefix(check))) {
|
||||
// if (hiddenBecauseOfIntrication.contains(ident.getPrefix(check)) == false) {
|
||||
|
||||
for (int check = ident.size() - 1; check > 0; check--)
|
||||
if (known.contains(ident.getPrefix(check)))
|
||||
// if (hiddenBecauseOfIntrication.contains(ident.getPrefix(check)) == false)
|
||||
return Display.getWithNewlines(ident.getSuffix(check).toString(sep))
|
||||
.withCreoleMode(CreoleMode.SIMPLE_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
return Display.getWithNewlines(ident.toString(sep)).withCreoleMode(CreoleMode.SIMPLE_LINE);
|
||||
}
|
||||
|
||||
|
@ -164,15 +163,13 @@ public final class EntityFactory {
|
|||
final Collection<IGroup> children = parent.getChildren();
|
||||
if (leafs == 0 && children.size() == 1) {
|
||||
final IGroup g = children.iterator().next();
|
||||
if (g.getLeafsDirect().size() == 0 && g.getChildren().size() == 0
|
||||
&& g.getGroupType() == GroupType.PACKAGE) {
|
||||
if (g.getLeafsDirect().size() == 0 && g.getChildren().size() == 0 && g.getGroupType() == GroupType.PACKAGE)
|
||||
return null;
|
||||
}
|
||||
for (Link link : this.getLinks()) {
|
||||
if (link.contains(parent)) {
|
||||
|
||||
for (Link link : this.getLinks())
|
||||
if (link.contains(parent))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
((EntityImpl) g).setIntricated(true);
|
||||
hiddenBecauseOfIntrication.add(parent.getIdent());
|
||||
return g;
|
||||
|
@ -197,17 +194,26 @@ public final class EntityFactory {
|
|||
|
||||
public boolean isHidden(ILeaf leaf) {
|
||||
boolean hidden = false;
|
||||
for (HideOrShow2 hide : hides2) {
|
||||
for (HideOrShow2 hide : hides2)
|
||||
hidden = hide.apply(hidden, leaf);
|
||||
}
|
||||
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public boolean isRemoved(ILeaf leaf) {
|
||||
boolean result = false;
|
||||
for (HideOrShow2 hide : removed) {
|
||||
for (HideOrShow2 hide : removed)
|
||||
result = hide.apply(result, leaf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isRemovedIgnoreUnlinked(ILeaf leaf) {
|
||||
boolean result = false;
|
||||
for (HideOrShow2 hide : removed)
|
||||
if (hide.isAboutUnlinked() == false)
|
||||
result = hide.apply(result, leaf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -237,17 +243,16 @@ public final class EntityFactory {
|
|||
public IGroup createGroup(Ident ident, Code code, Display display, Code namespace, GroupType groupType,
|
||||
IGroup parentContainer, Set<VisibilityModifier> hides, String namespaceSeparator) {
|
||||
Objects.requireNonNull(groupType);
|
||||
for (Entry<Ident, IGroup> ent : groups2.entrySet()) {
|
||||
if (ent.getKey().equals(ident)) {
|
||||
for (Entry<Ident, IGroup> ent : groups2.entrySet())
|
||||
if (ent.getKey().equals(ident))
|
||||
return ent.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
final Bodier bodier = BodyFactory.createGroup(hides);
|
||||
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace,
|
||||
namespaceSeparator, rawLayout);
|
||||
if (Display.isNull(display) == false) {
|
||||
if (Display.isNull(display) == false)
|
||||
result.setDisplay(display);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -355,13 +360,11 @@ public final class EntityFactory {
|
|||
if (!namespaceSeparator.V1972())
|
||||
throw new UnsupportedOperationException();
|
||||
final ILeaf result = leafs2.get(ident);
|
||||
if (result == null && ident.size() == 1) {
|
||||
for (Entry<Ident, ILeaf> ent : leafs2.entrySet()) {
|
||||
if (ent.getKey().getLast().equals(ident.getLast())) {
|
||||
if (result == null && ident.size() == 1)
|
||||
for (Entry<Ident, ILeaf> ent : leafs2.entrySet())
|
||||
if (ent.getKey().getLast().equals(ident.getLast()))
|
||||
return ent.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -369,45 +372,40 @@ public final class EntityFactory {
|
|||
if (!namespaceSeparator.V1972())
|
||||
throw new UnsupportedOperationException();
|
||||
final ILeaf result = leafs2.get(ident);
|
||||
if (result == null) {
|
||||
for (Entry<Ident, ILeaf> ent : leafs2.entrySet()) {
|
||||
if (ent.getKey().getLast().equals(ident.getLast())) {
|
||||
if (result == null)
|
||||
for (Entry<Ident, ILeaf> ent : leafs2.entrySet())
|
||||
if (ent.getKey().getLast().equals(ident.getLast()))
|
||||
return ent.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Ident buildFullyQualified(Ident currentPath, Ident id) {
|
||||
if (currentPath.equals(id) == false) {
|
||||
if (leafs2.containsKey(id) || groups2.containsKey(id)) {
|
||||
if (currentPath.equals(id) == false)
|
||||
if (leafs2.containsKey(id) || groups2.containsKey(id))
|
||||
return id;
|
||||
}
|
||||
}
|
||||
if (id.size() > 1) {
|
||||
|
||||
if (id.size() > 1)
|
||||
return id;
|
||||
}
|
||||
|
||||
return currentPath.add(id);
|
||||
}
|
||||
|
||||
public final IGroup getGroupStrict(Ident ident) {
|
||||
if (namespaceSeparator.getNamespaceSeparator() == null) {
|
||||
if (namespaceSeparator.getNamespaceSeparator() == null)
|
||||
return getGroupVerySmart(ident);
|
||||
}
|
||||
|
||||
final IGroup result = groups2.get(ident);
|
||||
return result;
|
||||
}
|
||||
|
||||
public final IGroup getGroupVerySmart(Ident ident) {
|
||||
final IGroup result = groups2.get(ident);
|
||||
if (result == null) {
|
||||
for (Entry<Ident, IGroup> ent : groups2.entrySet()) {
|
||||
if (ent.getKey().getLast().equals(ident.getLast())) {
|
||||
if (result == null)
|
||||
for (Entry<Ident, IGroup> ent : groups2.entrySet())
|
||||
if (ent.getKey().getLast().equals(ident.getLast()))
|
||||
return ent.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -415,9 +413,9 @@ public final class EntityFactory {
|
|||
if (namespaceSeparator.V1972())
|
||||
throw new UnsupportedOperationException();
|
||||
final ILeaf result = leafsByCode.get(code.getName());
|
||||
if (result != null && result != leafs2.get(result.getIdent())) {
|
||||
if (result != null && result != leafs2.get(result.getIdent()))
|
||||
bigError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -425,9 +423,9 @@ public final class EntityFactory {
|
|||
if (namespaceSeparator.V1972())
|
||||
throw new UnsupportedOperationException();
|
||||
final IGroup result = groupsByCode.get(code.getName());
|
||||
if (result != null && result != groups2.get(result.getIdent())) {
|
||||
if (result != null && result != groups2.get(result.getIdent()))
|
||||
bigError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -435,9 +433,9 @@ public final class EntityFactory {
|
|||
if (namespaceSeparator.V1972())
|
||||
return leafs2();
|
||||
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafsByCode.values());
|
||||
if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false) {
|
||||
if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false)
|
||||
bigError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -445,9 +443,9 @@ public final class EntityFactory {
|
|||
if (namespaceSeparator.V1972())
|
||||
return groups2();
|
||||
final Collection<IGroup> result = Collections.unmodifiableCollection(groupsByCode.values());
|
||||
if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false) {
|
||||
if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false)
|
||||
bigError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -470,39 +468,37 @@ public final class EntityFactory {
|
|||
}
|
||||
|
||||
public void addLink(Link link) {
|
||||
if (link.isSingle() && containsSimilarLink(link)) {
|
||||
if (link.isSingle() && containsSimilarLink(link))
|
||||
return;
|
||||
}
|
||||
|
||||
links.add(link);
|
||||
}
|
||||
|
||||
private boolean containsSimilarLink(Link other) {
|
||||
for (Link link : links) {
|
||||
if (other.sameConnections(link)) {
|
||||
for (Link link : links)
|
||||
if (other.sameConnections(link))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeLink(Link link) {
|
||||
final boolean ok = links.remove(link);
|
||||
if (ok == false) {
|
||||
if (ok == false)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IGroup getParentContainer(Ident ident, IGroup parentContainer) {
|
||||
if (namespaceSeparator.V1972()) {
|
||||
final Ident parent = ident.parent();
|
||||
if (parent.isRoot()) {
|
||||
if (parent.isRoot())
|
||||
return this.rootGroup;
|
||||
}
|
||||
|
||||
IGroup result = getGroupStrict(parent);
|
||||
if (result != null) {
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
// System.err.println("getParentContainer::groups2=" + groups2);
|
||||
|
||||
final Display display = Display.getWithNewlines(parent.getName());
|
||||
result = createGroup(parent, parent, display, null, GroupType.PACKAGE, null,
|
||||
Collections.<VisibilityModifier>emptySet(), namespaceSeparator.getNamespaceSeparator());
|
||||
|
|
|
@ -659,8 +659,12 @@ final public class EntityImpl implements ILeaf, IGroup {
|
|||
return false;
|
||||
|
||||
for (Link link : entityFactory.getLinks())
|
||||
if (link.contains(this) && link.getType().isInvisible() == false)
|
||||
return false;
|
||||
if (link.contains(this)) {
|
||||
final ILeaf other = (ILeaf) link.getOther(this);
|
||||
final boolean removed = entityFactory.isRemovedIgnoreUnlinked(other);
|
||||
if (removed == false && link.getType().isInvisible() == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ import net.sourceforge.plantuml.style.Style;
|
|||
import net.sourceforge.plantuml.svek.Bibliotekon;
|
||||
import net.sourceforge.plantuml.svek.Cluster;
|
||||
import net.sourceforge.plantuml.svek.ClusterDecoration;
|
||||
import net.sourceforge.plantuml.svek.ClusterPosition;
|
||||
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
|
||||
import net.sourceforge.plantuml.svek.DotStringFactory;
|
||||
import net.sourceforge.plantuml.svek.GeneralImageBuilder;
|
||||
|
@ -274,8 +275,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
|
|||
final TextBlock ztitle = getTitleBlock(group);
|
||||
final TextBlock zstereo = TextBlockUtils.empty(0, 0);
|
||||
|
||||
final ClusterPosition clusterPosition = new ClusterPosition(0, 0, elkNode.getWidth(), elkNode.getHeight());
|
||||
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle,
|
||||
zstereo, 0, 0, elkNode.getWidth(), elkNode.getHeight(), stroke);
|
||||
zstereo, clusterPosition, stroke);
|
||||
|
||||
final HColor borderColor = HColors.BLACK;
|
||||
decoration.drawU(ug.apply(new UTranslate(corner)), backColor, borderColor, shadowing, roundCorner,
|
||||
|
|
|
@ -109,22 +109,22 @@ public class EpsGraphics {
|
|||
private int maxY = 10;
|
||||
|
||||
final protected void ensureVisible(double x, double y) {
|
||||
if (x > maxX) {
|
||||
if (x > maxX)
|
||||
maxX = (int) (x + 1);
|
||||
}
|
||||
if (y > maxY) {
|
||||
|
||||
if (y > maxY)
|
||||
maxY = (int) (y + 1);
|
||||
}
|
||||
if (urlArea != null) {
|
||||
|
||||
if (urlArea != null)
|
||||
urlArea.ensureVisible((int) Math.round(x), (int) Math.round(y));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
final public void close() {
|
||||
checkCloseDone();
|
||||
|
||||
header.append("%%BoundingBox: 0 0 " + maxX + " " + maxY + BackSlash.NEWLINE);
|
||||
|
@ -137,15 +137,14 @@ public class EpsGraphics {
|
|||
header.append("0 " + maxY + " translate\n");
|
||||
header.append(".01 -.01 scale\n");
|
||||
|
||||
if (setcolorgradientUsed) {
|
||||
if (setcolorgradientUsed)
|
||||
header.append(setcolorgradient.getPostStringDefinition());
|
||||
}
|
||||
if (simplerectUsed) {
|
||||
|
||||
if (simplerectUsed)
|
||||
header.append(simplerect.getPostStringDefinition());
|
||||
}
|
||||
if (roundrectUsed) {
|
||||
|
||||
if (roundrectUsed)
|
||||
header.append(roundrect.getPostStringDefinition());
|
||||
}
|
||||
|
||||
append("grestore", true);
|
||||
|
||||
|
@ -159,15 +158,15 @@ public class EpsGraphics {
|
|||
}
|
||||
|
||||
private void checkCloseDone() {
|
||||
if (closeDone) {
|
||||
if (closeDone)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getEPSCode() {
|
||||
if (closeDone == false) {
|
||||
final public String getEPSCode() {
|
||||
if (closeDone == false)
|
||||
close();
|
||||
}
|
||||
|
||||
return header.toString() + getBodyString();
|
||||
}
|
||||
|
||||
|
@ -180,7 +179,7 @@ public class EpsGraphics {
|
|||
this.color = c;
|
||||
}
|
||||
|
||||
public void setFillColor(Color c) {
|
||||
final public void setFillColor(Color c) {
|
||||
checkCloseDone();
|
||||
this.fillcolor = c;
|
||||
}
|
||||
|
@ -195,15 +194,18 @@ public class EpsGraphics {
|
|||
private long dashVisible = 0;
|
||||
private long dashSpace = 0;
|
||||
|
||||
public void newpathDot() {
|
||||
final public void newpathDot() {
|
||||
final boolean dashed = isDashed();
|
||||
if (isNull(color))
|
||||
throw new IllegalStateException();
|
||||
|
||||
checkCloseDone();
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
|
||||
if (dashed) {
|
||||
if (dashed)
|
||||
append("[" + dashSpace + " " + dashVisible + "] 0 setdash", true);
|
||||
}
|
||||
|
||||
append("newpath", true);
|
||||
}
|
||||
|
||||
|
@ -219,15 +221,17 @@ public class EpsGraphics {
|
|||
return dashSpace != 0 && dashVisible != 0;
|
||||
}
|
||||
|
||||
public void closepathDot() {
|
||||
final public void closepathDot() {
|
||||
final boolean dashed = isDashed();
|
||||
append("stroke", true);
|
||||
if (dashed) {
|
||||
if (dashed)
|
||||
append("[] 0 setdash", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void epsLine(double x1, double y1, double x2, double y2) {
|
||||
final public void epsLine(double x1, double y1, double x2, double y2) {
|
||||
if (isNull(color))
|
||||
throw new IllegalStateException();
|
||||
ensureVisible(x1, y1);
|
||||
ensureVisible(x2, y2);
|
||||
checkCloseDone();
|
||||
|
@ -250,11 +254,11 @@ public class EpsGraphics {
|
|||
append(format(x) + " " + format(ymin) + " moveto", true);
|
||||
for (long y2 = (long) (ymin * COEF); y2 < (long) (ymax * COEF); y2 += (dashVisible + dashSpace)) {
|
||||
final long v;
|
||||
if (y2 + dashVisible > (long) (ymax * COEF)) {
|
||||
if (y2 + dashVisible > (long) (ymax * COEF))
|
||||
v = y2 - (long) (ymax * COEF);
|
||||
} else {
|
||||
else
|
||||
v = dashSpace;
|
||||
}
|
||||
|
||||
append("0 " + v + " rlineto", true);
|
||||
append("0 " + dashSpace + " rmoveto", true);
|
||||
}
|
||||
|
@ -264,19 +268,19 @@ public class EpsGraphics {
|
|||
append(format(xmin) + " " + format(y) + " moveto", true);
|
||||
for (long x2 = (long) (xmin * COEF); x2 < (long) (xmax * COEF); x2 += (dashVisible + dashSpace)) {
|
||||
final long v;
|
||||
if (x2 + dashVisible > (long) (xmax * COEF)) {
|
||||
if (x2 + dashVisible > (long) (xmax * COEF))
|
||||
v = x2 - (long) (xmax * COEF);
|
||||
} else {
|
||||
else
|
||||
v = dashSpace;
|
||||
}
|
||||
|
||||
append("" + v + " 0 rlineto", true);
|
||||
append("" + dashSpace + " 0 rmoveto", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void epsPath(double x, double y, UPath path) {
|
||||
final public void epsPath(double x, double y, UPath path) {
|
||||
checkCloseDone();
|
||||
if (mustApplyFillColor()) {
|
||||
if (isNull(fillcolor) == false) {
|
||||
appendColor(fillcolor);
|
||||
append("newpath", true);
|
||||
for (USegment seg : path) {
|
||||
|
@ -301,7 +305,7 @@ public class EpsGraphics {
|
|||
append("closepath eofill", true);
|
||||
}
|
||||
|
||||
if (color != null) {
|
||||
if (isNull(color) == false) {
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
append("newpath", true);
|
||||
|
@ -329,35 +333,31 @@ public class EpsGraphics {
|
|||
|
||||
}
|
||||
|
||||
private boolean mustApplyFillColor() {
|
||||
if (fillcolor == null)
|
||||
return false;
|
||||
if (fillcolor.getAlpha() == 0)
|
||||
return false;
|
||||
return true;
|
||||
private final boolean isNull(Color c) {
|
||||
return c == null || c.getAlpha() == 0;
|
||||
}
|
||||
|
||||
public void epsPolygon(HColorGradient gr, ColorMapper mapper, double... points) {
|
||||
final public void epsPolygon(HColorGradient gr, ColorMapper mapper, double... points) {
|
||||
assert points.length % 2 == 0;
|
||||
setFillColor(mapper.toColor(gr.getColor1()));
|
||||
epsPolygon(points);
|
||||
}
|
||||
|
||||
public void epsPolygon(double... points) {
|
||||
final public void epsPolygon(double... points) {
|
||||
assert points.length % 2 == 0;
|
||||
checkCloseDone();
|
||||
double lastX = 0;
|
||||
double lastY = 0;
|
||||
if (mustApplyFillColor()) {
|
||||
if (isNull(fillcolor) == false) {
|
||||
appendColor(fillcolor);
|
||||
append("newpath", true);
|
||||
for (int i = 0; i < points.length; i += 2) {
|
||||
ensureVisible(points[i], points[i + 1]);
|
||||
if (i == 0) {
|
||||
if (i == 0)
|
||||
append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
|
||||
} else {
|
||||
else
|
||||
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
|
||||
}
|
||||
|
||||
lastX = points[i];
|
||||
lastY = points[i + 1];
|
||||
}
|
||||
|
@ -365,17 +365,17 @@ public class EpsGraphics {
|
|||
append("closepath eofill", true);
|
||||
}
|
||||
|
||||
if (color != null) {
|
||||
if (isNull(color) == false) {
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
append("newpath", true);
|
||||
for (int i = 0; i < points.length; i += 2) {
|
||||
ensureVisible(points[i], points[i + 1]);
|
||||
if (i == 0) {
|
||||
if (i == 0)
|
||||
append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
|
||||
} else {
|
||||
else
|
||||
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
|
||||
}
|
||||
|
||||
lastX = points[i];
|
||||
lastY = points[i + 1];
|
||||
}
|
||||
|
@ -385,33 +385,33 @@ public class EpsGraphics {
|
|||
|
||||
}
|
||||
|
||||
public void epsRectangle(double x, double y, double width, double height, double rx, double ry) {
|
||||
final public void epsRectangle(double x, double y, double width, double height, double rx, double ry) {
|
||||
checkCloseDone();
|
||||
ensureVisible(x, y);
|
||||
ensureVisible(x + width, y + height);
|
||||
if (mustApplyFillColor()) {
|
||||
if (isNull(fillcolor) == false) {
|
||||
appendColor(fillcolor);
|
||||
epsRectangleInternal(x, y, width, height, rx, ry, true);
|
||||
append("closepath eofill", true);
|
||||
if (isDashed3()) {
|
||||
if (isDashed3())
|
||||
append("[] 0 setdash", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (color != null) {
|
||||
if (isNull(color) == false) {
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
epsRectangleInternal(x, y, width, height, rx, ry, false);
|
||||
append("closepath stroke", true);
|
||||
if (isDashed3()) {
|
||||
if (isDashed3())
|
||||
append("[] 0 setdash", true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void epsRectangle(double x, double y, double width, double height, double rx, double ry, HColorGradient gr,
|
||||
ColorMapper mapper) {
|
||||
final public void epsRectangle(double x, double y, double width, double height, double rx, double ry,
|
||||
HColorGradient gr, ColorMapper mapper) {
|
||||
if (isNull(color))
|
||||
throw new IllegalStateException();
|
||||
checkCloseDone();
|
||||
ensureVisible(x, y);
|
||||
ensureVisible(x + width, y + height);
|
||||
|
@ -469,17 +469,17 @@ public class EpsGraphics {
|
|||
|
||||
private void epsRectangleInternal(double x, double y, double width, double height, double rx, double ry,
|
||||
boolean fill) {
|
||||
if (rx == 0 && ry == 0) {
|
||||
if (rx == 0 && ry == 0)
|
||||
simpleRectangle(x, y, width, height, fill);
|
||||
} else {
|
||||
else
|
||||
roundRectangle(x, y, width, height, rx, ry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void roundRectangle(double x, double y, double width, double height, double rx, double ry) {
|
||||
if (isDashed3()) {
|
||||
if (isDashed3())
|
||||
append("[" + dashSpace + " " + dashVisible + "] 0 setdash", true);
|
||||
}
|
||||
|
||||
final double round = MathUtils.min((rx + ry) / 2, width / 2, height / 2);
|
||||
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " " + format(round)
|
||||
+ " roundrect", true);
|
||||
|
@ -487,9 +487,9 @@ public class EpsGraphics {
|
|||
}
|
||||
|
||||
private void simpleRectangle(double x, double y, double width, double height, boolean fill) {
|
||||
if (isDashed3()) {
|
||||
if (isDashed3())
|
||||
append("[" + dashSpace + " " + dashVisible + "] 0 setdash", true);
|
||||
}
|
||||
|
||||
// if (isDashed3() || fill) {
|
||||
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect", true);
|
||||
simplerectUsed = true;
|
||||
|
@ -507,7 +507,7 @@ public class EpsGraphics {
|
|||
return (int) (360.0 - counterClockwise);
|
||||
}
|
||||
|
||||
public void epsEllipse(double x, double y, double xRadius, double yRadius, double start, double extend) {
|
||||
final public void epsEllipse(double x, double y, double xRadius, double yRadius, double start, double extend) {
|
||||
checkCloseDone();
|
||||
ensureVisible(x + xRadius, y + yRadius);
|
||||
double scale = 1;
|
||||
|
@ -524,7 +524,7 @@ public class EpsGraphics {
|
|||
// append("closepath eofill", true);
|
||||
// }
|
||||
|
||||
if (color != null) {
|
||||
if (isNull(color) == false) {
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
append("newpath", true);
|
||||
|
@ -535,12 +535,12 @@ public class EpsGraphics {
|
|||
append("stroke", true);
|
||||
}
|
||||
|
||||
if (scale != 1) {
|
||||
if (scale != 1)
|
||||
append("grestore", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void epsEllipse(double x, double y, double xRadius, double yRadius) {
|
||||
final public void epsEllipse(double x, double y, double xRadius, double yRadius) {
|
||||
checkCloseDone();
|
||||
ensureVisible(x + xRadius, y + yRadius);
|
||||
double scale = 1;
|
||||
|
@ -549,14 +549,14 @@ public class EpsGraphics {
|
|||
append("gsave", true);
|
||||
append("1 " + formatSimple4(scale) + " scale", true);
|
||||
}
|
||||
if (mustApplyFillColor()) {
|
||||
if (isNull(fillcolor) == false) {
|
||||
appendColor(fillcolor);
|
||||
append("newpath", true);
|
||||
append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360 arc", true);
|
||||
append("closepath eofill", true);
|
||||
}
|
||||
|
||||
if (color != null) {
|
||||
if (isNull(color) == false) {
|
||||
append(strokeWidth + " setlinewidth", true);
|
||||
appendColor(color);
|
||||
append("newpath", true);
|
||||
|
@ -564,25 +564,25 @@ public class EpsGraphics {
|
|||
append("closepath stroke", true);
|
||||
}
|
||||
|
||||
if (scale != 1) {
|
||||
if (scale != 1)
|
||||
append("grestore", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void appendColor(Color c) {
|
||||
if (c == null) {
|
||||
final protected void appendColor(Color c) {
|
||||
if (isNull(c))
|
||||
return;
|
||||
}
|
||||
|
||||
final double r = c.getRed() / 255.0;
|
||||
final double g = c.getGreen() / 255.0;
|
||||
final double b = c.getBlue() / 255.0;
|
||||
append(formatSimple2(r) + " " + formatSimple2(g) + " " + formatSimple2(b) + " setrgbcolor", true);
|
||||
}
|
||||
|
||||
protected void appendColorShort(Color c) {
|
||||
if (c == null) {
|
||||
final protected void appendColorShort(Color c) {
|
||||
if (isNull(c))
|
||||
return;
|
||||
}
|
||||
|
||||
final double r = c.getRed() / 255.0;
|
||||
final double g = c.getGreen() / 255.0;
|
||||
final double b = c.getBlue() / 255.0;
|
||||
|
@ -590,40 +590,40 @@ public class EpsGraphics {
|
|||
}
|
||||
|
||||
static String format(double x) {
|
||||
if (x == 0) {
|
||||
if (x == 0)
|
||||
return "0";
|
||||
}
|
||||
|
||||
return Long.toString((long) (x * COEF));
|
||||
}
|
||||
|
||||
public static String formatSimple4(double x) {
|
||||
if (x == 0) {
|
||||
if (x == 0)
|
||||
return "0";
|
||||
}
|
||||
|
||||
String s = String.format(Locale.US, "%1.4f", x);
|
||||
s = s.replaceAll("(\\.\\d*?)0+$", "$1");
|
||||
if (s.endsWith(".")) {
|
||||
if (s.endsWith("."))
|
||||
s = s.substring(0, s.length() - 1);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private static String formatSimple2(double x) {
|
||||
if (x == 0) {
|
||||
if (x == 0)
|
||||
return "0";
|
||||
}
|
||||
|
||||
String s = String.format(Locale.US, "%1.2f", x);
|
||||
s = s.replaceAll("(\\.\\d*?)0+$", "$1");
|
||||
if (s.endsWith(".")) {
|
||||
if (s.endsWith("."))
|
||||
s = s.substring(0, s.length() - 1);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
protected void append(String s, boolean checkConsistence) {
|
||||
if (checkConsistence && s.indexOf(" ") != -1) {
|
||||
if (checkConsistence && s.indexOf(" ") != -1)
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
|
||||
body.append(s + BackSlash.NEWLINE);
|
||||
}
|
||||
|
||||
|
@ -683,14 +683,14 @@ public class EpsGraphics {
|
|||
|
||||
public void fill(int windingRule) {
|
||||
append("%fill", true);
|
||||
if (windingRule == PathIterator.WIND_EVEN_ODD) {
|
||||
if (windingRule == PathIterator.WIND_EVEN_ODD)
|
||||
append("eofill", true);
|
||||
} else if (windingRule == PathIterator.WIND_NON_ZERO) {
|
||||
else if (windingRule == PathIterator.WIND_NON_ZERO)
|
||||
append("fill", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawImage(BufferedImage image, double x, double y) {
|
||||
final public void drawImage(BufferedImage image, double x, double y) {
|
||||
final int width = image.getWidth();
|
||||
final int height = image.getHeight();
|
||||
append("gsave", true);
|
||||
|
@ -700,13 +700,13 @@ public class EpsGraphics {
|
|||
// append("" + width + " " + height + " 8 [0 0 0 0 0 0]");
|
||||
append("{<", true);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int j = height - 1; j >= 0; j--) {
|
||||
for (int j = height - 1; j >= 0; j--)
|
||||
for (int i = 0; i < width; i++) {
|
||||
final String hexString = getRgb(image.getRGB(i, j));
|
||||
assert hexString.length() == 6;
|
||||
sb.append(hexString);
|
||||
}
|
||||
}
|
||||
|
||||
append(sb.toString(), true);
|
||||
// append(">} image");
|
||||
append(">} false 3 colorimage", true);
|
||||
|
@ -719,12 +719,12 @@ public class EpsGraphics {
|
|||
return s.substring(s.length() - 6);
|
||||
}
|
||||
|
||||
public void drawEps(String eps, double x, double y) {
|
||||
final public void drawEps(String eps, double x, double y) {
|
||||
|
||||
final int idx = eps.indexOf("%%BoundingBox:");
|
||||
if (idx == -1) {
|
||||
if (idx == -1)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(eps.substring(idx + "%%BoundingBox:".length()), " \n\t\r");
|
||||
final int x1 = Integer.parseInt(st.nextToken());
|
||||
final int y1 = Integer.parseInt(st.nextToken());
|
||||
|
@ -763,24 +763,24 @@ public class EpsGraphics {
|
|||
}
|
||||
|
||||
void ensureVisible(int x, int y) {
|
||||
if (x < xmin) {
|
||||
if (x < xmin)
|
||||
xmin = x;
|
||||
}
|
||||
if (x > xmax) {
|
||||
|
||||
if (x > xmax)
|
||||
xmax = x;
|
||||
}
|
||||
if (y < ymin) {
|
||||
|
||||
if (y < ymin)
|
||||
ymin = y;
|
||||
}
|
||||
if (y > ymax) {
|
||||
|
||||
if (y > ymax)
|
||||
ymax = y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private UrlArea urlArea;
|
||||
|
||||
public void closeLink() {
|
||||
final public void closeLink() {
|
||||
if (urlArea != null && urlArea.xmin != Integer.MAX_VALUE) {
|
||||
final int width = urlArea.xmax - urlArea.xmin;
|
||||
final int height = urlArea.ymax - urlArea.ymin;
|
||||
|
@ -790,7 +790,7 @@ public class EpsGraphics {
|
|||
this.urlArea = null;
|
||||
}
|
||||
|
||||
public void epsUrlLink(int x, int y, int width, int height, String url) {
|
||||
final public void epsUrlLink(int x, int y, int width, int height, String url) {
|
||||
append("[ /Rect [ " + x + " " + y + " " + (x + width) + " " + (y + height) + " ]", true);
|
||||
append("/Border [ 0 0 0 ]", true);
|
||||
append("/Action << /Subtype /URI /URI (" + url + ") >>", true);
|
||||
|
@ -798,7 +798,7 @@ public class EpsGraphics {
|
|||
append("/ANN pdfmark", true);
|
||||
}
|
||||
|
||||
public void openLink(String url) {
|
||||
final public void openLink(String url) {
|
||||
// javascript: security issue
|
||||
if (SecurityUtils.ignoreThisLink(url))
|
||||
return;
|
||||
|
@ -809,7 +809,7 @@ public class EpsGraphics {
|
|||
// Shadow
|
||||
final private ShadowManager shadowManager = new ShadowManager(50, 200);
|
||||
|
||||
public void epsRectangleShadow(double x, double y, double width, double height, double rx, double ry,
|
||||
final public void epsRectangleShadow(double x, double y, double width, double height, double rx, double ry,
|
||||
double deltaShadow) {
|
||||
setStrokeColor(null);
|
||||
for (double i = 0; i <= deltaShadow; i += 0.5) {
|
||||
|
@ -820,7 +820,7 @@ public class EpsGraphics {
|
|||
}
|
||||
}
|
||||
|
||||
public void epsPolygonShadow(double deltaShadow, double... points) {
|
||||
final public void epsPolygonShadow(double deltaShadow, double... points) {
|
||||
assert points.length % 2 == 0;
|
||||
setStrokeColor(null);
|
||||
for (double i = 0; i <= deltaShadow; i += 0.5) {
|
||||
|
@ -830,7 +830,7 @@ public class EpsGraphics {
|
|||
}
|
||||
}
|
||||
|
||||
public void epsEllipseShadow(double x, double y, double xRadius, double yRadius, double deltaShadow) {
|
||||
final public void epsEllipseShadow(double x, double y, double xRadius, double yRadius, double deltaShadow) {
|
||||
setStrokeColor(null);
|
||||
for (double i = 0; i <= deltaShadow; i += 0.5) {
|
||||
setFillColor(shadowManager.getColor(i, deltaShadow));
|
||||
|
|
|
@ -51,9 +51,9 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
|
||||
@Override
|
||||
protected void append(String s, boolean checkConsistence) {
|
||||
if (checkConsistence && s.indexOf(" ") != -1) {
|
||||
if (checkConsistence && s.indexOf(" ") != -1)
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
|
||||
data.add(new PostScriptCommandRaw(s, checkConsistence));
|
||||
}
|
||||
|
||||
|
@ -90,14 +90,14 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
|
||||
@Override
|
||||
public void fill(int windingRule) {
|
||||
if (macroInProgress != null) {
|
||||
if (macroInProgress != null)
|
||||
closeMacro();
|
||||
}
|
||||
if (windingRule == PathIterator.WIND_EVEN_ODD) {
|
||||
|
||||
if (windingRule == PathIterator.WIND_EVEN_ODD)
|
||||
append("eofill", true);
|
||||
} else if (windingRule == PathIterator.WIND_NON_ZERO) {
|
||||
else if (windingRule == PathIterator.WIND_NON_ZERO)
|
||||
append("fill", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private PostScriptCommandMacro macroInProgress = null;
|
||||
|
@ -143,9 +143,9 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
}
|
||||
|
||||
private void openMacro() {
|
||||
if (macroInProgress != null) {
|
||||
if (macroInProgress != null)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
macroInProgress = new PostScriptCommandMacro(macroName());
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,9 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
}
|
||||
|
||||
private void closeMacro() {
|
||||
if (macroInProgress == null) {
|
||||
if (macroInProgress == null)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final String existingName = macros.get(macroInProgress);
|
||||
if (existingName == null) {
|
||||
macros.put(macroInProgress, macroInProgress.getName());
|
||||
|
@ -183,9 +183,9 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
append("0 " + getDashVisible() + " rlineto", true);
|
||||
append("0 " + getDashSpace() + " rmoveto", true);
|
||||
append("} repeat", true);
|
||||
if (v > 0) {
|
||||
if (v > 0)
|
||||
append("0 " + v + " rlineto", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,9 +203,9 @@ public class EpsGraphicsMacro extends EpsGraphics {
|
|||
append("" + getDashVisible() + " 0 rlineto", true);
|
||||
append("" + getDashSpace() + " 0 rmoveto", true);
|
||||
append("} repeat", true);
|
||||
if (v > 0) {
|
||||
if (v > 0)
|
||||
append(v + " 0 rlineto", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.UFont;
|
|||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorScheme;
|
||||
|
||||
public class CircledCharacter extends AbstractTextBlock implements TextBlock {
|
||||
|
||||
|
@ -60,10 +59,7 @@ public class CircledCharacter extends AbstractTextBlock implements TextBlock {
|
|||
this.font = font;
|
||||
this.spotBackColor = spotBackColor;
|
||||
this.spotBorder = spotBorder;
|
||||
if (fontColor instanceof HColorScheme)
|
||||
this.fontColor = ((HColorScheme) fontColor).getAppropriateColor(spotBackColor);
|
||||
else
|
||||
this.fontColor = fontColor;
|
||||
this.fontColor = fontColor.getAppropriateColor(spotBackColor);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
@ -85,27 +81,6 @@ public class CircledCharacter extends AbstractTextBlock implements TextBlock {
|
|||
return 2 * radius;
|
||||
}
|
||||
|
||||
// private PathIterator getPathIteratorCharacter(FontRenderContext frc) {
|
||||
// final TextLayout textLayout = new TextLayout(c, font.getFont(), frc);
|
||||
// final Shape s = textLayout.getOutline(null);
|
||||
// return s.getPathIterator(null);
|
||||
// }
|
||||
//
|
||||
// private UPath getUPath(FontRenderContext frc) {
|
||||
// final UPath result = new UPath();
|
||||
//
|
||||
// final PathIterator path = getPathIteratorCharacter(frc);
|
||||
//
|
||||
// final double coord[] = new double[6];
|
||||
// while (path.isDone() == false) {
|
||||
// final int code = path.currentSegment(coord);
|
||||
// result.add(coord, USegmentType.getByCode(code));
|
||||
// path.next();
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public XDimension2D calculateDimension(StringBounder stringBounder) {
|
||||
return new XDimension2D(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder));
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.sourceforge.plantuml.ugraphic.UImage;
|
|||
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class TextBlockVertical2 extends AbstractTextBlock implements TextBlock, WithPorts {
|
||||
|
||||
|
@ -101,7 +102,7 @@ public class TextBlockVertical2 extends AbstractTextBlock implements TextBlock,
|
|||
final XDimension2D dimb = block.calculateDimension(ug.getStringBounder());
|
||||
if (block instanceof TextBlockBackcolored) {
|
||||
final HColor back = ((TextBlockBackcolored) block).getBackcolor();
|
||||
if (back != null)
|
||||
if (HColors.isTransparent(back) == false)
|
||||
ug.apply(UTranslate.dy(y)).apply(back).apply(back.bg())
|
||||
.draw(new URectangle(dimtotal.getWidth(), dimb.getHeight()));
|
||||
|
||||
|
|
|
@ -95,7 +95,9 @@ public class PSystemJcckitFactory extends PSystemBasicFactory<PSystemJcckit> {
|
|||
private PSystemJcckit createSystem(UmlSource source) {
|
||||
final Properties p = new Properties();
|
||||
try {
|
||||
p.load(new StringReader(data.toString()));
|
||||
final String tmp = data.toString();
|
||||
final StringReader sr = new StringReader(tmp);
|
||||
p.load(sr);
|
||||
// For Java 1.5
|
||||
// p.load(new ByteArrayInputStream(data.toString().getBytes("ISO-8859-1")));
|
||||
} catch (IOException e) {
|
||||
|
@ -113,9 +115,9 @@ public class PSystemJcckitFactory extends PSystemBasicFactory<PSystemJcckit> {
|
|||
extractDimension(line);
|
||||
return createSystem(source);
|
||||
}
|
||||
if (data == null) {
|
||||
if (data == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
data.append(StringUtils.trin(line));
|
||||
data.append(BackSlash.NEWLINE);
|
||||
return createSystem(source);
|
||||
|
|
|
@ -59,6 +59,7 @@ import net.sourceforge.plantuml.ugraphic.UPath;
|
|||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class FingerImpl implements Finger, UDrawable {
|
||||
|
||||
|
@ -128,7 +129,9 @@ public class FingerImpl implements Finger, UDrawable {
|
|||
p2 = new XPoint2D(direction * (dimPhalanx.getWidth() + getX12()), stp.getY());
|
||||
|
||||
child.drawU(ug.apply(new UTranslate(p2)));
|
||||
drawLine(ug.apply(getLinkColor()).apply(getUStroke()), p1, p2);
|
||||
final HColor linkColor = getLinkColor();
|
||||
if (HColors.isTransparent(linkColor) == false)
|
||||
drawLine(ug.apply(linkColor).apply(getUStroke()), p1, p2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ import net.sourceforge.plantuml.openiconic.data.DummyIcon;
|
|||
import net.sourceforge.plantuml.security.SFile;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic;
|
||||
|
||||
public class OpenIcon {
|
||||
|
||||
|
@ -133,10 +132,7 @@ public class OpenIcon {
|
|||
public TextBlock asTextBlock(final HColor color, final double factor) {
|
||||
return new AbstractTextBlock() {
|
||||
public void drawU(UGraphic ug) {
|
||||
HColor textColor = color;
|
||||
if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null)
|
||||
textColor = ug.getParam().getBackcolor().opposite();
|
||||
|
||||
HColor textColor = color.getAppropriateColor(ug.getParam().getBackcolor());
|
||||
svgPath.drawMe(ug.apply(textColor), factor);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,7 @@ public class SvgPosition {
|
|||
}
|
||||
|
||||
public XPoint2D affine(AffineTransform at) {
|
||||
final XPoint2D tmp = new XPoint2D(getXDouble(), getYDouble());
|
||||
tmp.transform(at);
|
||||
final XPoint2D tmp = new XPoint2D(getXDouble(), getYDouble()).transform(at);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,10 +35,7 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
|
@ -46,34 +43,34 @@ import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
|||
|
||||
public class BezierUtils {
|
||||
|
||||
static public double getEndingAngle(final CubicCurve2D.Double left) {
|
||||
static public double getEndingAngle(final XCubicCurve2D left) {
|
||||
if (left.getCtrlP2().equals(left.getP2())) {
|
||||
return getAngle(left.getP1(), left.getP2());
|
||||
}
|
||||
return getAngle(left.getCtrlP2(), left.getP2());
|
||||
}
|
||||
|
||||
static public double getStartingAngle(final CubicCurve2D.Double left) {
|
||||
static public double getStartingAngle(final XCubicCurve2D left) {
|
||||
if (left.getP1().equals(left.getCtrlP1()))
|
||||
return getAngle(left.getP1(), left.getP2());
|
||||
|
||||
return getAngle(left.getP1(), left.getCtrlP1());
|
||||
}
|
||||
|
||||
static double getAngle(Point2D p1, Point2D p2) {
|
||||
static double getAngle(XPoint2D p1, XPoint2D p2) {
|
||||
if (p1.equals(p2))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
return Math.atan2(p2.getY() - p1.getY(), p2.getX() - p1.getX());
|
||||
}
|
||||
|
||||
static boolean isCutting(CubicCurve2D.Double bez, Shape shape) {
|
||||
private static boolean isCutting(XCubicCurve2D bez, XRectangle2D shape) {
|
||||
final boolean contains1 = shape.contains(bez.x1, bez.y1);
|
||||
final boolean contains2 = shape.contains(bez.x2, bez.y2);
|
||||
return contains1 ^ contains2;
|
||||
}
|
||||
|
||||
static void shorten(CubicCurve2D.Double bez, Shape shape) {
|
||||
private static void shorten(XCubicCurve2D bez, XRectangle2D shape) {
|
||||
final boolean contains1 = shape.contains(bez.x1, bez.y1);
|
||||
final boolean contains2 = shape.contains(bez.x2, bez.y2);
|
||||
if (contains1 ^ contains2 == false)
|
||||
|
@ -83,8 +80,8 @@ public class BezierUtils {
|
|||
bez.setCurve(bez.x2, bez.y2, bez.ctrlx2, bez.ctrly2, bez.ctrlx1, bez.ctrly1, bez.x1, bez.y1);
|
||||
|
||||
assert shape.contains(bez.x1, bez.y1) && shape.contains(bez.x2, bez.y2) == false;
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D left = new XCubicCurve2D();
|
||||
final XCubicCurve2D right = new XCubicCurve2D();
|
||||
subdivide(bez, left, right, 0.5);
|
||||
|
||||
if (isCutting(left, shape) ^ isCutting(right, shape) == false)
|
||||
|
@ -97,7 +94,7 @@ public class BezierUtils {
|
|||
|
||||
}
|
||||
|
||||
private static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right, final double coef) {
|
||||
private static void subdivide(XCubicCurve2D src, XCubicCurve2D left, XCubicCurve2D right, final double coef) {
|
||||
final double coef1 = coef;
|
||||
final double coef2 = 1 - coef;
|
||||
final double centerxA = src.getCtrlX1() * coef1 + src.getCtrlX2() * coef2;
|
||||
|
@ -122,7 +119,7 @@ public class BezierUtils {
|
|||
right.setCurve(centerxB, centeryB, ctrlx21, ctrly21, ctrlx2, ctrly2, x2, y2);
|
||||
}
|
||||
|
||||
static double dist(CubicCurve2D.Double seg) {
|
||||
static double dist(XCubicCurve2D seg) {
|
||||
return XPoint2D.distance(seg.x1, seg.y1, seg.x2, seg.y2);
|
||||
}
|
||||
|
||||
|
@ -138,8 +135,8 @@ public class BezierUtils {
|
|||
return new XPoint2D((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
|
||||
}
|
||||
|
||||
public static XPoint2D intersect(XLine2D orig, Shape shape) {
|
||||
final XLine2D copy = new XLine2D(orig.x1, orig.y1, orig.x2, orig.y2);
|
||||
public static XPoint2D intersect(XLine2D orig, XRectangle2D shape) {
|
||||
XLine2D copy = new XLine2D(orig.x1, orig.y1, orig.x2, orig.y2);
|
||||
final boolean contains1 = shape.contains(copy.x1, copy.y1);
|
||||
final boolean contains2 = shape.contains(copy.x2, copy.y2);
|
||||
if (contains1 ^ contains2 == false) {
|
||||
|
@ -147,22 +144,19 @@ public class BezierUtils {
|
|||
throw new IllegalArgumentException();
|
||||
}
|
||||
while (true) {
|
||||
final double mx = (copy.x1 + copy.x2) / 2;
|
||||
final double my = (copy.y1 + copy.y2) / 2;
|
||||
final boolean containsMiddle = shape.contains(mx, my);
|
||||
if (contains1 == containsMiddle) {
|
||||
copy.x1 = mx;
|
||||
copy.y1 = my;
|
||||
} else {
|
||||
copy.x2 = mx;
|
||||
copy.y2 = my;
|
||||
}
|
||||
final XPoint2D m = copy.getMiddle();
|
||||
final boolean containsMiddle = shape.contains(m.x, m.y);
|
||||
if (contains1 == containsMiddle)
|
||||
copy = copy.withPoint1(m);
|
||||
else
|
||||
copy = copy.withPoint2(m);
|
||||
|
||||
if (dist(copy) < 0.1) {
|
||||
if (contains1)
|
||||
return new XPoint2D(copy.x2, copy.y2);
|
||||
return copy.getP2();
|
||||
|
||||
if (contains2)
|
||||
return new XPoint2D(copy.x1, copy.y1);
|
||||
return copy.getP1();
|
||||
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/* ========================================================================
|
||||
* 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.posimo;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
|
||||
public interface Decor {
|
||||
|
||||
void drawDecor(UGraphic ug, Point2D start, double direction);
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/* ========================================================================
|
||||
* 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.posimo;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkStyle;
|
||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class DecorInterfaceProvider implements Decor {
|
||||
|
||||
private final double radius = 5;
|
||||
private final double radius2 = 9;
|
||||
private final LinkStyle style;
|
||||
|
||||
// private final double distanceCircle = 16;
|
||||
|
||||
public DecorInterfaceProvider(LinkStyle style) {
|
||||
// if (style != LinkStyle.__toremove_INTERFACE_PROVIDER && style != LinkStyle.__toremove_INTERFACE_USER) {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public void drawDecor(UGraphic ug, Point2D start, double direction) {
|
||||
final double cornerX = start.getX() - radius;
|
||||
final double cornerY = start.getY() - radius;
|
||||
final double cornerX2 = start.getX() - radius2 - 0 * Math.sin(direction * Math.PI / 180.0);
|
||||
final double cornerY2 = start.getY() - radius2 - 0 * Math.cos(direction * Math.PI / 180.0);
|
||||
|
||||
// if (style == LinkStyle.__toremove_INTERFACE_USER) {
|
||||
// direction += 180;
|
||||
// }
|
||||
if (direction >= 360) {
|
||||
direction -= 360;
|
||||
}
|
||||
|
||||
final UEllipse arc = new UEllipse(2 * radius2, 2 * radius2, direction + 15, 180 - 30);
|
||||
ug = ug.apply(new UStroke(1.5));
|
||||
ug.apply(new UTranslate(cornerX2, cornerY2)).draw(arc);
|
||||
ug.apply(new UTranslate(cornerX, cornerY)).draw(new UEllipse(2 * radius, 2 * radius));
|
||||
}
|
||||
|
||||
}
|
|
@ -37,31 +37,26 @@
|
|||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.EnsureVisible;
|
||||
import net.sourceforge.plantuml.asciiart.BasicCharArea;
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.eps.EpsGraphics;
|
||||
import net.sourceforge.plantuml.svek.Cluster;
|
||||
import net.sourceforge.plantuml.svek.ClusterPosition;
|
||||
import net.sourceforge.plantuml.svek.MinFinder;
|
||||
import net.sourceforge.plantuml.svek.PointAndAngle;
|
||||
import net.sourceforge.plantuml.svek.PointDirected;
|
||||
import net.sourceforge.plantuml.svek.SvgResult;
|
||||
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||
|
@ -94,19 +89,19 @@ public class DotPath implements UShape, Moveable {
|
|||
// }
|
||||
}
|
||||
|
||||
private final List<CubicCurve2D.Double> beziers = new ArrayList<>();
|
||||
private final List<XCubicCurve2D> beziers = new ArrayList<>();
|
||||
private String comment;
|
||||
private String codeLine;
|
||||
|
||||
public DotPath copy() {
|
||||
final DotPath result = new DotPath();
|
||||
for (CubicCurve2D.Double c : this.beziers)
|
||||
result.beziers.add(new CubicCurve2D.Double(c.x1, c.y1, c.ctrlx1, c.ctrly1, c.ctrlx2, c.ctrly2, c.x2, c.y2));
|
||||
for (XCubicCurve2D c : this.beziers)
|
||||
result.beziers.add(new XCubicCurve2D(c.x1, c.y1, c.ctrlx1, c.ctrly1, c.ctrlx2, c.ctrly2, c.x2, c.y2));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DotPath fromBeziers(List<CubicCurve2D.Double> beziers) {
|
||||
private static DotPath fromBeziers(List<XCubicCurve2D> beziers) {
|
||||
final DotPath result = new DotPath();
|
||||
result.beziers.addAll(Objects.requireNonNull(beziers));
|
||||
return result;
|
||||
|
@ -135,7 +130,7 @@ public class DotPath implements UShape, Moveable {
|
|||
double x = start.getX();
|
||||
double y = start.getY();
|
||||
for (TriPoints p : triPoints) {
|
||||
final CubicCurve2D.Double bezier = new CubicCurve2D.Double(x, y, p.x1, p.y1, p.x2, p.y2, p.x, p.y);
|
||||
final XCubicCurve2D bezier = new XCubicCurve2D(x, y, p.x1, p.y1, p.x2, p.y2, p.x, p.y);
|
||||
beziers.add(bezier);
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
|
@ -144,24 +139,18 @@ public class DotPath implements UShape, Moveable {
|
|||
}
|
||||
|
||||
public DotPath addCurve(XPoint2D pt1, XPoint2D pt2, XPoint2D pt3, XPoint2D pt4) {
|
||||
final List<CubicCurve2D.Double> beziersNew = new ArrayList<>(beziers);
|
||||
beziersNew.add(new CubicCurve2D.Double(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), pt3.getX(), pt3.getY(),
|
||||
final List<XCubicCurve2D> beziersNew = new ArrayList<>(beziers);
|
||||
beziersNew.add(new XCubicCurve2D(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), pt3.getX(), pt3.getY(),
|
||||
pt4.getX(), pt4.getY()));
|
||||
return fromBeziers(beziersNew);
|
||||
}
|
||||
|
||||
public DotPath addCurve(XPoint2D pt2, XPoint2D pt3, XPoint2D pt4) {
|
||||
final CubicCurve2D.Double last = beziers.get(beziers.size() - 1);
|
||||
final XPoint2D p1 = new XPoint2D(last.getP2());
|
||||
final XCubicCurve2D last = beziers.get(beziers.size() - 1);
|
||||
final XPoint2D p1 = last.getP2();
|
||||
return addCurve(p1, pt2, pt3, pt4);
|
||||
}
|
||||
|
||||
private XPoint2D mirror(Point2D center, Point2D pt) {
|
||||
final double x = 2 * center.getX() - pt.getX();
|
||||
final double y = 2 * center.getY() - pt.getY();
|
||||
return new XPoint2D(x, y);
|
||||
}
|
||||
|
||||
public static boolean isPathConsistent(String init) {
|
||||
if (init.startsWith("M") == false)
|
||||
return false;
|
||||
|
@ -172,23 +161,23 @@ public class DotPath implements UShape, Moveable {
|
|||
// private final String print;
|
||||
|
||||
public XPoint2D getStartPoint() {
|
||||
return new XPoint2D(beziers.get(0).getP1());
|
||||
return beziers.get(0).getP1();
|
||||
}
|
||||
|
||||
public Set<XPoint2D> sample() {
|
||||
final Set<XPoint2D> result = new HashSet<>();
|
||||
for (CubicCurve2D.Double bez : beziers)
|
||||
for (XCubicCurve2D bez : beziers)
|
||||
sample(bez, result);
|
||||
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
|
||||
private static void sample(CubicCurve2D bez, Set<XPoint2D> result) {
|
||||
final XPoint2D p1 = new XPoint2D(bez.getCtrlP1());
|
||||
final XPoint2D p2 = new XPoint2D(bez.getCtrlP2());
|
||||
private static void sample(XCubicCurve2D bez, Set<XPoint2D> result) {
|
||||
final XPoint2D p1 = bez.getCtrlP1();
|
||||
final XPoint2D p2 = bez.getCtrlP2();
|
||||
if (bez.getFlatnessSq() > 0.5 || p1.distance(p2) > 4) {
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D left = new XCubicCurve2D();
|
||||
final XCubicCurve2D right = new XCubicCurve2D();
|
||||
bez.subdivide(left, right);
|
||||
sample(left, result);
|
||||
sample(right, result);
|
||||
|
@ -201,14 +190,14 @@ public class DotPath implements UShape, Moveable {
|
|||
public PointAndAngle getMiddle() {
|
||||
XPoint2D result = null;
|
||||
double angle = 0;
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
final XCubicCurve2D left = new XCubicCurve2D();
|
||||
final XCubicCurve2D right = new XCubicCurve2D();
|
||||
bez.subdivide(left, right);
|
||||
final XPoint2D p1 = new XPoint2D(left.getP1());
|
||||
final XPoint2D p2 = new XPoint2D(left.getP2());
|
||||
final XPoint2D p3 = new XPoint2D(right.getP1());
|
||||
final XPoint2D p4 = new XPoint2D(right.getP2());
|
||||
final XPoint2D p1 = left.getP1();
|
||||
final XPoint2D p2 = left.getP2();
|
||||
final XPoint2D p3 = right.getP1();
|
||||
final XPoint2D p4 = right.getP2();
|
||||
if (result == null || getCost(p1) < getCost(result)) {
|
||||
result = p1;
|
||||
angle = BezierUtils.getStartingAngle(left);
|
||||
|
@ -241,7 +230,7 @@ public class DotPath implements UShape, Moveable {
|
|||
beziers.get(0).ctrlx1 = x;
|
||||
beziers.get(0).ctrly1 = y;
|
||||
}
|
||||
|
||||
|
||||
public void moveStartPoint(double dx, double dy) {
|
||||
beziers.get(0).x1 += dx;
|
||||
beziers.get(0).y1 += dy;
|
||||
|
@ -249,9 +238,8 @@ public class DotPath implements UShape, Moveable {
|
|||
beziers.get(0).ctrly1 += dy;
|
||||
}
|
||||
|
||||
|
||||
public XPoint2D getEndPoint() {
|
||||
return new XPoint2D(beziers.get(beziers.size() - 1).getP2());
|
||||
return beziers.get(beziers.size() - 1).getP2();
|
||||
}
|
||||
|
||||
public void forceEndPoint(double x, double y) {
|
||||
|
@ -270,7 +258,7 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
public MinFinder getMinFinder() {
|
||||
final MinFinder result = new MinFinder();
|
||||
for (CubicCurve2D.Double c : beziers) {
|
||||
for (XCubicCurve2D c : beziers) {
|
||||
result.manage(c.x1, c.y1);
|
||||
result.manage(c.x2, c.y2);
|
||||
result.manage(c.ctrlx1, c.ctrly1);
|
||||
|
@ -281,7 +269,7 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
public MinMax getMinMax() {
|
||||
MinMax result = MinMax.getEmpty(false);
|
||||
for (CubicCurve2D.Double c : beziers) {
|
||||
for (XCubicCurve2D c : beziers) {
|
||||
result = result.addPoint(c.x1, c.y1);
|
||||
result = result.addPoint(c.x2, c.y2);
|
||||
result = result.addPoint(c.ctrlx1, c.ctrly1);
|
||||
|
@ -292,7 +280,7 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
public double getMinDist(XPoint2D ref) {
|
||||
double result = Double.MAX_VALUE;
|
||||
for (CubicCurve2D.Double c : beziers) {
|
||||
for (XCubicCurve2D c : beziers) {
|
||||
final double d1 = ref.distance(c.x1, c.y1);
|
||||
if (d1 < result) {
|
||||
result = d1;
|
||||
|
@ -315,7 +303,7 @@ public class DotPath implements UShape, Moveable {
|
|||
}
|
||||
|
||||
public Line2D getEndTangeante() {
|
||||
final CubicCurve2D.Double last = beziers.get(beziers.size() - 1);
|
||||
final XCubicCurve2D last = beziers.get(beziers.size() - 1);
|
||||
double dx = last.x2 - last.ctrlx2;
|
||||
double dy = last.y2 - last.ctrly2;
|
||||
if (dx == 0 && dy == 0) {
|
||||
|
@ -338,7 +326,7 @@ public class DotPath implements UShape, Moveable {
|
|||
}
|
||||
|
||||
public Line2D getStartTangeante() {
|
||||
final CubicCurve2D.Double first = beziers.get(0);
|
||||
final XCubicCurve2D first = beziers.get(0);
|
||||
double dx = first.ctrlx1 - first.x1;
|
||||
double dy = first.ctrly1 - first.y1;
|
||||
if (dx == 0 && dy == 0) {
|
||||
|
@ -348,66 +336,42 @@ public class DotPath implements UShape, Moveable {
|
|||
return new Line2D.Double(first.x1, first.y1, first.x1 + dx, first.y1 + dy);
|
||||
}
|
||||
|
||||
public DotPath addBefore(CubicCurve2D.Double before) {
|
||||
final List<CubicCurve2D.Double> copy = new ArrayList<>(beziers);
|
||||
public DotPath addBefore(XCubicCurve2D before) {
|
||||
final List<XCubicCurve2D> copy = new ArrayList<>(beziers);
|
||||
copy.add(0, before);
|
||||
return fromBeziers(copy);
|
||||
}
|
||||
|
||||
private DotPath addBefore(DotPath other) {
|
||||
final List<CubicCurve2D.Double> copy = new ArrayList<>(beziers);
|
||||
final List<XCubicCurve2D> copy = new ArrayList<>(beziers);
|
||||
copy.addAll(0, other.beziers);
|
||||
return fromBeziers(copy);
|
||||
}
|
||||
|
||||
public DotPath addAfter(CubicCurve2D.Double after) {
|
||||
final List<CubicCurve2D.Double> copy = new ArrayList<>(beziers);
|
||||
public DotPath addAfter(XCubicCurve2D after) {
|
||||
final List<XCubicCurve2D> copy = new ArrayList<>(beziers);
|
||||
copy.add(after);
|
||||
return fromBeziers(copy);
|
||||
}
|
||||
|
||||
public DotPath addAfter(DotPath other) {
|
||||
final List<CubicCurve2D.Double> copy = new ArrayList<>(beziers);
|
||||
final List<XCubicCurve2D> copy = new ArrayList<>(beziers);
|
||||
copy.addAll(other.beziers);
|
||||
return fromBeziers(copy);
|
||||
}
|
||||
|
||||
public Map<Point2D, Double> somePoints() {
|
||||
final Map<Point2D, Double> result = new HashMap<>();
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
bez.subdivide(left, right);
|
||||
result.put(left.getP1(), BezierUtils.getStartingAngle(left));
|
||||
result.put(left.getP2(), BezierUtils.getEndingAngle(left));
|
||||
result.put(right.getP1(), BezierUtils.getStartingAngle(right));
|
||||
result.put(right.getP2(), BezierUtils.getEndingAngle(right));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private PointDirected getIntersection(ClusterPosition position) {
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
final PointDirected result = position.getIntersection(bez);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2d, double x, double y) {
|
||||
final GeneralPath p = new GeneralPath();
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2,
|
||||
y + bez.ctrly2, x + bez.x2, y + bez.y2);
|
||||
p.append(bez, true);
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
final CubicCurve2D.Double bez2 = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1,
|
||||
y + bez.ctrly1, x + bez.ctrlx2, y + bez.ctrly2, x + bez.x2, y + bez.y2);
|
||||
p.append(bez2, true);
|
||||
}
|
||||
g2d.draw(p);
|
||||
}
|
||||
|
||||
public void manageEnsureVisible(double x, double y, EnsureVisible visible) {
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
visible.ensureVisible(x + bez.x1, y + bez.y1);
|
||||
visible.ensureVisible(x + bez.x2, y + bez.y2);
|
||||
}
|
||||
|
@ -416,8 +380,8 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
public void drawOk(EpsGraphics eps, double x, double y) {
|
||||
// boolean first = true;
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2,
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
bez = new XCubicCurve2D(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2,
|
||||
y + bez.ctrly2, x + bez.x2, y + bez.y2);
|
||||
eps.epsLine(bez.x1, bez.y1, bez.x2, bez.y2);
|
||||
}
|
||||
|
@ -427,8 +391,8 @@ public class DotPath implements UShape, Moveable {
|
|||
eps.newpathDot();
|
||||
final boolean dashed = false;
|
||||
boolean first = true;
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2,
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
bez = new XCubicCurve2D(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2,
|
||||
y + bez.ctrly2, x + bez.x2, y + bez.y2);
|
||||
if (first) {
|
||||
eps.movetoNoMacro(bez.x1, bez.y1);
|
||||
|
@ -442,7 +406,7 @@ public class DotPath implements UShape, Moveable {
|
|||
public UPath toUPath() {
|
||||
final UPath result = new UPath(comment, codeLine);
|
||||
boolean start = true;
|
||||
for (CubicCurve2D.Double bez : beziers) {
|
||||
for (XCubicCurve2D bez : beziers) {
|
||||
if (start) {
|
||||
result.add(new double[] { bez.x1, bez.y1 }, USegmentType.SEG_MOVETO);
|
||||
start = false;
|
||||
|
@ -454,81 +418,8 @@ public class DotPath implements UShape, Moveable {
|
|||
return result;
|
||||
}
|
||||
|
||||
private XPoint2D getFrontierIntersection(Shape shape, Rectangle2D... notIn) {
|
||||
final List<CubicCurve2D.Double> all = new ArrayList<>(beziers);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (CubicCurve2D.Double immutable : all) {
|
||||
if (contains(immutable, notIn))
|
||||
continue;
|
||||
|
||||
final CubicCurve2D.Double bez = new CubicCurve2D.Double();
|
||||
bez.setCurve(immutable);
|
||||
if (BezierUtils.isCutting(bez, shape)) {
|
||||
while (BezierUtils.dist(bez) > 1.0)
|
||||
BezierUtils.shorten(bez, shape);
|
||||
|
||||
final XPoint2D result = new XPoint2D((bez.x1 + bez.x2) / 2, (bez.y1 + bez.y2) / 2);
|
||||
if (contains(result, notIn) == false)
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
cutAllCubic(all);
|
||||
}
|
||||
throw new IllegalArgumentException("shape=" + shape);
|
||||
}
|
||||
|
||||
private void cutAllCubic(List<CubicCurve2D.Double> all) {
|
||||
final List<CubicCurve2D.Double> tmp = new ArrayList<>(all);
|
||||
all.clear();
|
||||
for (CubicCurve2D.Double bez : tmp) {
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
bez.subdivide(left, right);
|
||||
all.add(left);
|
||||
all.add(right);
|
||||
}
|
||||
}
|
||||
|
||||
static private boolean contains(XPoint2D point, Rectangle2D... rects) {
|
||||
for (Rectangle2D r : rects)
|
||||
if (r.contains(point.toLegacy()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static private boolean contains(CubicCurve2D.Double cubic, Rectangle2D... rects) {
|
||||
for (Rectangle2D r : rects)
|
||||
if (r.contains(cubic.getP1()) && r.contains(cubic.getP2()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private DotPath manageRect(Rectangle2D start, Rectangle2D end) {
|
||||
final List<CubicCurve2D.Double> list = new ArrayList<>(this.beziers);
|
||||
while (true) {
|
||||
if (BezierUtils.isCutting(list.get(0), start) == false)
|
||||
throw new IllegalStateException();
|
||||
|
||||
if (BezierUtils.dist(list.get(0)) <= 1.0)
|
||||
break;
|
||||
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
list.get(0).subdivide(left, right);
|
||||
list.set(0, left);
|
||||
list.add(1, right);
|
||||
if (BezierUtils.isCutting(list.get(1), start))
|
||||
list.remove(0);
|
||||
|
||||
}
|
||||
return fromBeziers(list);
|
||||
}
|
||||
|
||||
public void draw(BasicCharArea area, double pixelXPerChar, double pixelYPerChar) {
|
||||
for (CubicCurve2D.Double bez : beziers)
|
||||
for (XCubicCurve2D bez : beziers)
|
||||
if (bez.x1 == bez.x2)
|
||||
area.drawVLine('|', (int) (bez.x1 / pixelXPerChar), (int) (bez.y1 / pixelYPerChar),
|
||||
(int) (bez.y2 / pixelYPerChar));
|
||||
|
@ -538,7 +429,7 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
}
|
||||
|
||||
static String toString(CubicCurve2D.Double c) {
|
||||
static String toString(XCubicCurve2D c) {
|
||||
return "(" + c.x1 + "," + c.y1 + ") " + "(" + c.ctrlx1 + "," + c.ctrly1 + ") " + "(" + c.ctrlx2 + "," + c.ctrly2
|
||||
+ ") " + "(" + c.x2 + "," + c.y2 + ") ";
|
||||
|
||||
|
@ -547,23 +438,23 @@ public class DotPath implements UShape, Moveable {
|
|||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (CubicCurve2D.Double c : beziers) {
|
||||
for (XCubicCurve2D c : beziers) {
|
||||
sb.append(toString(c));
|
||||
sb.append(" - ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static CubicCurve2D.Double reverse(CubicCurve2D curv) {
|
||||
return new CubicCurve2D.Double(curv.getX2(), curv.getY2(), curv.getCtrlX2(), curv.getCtrlY2(), curv.getCtrlX1(),
|
||||
public static XCubicCurve2D reverse(XCubicCurve2D curv) {
|
||||
return new XCubicCurve2D(curv.getX2(), curv.getY2(), curv.getCtrlX2(), curv.getCtrlY2(), curv.getCtrlX1(),
|
||||
curv.getCtrlY1(), curv.getX1(), curv.getY1());
|
||||
}
|
||||
|
||||
public DotPath reverse() {
|
||||
final List<CubicCurve2D.Double> reverse = new ArrayList<>(beziers);
|
||||
final List<XCubicCurve2D> reverse = new ArrayList<>(beziers);
|
||||
Collections.reverse(reverse);
|
||||
final List<CubicCurve2D.Double> copy = new ArrayList<>();
|
||||
for (CubicCurve2D.Double cub : reverse)
|
||||
final List<XCubicCurve2D> copy = new ArrayList<>();
|
||||
for (XCubicCurve2D cub : reverse)
|
||||
copy.add(reverse(cub));
|
||||
|
||||
return fromBeziers(copy);
|
||||
|
@ -572,14 +463,14 @@ public class DotPath implements UShape, Moveable {
|
|||
|
||||
public void moveSvek(double deltaX, double deltaY) {
|
||||
for (int i = 0; i < beziers.size(); i++) {
|
||||
final CubicCurve2D.Double c = beziers.get(i);
|
||||
beziers.set(i, new CubicCurve2D.Double(c.x1 + deltaX, c.y1 + deltaY, c.ctrlx1 + deltaX, c.ctrly1 + deltaY,
|
||||
final XCubicCurve2D c = beziers.get(i);
|
||||
beziers.set(i, new XCubicCurve2D(c.x1 + deltaX, c.y1 + deltaY, c.ctrlx1 + deltaX, c.ctrly1 + deltaY,
|
||||
c.ctrlx2 + deltaX, c.ctrly2 + deltaY, c.x2 + deltaX, c.y2 + deltaY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final List<CubicCurve2D.Double> getBeziers() {
|
||||
public final List<XCubicCurve2D> getBeziers() {
|
||||
return Collections.unmodifiableList(beziers);
|
||||
}
|
||||
|
||||
|
@ -599,9 +490,9 @@ public class DotPath implements UShape, Moveable {
|
|||
final DotPath result = new DotPath();
|
||||
int idx = 0;
|
||||
while (idx + 1 < this.beziers.size() && clusterPosition.contains(this.beziers.get(idx).getP2())) {
|
||||
if (clusterPosition.contains(this.beziers.get(idx).getP1()) == false) {
|
||||
if (clusterPosition.contains(this.beziers.get(idx).getP1()) == false)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
if (clusterPosition.contains(this.beziers.get(idx).getP2())) {
|
||||
|
@ -609,11 +500,11 @@ public class DotPath implements UShape, Moveable {
|
|||
} else {
|
||||
assert clusterPosition.contains(this.beziers.get(idx).getP1());
|
||||
assert clusterPosition.contains(this.beziers.get(idx).getP2()) == false;
|
||||
CubicCurve2D current = this.beziers.get(idx);
|
||||
XCubicCurve2D current = this.beziers.get(idx);
|
||||
for (int k = 0; k < 8; k++) {
|
||||
// System.err.println("length=" + length(current));
|
||||
final CubicCurve2D.Double part1 = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double part2 = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D part1 = new XCubicCurve2D();
|
||||
final XCubicCurve2D part2 = new XCubicCurve2D();
|
||||
current.subdivide(part1, part2);
|
||||
assert part1.getP2().equals(part2.getP1());
|
||||
if (clusterPosition.contains(part1.getP2())) {
|
||||
|
@ -623,9 +514,9 @@ public class DotPath implements UShape, Moveable {
|
|||
current = part1;
|
||||
}
|
||||
}
|
||||
for (int i = idx + 1; i < this.beziers.size(); i++) {
|
||||
for (int i = idx + 1; i < this.beziers.size(); i++)
|
||||
result.beziers.add(this.beziers.get(i));
|
||||
}
|
||||
|
||||
me = result;
|
||||
}
|
||||
}
|
||||
|
@ -635,7 +526,7 @@ public class DotPath implements UShape, Moveable {
|
|||
final DotPath result = new DotPath();
|
||||
final ClusterPosition clusterPosition = head.getClusterPosition();
|
||||
if (clusterPosition.contains(getEndPoint())) {
|
||||
for (CubicCurve2D.Double current : me.beziers) {
|
||||
for (XCubicCurve2D current : me.beziers) {
|
||||
if (clusterPosition.contains(current.getP2()) == false) {
|
||||
result.beziers.add(current);
|
||||
} else {
|
||||
|
@ -647,8 +538,8 @@ public class DotPath implements UShape, Moveable {
|
|||
assert clusterPosition.contains(current.getP2());
|
||||
for (int k = 0; k < 8; k++) {
|
||||
// System.err.println("length=" + length(current));
|
||||
final CubicCurve2D.Double part1 = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double part2 = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D part1 = new XCubicCurve2D();
|
||||
final XCubicCurve2D part2 = new XCubicCurve2D();
|
||||
current.subdivide(part1, part2);
|
||||
assert part1.getP2().equals(part2.getP1());
|
||||
if (clusterPosition.contains(part1.getP2())) {
|
||||
|
@ -669,16 +560,11 @@ public class DotPath implements UShape, Moveable {
|
|||
return me;
|
||||
}
|
||||
|
||||
private double length(CubicCurve2D curve) {
|
||||
return curve.getP1().distance(curve.getP2());
|
||||
}
|
||||
|
||||
public boolean isLine() {
|
||||
for (CubicCurve2D.Double curve : beziers) {
|
||||
if (curve.getFlatnessSq() > 0.001) {
|
||||
for (XCubicCurve2D curve : beziers)
|
||||
if (curve.getFlatnessSq() > 0.001)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,16 +35,15 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public class LineRectIntersection {
|
||||
|
||||
private final XPoint2D inter;
|
||||
|
||||
public LineRectIntersection(XLine2D line, Rectangle2D rect) {
|
||||
public LineRectIntersection(XLine2D line, XRectangle2D rect) {
|
||||
final XPoint2D p1 = new XPoint2D(rect.getMinX(), rect.getMinY());
|
||||
final XPoint2D p2 = new XPoint2D(rect.getMaxX(), rect.getMinY());
|
||||
final XPoint2D p3 = new XPoint2D(rect.getMaxX(), rect.getMaxY());
|
||||
|
@ -64,7 +63,7 @@ public class LineRectIntersection {
|
|||
double minDist = Double.MAX_VALUE;
|
||||
XPoint2D result = null;
|
||||
|
||||
for (XPoint2D pt : other) {
|
||||
for (XPoint2D pt : other)
|
||||
if (pt != null) {
|
||||
final double dist = pt.distanceSq(o);
|
||||
if (dist < minDist) {
|
||||
|
@ -72,7 +71,6 @@ public class LineRectIntersection {
|
|||
result = pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ package net.sourceforge.plantuml.posimo;
|
|||
import net.sourceforge.plantuml.awt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
|
||||
public class PositionableImpl implements Positionable {
|
||||
public final class PositionableImpl implements Positionable {
|
||||
|
||||
private final XPoint2D pos;
|
||||
private XPoint2D pos;
|
||||
|
||||
private final XDimension2D dim;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class PositionableImpl implements Positionable {
|
|||
}
|
||||
|
||||
public void moveSvek(double deltaX, double deltaY) {
|
||||
this.pos.setLocation(pos.getX() + deltaX, pos.getY() + deltaY);
|
||||
this.pos = this.pos.move(deltaX, deltaY);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,11 +35,10 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public interface Racorder {
|
||||
public DotPath getRacordIn(Rectangle2D rect, XLine2D tangeante);
|
||||
public DotPath getRacordOut(Rectangle2D rect, XLine2D tangeante);
|
||||
public DotPath getRacordIn(XRectangle2D rect, XLine2D tangeante);
|
||||
public DotPath getRacordOut(XRectangle2D rect, XLine2D tangeante);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,12 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public abstract class RacorderAbstract implements Racorder {
|
||||
|
||||
public final DotPath getRacordOut(Rectangle2D rect, XLine2D tangeante) {
|
||||
public final DotPath getRacordOut(XRectangle2D rect, XLine2D tangeante) {
|
||||
tangeante = symetric(tangeante);
|
||||
return getRacordIn(rect, tangeante).reverse();
|
||||
}
|
||||
|
|
|
@ -35,28 +35,19 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public class RacorderFollowTangeante extends RacorderAbstract implements Racorder {
|
||||
|
||||
@Override
|
||||
public DotPath getRacordIn(Rectangle2D rect, XLine2D tangeante) {
|
||||
|
||||
// Log.println("rect x=" + rect.getX() + " y=" + rect.getY() + " w=" + rect.getWidth() + " h="
|
||||
// + rect.getHeight());
|
||||
// Log.println("tangeante (" + tangeante.getX1() + "," + tangeante.getY1() + ") (" + tangeante.getX2()
|
||||
// + "," + tangeante.getY2() + ")");
|
||||
public DotPath getRacordIn(XRectangle2D rect, XLine2D tangeante) {
|
||||
|
||||
final DotPath result = new DotPath();
|
||||
|
||||
// final XPoint2D inter = BezierUtils.intersect((Line2D.Double)
|
||||
// tangeante, rect);
|
||||
XPoint2D inter = new LineRectIntersection(tangeante, rect).getIntersection();
|
||||
// Log.println("inter=" + inter);
|
||||
|
||||
if (inter == null) {
|
||||
final XPoint2D p1 = new XPoint2D(rect.getMinX(), rect.getMinY());
|
||||
|
@ -67,8 +58,8 @@ public class RacorderFollowTangeante extends RacorderAbstract implements Racorde
|
|||
inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
|
||||
tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
final XCubicCurve2D curv = new XCubicCurve2D(tangeante.getX1(), tangeante.getY1(), tangeante.getX1(),
|
||||
tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
return result.addAfter(curv);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,15 +35,14 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public class RacorderFollowTangeanteOld extends RacorderAbstract implements Racorder {
|
||||
|
||||
public DotPath getRacordIn(Rectangle2D rect, XLine2D tangeante) {
|
||||
public DotPath getRacordIn(XRectangle2D rect, XLine2D tangeante) {
|
||||
|
||||
final DotPath result = new DotPath();
|
||||
|
||||
|
@ -51,8 +50,8 @@ public class RacorderFollowTangeanteOld extends RacorderAbstract implements Raco
|
|||
final XLine2D line = new XLine2D(tangeante.getP1(), center);
|
||||
final XPoint2D inter = BezierUtils.intersect(line, rect);
|
||||
|
||||
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), tangeante
|
||||
.getX2(), tangeante.getY2(), tangeante.getX2(), tangeante.getY2(), inter.getX(), inter.getY());
|
||||
final XCubicCurve2D curv = new XCubicCurve2D(tangeante.getX1(), tangeante.getY1(), tangeante.getX2(),
|
||||
tangeante.getY2(), tangeante.getX2(), tangeante.getY2(), inter.getX(), inter.getY());
|
||||
return result.addAfter(curv);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,24 +35,23 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public class RacorderInToCenter extends RacorderAbstract implements Racorder {
|
||||
|
||||
@Override
|
||||
public DotPath getRacordIn(Rectangle2D rect, XLine2D tangeante) {
|
||||
public DotPath getRacordIn(XRectangle2D rect, XLine2D tangeante) {
|
||||
final DotPath result = new DotPath();
|
||||
|
||||
final XPoint2D center = new XPoint2D(rect.getCenterX(), rect.getCenterY());
|
||||
final XLine2D line = new XLine2D(tangeante.getP1(), center);
|
||||
final XPoint2D inter = BezierUtils.intersect(line, rect);
|
||||
|
||||
final CubicCurve2D.Double curv = new CubicCurve2D.Double(line.getX1(), line.getY1(), line.getX1(),
|
||||
line.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
final XCubicCurve2D curv = new XCubicCurve2D(line.getX1(), line.getY1(), line.getX1(), line.getY1(),
|
||||
inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
return result.addAfter(curv);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,16 +35,15 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XLine2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
|
||||
|
||||
public class RacorderOrthogonal extends RacorderAbstract implements Racorder {
|
||||
|
||||
@Override
|
||||
public DotPath getRacordIn(Rectangle2D rect, XLine2D tangeante) {
|
||||
public DotPath getRacordIn(XRectangle2D rect, XLine2D tangeante) {
|
||||
|
||||
final XPoint2D in = tangeante.getP1();
|
||||
|
||||
|
@ -52,21 +51,21 @@ public class RacorderOrthogonal extends RacorderAbstract implements Racorder {
|
|||
XPoint2D inter = null;
|
||||
|
||||
if (in.getX() > rect.getMinX() && in.getX() < rect.getMaxX()) {
|
||||
if (in.getY() < rect.getMinY()) {
|
||||
if (in.getY() < rect.getMinY())
|
||||
inter = new XPoint2D(in.getX(), rect.getMinY());
|
||||
} else if (in.getY() > rect.getMaxY()) {
|
||||
else if (in.getY() > rect.getMaxY())
|
||||
inter = new XPoint2D(in.getX(), rect.getMaxY());
|
||||
} else {
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
} else if (in.getY() > rect.getMinY() && in.getY() < rect.getMaxY()) {
|
||||
if (in.getX() < rect.getMinX()) {
|
||||
if (in.getX() < rect.getMinX())
|
||||
inter = new XPoint2D(rect.getMinX(), in.getY());
|
||||
} else if (in.getX() > rect.getMaxX()) {
|
||||
else if (in.getX() > rect.getMaxX())
|
||||
inter = new XPoint2D(rect.getMaxX(), in.getY());
|
||||
} else {
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
} else {
|
||||
final XPoint2D p1 = new XPoint2D(rect.getMinX(), rect.getMinY());
|
||||
final XPoint2D p2 = new XPoint2D(rect.getMaxX(), rect.getMinY());
|
||||
|
@ -77,8 +76,8 @@ public class RacorderOrthogonal extends RacorderAbstract implements Racorder {
|
|||
|
||||
}
|
||||
|
||||
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
|
||||
tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
final XCubicCurve2D curv = new XCubicCurve2D(tangeante.getX1(), tangeante.getY1(), tangeante.getX1(),
|
||||
tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
|
||||
return result.addAfter(curv);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,9 +139,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
ug = ug.apply(new UTranslate(6 - minMax.getMinX(), 6));
|
||||
}
|
||||
|
||||
for (Map.Entry<IGroup, ST_Agraph_s> ent : clusters.entrySet()) {
|
||||
for (Map.Entry<IGroup, ST_Agraph_s> ent : clusters.entrySet())
|
||||
drawGroup(ug, ymirror, ent.getKey(), ent.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<ILeaf, ST_Agnode_s> ent : nodes.entrySet()) {
|
||||
final ILeaf leaf = ent.getKey();
|
||||
|
@ -155,9 +154,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
for (Map.Entry<Link, ST_Agedge_s> ent : edges.entrySet()) {
|
||||
final Link link = ent.getKey();
|
||||
if (link.isInvis()) {
|
||||
if (link.isInvis())
|
||||
continue;
|
||||
}
|
||||
|
||||
final ST_Agedge_s edge = ent.getValue();
|
||||
new SmetanaPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1),
|
||||
getQualifier(link, 2)).drawU(ug);
|
||||
|
@ -165,9 +164,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
}
|
||||
|
||||
public XDimension2D calculateDimension(StringBounder stringBounder) {
|
||||
if (minMax == null) {
|
||||
if (minMax == null)
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
return minMax.getDimension();
|
||||
}
|
||||
|
||||
|
@ -178,9 +177,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
final double x = data.coord.x;
|
||||
final double y = data.coord.y;
|
||||
|
||||
if (ymirror == null) {
|
||||
if (ymirror == null)
|
||||
return new XPoint2D(x - width / 2, y - height / 2);
|
||||
}
|
||||
|
||||
return ymirror.getMirrored(new XPoint2D(x - width / 2, y + height / 2));
|
||||
}
|
||||
|
||||
|
@ -217,7 +216,13 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
}
|
||||
|
||||
final Cluster cluster = dotStringFactory.getBibliotekon().getCluster(group);
|
||||
cluster.setPosition(llx, lly, urx, ury);
|
||||
cluster.setPosition(new XPoint2D(llx, lly), new XPoint2D(urx, ury));
|
||||
|
||||
final XDimension2D dimTitle = cluster.getTitleDimension(ug.getStringBounder());
|
||||
if (dimTitle != null) {
|
||||
final double x = (llx + urx) / 2 - dimTitle.getWidth() / 2;
|
||||
cluster.setTitlePosition(new XPoint2D(x, lly));
|
||||
}
|
||||
JUtils.LOG2("cluster=" + cluster);
|
||||
// ug.apply(new UTranslate(llx, lly)).apply(new
|
||||
// UChangeColor(HtmlColorUtils.BLUE))
|
||||
|
@ -230,9 +235,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private void printAllSubgroups(IGroup parent) {
|
||||
for (IGroup g : diagram.getChildrenGroups(parent)) {
|
||||
if (g.isRemoved()) {
|
||||
if (g.isRemoved())
|
||||
continue;
|
||||
}
|
||||
|
||||
if (diagram.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) {
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
final EntityFactory entityFactory = diagram.getEntityFactory();
|
||||
|
@ -245,9 +250,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
}
|
||||
|
||||
private void printSingleGroup(IGroup g) {
|
||||
if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
|
||||
if (g.getGroupType() == GroupType.CONCURRENT_STATE)
|
||||
return;
|
||||
}
|
||||
|
||||
int titleAndAttributeWidth = 0;
|
||||
int titleAndAttributeHeight = 0;
|
||||
|
||||
|
@ -287,18 +292,17 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private void printEntities(Collection<ILeaf> entities) {
|
||||
for (ILeaf ent : entities) {
|
||||
if (ent.isRemoved()) {
|
||||
if (ent.isRemoved())
|
||||
continue;
|
||||
}
|
||||
|
||||
printEntity(ent);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportEntities(ST_Agraph_s g, Collection<ILeaf> entities) {
|
||||
for (ILeaf ent : entities) {
|
||||
if (ent.isRemoved()) {
|
||||
if (ent.isRemoved())
|
||||
continue;
|
||||
}
|
||||
exportEntity(g, ent);
|
||||
}
|
||||
}
|
||||
|
@ -321,9 +325,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
}
|
||||
|
||||
private void printEntity(ILeaf ent) {
|
||||
if (ent.isRemoved()) {
|
||||
if (ent.isRemoved())
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final IEntityImage image = printEntityInternal(ent);
|
||||
final SvekNode node = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(),
|
||||
stringBounder);
|
||||
|
@ -332,9 +336,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private TextBlock getTitleBlock(IGroup g) {
|
||||
final Display label = g.getDisplay();
|
||||
if (label == null) {
|
||||
if (label == null)
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
final FontConfiguration fontConfiguration = g.getFontConfigurationForTitle(skinParam);
|
||||
|
@ -343,21 +346,20 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private TextBlock getStereoBlock(IGroup g) {
|
||||
final Stereotype stereotype = g.getStereotype();
|
||||
if (stereotype == null) {
|
||||
if (stereotype == null)
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
|
||||
final TextBlock tmp = stereotype.getSprite(diagram.getSkinParam());
|
||||
if (tmp != null) {
|
||||
if (tmp != null)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
final List<String> stereos = stereotype.getLabels(diagram.getSkinParam().guillemet());
|
||||
if (stereos == null) {
|
||||
if (stereos == null)
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
|
||||
final boolean show = diagram.showPortion(EntityPortion.STEREOTYPE, g);
|
||||
if (show == false) {
|
||||
if (show == false)
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
|
||||
final FontParam fontParam = FontParam.PACKAGE_STEREOTYPE;
|
||||
return Display.create(stereos).create(FontConfiguration.create(diagram.getSkinParam(), fontParam, stereotype),
|
||||
|
@ -366,11 +368,10 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private Collection<ILeaf> getUnpackagedEntities() {
|
||||
final List<ILeaf> result = new ArrayList<>();
|
||||
for (ILeaf ent : diagram.getLeafsvalues()) {
|
||||
if (diagram.getEntityFactory().getRootGroup() == ent.getParentContainer()) {
|
||||
for (ILeaf ent : diagram.getLeafsvalues())
|
||||
if (diagram.getEntityFactory().getRootGroup() == ent.getParentContainer())
|
||||
result.add(ent);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -403,9 +404,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
private ImageData createFileLocked(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
for (ILeaf leaf : diagram.getLeafsvalues()) {
|
||||
for (ILeaf leaf : diagram.getLeafsvalues())
|
||||
printEntityNew(leaf);
|
||||
}
|
||||
|
||||
Z.open();
|
||||
try {
|
||||
|
@ -433,9 +433,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
// System.err.println("link=" + link);
|
||||
final ST_Agedge_s e = createEdge(g, link);
|
||||
// System.err.println("Agedge_s=" + e);
|
||||
if (e != null) {
|
||||
if (e != null)
|
||||
edges.put(link, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final ST_GVC_s gvc = gvContext();
|
||||
|
@ -464,9 +464,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
|
||||
private void exportGroups(ST_Agraph_s graph, IGroup parent) {
|
||||
for (IGroup g : diagram.getChildrenGroups(parent)) {
|
||||
if (g.isRemoved()) {
|
||||
if (g.isRemoved())
|
||||
continue;
|
||||
}
|
||||
|
||||
if (diagram.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) {
|
||||
final EntityFactory entityFactory = diagram.getEntityFactory();
|
||||
final ILeaf folder = entityFactory.getLeafForEmptyGroup(g);
|
||||
|
@ -503,40 +503,39 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
final FontConfiguration labelFont = FontConfiguration.create(skinParam, FontParam.ARROW, null);
|
||||
final TextBlock label = link.getLabel().create(labelFont,
|
||||
skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER), skinParam);
|
||||
if (TextBlockUtils.isEmpty(label, stringBounder)) {
|
||||
if (TextBlockUtils.isEmpty(label, stringBounder))
|
||||
return label;
|
||||
}
|
||||
|
||||
return TextBlockUtils.withMargin(label, marginLabel, marginLabel);
|
||||
}
|
||||
|
||||
private TextBlock getQualifier(Link link, int n) {
|
||||
final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2();
|
||||
if (tmp == null) {
|
||||
if (tmp == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
final double marginLabel = 1; // startUid.equals(endUid) ? 6 : 1;
|
||||
ISkinParam skinParam = diagram.getSkinParam();
|
||||
final FontConfiguration labelFont = FontConfiguration.create(skinParam, FontParam.ARROW, null);
|
||||
final TextBlock label = Display.getWithNewlines(tmp).create(labelFont,
|
||||
skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER), skinParam);
|
||||
if (TextBlockUtils.isEmpty(label, stringBounder)) {
|
||||
if (TextBlockUtils.isEmpty(label, stringBounder))
|
||||
return label;
|
||||
}
|
||||
|
||||
return TextBlockUtils.withMargin(label, marginLabel, marginLabel);
|
||||
}
|
||||
|
||||
private ST_Agnode_s getAgnodeFromLeaf(IEntity entity) {
|
||||
final ST_Agnode_s n = nodes.get(entity);
|
||||
if (n != null) {
|
||||
if (n != null)
|
||||
return n;
|
||||
}
|
||||
|
||||
try {
|
||||
final String id = getBibliotekon().getNodeUid((ILeaf) entity);
|
||||
for (Map.Entry<ILeaf, ST_Agnode_s> ent : nodes.entrySet()) {
|
||||
if (id.equals(getBibliotekon().getNodeUid(ent.getKey()))) {
|
||||
for (Map.Entry<ILeaf, ST_Agnode_s> ent : nodes.entrySet())
|
||||
if (id.equals(getBibliotekon().getNodeUid(ent.getKey())))
|
||||
return ent.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IllegalStateException e) {
|
||||
System.err.println("UNKNOWN ENTITY");
|
||||
}
|
||||
|
@ -547,12 +546,12 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
private ST_Agedge_s createEdge(final ST_Agraph_s g, Link link) {
|
||||
final ST_Agnode_s n = getAgnodeFromLeaf(link.getEntity1());
|
||||
final ST_Agnode_s m = getAgnodeFromLeaf(link.getEntity2());
|
||||
if (n == null) {
|
||||
if (n == null)
|
||||
return null;
|
||||
}
|
||||
if (m == null) {
|
||||
|
||||
if (m == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
final ST_Agedge_s e = agedge(g, n, m, null, true);
|
||||
// System.err.println("createEdge " + link);
|
||||
agsafeset(e, new CString("arrowtail"), new CString("none"), new CString(""));
|
||||
|
@ -630,9 +629,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||
}
|
||||
|
||||
private IEntityImage printEntityInternal(ILeaf ent) {
|
||||
if (ent.isRemoved()) {
|
||||
if (ent.isRemoved())
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
if (ent.getSvekImage() == null) {
|
||||
ISkinParam skinParam = diagram.getSkinParam();
|
||||
if (skinParam.sameClassWidth()) {
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.sdot;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
@ -62,14 +60,9 @@ public class YMirror {
|
|||
return new XPoint2D(pt.getX(), max - pt.getY());
|
||||
}
|
||||
|
||||
private XPoint2D getMirrored(Point2D pt) {
|
||||
// return pt;
|
||||
return new XPoint2D(pt.getX(), max - pt.getY());
|
||||
}
|
||||
|
||||
public DotPath getMirrored(DotPath path) {
|
||||
DotPath result = new DotPath();
|
||||
for (CubicCurve2D.Double bez : path.getBeziers()) {
|
||||
for (XCubicCurve2D bez : path.getBeziers()) {
|
||||
result = result.addCurve(getMirrored(bez.getP1()), getMirrored(bez.getCtrlP1()),
|
||||
getMirrored(bez.getCtrlP2()), getMirrored(bez.getP2()));
|
||||
}
|
||||
|
|
|
@ -36,13 +36,11 @@
|
|||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
|
@ -68,20 +66,20 @@ class CircleAndArrow implements UDrawable {
|
|||
this.p1 = putOnCircle(p1);
|
||||
this.p2 = putOnCircle(p2);
|
||||
|
||||
this.p3 = this.p1.getTransform(at);
|
||||
this.p3 = this.p1.transform(at);
|
||||
this.p3 = new XPoint2D(p3.getY(), -p3.getX());
|
||||
this.p3 = this.p3.getTransform(at2);
|
||||
this.p3 = this.p3.transform(at2);
|
||||
|
||||
this.p4 = this.p2.getTransform(at);
|
||||
this.p4 = this.p2.transform(at);
|
||||
this.p4 = new XPoint2D(p4.getY(), -p4.getX());
|
||||
this.p4 = this.p4.getTransform(at2);
|
||||
this.p4 = this.p4.transform(at2);
|
||||
}
|
||||
|
||||
private XPoint2D putOnCircle(XPoint2D p) {
|
||||
p = p.getTransform(at);
|
||||
p = p.transform(at);
|
||||
final double coef = p.distance(new XPoint2D()) / radius;
|
||||
p = new XPoint2D(p.getX() / coef, p.getY() / coef);
|
||||
return p.getTransform(at2);
|
||||
return p.transform(at2);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
@ -91,11 +89,4 @@ class CircleAndArrow implements UDrawable {
|
|||
// drawLine(ug, x, y, p3, p4);
|
||||
}
|
||||
|
||||
static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {
|
||||
final double dx = p2.getX() - p1.getX();
|
||||
final double dy = p2.getY() - p1.getY();
|
||||
ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,29 +113,22 @@ public class Cluster implements Moveable {
|
|||
private TextBlock ztitle;
|
||||
private TextBlock zstereo;
|
||||
|
||||
private double xTitle;
|
||||
private double yTitle;
|
||||
private XPoint2D xyTitle;
|
||||
|
||||
private XPoint2D xyNoteTop;
|
||||
private XPoint2D xyNoteBottom;
|
||||
|
||||
private double minX;
|
||||
private double minY;
|
||||
private double maxX;
|
||||
private double maxY;
|
||||
private ClusterPosition clusterPosition;
|
||||
|
||||
public void moveSvek(double deltaX, double deltaY) {
|
||||
if (this.xyNoteTop != null)
|
||||
this.xyNoteTop = this.xyNoteTop.move(deltaX, deltaY);
|
||||
if (this.xyNoteBottom != null)
|
||||
this.xyNoteBottom = this.xyNoteBottom.move(deltaX, deltaY);
|
||||
|
||||
this.xTitle += deltaX;
|
||||
this.yTitle += deltaY;
|
||||
this.minX += deltaX;
|
||||
this.minY += deltaY;
|
||||
this.maxX += deltaX;
|
||||
this.maxY += deltaY;
|
||||
if (this.xyTitle != null)
|
||||
this.xyTitle = this.xyTitle.move(deltaX, deltaY);
|
||||
if (this.clusterPosition != null)
|
||||
this.clusterPosition = this.clusterPosition.move(deltaX, deltaY);
|
||||
|
||||
}
|
||||
|
||||
|
@ -269,21 +262,12 @@ public class Cluster implements Moveable {
|
|||
return titleAndAttributeHeight;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double getMinX() {
|
||||
return minX;
|
||||
}
|
||||
|
||||
public ClusterPosition getClusterPosition() {
|
||||
return new ClusterPosition(minX, minY, maxX, maxY);
|
||||
return clusterPosition;
|
||||
}
|
||||
|
||||
public void setTitlePosition(XPoint2D pos) {
|
||||
this.xTitle = pos.getX();
|
||||
this.yTitle = pos.getY();
|
||||
this.xyTitle = pos;
|
||||
}
|
||||
|
||||
public void setNoteTopPosition(XPoint2D pos) {
|
||||
|
@ -314,11 +298,11 @@ public class Cluster implements Moveable {
|
|||
return;
|
||||
|
||||
if (diagram.getPragma().useKermor()) {
|
||||
if (xyNoteTop != null)
|
||||
if (xyNoteTop != null)
|
||||
getCucaNote(Position.TOP).drawU(ug.apply(new UTranslate(xyNoteTop)));
|
||||
if (xyNoteBottom != null)
|
||||
if (xyNoteBottom != null)
|
||||
getCucaNote(Position.BOTTOM).drawU(ug.apply(new UTranslate(xyNoteBottom)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
final String fullName = group.getCodeGetName();
|
||||
|
@ -367,19 +351,21 @@ public class Cluster implements Moveable {
|
|||
backColor = getBackColor(backColor, group.getStereotype(), umlDiagramType.getStyleName(),
|
||||
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getThemeStyle(),
|
||||
skinParam.getIHtmlColorSet());
|
||||
|
||||
if (ztitle != null || zstereo != null) {
|
||||
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle,
|
||||
zstereo, minX, minY, maxX, maxY, stroke);
|
||||
zstereo, clusterPosition, stroke);
|
||||
decoration.drawU(ug, backColor, borderColor, shadowing, rounded,
|
||||
skinParam.getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null),
|
||||
skinParam.getStereotypeAlignment(), diagonalCorner);
|
||||
return;
|
||||
}
|
||||
final URectangle rect = new URectangle(maxX - minX, maxY - minY);
|
||||
final URectangle rect = new URectangle(clusterPosition.getDimension());
|
||||
rect.setDeltaShadow(shadowing);
|
||||
ug = ug.apply(backColor.bg()).apply(borderColor);
|
||||
ug.apply(new UStroke(2)).apply(new UTranslate(minX, minY)).draw(rect);
|
||||
|
||||
ug.apply(new UStroke(2)).apply(clusterPosition.getPosition()).draw(rect);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (url != null)
|
||||
ug.closeUrl();
|
||||
|
@ -420,25 +406,22 @@ public class Cluster implements Moveable {
|
|||
if (titleAndAttributeHeight > 0 && titleAndAttributeWidth > 0)
|
||||
frontierCalculator.ensureMinWidth(titleAndAttributeWidth + 10);
|
||||
|
||||
final ClusterPosition forced = frontierCalculator.getSuggestedPosition();
|
||||
// xTitle += ((forced.getMinX() - minX) + (forced.getMaxX() - maxX)) / 2;
|
||||
minX = forced.getMinX();
|
||||
minY = forced.getMinY();
|
||||
maxX = forced.getMaxX();
|
||||
maxY = forced.getMaxY();
|
||||
yTitle = minY + IEntityImage.MARGIN;
|
||||
this.clusterPosition = frontierCalculator.getSuggestedPosition();
|
||||
|
||||
final double widthTitle = ztitle.calculateDimension(stringBounder).getWidth();
|
||||
xTitle = minX + ((maxX - minX - widthTitle) / 2);
|
||||
final double minX = clusterPosition.getMinX();
|
||||
final double minY = clusterPosition.getMinY();
|
||||
this.xyTitle = new XPoint2D(minX + ((clusterPosition.getWidth() - widthTitle) / 2), minY + IEntityImage.MARGIN);
|
||||
}
|
||||
|
||||
private void drawSwinLinesState(UGraphic ug, HColor borderColor) {
|
||||
if (ztitle != null)
|
||||
ztitle.drawU(ug.apply(UTranslate.dx(xTitle)));
|
||||
ztitle.drawU(ug.apply(UTranslate.dx(xyTitle.x)));
|
||||
|
||||
final ULine line = ULine.vline(maxY - minY);
|
||||
final ULine line = ULine.vline(clusterPosition.getHeight());
|
||||
ug = ug.apply(borderColor);
|
||||
ug.apply(UTranslate.dx(minX)).draw(line);
|
||||
ug.apply(UTranslate.dx(maxX)).draw(line);
|
||||
ug.apply(UTranslate.dx(clusterPosition.getMinX())).draw(line);
|
||||
ug.apply(UTranslate.dx(clusterPosition.getMaxX())).draw(line);
|
||||
|
||||
}
|
||||
|
||||
|
@ -461,13 +444,12 @@ public class Cluster implements Moveable {
|
|||
// GroupPngMakerState
|
||||
|
||||
private void drawUState(UGraphic ug, UmlDiagramType umlDiagramType, double rounded, double shadowing) {
|
||||
final XDimension2D total = new XDimension2D(maxX - minX, maxY - minY);
|
||||
final XDimension2D total = clusterPosition.getDimension();
|
||||
final double suppY;
|
||||
if (ztitle == null)
|
||||
suppY = 0;
|
||||
else
|
||||
suppY = ztitle.calculateDimension(ug.getStringBounder()).getHeight() + IEntityImage.MARGIN
|
||||
+ IEntityImage.MARGIN_LINE;
|
||||
suppY = ztitle.calculateDimension(ug.getStringBounder()).getHeight() + IEntityImage.MARGIN;
|
||||
|
||||
final Style styleGroup = getDefaultStyleDefinitionStateGroup(group.getStereotype())
|
||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||
|
@ -505,35 +487,24 @@ public class Cluster implements Moveable {
|
|||
final RoundedContainer r = new RoundedContainer(total, suppY,
|
||||
attributeHeight + (attributeHeight > 0 ? IEntityImage.MARGIN : 0), borderColor, backColor, imgBackcolor,
|
||||
stroke, rounded, shadowing);
|
||||
r.drawU(ug.apply(new UTranslate(minX, minY)));
|
||||
r.drawU(ug.apply(clusterPosition.getPosition()));
|
||||
|
||||
if (ztitle != null)
|
||||
ztitle.drawU(ug.apply(new UTranslate(xTitle, yTitle)));
|
||||
ztitle.drawU(ug.apply(new UTranslate(xyTitle)));
|
||||
|
||||
if (attributeHeight > 0)
|
||||
attribute.drawU(
|
||||
ug.apply(new UTranslate(minX + IEntityImage.MARGIN, minY + suppY + IEntityImage.MARGIN / 2.0)));
|
||||
attribute.drawU(ug.apply(new UTranslate(clusterPosition.getMinX() + IEntityImage.MARGIN,
|
||||
clusterPosition.getMinY() + suppY + IEntityImage.MARGIN / 2.0)));
|
||||
|
||||
final Stereotype stereotype = group.getStereotype();
|
||||
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
|
||||
if (withSymbol)
|
||||
EntityImageState.drawSymbol(ug.apply(borderColor), maxX, maxY);
|
||||
EntityImageState.drawSymbol(ug.apply(borderColor), clusterPosition.getMaxX(), clusterPosition.getMaxY());
|
||||
|
||||
}
|
||||
|
||||
public void setPosition(XPoint2D min, XPoint2D max) {
|
||||
this.minX = min.getX();
|
||||
this.minY = min.getY();
|
||||
this.maxX = max.getX();
|
||||
this.maxY = max.getY();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPosition(double minX, double minY, double maxX, double maxY) {
|
||||
this.minX = minX;
|
||||
this.maxX = maxX;
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
this.clusterPosition = new ClusterPosition(min, max);
|
||||
}
|
||||
|
||||
public boolean printCluster1(StringBuilder sb, Collection<SvekLine> lines, StringBounder stringBounder) {
|
||||
|
@ -721,6 +692,12 @@ public class Cluster implements Moveable {
|
|||
return colorNoteBottom;
|
||||
}
|
||||
|
||||
public XDimension2D getTitleDimension(StringBounder stringBounder) {
|
||||
if (ztitle == null)
|
||||
return null;
|
||||
return ztitle.calculateDimension(stringBounder);
|
||||
}
|
||||
|
||||
// public XPoint2D projection(double x, double y) {
|
||||
// final double v1 = Math.abs(minX - x);
|
||||
// final double v2 = Math.abs(maxX - x);
|
||||
|
|
|
@ -52,20 +52,14 @@ public class ClusterDecoration {
|
|||
final private TextBlock title;
|
||||
final private TextBlock stereo;
|
||||
|
||||
final private double minX;
|
||||
final private double minY;
|
||||
final private double maxX;
|
||||
final private double maxY;
|
||||
final private ClusterPosition clusterPosition;
|
||||
|
||||
public ClusterDecoration(PackageStyle style, USymbol symbol, TextBlock title, TextBlock stereo, double minX,
|
||||
double minY, double maxX, double maxY, UStroke stroke) {
|
||||
public ClusterDecoration(PackageStyle style, USymbol symbol, TextBlock title, TextBlock stereo,
|
||||
ClusterPosition clusterPosition, UStroke stroke) {
|
||||
this.symbol = guess(symbol, style);
|
||||
this.stereo = stereo;
|
||||
this.title = title;
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.clusterPosition = clusterPosition;
|
||||
this.defaultStroke = stroke;
|
||||
}
|
||||
|
||||
|
@ -84,8 +78,8 @@ public class ClusterDecoration {
|
|||
|
||||
final SymbolContext symbolContext = biColor.withShadow(shadowing).withStroke(defaultStroke)
|
||||
.withCorner(roundCorner, diagonalCorner);
|
||||
symbol.asBig(title, titleAlignment, stereo, maxX - minX, maxY - minY, symbolContext, stereoAlignment)
|
||||
.drawU(ug.apply(new UTranslate(minX, minY)));
|
||||
symbol.asBig(title, titleAlignment, stereo, clusterPosition.getWidth(), clusterPosition.getHeight(),
|
||||
symbolContext, stereoAlignment).drawU(ug.apply(clusterPosition.getPosition()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,12 +35,11 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.posimo.BezierUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class ClusterPosition {
|
||||
|
||||
|
@ -56,6 +55,22 @@ public class ClusterPosition {
|
|||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
public ClusterPosition(XPoint2D min, XPoint2D max) {
|
||||
this(min.x, min.y, max.x, max.y);
|
||||
}
|
||||
|
||||
public ClusterPosition move(double deltaX, double deltaY) {
|
||||
return new ClusterPosition(minX + deltaX, minY + deltaY, maxX + deltaX, maxY + deltaY);
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public boolean contains(double x, double y) {
|
||||
return x >= minX && x < maxX && y >= minY && y < maxY;
|
||||
}
|
||||
|
@ -76,10 +91,6 @@ public class ClusterPosition {
|
|||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean contains(Point2D p) {
|
||||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "minX=" + minX + " maxX=" + maxX + " minY=" + minY + " maxY=" + maxY;
|
||||
|
@ -101,7 +112,7 @@ public class ClusterPosition {
|
|||
return maxY;
|
||||
}
|
||||
|
||||
public PointDirected getIntersection(CubicCurve2D.Double bez) {
|
||||
public PointDirected getIntersection(XCubicCurve2D bez) {
|
||||
if (contains(bez.x1, bez.y1) == contains(bez.x2, bez.y2))
|
||||
return null;
|
||||
|
||||
|
@ -110,8 +121,8 @@ public class ClusterPosition {
|
|||
final double angle = BezierUtils.getStartingAngle(bez);
|
||||
return new PointDirected(bez.getP1(), angle);
|
||||
}
|
||||
final CubicCurve2D.Double left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D.Double right = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D left = new XCubicCurve2D();
|
||||
final XCubicCurve2D right = new XCubicCurve2D();
|
||||
bez.subdivide(left, right);
|
||||
final PointDirected int1 = getIntersection(left);
|
||||
if (int1 != null)
|
||||
|
@ -186,6 +197,10 @@ public class ClusterPosition {
|
|||
return new XDimension2D(maxX - minX, maxY - minY);
|
||||
}
|
||||
|
||||
public UTranslate getPosition() {
|
||||
return new UTranslate(getMinX(), getMinY());
|
||||
}
|
||||
|
||||
public boolean isPointJustUpper(XPoint2D pt) {
|
||||
if (pt.getX() >= minX && pt.getX() <= maxX && pt.getY() <= minY) {
|
||||
return true;
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
|
||||
public class PointDirected {
|
||||
|
@ -45,7 +43,7 @@ public class PointDirected {
|
|||
final private double y;
|
||||
final private double angle;
|
||||
|
||||
public PointDirected(Point2D p, double angle) {
|
||||
public PointDirected(XPoint2D p, double angle) {
|
||||
this.x = p.getX();
|
||||
this.y = p.getY();
|
||||
this.angle = angle;
|
||||
|
|
|
@ -653,7 +653,7 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
|||
Log.info("DotPath is null for " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ug.draw(link.commentForSvg());
|
||||
final Map<UGroupType, String> typeIDent = new EnumMap<>(UGroupType.class);
|
||||
typeIDent.put(UGroupType.CLASS,
|
||||
|
@ -669,8 +669,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
|||
if (link.isAutoLinkOfAGroup()) {
|
||||
final Cluster cl = bibliotekon.getCluster((IGroup) link.getEntity1());
|
||||
if (cl != null) {
|
||||
x += cl.getWidth();
|
||||
x -= dotPath.getStartPoint().getX() - cl.getMinX();
|
||||
x += cl.getClusterPosition().getWidth();
|
||||
x -= dotPath.getStartPoint().getX() - cl.getClusterPosition().getMinX();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,7 +712,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
|||
|
||||
if (extremity1 instanceof Extremity && extremity2 instanceof Extremity) {
|
||||
// http://forum.plantuml.net/9421/arrow-inversion-with-skinparam-linetype-ortho-missing-arrow
|
||||
final XPoint2D p1 = ((Extremity) extremity1).isTooSmallSoGiveThePointCloserToThisOne(todraw.getStartPoint());
|
||||
final XPoint2D p1 = ((Extremity) extremity1)
|
||||
.isTooSmallSoGiveThePointCloserToThisOne(todraw.getStartPoint());
|
||||
if (p1 != null)
|
||||
todraw.forceStartPoint(p1.getX(), p1.getY());
|
||||
|
||||
|
@ -919,33 +920,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
|||
|
||||
}
|
||||
|
||||
// final Positionable start = getStartTailPositionnable();
|
||||
// if (start != null) {
|
||||
// for (Shape sh : allShapes) {
|
||||
// if (cut(start, sh)) {
|
||||
// avoid(startTailLabelXY, start, sh);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final Positionable end = getEndHeadPositionnable();
|
||||
// if (end != null) {
|
||||
// for (Shape sh : allShapes) {
|
||||
// if (cut(end, sh)) {
|
||||
// avoid(endHeadLabelXY, end, sh);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private void avoid(XPoint2D move, Positionable pos, SvekNode sh) {
|
||||
private XPoint2D avoid2(XPoint2D move, Positionable pos, SvekNode sh) {
|
||||
final Oscillator oscillator = new Oscillator();
|
||||
final XPoint2D orig = new XPoint2D(move.x, move.y);
|
||||
while (cut(pos, sh)) {
|
||||
final XPoint2D m = oscillator.nextPosition();
|
||||
move.setLocation(orig.x + m.x, orig.y + m.y);
|
||||
move = new XPoint2D(orig.x + m.x, orig.y + m.y);
|
||||
}
|
||||
return move;
|
||||
}
|
||||
|
||||
private boolean cut(Positionable pos, SvekNode sh) {
|
||||
|
|
|
@ -69,10 +69,10 @@ class ExtremityCircleCrowfoot extends Extremity {
|
|||
XPoint2D right = new XPoint2D(0, yAperture);
|
||||
XPoint2D circleBase = new XPoint2D(-xWing - radius - 2, 0);
|
||||
|
||||
left.transform(rotate);
|
||||
base.transform(rotate);
|
||||
right.transform(rotate);
|
||||
circleBase.transform(rotate);
|
||||
left = left.transform(rotate);
|
||||
base = base.transform(rotate);
|
||||
right = right.transform(rotate);
|
||||
circleBase = circleBase.transform(rotate);
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, left);
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, right);
|
||||
|
|
|
@ -72,16 +72,15 @@ class ExtremityCircleLine extends Extremity {
|
|||
XPoint2D lineTop = new XPoint2D(-xWing, -lineHeight);
|
||||
XPoint2D lineBottom = new XPoint2D(-xWing, lineHeight);
|
||||
|
||||
lineTop.transform(rotate);
|
||||
lineBottom.transform(rotate);
|
||||
base.transform(rotate);
|
||||
circleBase.transform(rotate);
|
||||
lineTop = lineTop.transform(rotate);
|
||||
lineBottom = lineBottom.transform(rotate);
|
||||
base = base.transform(rotate);
|
||||
circleBase = circleBase.transform(rotate);
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, middle);
|
||||
final UStroke stroke = new UStroke(thickness);
|
||||
ug.apply(
|
||||
new UTranslate(contact.getX() + circleBase.getX() - radius, contact.getY() + circleBase.getY() - radius))
|
||||
.apply(stroke).draw(new UEllipse(2 * radius, 2 * radius));
|
||||
ug.apply(new UTranslate(contact.getX() + circleBase.getX() - radius,
|
||||
contact.getY() + circleBase.getY() - radius)).apply(stroke).draw(new UEllipse(2 * radius, 2 * radius));
|
||||
drawLine(ug.apply(stroke), contact.getX(), contact.getY(), lineTop, lineBottom);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,17 +68,17 @@ class ExtremityCrowfoot extends Extremity {
|
|||
XPoint2D left = new XPoint2D(0, -yAperture);
|
||||
XPoint2D base = new XPoint2D(-xWing, 0);
|
||||
XPoint2D right = new XPoint2D(0, yAperture);
|
||||
left.transform(rotate);
|
||||
base.transform(rotate);
|
||||
right.transform(rotate);
|
||||
left = left.transform(rotate);
|
||||
base = base.transform(rotate);
|
||||
right = right.transform(rotate);
|
||||
|
||||
if (side == Side.WEST || side == Side.EAST) {
|
||||
left.setLocation(middle.getX(), left.getY());
|
||||
right.setLocation(middle.getX(), right.getY());
|
||||
left = new XPoint2D(middle.getX(), left.getY());
|
||||
right = new XPoint2D(middle.getX(), right.getY());
|
||||
}
|
||||
if (side == Side.SOUTH || side == Side.NORTH) {
|
||||
left.setLocation(left.getX(), middle.getY());
|
||||
right.setLocation(right.getX(), middle.getY());
|
||||
left = new XPoint2D(left.getX(), middle.getY());
|
||||
right = new XPoint2D(right.getX(), middle.getY());
|
||||
}
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, left);
|
||||
|
|
|
@ -69,12 +69,12 @@ class ExtremityDoubleLine extends Extremity {
|
|||
XPoint2D middle = new XPoint2D(0, 0);
|
||||
XPoint2D base = new XPoint2D(-xWing - 4, 0);
|
||||
|
||||
middle.transform(rotate);
|
||||
base.transform(rotate);
|
||||
firstLineTop.transform(rotate);
|
||||
firstLineBottom.transform(rotate);
|
||||
secondLineTop.transform(rotate);
|
||||
secondLineBottom.transform(rotate);
|
||||
middle = middle.transform(rotate);
|
||||
base = base.transform(rotate);
|
||||
firstLineTop = firstLineTop.transform(rotate);
|
||||
firstLineBottom = firstLineBottom.transform(rotate);
|
||||
secondLineTop = secondLineTop.transform(rotate);
|
||||
secondLineBottom = secondLineBottom.transform(rotate);
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), firstLineTop, firstLineBottom);
|
||||
drawLine(ug, contact.getX(), contact.getY(), secondLineTop, secondLineBottom);
|
||||
|
|
|
@ -59,8 +59,8 @@ class ExtremityHalfArrow extends Extremity {
|
|||
final AffineTransform rotate = AffineTransform.getRotateInstance(angle + Math.PI / 2);
|
||||
final int xWing = 9;
|
||||
final int yAperture = 4;
|
||||
final XPoint2D other = new XPoint2D(-xWing, -yAperture);
|
||||
other.transform(rotate);
|
||||
XPoint2D other = new XPoint2D(-xWing, -yAperture);
|
||||
other = other.transform(rotate);
|
||||
|
||||
this.contact = p1;
|
||||
this.line = new ULine(center.getX() - contact.getX(), center.getY() - contact.getY());
|
||||
|
|
|
@ -47,7 +47,6 @@ class ExtremityLineCrowfoot extends Extremity {
|
|||
private final XPoint2D contact;
|
||||
private final double angle;
|
||||
private final double lineHeight = 4;
|
||||
|
||||
|
||||
@Override
|
||||
public XPoint2D somePoint() {
|
||||
|
@ -60,22 +59,22 @@ class ExtremityLineCrowfoot extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
||||
|
||||
final int xWing = 8;
|
||||
final int yAperture = 6;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
XPoint2D middle = new XPoint2D(0, 0);
|
||||
XPoint2D left = new XPoint2D(0, -yAperture);
|
||||
XPoint2D base = new XPoint2D(-xWing, 0);
|
||||
XPoint2D lineTop = new XPoint2D(-xWing-2, -lineHeight);
|
||||
XPoint2D lineBottom = new XPoint2D(-xWing-2, lineHeight);
|
||||
XPoint2D lineTop = new XPoint2D(-xWing - 2, -lineHeight);
|
||||
XPoint2D lineBottom = new XPoint2D(-xWing - 2, lineHeight);
|
||||
XPoint2D right = new XPoint2D(0, yAperture);
|
||||
|
||||
left.transform(rotate);
|
||||
base.transform(rotate);
|
||||
right.transform(rotate);
|
||||
lineTop.transform(rotate);
|
||||
lineBottom.transform(rotate);
|
||||
|
||||
left = left.transform(rotate);
|
||||
base = base.transform(rotate);
|
||||
right = right.transform(rotate);
|
||||
lineTop = lineTop.transform(rotate);
|
||||
lineBottom = lineBottom.transform(rotate);
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, left);
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, right);
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.svek.extremity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
|
@ -59,7 +57,7 @@ class ExtremityStateLine1 extends Extremity {
|
|||
}
|
||||
|
||||
|
||||
public ExtremityStateLine1(double angle, Point2D center) {
|
||||
public ExtremityStateLine1(double angle, XPoint2D center) {
|
||||
this.angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
this.dest = new XPoint2D(center.getX(), center.getY());
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.svek.extremity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
|
@ -51,14 +49,13 @@ class ExtremityStateLine2 extends Extremity {
|
|||
private final XPoint2D dest;
|
||||
private final double radius = 5;
|
||||
private final double angle;
|
||||
|
||||
|
||||
@Override
|
||||
public XPoint2D somePoint() {
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
public ExtremityStateLine2(double angle, Point2D center) {
|
||||
public ExtremityStateLine2(double angle, XPoint2D center) {
|
||||
this.angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
this.dest = new XPoint2D(center.getX(), center.getY());
|
||||
|
@ -74,8 +71,11 @@ class ExtremityStateLine2 extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug.apply(ug.getParam().getColor().bg()).apply(new UTranslate(-radius * Math.cos(angle), -radius * Math.sin(angle))).draw(polygon);
|
||||
ug.apply(new UStroke(1.5)).apply(HColors.WHITE.bg()).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
|
||||
ug.apply(ug.getParam().getColor().bg())
|
||||
.apply(new UTranslate(-radius * Math.cos(angle), -radius * Math.sin(angle))).draw(polygon);
|
||||
ug.apply(new UStroke(1.5)).apply(HColors.WHITE.bg())
|
||||
.apply(new UTranslate(dest.getX() - radius, dest.getY() - radius))
|
||||
.draw(new UEllipse(radius * 2, radius * 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ import net.sourceforge.plantuml.style.StyleSignature;
|
|||
import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
||||
import net.sourceforge.plantuml.svek.AbstractEntityImage;
|
||||
import net.sourceforge.plantuml.svek.ClusterDecoration;
|
||||
import net.sourceforge.plantuml.svek.ClusterPosition;
|
||||
import net.sourceforge.plantuml.svek.ShapeType;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
|
@ -156,8 +157,9 @@ public class EntityImageEmptyPackage extends AbstractEntityImage {
|
|||
final double widthTotal = dimTotal.getWidth();
|
||||
final double heightTotal = dimTotal.getHeight();
|
||||
|
||||
final ClusterPosition clusterPosition = new ClusterPosition(0, 0, widthTotal, heightTotal);
|
||||
final ClusterDecoration decoration = new ClusterDecoration(getSkinParam().packageStyle(), null, desc,
|
||||
stereoBlock, 0, 0, widthTotal, heightTotal, stroke);
|
||||
stereoBlock, clusterPosition, stroke);
|
||||
|
||||
final HorizontalAlignment horizontalAlignment = getSkinParam()
|
||||
.getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class EntityImageStateEmptyDescription extends EntityImageStateCommon {
|
|||
final XDimension2D dimTotal = calculateDimension(stringBounder);
|
||||
final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
|
||||
|
||||
final UStroke stroke = getStyleState().getStroke();
|
||||
final UStroke stroke = getStyleState().getStroke(lineConfig.getColors());
|
||||
|
||||
ug = applyColor(ug);
|
||||
ug = ug.apply(stroke);
|
||||
|
|
|
@ -379,25 +379,29 @@ public class SvgGraphics {
|
|||
}
|
||||
|
||||
public final void setFillColor(String fill) {
|
||||
this.fill = fill == null ? "none" : fill;
|
||||
this.fill = fixColor(fill);
|
||||
// this.fillDark = this.fill;
|
||||
}
|
||||
|
||||
public final void setFillColor(String fill, String fillDark) {
|
||||
this.fill = fill == null ? "none" : fill;
|
||||
this.fill = fixColor(fill);
|
||||
// this.fillDark = fillDark == null ? "none" : fillDark;
|
||||
}
|
||||
|
||||
public final void setStrokeColor(String stroke) {
|
||||
this.stroke = stroke == null ? "none" : stroke;
|
||||
this.stroke = fixColor(stroke);
|
||||
// this.strokeDark = stroke;
|
||||
}
|
||||
|
||||
public final void setStrokeColor(String stroke, String strokeDark) {
|
||||
this.stroke = stroke == null ? "none" : stroke;
|
||||
this.stroke = fixColor(stroke);
|
||||
// this.strokeDark = strokeDark == null ? "none" : strokeDark;
|
||||
}
|
||||
|
||||
private String fixColor(String color) {
|
||||
return color == null || "#00000000".equals(color) ? "none" : color;
|
||||
}
|
||||
|
||||
public final void setStrokeWidth(double strokeWidth, String strokeDasharray) {
|
||||
this.strokeWidth = "" + (scale * strokeWidth);
|
||||
this.strokeDasharray = strokeDasharray;
|
||||
|
@ -897,7 +901,6 @@ public class SvgGraphics {
|
|||
|
||||
private final Map<String, String> images = new HashMap<String, String>();
|
||||
|
||||
|
||||
private void svgImageUnsecure(UImageSvg image, double x, double y) {
|
||||
if (hidden == false) {
|
||||
String svg = manageScale(image);
|
||||
|
@ -912,7 +915,6 @@ public class SvgGraphics {
|
|||
ensureVisible(x + image.getData("width"), y + image.getData("height"));
|
||||
}
|
||||
|
||||
|
||||
public void svgImage(UImageSvg image, double x, double y) {
|
||||
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) {
|
||||
svgImageUnsecure(image, x, y);
|
||||
|
|
|
@ -41,17 +41,16 @@ import java.util.Objects;
|
|||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapperTransparentWrapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorNone;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public abstract class AbstractCommonUGraphic implements UGraphic {
|
||||
|
||||
private UStroke stroke = new UStroke();
|
||||
private UPattern pattern = UPattern.FULL;
|
||||
private boolean hidden = false;
|
||||
private HColor backColor = null;
|
||||
private HColor color = null;
|
||||
private HColor backColor = HColors.none();
|
||||
private HColor color = HColors.none();
|
||||
private boolean enlargeClip = false;
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
|
@ -87,8 +86,6 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||
copy.hidden = change == UHidden.HIDDEN;
|
||||
} else if (change instanceof UBackground) {
|
||||
copy.backColor = ((UBackground) change).getBackColor();
|
||||
} else if (change instanceof HColorNone) {
|
||||
copy.color = null;
|
||||
} else if (change instanceof HColor) {
|
||||
copy.color = (HColor) change;
|
||||
}
|
||||
|
@ -96,9 +93,9 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||
}
|
||||
|
||||
final public UClip getClip() {
|
||||
if (enlargeClip && clip != null) {
|
||||
if (enlargeClip && clip != null)
|
||||
return clip.enlarge(1);
|
||||
}
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
|
@ -107,6 +104,9 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||
}
|
||||
|
||||
public AbstractCommonUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
|
||||
if (defaultBackground == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.colorMapper = colorMapper;
|
||||
this.defaultBackground = defaultBackground;
|
||||
this.stringBounder = stringBounder;
|
||||
|
@ -114,6 +114,8 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||
|
||||
protected AbstractCommonUGraphic(AbstractCommonUGraphic other) {
|
||||
this.defaultBackground = other.defaultBackground;
|
||||
if (defaultBackground == null)
|
||||
throw new IllegalArgumentException();
|
||||
this.enlargeClip = other.enlargeClip;
|
||||
this.colorMapper = other.colorMapper;
|
||||
this.stringBounder = other.stringBounder;
|
||||
|
@ -168,7 +170,7 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||
}
|
||||
|
||||
final public ColorMapper getColorMapper() {
|
||||
return new ColorMapperTransparentWrapper(colorMapper);
|
||||
return colorMapper;
|
||||
}
|
||||
|
||||
final public void flushUg() {
|
||||
|
|
|
@ -57,8 +57,7 @@ public class ULine extends AbstractShadowable implements UShapeSized {
|
|||
if (theta == 0)
|
||||
return this;
|
||||
final AffineTransform rot = AffineTransform.getRotateInstance(theta);
|
||||
final XPoint2D tmp = new XPoint2D(dx, dy);
|
||||
tmp.transform(rot);
|
||||
final XPoint2D tmp = new XPoint2D(dx, dy).transform(rot);
|
||||
return new ULine(tmp.getX(), tmp.getY());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
|
||||
|
@ -55,11 +55,11 @@ public class UMotif {
|
|||
}
|
||||
|
||||
public UMotif(String s) {
|
||||
final XPoint2D last = new XPoint2D();
|
||||
XPoint2D last = new XPoint2D();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
final XPoint2D read = convertPoint(s.charAt(i));
|
||||
last.setLocation(last.getX() + read.getX(), last.getY() + read.getY());
|
||||
points.add(new XPoint2D(last.getX(), last.getY()));
|
||||
last = last.move(read);
|
||||
points.add(last);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class UMotif {
|
|||
final double y1 = lasty + y;
|
||||
final double x2 = p.getX() + x;
|
||||
final double y2 = p.getY() + y;
|
||||
path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
|
||||
path = path.addAfter(new XCubicCurve2D(x1, y1, x1, y1, x2, y2, x2, y2));
|
||||
lastx = p.getX();
|
||||
lasty = p.getY();
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class UMotif {
|
|||
final double y1 = lasty + y;
|
||||
final double x2 = p.getY() + x;
|
||||
final double y2 = p.getX() + y;
|
||||
path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
|
||||
path = path.addAfter(new XCubicCurve2D(x1, y1, x1, y1, x2, y2, x2, y2));
|
||||
lastx = p.getY();
|
||||
lasty = p.getX();
|
||||
}
|
||||
|
|
|
@ -36,15 +36,16 @@
|
|||
package net.sourceforge.plantuml.ugraphic;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class UParamNull implements UParam {
|
||||
|
||||
public HColor getColor() {
|
||||
return null;
|
||||
return HColors.BLACK;
|
||||
}
|
||||
|
||||
public HColor getBackcolor() {
|
||||
return null;
|
||||
return HColors.BLACK;
|
||||
}
|
||||
|
||||
public UStroke getStroke() {
|
||||
|
|
|
@ -69,8 +69,7 @@ public class UPolygon extends AbstractShadowable {
|
|||
for (int i = 0; i < all.size() - 1; i++) {
|
||||
final XPoint2D pt1 = all.get(i);
|
||||
final XPoint2D pt2 = all.get(i + 1);
|
||||
final XPoint2D middle = new XPoint2D((pt1.getX() + pt2.getX()) / 2,
|
||||
(pt1.getY() + pt2.getY()) / 2);
|
||||
final XPoint2D middle = new XPoint2D((pt1.getX() + pt2.getX()) / 2, (pt1.getY() + pt2.getY()) / 2);
|
||||
final double delta = middle.distance(center);
|
||||
if (delta < 1)
|
||||
return all.get((i + all.size() - 1) % all.size());
|
||||
|
@ -111,8 +110,8 @@ public class UPolygon extends AbstractShadowable {
|
|||
}
|
||||
|
||||
public void affine(AffineTransform rotate) {
|
||||
for (XPoint2D pt : all)
|
||||
pt.transform(rotate);
|
||||
for (int i = 0; i < all.size(); i++)
|
||||
all.set(i, all.get(i).transform(rotate));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class USegment {
|
|||
}
|
||||
XPoint2D p1 = new XPoint2D(coord[0], coord[1]);
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
|
||||
p1.transform(rotate);
|
||||
p1 = p1.transform(rotate);
|
||||
|
||||
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* ========================================================================
|
||||
* 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.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public abstract class AbstractColorMapper implements ColorMapper {
|
||||
|
||||
final public String toRGB(HColor hcolor) {
|
||||
if (hcolor == null)
|
||||
return null;
|
||||
|
||||
final Color color = toColor(hcolor);
|
||||
return StringUtils.sharp000000(color.getRGB());
|
||||
}
|
||||
|
||||
final public String toSvg(HColor hcolor) {
|
||||
if (hcolor == null)
|
||||
return "none";
|
||||
|
||||
if (HColors.isTransparent(hcolor))
|
||||
return "#00000000";
|
||||
|
||||
final Color color = toColor(hcolor);
|
||||
final int alpha = color.getAlpha();
|
||||
if (alpha == 255)
|
||||
return toRGB(hcolor);
|
||||
|
||||
String s = "0" + Integer.toHexString(alpha).toUpperCase();
|
||||
s = s.substring(s.length() - 2);
|
||||
return toRGB(hcolor) + s;
|
||||
}
|
||||
|
||||
private static String sharpAlpha(int color) {
|
||||
final int v = color & 0xFFFFFF;
|
||||
String s = "00000" + Integer.toHexString(v).toUpperCase();
|
||||
s = s.substring(s.length() - 6);
|
||||
final int alpha = (int) (((long) color) & 0x000000FF) << 24;
|
||||
final String s2 = "0" + Integer.toHexString(alpha).toUpperCase();
|
||||
return "#" + s + s2.substring(0, 2);
|
||||
}
|
||||
|
||||
}
|
|
@ -37,11 +37,44 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public interface ColorMapper {
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public Color toColor(HColor color);
|
||||
public abstract class ColorMapper {
|
||||
|
||||
public String toSvg(HColor color);
|
||||
public abstract Color toColor(HColor color);
|
||||
|
||||
final public String toRGB(HColor hcolor) {
|
||||
if (hcolor == null)
|
||||
return null;
|
||||
|
||||
final Color color = toColor(hcolor);
|
||||
return StringUtils.sharp000000(color.getRGB());
|
||||
}
|
||||
|
||||
final public String toSvg(HColor hcolor) {
|
||||
if (hcolor == null)
|
||||
return "none";
|
||||
|
||||
if (HColors.isTransparent(hcolor))
|
||||
return "#00000000";
|
||||
|
||||
final Color color = toColor(hcolor);
|
||||
final int alpha = color.getAlpha();
|
||||
if (alpha == 255)
|
||||
return toRGB(hcolor);
|
||||
|
||||
String s = "0" + Integer.toHexString(alpha).toUpperCase();
|
||||
s = s.substring(s.length() - 2);
|
||||
return toRGB(hcolor) + s;
|
||||
}
|
||||
|
||||
private static String sharpAlpha(int color) {
|
||||
final int v = color & 0xFFFFFF;
|
||||
String s = "00000" + Integer.toHexString(v).toUpperCase();
|
||||
s = s.substring(s.length() - 6);
|
||||
final int alpha = (int) (((long) color) & 0x000000FF) << 24;
|
||||
final String s2 = "0" + Integer.toHexString(alpha).toUpperCase();
|
||||
return "#" + s + s2.substring(0, 2);
|
||||
}
|
||||
|
||||
public String toRGB(HColor color);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,12 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperForceDark extends AbstractColorMapper implements ColorMapper {
|
||||
public class ColorMapperForceDark extends ColorMapper {
|
||||
|
||||
@Override
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null)
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if (color instanceof HColorNone)
|
||||
return new Color(0, 0, 0, 0);
|
||||
|
|
|
@ -37,11 +37,12 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperIdentity extends AbstractColorMapper implements ColorMapper {
|
||||
public class ColorMapperIdentity extends ColorMapper {
|
||||
|
||||
@Override
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null)
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if (color instanceof HColorNone)
|
||||
return new Color(0, 0, 0, 0);
|
||||
|
|
|
@ -37,11 +37,12 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperLightnessInverse extends AbstractColorMapper implements ColorMapper {
|
||||
public class ColorMapperLightnessInverse extends ColorMapper {
|
||||
|
||||
@Override
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null)
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if (color instanceof HColorGradient)
|
||||
return toColor(((HColorGradient) color).getColor1());
|
||||
|
|
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperMonochrome extends AbstractColorMapper implements ColorMapper {
|
||||
public class ColorMapperMonochrome extends ColorMapper {
|
||||
|
||||
private final boolean reverse;
|
||||
|
||||
|
@ -45,15 +45,16 @@ public class ColorMapperMonochrome extends AbstractColorMapper implements ColorM
|
|||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color toColor(HColor htmlColor) {
|
||||
if (htmlColor == null)
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
final Color color = new ColorMapperIdentity().toColor(htmlColor);
|
||||
if (HColors.isTransparent(htmlColor))
|
||||
return color;
|
||||
|
||||
if (reverse && HColors.isTransparent(htmlColor) == false)
|
||||
if (reverse)
|
||||
return ColorUtils.getGrayScaleColorReverse(color);
|
||||
|
||||
return ColorUtils.getGrayScaleColor(color);
|
||||
|
|
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperReverse extends AbstractColorMapper implements ColorMapper {
|
||||
public class ColorMapperReverse extends ColorMapper {
|
||||
|
||||
private final ColorOrder order;
|
||||
|
||||
|
@ -45,15 +45,16 @@ public class ColorMapperReverse extends AbstractColorMapper implements ColorMapp
|
|||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null)
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if (color instanceof HColorMiddle)
|
||||
return ((HColorMiddle) color).getMappedColor(this);
|
||||
|
||||
if (color instanceof HColorNone)
|
||||
return getReverse(new Color(0, 0, 0, 0));
|
||||
return new Color(0, 0, 0, 0);
|
||||
|
||||
return getReverse(((HColorSimple) color).getColor999());
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* ========================================================================
|
||||
* 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.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ColorMapperTransparentWrapper extends AbstractColorMapper implements ColorMapper {
|
||||
|
||||
private final ColorMapper mapper;
|
||||
|
||||
public ColorMapperTransparentWrapper(ColorMapper mapper) {
|
||||
this.mapper = Objects.requireNonNull(mapper);
|
||||
}
|
||||
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null)
|
||||
return null;
|
||||
|
||||
if (color instanceof HColorNone)
|
||||
return null;
|
||||
|
||||
return mapper.toColor(color);
|
||||
}
|
||||
|
||||
}
|
|
@ -41,24 +41,24 @@ public enum ColorOrder {
|
|||
RGB, RBG, GRB, GBR, BRG, BGR;
|
||||
|
||||
public Color getColor(Color color) {
|
||||
if (this == RGB) {
|
||||
if (this == RGB)
|
||||
return new Color(color.getRed(), color.getGreen(), color.getBlue());
|
||||
}
|
||||
if (this == RBG) {
|
||||
|
||||
if (this == RBG)
|
||||
return new Color(color.getRed(), color.getBlue(), color.getGreen());
|
||||
}
|
||||
if (this == GRB) {
|
||||
|
||||
if (this == GRB)
|
||||
return new Color(color.getGreen(), color.getRed(), color.getBlue());
|
||||
}
|
||||
if (this == GBR) {
|
||||
|
||||
if (this == GBR)
|
||||
return new Color(color.getGreen(), color.getBlue(), color.getRed());
|
||||
}
|
||||
if (this == BRG) {
|
||||
|
||||
if (this == BRG)
|
||||
return new Color(color.getBlue(), color.getRed(), color.getGreen());
|
||||
}
|
||||
if (this == BGR) {
|
||||
|
||||
if (this == BGR)
|
||||
return new Color(color.getBlue(), color.getGreen(), color.getRed());
|
||||
}
|
||||
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
@ -38,26 +37,54 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
import net.sourceforge.plantuml.ugraphic.UBackground;
|
||||
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||
|
||||
public interface HColor extends UChange {
|
||||
public abstract class HColor implements UChange {
|
||||
|
||||
public UBackground bg();
|
||||
public UBackground bg() {
|
||||
return new UBackground() {
|
||||
public HColor getBackColor() {
|
||||
return HColor.this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public HColor withDark(HColor dark);
|
||||
public HColor lighten(int ratio) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HColor darken(int ratio);
|
||||
public HColor darken(int ratio) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HColor lighten(int ratio);
|
||||
public HColor reverseHsluv() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String asString();
|
||||
public HColor reverse() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDark();
|
||||
public boolean isDark() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public HColor reverseHsluv();
|
||||
public String asString() {
|
||||
return "?" + getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public HColor reverse();
|
||||
public HColor darkSchemeTheme() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HColor darkSchemeTheme();
|
||||
public HColor getAppropriateColor(HColor back) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HColor opposite();
|
||||
public HColor withDark(HColor dark) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public HColor opposite() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/* ========================================================================
|
||||
* 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.ugraphic.color;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.UBackground;
|
||||
|
||||
abstract class HColorAbstract implements HColor {
|
||||
|
||||
public UBackground bg() {
|
||||
return new UBackground() {
|
||||
public HColor getBackColor() {
|
||||
return HColorAbstract.this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor lighten(int ratio) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor darken(int ratio) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor reverseHsluv() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor reverse() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDark() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return "?" + getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor darkSchemeTheme() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor withDark(HColor dark) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor opposite() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -34,6 +34,11 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
public class HColorAutomagic extends HColorAbstract implements HColor {
|
||||
class HColorAutomagic extends HColor {
|
||||
|
||||
@Override
|
||||
public HColor getAppropriateColor(HColor back) {
|
||||
return back.opposite();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
import java.awt.Color;
|
||||
import java.util.Objects;
|
||||
|
||||
public class HColorGradient extends HColorAbstract implements HColor {
|
||||
public class HColorGradient extends HColor {
|
||||
|
||||
private final HColor color1;
|
||||
private final HColor color2;
|
||||
|
|
|
@ -37,19 +37,19 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class HColorMiddle extends HColorAbstract implements HColor {
|
||||
public class HColorMiddle extends HColor {
|
||||
|
||||
private final HColor c1;
|
||||
private final HColor c2;
|
||||
private final HColor color1;
|
||||
private final HColor color2;
|
||||
|
||||
HColorMiddle(HColor c1, HColor c2) {
|
||||
this.c1 = c1;
|
||||
this.c2 = c2;
|
||||
this.color1 = c1;
|
||||
this.color2 = c2;
|
||||
}
|
||||
|
||||
public Color getMappedColor(ColorMapper colorMapper) {
|
||||
final Color cc1 = colorMapper.toColor(c1);
|
||||
final Color cc2 = colorMapper.toColor(c2);
|
||||
final Color cc1 = colorMapper.toColor(color1);
|
||||
final Color cc2 = colorMapper.toColor(color2);
|
||||
final int r1 = cc1.getRed();
|
||||
final int g1 = cc1.getGreen();
|
||||
final int b1 = cc1.getBlue();
|
||||
|
@ -63,12 +63,12 @@ public class HColorMiddle extends HColorAbstract implements HColor {
|
|||
return new Color(r, g, b);
|
||||
}
|
||||
|
||||
public final HColor getC1() {
|
||||
return c1;
|
||||
public final HColor getColor1() {
|
||||
return color1;
|
||||
}
|
||||
|
||||
public final HColor getC2() {
|
||||
return c2;
|
||||
public final HColor getColor2() {
|
||||
return color2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
|||
|
||||
import net.sourceforge.plantuml.ugraphic.UBackground;
|
||||
|
||||
public class HColorNone extends HColorAbstract implements HColor {
|
||||
public class HColorNone extends HColor {
|
||||
|
||||
HColorNone() {
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class HColorNone extends HColorAbstract implements HColor {
|
|||
public UBackground bg() {
|
||||
return new UBackground() {
|
||||
public HColor getBackColor() {
|
||||
return null;
|
||||
return HColors.none();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
public class HColorScheme extends HColorAbstract implements HColor {
|
||||
class HColorScheme extends HColor {
|
||||
|
||||
private final HColor colorForLight;
|
||||
private final HColor colorForDark;
|
||||
|
@ -46,12 +46,13 @@ public class HColorScheme extends HColorAbstract implements HColor {
|
|||
this.colorForTransparent = colorForTransparent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor getAppropriateColor(HColor back) {
|
||||
if (back == null || HColors.isTransparent(back)) {
|
||||
if (HColors.isTransparent(back)) {
|
||||
if (colorForTransparent != null)
|
||||
return colorForTransparent;
|
||||
|
||||
return ((HColorSimple) colorForLight).withDark(colorForDark);
|
||||
return colorForLight.withDark(colorForDark);
|
||||
|
||||
}
|
||||
if (back.isDark())
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.awt.Color;
|
|||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class HColorSimple extends HColorAbstract implements HColor {
|
||||
public class HColorSimple extends HColor {
|
||||
|
||||
private final Color color;
|
||||
private final HColor dark;
|
||||
|
|
|
@ -323,7 +323,7 @@ public class HSLColor {
|
|||
* @return the RGB Color object
|
||||
*/
|
||||
public static Color toRGB(float h, float s, float l, float alpha) {
|
||||
|
||||
|
||||
if (s < 0)
|
||||
s = 0;
|
||||
if (s > 100)
|
||||
|
|
|
@ -8,8 +8,7 @@ import java.util.List;
|
|||
* Taken from
|
||||
* https://github.com/hsluv/hsluv-java/blob/master/src/main/java/org/hsluv/HUSLColorConverter.java
|
||||
*
|
||||
* Some other pointer:
|
||||
* https://twitter.com/kuon_orochi/ https://www.hsluv.org/
|
||||
* Some other pointer: https://twitter.com/kuon_orochi/ https://www.hsluv.org/
|
||||
* https://www.kuon.ch/post/2020-03-08-hsluv/
|
||||
*
|
||||
*
|
||||
|
|
|
@ -96,8 +96,8 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
|
|||
this.preserveAspectRatio = preserveAspectRatio;
|
||||
}
|
||||
|
||||
public UGraphicDebug(double scaleFactor, XDimension2D dim, String svgLinkTarget, String hoverPathColorRGB, long seed,
|
||||
String preserveAspectRatio) {
|
||||
public UGraphicDebug(double scaleFactor, XDimension2D dim, String svgLinkTarget, String hoverPathColorRGB,
|
||||
long seed, String preserveAspectRatio) {
|
||||
super(HColors.WHITE, new ColorMapperIdentity(), new StringBounderDebug());
|
||||
this.output = new ArrayList<>();
|
||||
this.scaleFactor = scaleFactor;
|
||||
|
@ -266,7 +266,7 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
|
|||
}
|
||||
if (color instanceof HColorMiddle) {
|
||||
final HColorMiddle middle = (HColorMiddle) color;
|
||||
return "middle(" + colorToString(middle.getC1()) + " & " + colorToString(middle.getC1()) + " )";
|
||||
return "middle(" + colorToString(middle.getColor1()) + " & " + colorToString(middle.getColor1()) + " )";
|
||||
}
|
||||
System.err.println("Error colorToString " + color.getClass().getSimpleName());
|
||||
return color.getClass().getSimpleName() + " " + new Date();
|
||||
|
@ -283,9 +283,9 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
|
|||
print(os, "preserveAspectRatio: " + preserveAspectRatio);
|
||||
print(os, "");
|
||||
|
||||
for (String s : output) {
|
||||
for (String s : output)
|
||||
print(os, s);
|
||||
}
|
||||
|
||||
os.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,16 +40,17 @@ import net.sourceforge.plantuml.posimo.DotPath;
|
|||
import net.sourceforge.plantuml.ugraphic.UDriver;
|
||||
import net.sourceforge.plantuml.ugraphic.UParam;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class DriverDotPathEps implements UDriver<DotPath, EpsGraphics> {
|
||||
|
||||
public void draw(DotPath shape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
|
||||
//DriverLineG2d.manageStroke(param, g2d);
|
||||
// DriverLineG2d.manageStroke(param, g2d);
|
||||
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false) {
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
|
||||
.getDashSpace());
|
||||
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(),
|
||||
param.getStroke().getDashSpace());
|
||||
shape.draw(eps, x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import net.sourceforge.plantuml.posimo.DotPath;
|
|||
import net.sourceforge.plantuml.ugraphic.UDriver;
|
||||
import net.sourceforge.plantuml.ugraphic.UParam;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class DriverDotPathG2d implements UDriver<DotPath, Graphics2D> {
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class DriverDotPathG2d implements UDriver<DotPath, Graphics2D> {
|
|||
public void draw(DotPath shape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
|
||||
DriverLineG2d.manageStroke(param, g2d);
|
||||
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false) {
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
shape.draw(g2d, x, y);
|
||||
shape.manageEnsureVisible(x, y, visible);
|
||||
|
|
|
@ -49,6 +49,7 @@ import net.sourceforge.plantuml.ugraphic.UParam;
|
|||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorGradient;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<UEllipse, Graphics2D> {
|
||||
|
||||
|
@ -81,19 +82,19 @@ public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<UElli
|
|||
g2d.fill(shape);
|
||||
DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y);
|
||||
} else {
|
||||
if (back != null) {
|
||||
if (HColors.isTransparent(back) == false) {
|
||||
g2d.setColor(mapper.toColor(param.getBackcolor()));
|
||||
DriverRectangleG2d.managePattern(param, g2d);
|
||||
g2d.fill(shape);
|
||||
}
|
||||
if (color != null && color.equals(param.getBackcolor()) == false) {
|
||||
if (HColors.isTransparent(color) == false && color.equals(param.getBackcolor()) == false)
|
||||
DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
final Shape arc = new Arc2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight(),
|
||||
round(ellipse.getStart()), round(ellipse.getExtend()), Arc2D.OPEN);
|
||||
if (color != null) {
|
||||
final Shape arc = new Arc2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight(), round(ellipse.getStart()),
|
||||
round(ellipse.getExtend()), Arc2D.OPEN);
|
||||
if (HColors.isTransparent(color) == false) {
|
||||
g2d.setColor(mapper.toColor(color));
|
||||
g2d.draw(arc);
|
||||
}
|
||||
|
|
|
@ -92,13 +92,11 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<UPath, G
|
|||
}
|
||||
|
||||
// Shadow
|
||||
if (shape.getDeltaShadow() != 0) {
|
||||
if (back == null || HColors.isTransparent(back)) {
|
||||
if (shape.getDeltaShadow() != 0)
|
||||
if (back == null || HColors.isTransparent(back))
|
||||
drawOnlyLineShadowSpecial(g2d, p, shape.getDeltaShadow(), dpiFactor);
|
||||
} else {
|
||||
else
|
||||
drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
|
||||
}
|
||||
}
|
||||
|
||||
if (back instanceof HColorGradient) {
|
||||
final HColorGradient gr = (HColorGradient) back;
|
||||
|
@ -123,12 +121,12 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<UPath, G
|
|||
}
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(p);
|
||||
} else if (back != null) {
|
||||
} else if (HColors.isTransparent(back) == false) {
|
||||
g2d.setColor(mapper.toColor(back));
|
||||
g2d.fill(p);
|
||||
}
|
||||
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false) {
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.draw(p);
|
||||
}
|
||||
|
|
|
@ -72,56 +72,53 @@ public class DriverPolygonG2d extends DriverShadowedG2d implements UDriver<UPoly
|
|||
final double xp = pt.getX() + x;
|
||||
final double yp = pt.getY() + y;
|
||||
visible.ensureVisible(xp, yp);
|
||||
if (last == null) {
|
||||
if (last == null)
|
||||
path.moveTo((float) xp, (float) yp);
|
||||
} else {
|
||||
else
|
||||
path.lineTo((float) xp, (float) yp);
|
||||
}
|
||||
|
||||
last = new XPoint2D(xp, yp);
|
||||
}
|
||||
|
||||
if (last != null) {
|
||||
if (last != null)
|
||||
path.closePath();
|
||||
}
|
||||
|
||||
if (shape.getDeltaShadow() != 0) {
|
||||
if (HColors.isTransparent(back)) {
|
||||
if (shape.getDeltaShadow() != 0)
|
||||
if (HColors.isTransparent(back))
|
||||
drawOnlyLineShadowSpecial(g2d, path, shape.getDeltaShadow(), dpiFactor);
|
||||
} else {
|
||||
else
|
||||
drawShadow(g2d, path, shape.getDeltaShadow(), dpiFactor);
|
||||
}
|
||||
}
|
||||
|
||||
if (back instanceof HColorGradient) {
|
||||
final HColorGradient gr = (HColorGradient) back;
|
||||
final char policy = gr.getPolicy();
|
||||
final GradientPaint paint;
|
||||
if (policy == '|') {
|
||||
if (policy == '|')
|
||||
paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2,
|
||||
mapper.toColor(gr.getColor1()), (float) (x + shape.getWidth()),
|
||||
(float) (y + shape.getHeight()) / 2, mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '\\') {
|
||||
else if (policy == '\\')
|
||||
paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.toColor(gr.getColor1()),
|
||||
(float) (x + shape.getWidth()), (float) y, mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '-') {
|
||||
else if (policy == '-')
|
||||
paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else {
|
||||
else
|
||||
// for /
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) (x + shape.getWidth()), (float) (y + shape.getHeight()),
|
||||
mapper.toColor(gr.getColor2()));
|
||||
}
|
||||
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(path);
|
||||
} else if (back != null) {
|
||||
} else if (HColors.isTransparent(back) == false) {
|
||||
g2d.setColor(mapper.toColor(back));
|
||||
DriverRectangleG2d.managePattern(param, g2d);
|
||||
g2d.fill(path);
|
||||
}
|
||||
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false) {
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
DriverLineG2d.manageStroke(param, g2d);
|
||||
g2d.draw(path);
|
||||
|
|
|
@ -72,11 +72,10 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
|
|||
final double rx = rect.getRx();
|
||||
final double ry = rect.getRy();
|
||||
final Shape shape;
|
||||
if (rx == 0 && ry == 0) {
|
||||
if (rx == 0 && ry == 0)
|
||||
shape = new Rectangle2D.Double(x, y, rect.getWidth(), rect.getHeight());
|
||||
} else {
|
||||
else
|
||||
shape = new RoundRectangle2D.Double(x, y, rect.getWidth(), rect.getHeight(), rx, ry);
|
||||
}
|
||||
|
||||
visible.ensureVisible(x, y);
|
||||
visible.ensureVisible(x + rect.getWidth(), y + rect.getHeight());
|
||||
|
@ -85,37 +84,39 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
|
|||
|
||||
// Shadow
|
||||
if (rect.getDeltaShadow() != 0) {
|
||||
if (HColors.isTransparent(back)) {
|
||||
if (HColors.isTransparent(back))
|
||||
drawOnlyLineShadowSpecial(g2d, shape, rect.getDeltaShadow(), dpiFactor);
|
||||
} else {
|
||||
else
|
||||
drawShadow(g2d, shape, rect.getDeltaShadow(), dpiFactor);
|
||||
}
|
||||
}
|
||||
|
||||
final HColor color = param.getColor();
|
||||
if (color == null) {
|
||||
param.getColor();
|
||||
}
|
||||
if (back instanceof HColorGradient) {
|
||||
final GradientPaint paint = getPaintGradient(x, y, mapper, rect.getWidth(), rect.getHeight(), back);
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(shape);
|
||||
drawBorder(param, color, mapper, rect, shape, g2d, x, y);
|
||||
} else {
|
||||
if (param.getBackcolor() != null) {
|
||||
if (HColors.isTransparent(param.getBackcolor()) == false) {
|
||||
g2d.setColor(mapper.toColor(param.getBackcolor()));
|
||||
DriverLineG2d.manageStroke(param, g2d);
|
||||
managePattern(param, g2d);
|
||||
g2d.fill(shape);
|
||||
}
|
||||
if (color != null && color.equals(param.getBackcolor()) == false) {
|
||||
if (color.equals(param.getBackcolor()) == false)
|
||||
drawBorder(param, color, mapper, rect, shape, g2d, x, y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawBorder(UParam param, HColor color, ColorMapper mapper, UShapeSized sized, Shape shape,
|
||||
Graphics2D g2d, double x, double y) {
|
||||
if (color == null) {
|
||||
if (HColors.isTransparent(color))
|
||||
return;
|
||||
}
|
||||
|
||||
if (color instanceof HColorGradient) {
|
||||
final GradientPaint paint = getPaintGradient(x, y, mapper, sized.getWidth(), sized.getHeight(), color);
|
||||
g2d.setPaint(paint);
|
||||
|
@ -131,20 +132,20 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
|
|||
final HColorGradient gr = (HColorGradient) back;
|
||||
final char policy = gr.getPolicy();
|
||||
final GradientPaint paint;
|
||||
if (policy == '|') {
|
||||
if (policy == '|')
|
||||
paint = new GradientPaint((float) x, (float) (y + height) / 2, mapper.toColor(gr.getColor1()),
|
||||
(float) (x + width), (float) (y + height) / 2, mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '\\') {
|
||||
else if (policy == '\\')
|
||||
paint = new GradientPaint((float) x, (float) (y + height), mapper.toColor(gr.getColor1()),
|
||||
(float) (x + width), (float) y, mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '-') {
|
||||
else if (policy == '-')
|
||||
paint = new GradientPaint((float) (x + width) / 2, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) (x + width) / 2, (float) (y + height), mapper.toColor(gr.getColor2()));
|
||||
} else {
|
||||
else
|
||||
// for /
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()), (float) (x + width),
|
||||
(float) (y + height), mapper.toColor(gr.getColor2()));
|
||||
}
|
||||
|
||||
return paint;
|
||||
}
|
||||
|
||||
|
@ -154,25 +155,21 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
|
|||
final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
|
||||
final Rectangle r = new Rectangle(0, 0, 4, 4);
|
||||
final int rgb = ((HColorSimple) param.getBackcolor()).getColor999().getRGB();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (i == 0 || i == 1) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
if (i == 0 || i == 1)
|
||||
bi.setRGB(i, j, rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g2d.setPaint(new TexturePaint(bi, r));
|
||||
} else if (pattern == UPattern.HORIZONTAL_STRIPE) {
|
||||
final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
|
||||
final Rectangle r = new Rectangle(0, 0, 4, 4);
|
||||
final int rgb = ((HColorSimple) param.getBackcolor()).getColor999().getRGB();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (j == 0 || j == 1) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
if (j == 0 || j == 1)
|
||||
bi.setRGB(i, j, rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g2d.setPaint(new TexturePaint(bi, r));
|
||||
} else if (pattern == UPattern.SMALL_CIRCLE) {
|
||||
final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
|
||||
|
|
|
@ -95,9 +95,9 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
|
|||
@Override
|
||||
public UGraphic apply(UChange change) {
|
||||
final UGraphicG2d copy = (UGraphicG2d) super.apply(change);
|
||||
if (change instanceof UAntiAliasing) {
|
||||
if (change instanceof UAntiAliasing)
|
||||
copy.antiAliasing = (UAntiAliasing) change;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -140,11 +140,11 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
|
|||
|
||||
private void register(double dpiFactor) {
|
||||
registerDriver(URectangle.class, new DriverRectangleG2d(dpiFactor, this));
|
||||
if (this.hasAffineTransform || dpiFactor != 1.0) {
|
||||
if (this.hasAffineTransform || dpiFactor != 1.0)
|
||||
registerDriver(UText.class, new DriverTextAsPathG2d(this, getStringBounder()));
|
||||
} else {
|
||||
else
|
||||
registerDriver(UText.class, new DriverTextG2d(this, getStringBounder()));
|
||||
}
|
||||
|
||||
registerDriver(ULine.class, new DriverLineG2d(dpiFactor));
|
||||
registerDriver(UPixel.class, new DriverPixelG2d());
|
||||
registerDriver(UPolygon.class, new DriverPolygonG2d(dpiFactor, this));
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.hand;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
|
@ -88,9 +88,8 @@ public class HandJiggle {
|
|||
final double diffX = Math.abs(endX - startX);
|
||||
final double diffY = Math.abs(endY - startY);
|
||||
final double distance = Math.sqrt(diffX * diffX + diffY * diffY);
|
||||
if (distance < 0.001) {
|
||||
if (distance < 0.001)
|
||||
return;
|
||||
}
|
||||
|
||||
int segments = (int) Math.round(distance / 10);
|
||||
double variation = defaultVariation;
|
||||
|
@ -118,25 +117,25 @@ public class HandJiggle {
|
|||
this.startY = endY;
|
||||
}
|
||||
|
||||
public void curveTo(CubicCurve2D curve) {
|
||||
public void curveTo(XCubicCurve2D curve) {
|
||||
final double flatness = curve.getFlatness();
|
||||
final double dist = curve.getP1().distance(curve.getP2());
|
||||
if (flatness > 0.1 && dist > 20) {
|
||||
final CubicCurve2D left = new CubicCurve2D.Double();
|
||||
final CubicCurve2D right = new CubicCurve2D.Double();
|
||||
final XCubicCurve2D left = new XCubicCurve2D();
|
||||
final XCubicCurve2D right = new XCubicCurve2D();
|
||||
curve.subdivide(left, right);
|
||||
curveTo(left);
|
||||
curveTo(right);
|
||||
return;
|
||||
}
|
||||
lineTo(new XPoint2D(curve.getP2()));
|
||||
lineTo(curve.getP2());
|
||||
}
|
||||
|
||||
public UPolygon toUPolygon() {
|
||||
final UPolygon result = new UPolygon();
|
||||
for (XPoint2D p : points) {
|
||||
for (XPoint2D p : points)
|
||||
result.addPoint(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -150,16 +149,16 @@ public class HandJiggle {
|
|||
path.lineTo(p);
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
if (path == null)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public void appendTo(UPath result) {
|
||||
for (XPoint2D p : points) {
|
||||
for (XPoint2D p : points)
|
||||
result.lineTo(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.hand;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.util.Random;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||
|
||||
|
@ -47,9 +47,8 @@ public class UDotPathHand {
|
|||
public UDotPathHand(DotPath source, Random rnd) {
|
||||
|
||||
final HandJiggle jiggle = HandJiggle.create(source.getStartPoint(), 2.0, rnd);
|
||||
for (CubicCurve2D curve : source.getBeziers()) {
|
||||
for (XCubicCurve2D curve : source.getBeziers())
|
||||
jiggle.curveTo(curve);
|
||||
}
|
||||
|
||||
this.path = jiggle.toUPath();
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.hand;
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.util.Random;
|
||||
|
||||
import net.sourceforge.plantuml.awt.geom.XCubicCurve2D;
|
||||
import net.sourceforge.plantuml.awt.geom.XPoint2D;
|
||||
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||
import net.sourceforge.plantuml.ugraphic.USegment;
|
||||
|
@ -65,7 +65,7 @@ public class UPathHand {
|
|||
final double y2 = segment.getCoord()[5];
|
||||
final HandJiggle jiggle = HandJiggle.create(last, 2.0, rnd);
|
||||
|
||||
final CubicCurve2D tmp = new CubicCurve2D.Double(last.getX(), last.getY(), segment.getCoord()[0],
|
||||
final XCubicCurve2D tmp = new XCubicCurve2D(last.getX(), last.getY(), segment.getCoord()[0],
|
||||
segment.getCoord()[1], segment.getCoord()[2], segment.getCoord()[3], x2, y2);
|
||||
jiggle.curveTo(tmp);
|
||||
jiggle.appendTo(result);
|
||||
|
|
|
@ -40,13 +40,14 @@ import net.sourceforge.plantuml.svg.SvgGraphics;
|
|||
import net.sourceforge.plantuml.ugraphic.UDriver;
|
||||
import net.sourceforge.plantuml.ugraphic.UParam;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class DriverDotPathSvg implements UDriver<DotPath, SvgGraphics> {
|
||||
|
||||
public void draw(DotPath shape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
|
||||
// DriverLineG2d.manageStroke(param, g2d);
|
||||
|
||||
if (param.getColor() != null) {
|
||||
if (HColors.isTransparent(param.getColor()) == false) {
|
||||
DriverRectangleSvg.applyStrokeColor(svg, mapper, param);
|
||||
|
||||
svg.setFillColor(null);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Version {
|
|||
}
|
||||
|
||||
public static int beta() {
|
||||
final int beta = 5;
|
||||
final int beta = 6;
|
||||
return beta;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user