This commit is contained in:
Arnaud Roques 2022-01-19 22:35:53 +01:00
parent 402c492b70
commit c623158c6c
11 changed files with 208 additions and 178 deletions

View File

@ -60,11 +60,15 @@ public class EmptyImageBuilder {
private final Color background;
private final StringBounder stringBounder;
public EmptyImageBuilder(String watermark, double width, double height, Color background, StringBounder stringBounder) {
public EmptyImageBuilder(String watermark, double width, double height, Color background,
StringBounder stringBounder) {
this(watermark, (int) width, (int) height, background, stringBounder);
}
public EmptyImageBuilder(String watermark, int width, int height, Color background, StringBounder stringBounder) {
if (width <= 0 || height <= 0)
throw new IllegalArgumentException("width and height must be positive");
if (width > GraphvizUtils.getenvImageLimit()) {
Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE");
width = GraphvizUtils.getenvImageLimit();
@ -152,7 +156,8 @@ public class EmptyImageBuilder {
return result;
}
public EmptyImageBuilder(String watermark, int width, int height, Color background, StringBounder stringBounder, double dpiFactor) {
public EmptyImageBuilder(String watermark, int width, int height, Color background, StringBounder stringBounder,
double dpiFactor) {
this(watermark, width * dpiFactor, height * dpiFactor, background, stringBounder);
if (dpiFactor != 1.0) {
g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor));

View File

@ -610,7 +610,11 @@ public class SkinParam implements ISkinParam {
}
public int getDpi() {
return getAsInt("dpi", 96);
final int defaultValue = 96;
final int dpi = getAsInt("dpi", defaultValue);
if (dpi <= 0)
return defaultValue;
return dpi;
}
public DotSplines getDotSplines() {

View File

@ -66,6 +66,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
private final Swimlane swimlane;
private final Swimlanes swimlanes;
private Swimlane swimlaneOut;
private Swimlane swimlaneBackward;
private BoxStyle boxStyle;
private boolean killed = false;
private final BoxStyle boxStyleIn;
@ -107,10 +108,10 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
return false;
}
public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle, LinkRendering incoming1,
public void setBackward(Display label, Swimlane swimlaneBackward, BoxStyle boxStyle, LinkRendering incoming1,
LinkRendering incoming2) {
this.backward = label;
this.swimlaneOut = swimlaneOut;
this.swimlaneBackward = swimlaneBackward;
this.boxStyle = boxStyle;
this.incoming1 = incoming1;
this.incoming2 = incoming2;
@ -162,9 +163,9 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
if (Display.isNull(backward))
return null;
Ftile result = factory.activity(backward, swimlaneOut, boxStyle, Colors.empty(), null);
Ftile result = factory.activity(backward, swimlaneBackward, boxStyle, Colors.empty(), null);
if (backwardNotes.size() > 0)
result = factory.addNote(result, swimlaneOut, backwardNotes);
result = factory.addNote(result, swimlaneBackward, backwardNotes);
return result;
}

View File

@ -112,6 +112,8 @@ class FtileRepeat extends AbstractFtile {
final Set<Swimlane> result = new HashSet<>(repeat.getSwimlanes());
result.addAll(diamond1.getSwimlanes());
result.addAll(diamond2.getSwimlanes());
if (backward != null)
result.addAll(backward.getSwimlanes());
return Collections.unmodifiableSet(result);
}
@ -132,20 +134,20 @@ class FtileRepeat extends AbstractFtile {
final Ftile diamond1;
// assert swimlane == repeat.getSwimlaneIn();
if (entry == null) {
if (entry == null)
diamond1 = new FtileDiamond(repeat.skinParam(), diamondColor, borderColor, repeat.getSwimlaneIn());
} else {
else
diamond1 = entry;
}
final FtileRepeat result;
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON) {
final Ftile diamond2;
if (noOut && Display.isNull(test)) {
if (noOut && Display.isNull(test))
diamond2 = new FtileEmpty(repeat.skinParam());
} else {
else
diamond2 = new FtileDiamondInside(tbTest, repeat.skinParam(), diamondColor, borderColor, swimlaneOut)
.withEast(yesTb).withSouth(outTb);
}
result = new FtileRepeat(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0), backward);
} else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND) {
final Ftile diamond2 = new FtileDiamond(repeat.skinParam(), diamondColor, borderColor, swimlane)
@ -254,9 +256,8 @@ class FtileRepeat extends AbstractFtile {
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) {
if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false)
return;
}
final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(tbout,
arrowHorizontalAlignment());
@ -269,9 +270,9 @@ class FtileRepeat extends AbstractFtile {
@Override
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
final StringBounder stringBounder = ug.getStringBounder();
if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) {
if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false)
return;
}
final Snake snake = Snake.create(arrowColor);
final Point2D mp1a = translate1.getTranslated(getP1(stringBounder));
final Point2D mp2b = translate2.getTranslated(getP2(stringBounder));
@ -353,7 +354,7 @@ class FtileRepeat extends AbstractFtile {
}
class ConnectionBackBackward1 extends AbstractConnection {
class ConnectionBackBackward1 extends AbstractConnection implements ConnectionTranslatable {
private final Rainbow arrowColor;
private final TextBlock tbback;
@ -392,6 +393,30 @@ class FtileRepeat extends AbstractFtile {
ug.draw(snake);
}
@Override
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
final StringBounder stringBounder = ug.getStringBounder();
Point2D p1 = getP1(stringBounder);
Point2D p2 = getP2(stringBounder);
p1 = translate1.getTranslated(p1);
p2 = translate2.getTranslated(p2);
final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
final double x1 = p1.getX() + dimDiamond2.getWidth();
final double y1 = p1.getY() + dimDiamond2.getHeight() / 2;
final double x2 = p2.getX();
final double y2 = p2.getY();
final Snake snake = Snake.create(arrowColor, Arrows.asToUp()).withLabel(tbback, arrowHorizontalAlignment());
snake.addPoint(x1, y1);
snake.addPoint(x2, y1);
snake.addPoint(x2, y2);
ug.draw(snake);
}
}
class ConnectionBackBackward2 extends AbstractConnection implements ConnectionTranslatable {
@ -545,9 +570,8 @@ class FtileRepeat extends AbstractFtile {
ug.apply(getTranslateForRepeat(stringBounder)).draw(repeat);
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
if (backward != null) {
if (backward != null)
ug.apply(getTranslateBackward(stringBounder)).draw(backward);
}
}
@ -566,9 +590,9 @@ class FtileRepeat extends AbstractFtile {
double width = getLeft(stringBounder) + getRight(stringBounder);
width = Math.max(width, w + 2 * Hexagon.hexagonHalfSize);
if (backward != null) {
if (backward != null)
width += backward.calculateDimension(stringBounder).getWidth();
}
final double height = dimDiamond1.getHeight() + dimRepeat.getHeight() + dimDiamond2.getHeight()
+ 8 * Hexagon.hexagonHalfSize;
return new Dimension2DDouble(width + 2 * Hexagon.hexagonHalfSize, height);
@ -577,12 +601,12 @@ class FtileRepeat extends AbstractFtile {
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == repeat) {
if (child == repeat)
return getTranslateForRepeat(stringBounder);
}
if (child == diamond1) {
if (child == diamond1)
return getTranslateDiamond1(stringBounder);
}
throw new UnsupportedOperationException();
}

View File

@ -93,12 +93,12 @@ public class Neighborhood {
final SvekLine line = bibliotekon.getLine(link);
final Point2D contact = link.getEntity1() == leaf ? line.getStartContactPoint() : line.getEndContactPoint();
if (contact == null) {
assert false;
// assert false;
continue;
}
final Point2D inter = intersection(rect, center, contact);
if (inter == null) {
assert false;
// assert false;
continue;
}
drawLine(ug, inter, contact);

View File

@ -219,7 +219,10 @@ public class Emoji {
final HColorSimple result = (HColorSimple) HColorSet.instance().getColorOrWhite(code);
if (colorForMonochrome == null)
return result;
return result.asMonochrome((HColorSimple) colorForMonochrome, this.minGray, this.maxGray);
final HColorSimple color = (HColorSimple) colorForMonochrome;
if (color.isGray())
return result.asMonochrome();
return result.asMonochrome(color, this.minGray, this.maxGray);
}
private void drawCircle(UGraphicWithScale ugs, String s, HColor colorForMonochrome) {

View File

@ -55,7 +55,9 @@ public class EntityImageProtected extends AbstractTextBlock implements IEntityIm
private final Neighborhood neighborhood;
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
throw new UnsupportedOperationException();
final Rectangle2D result = orig.getInnerPosition(member, stringBounder, strategy);
return new Rectangle2D.Double(result.getMinX() + border, result.getMinY() + border, result.getWidth(),
result.getHeight());
}
public EntityImageProtected(IEntityImage orig, double border, Neighborhood neighborhood, Bibliotekon bibliotekon) {

View File

@ -156,9 +156,9 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public Direction getArrowDirection() {
if (getLinkArrow() == LinkArrow.BACKWARD) {
if (getLinkArrow() == LinkArrow.BACKWARD)
return getArrowDirectionInternal().getInv();
}
return getArrowDirectionInternal();
}
@ -170,19 +170,19 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
final Point2D start = dotPath.getStartPoint();
final Point2D end = dotPath.getEndPoint();
final double ang = Math.atan2(end.getX() - start.getX(), end.getY() - start.getY());
if (ang > -Math.PI / 4 && ang < Math.PI / 4) {
if (ang > -Math.PI / 4 && ang < Math.PI / 4)
return Direction.DOWN;
}
if (ang > Math.PI * 3 / 4 || ang < -Math.PI * 3 / 4) {
if (ang > Math.PI * 3 / 4 || ang < -Math.PI * 3 / 4)
return Direction.UP;
}
return end.getX() > start.getX() ? Direction.RIGHT : Direction.LEFT;
}
public double getArrowDirection2() {
if (getLinkArrow() == LinkArrow.BACKWARD) {
if (getLinkArrow() == LinkArrow.BACKWARD)
return Math.PI + getArrowDirectionInternal2();
}
return getArrowDirectionInternal2();
}
@ -198,11 +198,10 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
private Cluster getCluster2(Bibliotekon bibliotekon, IEntity entityMutable) {
for (Cluster cl : bibliotekon.allCluster()) {
if (cl.getGroups().contains(entityMutable)) {
for (Cluster cl : bibliotekon.allCluster())
if (cl.getGroups().contains(entityMutable))
return cl;
}
}
throw new IllegalArgumentException();
}
@ -217,13 +216,12 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
this.endUid = link.getEntityPort2(bibliotekon);
Cluster ltail = null;
if (startUid.startsWith(Cluster.CENTER_ID)) {
if (startUid.startsWith(Cluster.CENTER_ID))
ltail = getCluster2(bibliotekon, link.getEntity1());
}
Cluster lhead = null;
if (endUid.startsWith(Cluster.CENTER_ID)) {
if (endUid.startsWith(Cluster.CENTER_ID))
lhead = getCluster2(bibliotekon, link.getEntity2());
}
if (link.getColors() != null) {
skinParam = link.getColors().mute(skinParam);
@ -232,9 +230,9 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
this.backgroundColor = skinParam.getBackgroundColor();
this.defaultThickness = skinParam.getThickness(LineParam.arrow, null);
this.arrowLollipopColor = skinParam.getHtmlColor(ColorParam.arrowLollipop, null, false);
if (arrowLollipopColor == null) {
if (arrowLollipopColor == null)
this.arrowLollipopColor = backgroundColor;
}
this.pragma = pragma;
this.bibliotekon = bibliotekon;
this.stringBounder = stringBounder;
@ -249,22 +247,22 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
TextBlock labelOnly;
if (Display.isNull(link.getLabel())) {
labelOnly = TextBlockUtils.EMPTY_TEXT_BLOCK;
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL) {
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL)
labelOnly = StringWithArrow.addMagicArrow(labelOnly, this, font);
}
} else {
final HorizontalAlignment alignment = getMessageTextAlignment(link.getUmlDiagramType(), skinParam);
final boolean hasSeveralGuideLines = link.getLabel().hasSeveralGuideLines();
final TextBlock block;
if (hasSeveralGuideLines) {
if (hasSeveralGuideLines)
block = StringWithArrow.addSeveralMagicArrows(link.getLabel(), this, font, alignment, skinParam);
} else {
else
block = link.getLabel().create9(font, alignment, skinParam, skinParam.maxMessageSize());
}
labelOnly = addVisibilityModifier(block, link, skinParam);
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL && hasSeveralGuideLines == false) {
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL && hasSeveralGuideLines == false)
labelOnly = StringWithArrow.addMagicArrow(labelOnly, this, font);
}
}
final TextBlock noteOnly;
@ -273,40 +271,36 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
} else {
noteOnly = new EntityImageNoteLink(link.getNote(), link.getNoteColors(), skinParam, link.getStyleBuilder());
if (link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_NOT_PRINTED
|| link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_PRINTED_FULL) {
|| link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_PRINTED_FULL)
divideLabelWidthByTwo = true;
}
}
if (link.getNotePosition() == Position.LEFT) {
if (link.getNotePosition() == Position.LEFT)
labelText = TextBlockUtils.mergeLR(noteOnly, labelOnly, VerticalAlignment.CENTER);
} else if (link.getNotePosition() == Position.RIGHT) {
else if (link.getNotePosition() == Position.RIGHT)
labelText = TextBlockUtils.mergeLR(labelOnly, noteOnly, VerticalAlignment.CENTER);
} else if (link.getNotePosition() == Position.TOP) {
else if (link.getNotePosition() == Position.TOP)
labelText = TextBlockUtils.mergeTB(noteOnly, labelOnly, HorizontalAlignment.CENTER);
} else {
else
labelText = TextBlockUtils.mergeTB(labelOnly, noteOnly, HorizontalAlignment.CENTER);
}
if (link.getQualifier1() == null) {
if (link.getQualifier1() == null)
startTailText = null;
} else {
else
startTailText = Display.getWithNewlines(link.getQualifier1()).create(font, HorizontalAlignment.CENTER,
skinParam);
}
if (link.getQualifier2() == null) {
if (link.getQualifier2() == null)
endHeadText = null;
} else {
else
endHeadText = Display.getWithNewlines(link.getQualifier2()).create(font, HorizontalAlignment.CENTER,
skinParam);
}
if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE) {
if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE)
this.labelShield = 0;
} else {
else
this.labelShield = 7;
}
}
@ -324,9 +318,9 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
private HorizontalAlignment getMessageTextAlignment(UmlDiagramType umlDiagramType, ISkinParam skinParam) {
if (umlDiagramType == UmlDiagramType.STATE) {
if (umlDiagramType == UmlDiagramType.STATE)
return skinParam.getHorizontalAlignment(AlignmentParam.stateMessageAlignment, null, false, null);
}
return skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER);
}
@ -352,15 +346,15 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
sb.append("[");
final LinkType linkType = link.getTypePatchCluster();
String decoration = linkType.getSpecificDecorationSvek();
if (decoration.length() > 0 && decoration.endsWith(",") == false) {
if (decoration.length() > 0 && decoration.endsWith(",") == false)
decoration += ",";
}
sb.append(decoration);
int length = link.getLength();
if (graphvizVersion.ignoreHorizontalLinks() && length == 1) {
if (graphvizVersion.ignoreHorizontalLinks() && length == 1)
length = 2;
}
if (useRankSame) {
if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
// if (graphvizVersion.isJs() == false) {
@ -406,22 +400,20 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
sb.append("style=invis");
}
if (link.isConstraint() == false || link.hasTwoEntryPointsSameContainer()) {
if (link.isConstraint() == false || link.hasTwoEntryPointsSameContainer())
sb.append(",constraint=false");
}
if (link.getSametail() != null) {
if (link.getSametail() != null)
sb.append(",sametail=" + link.getSametail());
}
sb.append("];");
SvekUtils.println(sb);
}
private Dimension2D eventuallyDivideByTwo(Dimension2D dim) {
if (divideLabelWidthByTwo) {
if (divideLabelWidthByTwo)
return new Dimension2DDouble(dim.getWidth() / 2, dim.getHeight());
}
return dim;
}
@ -474,24 +466,24 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
// System.err.println("angle=" + angle * 180 / Math.PI);
return extremityFactory.createUDrawable(center, angle, null);
}
if (decor == LinkDecor.EXTENDS) {
if (decor == LinkDecor.EXTENDS)
return new ExtremityFactoryExtends(backgroundColor).createUDrawable(center, angle, null);
}
return null;
}
if (extremityFactory != null) {
final List<Point2D.Double> points = pointListIterator.next();
if (points.size() == 0) {
if (points.size() == 0)
return extremityFactory.createUDrawable(center, angle, null);
}
final Point2D p0 = points.get(0);
final Point2D p1 = points.get(1);
final Point2D p2 = points.get(2);
Side side = null;
if (nodeContact != null) {
if (nodeContact != null)
side = nodeContact.getClusterPosition().getClosestSide(p1);
}
return extremityFactory.createUDrawable(p0, p1, p2, side);
} else if (decor == LinkDecor.NONE) {
final UPolygon sh = new UPolygon(pointListIterator.cloneMe().next());
@ -514,9 +506,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public void solveLine(SvgResult fullSvg) {
if (this.link.isInvis()) {
if (this.link.isInvis())
return;
}
int idx = fullSvg.getIndexFromColor(this.lineColor);
if (idx == -1) {
@ -524,15 +515,15 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
// throw new IllegalStateException();
}
idx = fullSvg.indexOf("d=\"", idx);
if (idx == -1) {
if (idx == -1)
throw new IllegalStateException();
}
final int end = fullSvg.indexOf("\"", idx + 3);
final SvgResult path = fullSvg.substring(idx + 3, end);
if (DotPath.isPathConsistent(path.getSvg()) == false) {
if (DotPath.isPathConsistent(path.getSvg()) == false)
return;
}
dotPath = new DotPath(path);
if (projectionCluster != null) {
@ -557,12 +548,11 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
this.extremity2 = getExtremity(linkType.getDecor1(), pointListIterator, dotPath.getEndPoint(),
dotPath.getEndAngle(), lhead, bibliotekon.getNode(link.getEntity2()));
if (link.getEntity1().getLeafType() == LeafType.LOLLIPOP_HALF) {
if (link.getEntity1().getLeafType() == LeafType.LOLLIPOP_HALF)
bibliotekon.getNode(link.getEntity1()).addImpact(dotPath.getStartAngle() + Math.PI);
}
if (link.getEntity2().getLeafType() == LeafType.LOLLIPOP_HALF) {
if (link.getEntity2().getLeafType() == LeafType.LOLLIPOP_HALF)
bibliotekon.getNode(link.getEntity2()).addImpact(dotPath.getEndAngle());
}
if (extremity1 instanceof Extremity && extremity2 instanceof Extremity) {
final Point2D p1 = ((Extremity) extremity1).somePoint();
@ -610,9 +600,9 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
}
if (isOpalisable() == false) {
if (isOpalisable() == false)
setOpale(false);
}
}
private boolean isOpalisable() {
@ -621,26 +611,25 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
private Point2D.Double getXY(SvgResult svgResult, int color) {
final int idx = svgResult.getIndexFromColor(color);
if (idx == -1) {
if (idx == -1)
return null;
}
return SvekUtils.getMinXY(svgResult.substring(idx).extractList(SvgResult.POINTS_EQUALS));
}
public void drawU(UGraphic ug, UStroke suggestedStroke, HColor color, Set<String> ids) {
if (opale) {
if (opale)
return;
}
ug.draw(link.commentForSvg());
ug.startGroup(UGroupType.CLASS,
"link " + link.getEntity1().getCode() + " " + link.getEntity2().getCode() + " selected");
double x = 0;
double y = 0;
final Url url = link.getUrl();
if (url != null) {
if (url != null)
ug.startUrl(url);
}
if (link.isAutoLinkOfAGroup()) {
final Cluster cl = bibliotekon.getCluster((IGroup) link.getEntity1());
@ -653,28 +642,24 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
x += dx;
y += dy;
if (link.isInvis()) {
if (link.isInvis())
return;
}
if (this.link.getColors() != null) {
final HColor newColor = this.link.getColors().getColor(ColorType.ARROW, ColorType.LINE);
if (newColor != null) {
if (newColor != null)
color = newColor;
}
} else if (this.link.getSpecificColor() != null) {
} else if (this.link.getSpecificColor() != null)
color = this.link.getSpecificColor();
}
ug = ug.apply(new HColorNone().bg()).apply(color);
final LinkType linkType = link.getType();
UStroke stroke = suggestedStroke == null || linkType.getStyle().isNormal() == false
? linkType.getStroke3(defaultThickness)
: suggestedStroke;
if (link.getColors() != null && link.getColors().getSpecificLineStroke() != null) {
if (link.getColors() != null && link.getColors().getSpecificLineStroke() != null)
stroke = link.getColors().getSpecificLineStroke();
}
ug = ug.apply(stroke);
// double moveEndY = 0;
@ -697,13 +682,12 @@ 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 Point2D p1 = ((Extremity) extremity1).isTooSmallSoGiveThePointCloserToThisOne(todraw.getStartPoint());
if (p1 != null) {
if (p1 != null)
todraw.forceStartPoint(p1.getX(), p1.getY());
}
final Point2D p2 = ((Extremity) extremity2).isTooSmallSoGiveThePointCloserToThisOne(todraw.getEndPoint());
if (p2 != null) {
if (p2 != null)
todraw.forceEndPoint(p2.getX(), p2.getY());
}
}
@ -716,19 +700,17 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
ug = ug.apply(new UStroke()).apply(color);
if (hasNoteLabelText() && this.labelXY != null
&& link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) {
&& link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED)
this.labelText.drawU(ug.apply(new UTranslate(x + this.labelXY.getPosition().getX() + labelShield,
y + this.labelXY.getPosition().getY() + labelShield)));
}
if (this.startTailText != null && this.startTailLabelXY != null
&& this.startTailLabelXY.getPosition() != null) {
if (this.startTailText != null && this.startTailLabelXY != null && this.startTailLabelXY.getPosition() != null)
this.startTailText.drawU(ug.apply(new UTranslate(x + this.startTailLabelXY.getPosition().getX(),
y + this.startTailLabelXY.getPosition().getY())));
}
if (this.endHeadText != null && this.endHeadLabelXY != null && this.endHeadLabelXY.getPosition() != null) {
if (this.endHeadText != null && this.endHeadLabelXY != null && this.endHeadLabelXY.getPosition() != null)
this.endHeadText.drawU(ug.apply(new UTranslate(x + this.endHeadLabelXY.getPosition().getX(),
y + this.endHeadLabelXY.getPosition().getY())));
}
if (linkType.getMiddleDecor() != LinkMiddleDecor.NONE) {
final PointAndAngle middle = dotPath.getMiddle();
@ -739,9 +721,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
mi.drawU(ug.apply(new UTranslate(x + middle.getX(), y + middle.getY())));
}
if (url != null) {
if (url != null)
ug.closeUrl();
}
if (link.getLinkConstraint() != null) {
final double xConstraint = x + this.labelXY.getPosition().getX();
@ -789,9 +770,9 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
while (true) {
final String candidate = comment + "-" + i;
changed = ids.add(candidate);
if (changed) {
if (changed)
return candidate;
}
i++;
}
}
@ -803,21 +784,21 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
if (this.extremity2 != null) {
UGraphic ug2 = ug.apply(color).apply(stroke.onlyThickness());
if (linkType.getDecor1().isFill()) {
if (linkType.getDecor1().isFill())
ug2 = ug2.apply(color.bg());
} else {
else
ug2 = ug2.apply(new HColorNone().bg());
}
// System.err.println("Line::draw EXTREMITY1");
this.extremity2.drawU(ug2);
}
if (this.extremity1 != null) {
UGraphic ug2 = ug.apply(color).apply(stroke.onlyThickness());
if (linkType.getDecor2().isFill()) {
if (linkType.getDecor2().isFill())
ug2 = ug2.apply(color.bg());
} else {
else
ug2 = ug2.apply(new HColorNone().bg());
}
// System.err.println("Line::draw EXTREMITY2");
this.extremity1.drawU(ug2);
}
@ -840,24 +821,24 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public double getHorizontalDzeta(StringBounder stringBounder) {
if (startUid.equalsId(endUid)) {
if (startUid.equalsId(endUid))
return getDecorDzeta();
}
final ArithmeticStrategy strategy;
if (isHorizontal()) {
if (isHorizontal())
strategy = new ArithmeticStrategySum();
} else {
else
return 0;
}
if (hasNoteLabelText()) {
if (hasNoteLabelText())
strategy.eat(labelText.calculateDimension(stringBounder).getWidth());
}
if (startTailText != null) {
if (startTailText != null)
strategy.eat(startTailText.calculateDimension(stringBounder).getWidth());
}
if (endHeadText != null) {
if (endHeadText != null)
strategy.eat(endHeadText.calculateDimension(stringBounder).getWidth());
}
return strategy.getResult() + getDecorDzeta();
}
@ -866,36 +847,34 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public double getVerticalDzeta(StringBounder stringBounder) {
if (startUid.equalsId(endUid)) {
if (startUid.equalsId(endUid))
return getDecorDzeta();
}
if (isHorizontal()) {
if (isHorizontal())
return 0;
}
final ArithmeticStrategy strategy = new ArithmeticStrategySum();
if (hasNoteLabelText()) {
if (hasNoteLabelText())
strategy.eat(labelText.calculateDimension(stringBounder).getHeight());
}
if (startTailText != null) {
if (startTailText != null)
strategy.eat(startTailText.calculateDimension(stringBounder).getHeight());
}
if (endHeadText != null) {
if (endHeadText != null)
strategy.eat(endHeadText.calculateDimension(stringBounder).getHeight());
}
return strategy.getResult() + getDecorDzeta();
}
public void manageCollision(Collection<SvekNode> allNodes) {
for (SvekNode sh : allNodes) {
final Positionable cl = PositionableUtils.addMargin(sh, 8, 8);
if (startTailText != null && startTailLabelXY != null
&& PositionableUtils.intersect(cl, startTailLabelXY)) {
if (startTailText != null && startTailLabelXY != null && PositionableUtils.intersect(cl, startTailLabelXY))
startTailLabelXY = PositionableUtils.moveAwayFrom(cl, startTailLabelXY);
}
if (endHeadText != null && endHeadLabelXY != null && PositionableUtils.intersect(cl, endHeadLabelXY)) {
if (endHeadText != null && endHeadLabelXY != null && PositionableUtils.intersect(cl, endHeadLabelXY))
endHeadLabelXY = PositionableUtils.moveAwayFrom(cl, endHeadLabelXY);
}
}
// final Positionable start = getStartTailPositionnable();
@ -993,12 +972,12 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public Point2D getMyPoint(IEntity entity) {
if (link.getEntity1() == entity) {
if (link.getEntity1() == entity)
return moveDelta(dotPath.getStartPoint());
}
if (link.getEntity2() == entity) {
if (link.getEntity2() == entity)
return moveDelta(dotPath.getEndPoint());
}
throw new IllegalArgumentException();
}
@ -1011,25 +990,27 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
}
public Point2D getStartContactPoint() {
final Point2D start = dotPath.getStartPoint();
if (start == null) {
if (dotPath == null)
return null;
}
final Point2D start = dotPath.getStartPoint();
if (start == null)
return null;
return new Point2D.Double(dx + start.getX(), dy + start.getY());
}
public Point2D getEndContactPoint() {
final Point2D end = dotPath.getEndPoint();
if (end == null) {
if (end == null)
return null;
}
return new Point2D.Double(dx + end.getX(), dy + end.getY());
}
public IEntity getOther(IEntity entity) {
if (link.contains(entity)) {
if (link.contains(entity))
return link.getOther(entity);
}
return null;
}

View File

@ -270,6 +270,8 @@ public class ImageBuilder {
final Scale scale = titledDiagram == null ? null : titledDiagram.getScale();
final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * getDpi()
/ 96.0;
if (scaleFactor <= 0)
throw new IllegalStateException("Bad scaleFactor");
UGraphic ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor);
maybeDrawBorder(ug, dim);
if (randomPixel) {
@ -442,8 +444,8 @@ public class ImageBuilder {
}
private UGraphic createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms,
double dx, double dy, String watermark) {
private UGraphic createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms, double dx,
double dy, String watermark) {
Color backColor = getDefaultBackColor();
if (this.backcolor instanceof HColorSimple) {

View File

@ -150,6 +150,14 @@ public class HColorSimple extends HColorAbstract implements HColor {
return monochrome;
}
public boolean isGray() {
if (monochrome)
return true;
if (color.getRed() == color.getGreen() && color.getGreen() == color.getBlue())
return true;
return false;
}
public static HColorSimple unlinear(HColorSimple color1, HColorSimple color2, int completionInt) {
final HSLColor col1 = new HSLColor(color1.color);
final HSLColor col2 = new HSLColor(color2.color);

View File

@ -80,7 +80,7 @@ public class Version {
}
public static int beta() {
final int beta = 3;
final int beta = 4;
return beta;
}