1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 04:55:10 +00:00
This commit is contained in:
Arnaud Roques 2022-09-15 19:24:26 +02:00
parent 206f807952
commit 2d07f5ae2c
89 changed files with 594 additions and 826 deletions

View File

@ -72,13 +72,12 @@ stereotype {
element {
Shadowing 0.0
title {
FontStyle bold
}
}
element {
LineThickness 0.5
composite {
title {
FontStyle bold
}
}
}
group {
@ -226,6 +225,9 @@ stateDiagram {
group {
LineThickness 0.5
}
header {
FontSize 12
}
}

View File

@ -68,8 +68,10 @@ stereotype {
element {
Shadowing 4.0
title {
FontStyle bold
composite {
title {
FontStyle bold
}
}
}

View File

@ -210,7 +210,8 @@ try {
ST_adjmatrix_t rv = new ST_adjmatrix_t();
rv.nrows = i;
rv.ncols = j;
rv.data = new int[i][j]; // Or maybe new int[j][i] ?
// Arnaud 15/09/2022: the j+1 is needed in some case to avoid ArrayIndexOutOfBoundsException
rv.data = new int[i][j+1]; // Or maybe new int[j][i] ?
return rv;
} finally {
LEAVING("756bre1tpxb1tq68p7xhkrxkc","new_matrix");

View File

@ -306,7 +306,7 @@ static private HColorSet colors = HColorSet.instance();
private Color decodeInternal(String value) {
if (value!=null) {
try {
return new ColorMapperIdentity().toColor(colors.getColor(ThemeStyle.LIGHT_REGULAR, value));
return colors.getColor(ThemeStyle.LIGHT_REGULAR, value).toColor(new ColorMapperIdentity());
} catch (NoSuchColorException e) {
return Color.WHITE;
}

View File

@ -83,7 +83,6 @@ 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;
@ -302,7 +301,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 (HColors.isTransparent(back) == false) {
if (back != null && back.isTransparent() == false) {
final LaneDivider divider2 = dividers.get(i + 1);
final UGraphic background = ug.apply(back.bg()).apply(back)
.apply(UTranslate.dx(xpos - divider1.getX2()));

View File

@ -39,12 +39,11 @@ 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 (HColors.isTransparent(param.getColor()) == false)
if (param.getColor().isTransparent() == false)
grid.drawDotPath(x, y, shape);
}

View File

@ -36,6 +36,6 @@
package net.sourceforge.plantuml.creole;
public enum CreoleMode {
FULL, SIMPLE_LINE, NO_CREOLE;
FULL, SIMPLE_LINE, NO_CREOLE, FULL_BUT_UNDERSCORE;
}

View File

@ -101,7 +101,7 @@ public class AtomMath extends AbstractAtom implements Atom {
private Color getColor(HColor color, Color defaultValue) {
if (color instanceof HColorSimple)
return colorMapper.toColor(color);
return color.toColor(colorMapper);
return defaultValue;

View File

@ -57,7 +57,6 @@ 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.HColors;
import net.sourceforge.plantuml.utils.CharHidder;
public final class AtomText extends AbstractAtom implements Atom {
@ -142,7 +141,7 @@ public final class AtomText extends AbstractAtom implements Atom {
FontConfiguration useFontConfiguration = fontConfiguration;
HColor backcolor = ug.getParam().getBackcolor();
if (HColors.isTransparent(backcolor))
if (backcolor.isTransparent())
backcolor = ug.getDefaultBackground();
textColor = textColor.getAppropriateColor(backcolor);

View File

@ -76,16 +76,23 @@ import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbols;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Kal;
import net.sourceforge.plantuml.svek.Margins;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy;
import net.sourceforge.plantuml.svek.image.EntityImageStateCommon;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -839,4 +846,29 @@ final public class EntityImpl implements ILeaf, IGroup {
return isStatic;
}
// For group
public TextBlock getStateHeader(ISkinParam skinParam) {
checkGroup();
final Style style = EntityImageStateCommon.getStyleStateHeader(this, skinParam);
final List<CharSequence> details = getBodier().getRawBody();
if (details.size() == 0)
return new TextBlockEmpty();
if (style == null)
throw new IllegalArgumentException();
final FontConfiguration fontConfiguration = FontConfiguration.create(skinParam, style);
Display display = null;
for (CharSequence s : details)
if (display == null)
display = Display.getWithNewlines(s.toString());
else
display = display.addAll(Display.getWithNewlines(s.toString()));
return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
}
}

View File

@ -72,7 +72,7 @@ public class SpriteSvgNanoParser implements Sprite {
} else if (color == null)
ug.draw(img.scale(scale));
else
ug.draw(img.muteColor(colorMapper.toColor(color)).scale(scale));
ug.draw(img.muteColor(color.toColor(colorMapper)).scale(scale));
// ug.draw(img.muteColor(((HColorSimple) color).getColor999()).scale(scale));

View File

@ -21,8 +21,9 @@ import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorChangerMonochrome;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperMonochrome;
import net.sourceforge.plantuml.ugraphic.color.ColorUtils;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
@ -120,7 +121,7 @@ public class SvgNanoParser implements Sprite {
}
private int getGray(HColor col) {
final Color tmp = new ColorChangerMonochrome().getChangedColor(col);
final Color tmp = ColorUtils.getGrayScaleColor(col.toColor(new ColorMapperMonochrome(false)));
return tmp.getGreen();
}

View File

@ -339,7 +339,7 @@ public class EpsGraphics {
final public void epsPolygon(HColorGradient gr, ColorMapper mapper, double... points) {
assert points.length % 2 == 0;
setFillColor(mapper.toColor(gr.getColor1()));
setFillColor(gr.getColor1().toColor(mapper));
epsPolygon(points);
}
@ -419,8 +419,8 @@ public class EpsGraphics {
if (rx == 0 && ry == 0) {
simplerectUsed = true;
appendColorShort(mapper.toColor(gr.getColor1()));
appendColorShort(mapper.toColor(gr.getColor2()));
appendColorShort(gr.getColor1().toColor(mapper));
appendColorShort(gr.getColor2().toColor(mapper));
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y), true);
append("100 -1 1 {", true);
append("100 div", true);
@ -442,8 +442,8 @@ public class EpsGraphics {
append("initclip", true);
} else {
roundrectUsed = true;
appendColorShort(mapper.toColor(gr.getColor1()));
appendColorShort(mapper.toColor(gr.getColor2()));
appendColorShort(gr.getColor1().toColor(mapper));
appendColorShort(gr.getColor2().toColor(mapper));
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " "
+ format((rx + ry) / 2), true);
append("100 -1 1 {", true);

View File

@ -111,7 +111,7 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage {
public static TextBlockBackcolored createBlackOnWhite(List<String> strings, BufferedImage image,
GraphicPosition position) {
return new GraphicStrings(strings, sansSerif12(HColors.BLACK), HColors.WHITE, image, position,
CreoleMode.FULL);
CreoleMode.FULL_BUT_UNDERSCORE);
}
public static FontConfiguration sansSerif12(HColor color) {

View File

@ -48,7 +48,6 @@ 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 {
@ -102,7 +101,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 (HColors.isTransparent(back) == false)
if (back != null && back.isTransparent() == false)
ug.apply(UTranslate.dy(y)).apply(back).apply(back.bg())
.draw(new URectangle(dimtotal.getWidth(), dimb.getHeight()));

View File

@ -113,7 +113,7 @@ public class PSystemLatex extends AbstractPSystem {
private Color getColor(final String col) {
final HColor col2 = col == null ? null : HColorSet.instance().getColorOrWhite(col);
final Color col3 = new ColorMapperIdentity().toColor(col2);
final Color col3 = col2.toColor(new ColorMapperIdentity());
return col3;
}

View File

@ -114,7 +114,7 @@ public class PSystemMath extends AbstractPSystem {
private Color getColor(final String col) {
final HColor col2 = col == null ? null : HColorSet.instance().getColorOrWhite(col);
final Color col3 = new ColorMapperIdentity().toColor(col2);
final Color col3 = col2.toColor(new ColorMapperIdentity());
return col3;
}

View File

@ -59,7 +59,6 @@ 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 {
@ -130,7 +129,7 @@ public class FingerImpl implements Finger, UDrawable {
child.drawU(ug.apply(new UTranslate(p2)));
final HColor linkColor = getLinkColor();
if (HColors.isTransparent(linkColor) == false)
if (linkColor.isTransparent() == false)
drawLine(ug.apply(linkColor).apply(getUStroke()), p1, p2);
}

View File

@ -226,7 +226,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
final HColor back = timelineStyle.value(PName.BackGroundColor)
.asColor(getSkinParam().getThemeStyle(), getIHtmlColorSet());
if (HColors.isTransparent(back) == false) {
if (back.isTransparent() == false) {
final URectangle rect1 = new URectangle(calculateDimension(ug.getStringBounder()).getWidth(),
timeHeader.getTimeHeaderHeight());
ug.apply(back.bg()).draw(rect1);

View File

@ -63,7 +63,6 @@ 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.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class TaskDrawSeparator implements TaskDraw {
@ -142,7 +141,7 @@ public class TaskDrawSeparator implements TaskDraw {
final HColor backColor = getStyle().value(PName.BackGroundColor)
.asColor(styleBuilder.getSkinParam().getThemeStyle(), colorSet);
if (HColors.isTransparent(backColor) == false) {
if (backColor.isTransparent() == false) {
final double height = padding.getTop() + getTextHeight(stringBounder) + padding.getBottom();
if (height > 0) {
final URectangle rect = new URectangle(end - start, height);

View File

@ -72,14 +72,13 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -87,12 +86,10 @@ import net.sourceforge.plantuml.graphic.QuoteUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Cluster;
import net.sourceforge.plantuml.svek.ClusterHeader;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.DotStringFactory;
import net.sourceforge.plantuml.svek.GeneralImageBuilder;
@ -253,31 +250,9 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
if (g.getGroupType() == GroupType.CONCURRENT_STATE)
return;
int titleAndAttributeWidth = 0;
int titleAndAttributeHeight = 0;
final TextBlock title = getTitleBlock(g);
final TextBlock stereo = getStereoBlock(g);
final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
final XDimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
if (dimLabel.getWidth() > 0) {
final TextBlock attribute = GeneralImageBuilder.stateHeader(g, null, diagram.getSkinParam());
final XDimension2D dimAttribute = attribute.calculateDimension(stringBounder);
final double attributeHeight = dimAttribute.getHeight();
final double attributeWidth = dimAttribute.getWidth();
final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0;
final USymbol uSymbol = g.getUSymbol();
final int suppHeightBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppHeightBecauseOfShape();
final int suppWidthBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppWidthBecauseOfShape();
titleAndAttributeWidth = (int) Math.max(dimLabel.getWidth(), attributeWidth) + suppWidthBecauseOfShape;
titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields
+ suppHeightBecauseOfShape);
}
dotStringFactory.openCluster(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo, g);
final ClusterHeader clusterHeader = new ClusterHeader((EntityImpl) g, diagram.getSkinParam(), diagram,
stringBounder);
dotStringFactory.openCluster(g, clusterHeader);
this.printEntities(g.getLeafsDirect());
printAllSubgroups(g);
@ -285,11 +260,6 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
dotStringFactory.closeCluster();
}
private Style getStyle(FontParam fontParam) {
return fontParam.getStyleDefinition(SName.stateDiagram)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
}
private void printEntities(Collection<ILeaf> entities) {
for (ILeaf ent : entities) {
if (ent.isRemoved())
@ -334,38 +304,6 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
dotStringFactory.addNode(node);
}
private TextBlock getTitleBlock(IGroup g) {
final Display label = g.getDisplay();
if (label == null)
return TextBlockUtils.empty(0, 0);
final ISkinParam skinParam = diagram.getSkinParam();
final FontConfiguration fontConfiguration = g.getFontConfigurationForTitle(skinParam);
return label.create(fontConfiguration, HorizontalAlignment.CENTER, skinParam);
}
private TextBlock getStereoBlock(IGroup g) {
final Stereotype stereotype = g.getStereotype();
if (stereotype == null)
return TextBlockUtils.empty(0, 0);
final TextBlock tmp = stereotype.getSprite(diagram.getSkinParam());
if (tmp != null)
return tmp;
final List<String> stereos = stereotype.getLabels(diagram.getSkinParam().guillemet());
if (stereos == null)
return TextBlockUtils.empty(0, 0);
final boolean show = diagram.showPortion(EntityPortion.STEREOTYPE, g);
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),
HorizontalAlignment.CENTER, diagram.getSkinParam());
}
private Collection<ILeaf> getUnpackagedEntities() {
final List<ILeaf> result = new ArrayList<>();
for (ILeaf ent : diagram.getLeafsvalues())

View File

@ -71,7 +71,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
@Override
protected void drawBackgroundInternalU(UGraphic ug, Area area) {
if (HColors.isTransparent(backgroundColor))
if (backgroundColor.isTransparent())
return;
final XDimension2D dimensionToUse = area.getDimensionToUse();

View File

@ -51,14 +51,13 @@ import net.sourceforge.plantuml.code.NoPlantumlCompressionException;
import net.sourceforge.plantuml.code.PairInt;
import net.sourceforge.plantuml.code.SpiralOnRectangle;
import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.ugraphic.color.ColorChangerMonochrome;
import net.sourceforge.plantuml.ugraphic.color.ColorUtils;
public enum SpriteGrayLevel {
GRAY_16(16), GRAY_8(8), GRAY_4(4);
private final int nbColor;
private static final ColorChangerMonochrome mono = new ColorChangerMonochrome();
private SpriteGrayLevel(int nbColor) {
this.nbColor = nbColor;
@ -166,7 +165,7 @@ public enum SpriteGrayLevel {
if (y >= img.getHeight()) {
return 0;
}
final Color g = mono.getChangedColor(new Color(img.getRGB(x, y)));
final Color g = ColorUtils.getGrayScaleColor(new Color(img.getRGB(x, y)));
final int gray = 255 - g.getRed();
return gray / 16;
}

View File

@ -71,7 +71,7 @@ public class SpriteImage implements Sprite {
else if (color == null)
ug.draw(img.scale(scale));
else
ug.draw(img.muteColor(colorMapper.toColor(color)).scale(scale));
ug.draw(img.muteColor(color.toColor(colorMapper)).scale(scale));
}
public XDimension2D calculateDimension(StringBounder stringBounder) {

View File

@ -178,10 +178,10 @@ public class SpriteMonochrome implements Sprite {
public UImage toUImage(ColorMapper colorMapper, HColor backcolor, HColor color) {
if (backcolor == null || HColors.isTransparent(backcolor))
if (backcolor == null || backcolor.isTransparent())
backcolor = HColors.WHITE.withDark(HColors.BLACK);
if (color == null || HColors.isTransparent(color))
if (color == null || color.isTransparent())
color = HColors.BLACK.withDark(HColors.WHITE);
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

View File

@ -161,7 +161,7 @@ public class FromSkinparamToStyle {
addConvert("titleBorderColor", PName.LineColor, SName.title);
addConvert("titleBackgroundColor", PName.BackGroundColor, SName.title);
addConvert("titleBorderRoundCorner", PName.RoundCorner, SName.title);
addConFont("title", SName.title);
addConFont("title", SName.document, SName.title);
addConvert("legendBorderThickness", PName.LineThickness, SName.legend);
addConvert("legendBorderColor", PName.LineColor, SName.legend);

View File

@ -60,6 +60,7 @@ public enum SName {
collection, //
collections, //
component, //
composite, //
robust, //
concise, //
clock, //

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.USymbol;
@ -75,15 +76,14 @@ import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.image.EntityImageNoteLink;
import net.sourceforge.plantuml.svek.image.EntityImageState;
import net.sourceforge.plantuml.svek.image.EntityImageStateCommon;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGroupType;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -108,10 +108,7 @@ public class Cluster implements Moveable {
private final ISkinParam skinParam;
protected final CucaDiagram diagram;
private int titleAndAttributeWidth;
private int titleAndAttributeHeight;
private TextBlock ztitle;
private TextBlock zstereo;
private ClusterHeader clusterHeader;
private XPoint2D xyTitle;
@ -235,13 +232,10 @@ public class Cluster implements Moveable {
return Collections.unmodifiableList(children);
}
public Cluster createChild(int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title,
TextBlock stereo, ColorSequence colorSequence, ISkinParam skinParam, IGroup g) {
public Cluster createChild(ClusterHeader clusterHeader, ColorSequence colorSequence, ISkinParam skinParam,
IGroup g) {
final Cluster child = new Cluster(diagram, this, colorSequence, skinParam, g);
child.titleAndAttributeWidth = titleAndAttributeWidth;
child.titleAndAttributeHeight = titleAndAttributeHeight;
child.ztitle = title;
child.zstereo = stereo;
child.clusterHeader = clusterHeader;
this.children.add(child);
return child;
}
@ -255,11 +249,11 @@ public class Cluster implements Moveable {
}
public final int getTitleAndAttributeWidth() {
return titleAndAttributeWidth;
return clusterHeader.getTitleAndAttributeWidth();
}
public final int getTitleAndAttributeHeight() {
return titleAndAttributeHeight;
return clusterHeader.getTitleAndAttributeHeight();
}
public ClusterPosition getClusterPosition() {
@ -286,13 +280,6 @@ public class Cluster implements Moveable {
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group, symbol.getSName());
}
static public StyleSignature getDefaultStyleDefinitionStateGroup(Stereotype stereotype) {
if (stereotype == null)
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.group);
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.group)
.withTOBECHANGED(stereotype);
}
public void drawU(UGraphic ug, UmlDiagramType umlDiagramType, ISkinParam skinParam2unused) {
if (group.isHidden())
return;
@ -302,7 +289,6 @@ public class Cluster implements Moveable {
getCucaNote(Position.TOP).drawU(ug.apply(new UTranslate(xyNoteTop)));
if (xyNoteBottom != null)
getCucaNote(Position.BOTTOM).drawU(ug.apply(new UTranslate(xyNoteBottom)));
}
final String fullName = group.getCodeGetName();
@ -352,18 +338,12 @@ public class Cluster implements Moveable {
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
if (ztitle != null || zstereo != null) {
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle,
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(clusterPosition.getDimension());
rect.setDeltaShadow(shadowing);
ug = ug.apply(backColor.bg()).apply(borderColor);
ug.apply(new UStroke(2)).apply(clusterPosition.getPosition()).draw(rect);
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(),
clusterHeader.getTitle(), clusterHeader.getStereo(), clusterPosition, stroke);
decoration.drawU(ug, backColor, borderColor, shadowing, rounded,
skinParam.getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null),
skinParam.getStereotypeAlignment(), diagonalCorner);
} catch (Exception e) {
e.printStackTrace();
} finally {
@ -403,20 +383,19 @@ public class Cluster implements Moveable {
insides.add(in.getClusterPosition());
final FrontierCalculator frontierCalculator = new FrontierCalculator(getClusterPosition(), insides, points);
if (titleAndAttributeHeight > 0 && titleAndAttributeWidth > 0)
frontierCalculator.ensureMinWidth(titleAndAttributeWidth + 10);
if (getTitleAndAttributeWidth() > 0 && getTitleAndAttributeHeight() > 0)
frontierCalculator.ensureMinWidth(getTitleAndAttributeWidth() + 10);
this.clusterPosition = frontierCalculator.getSuggestedPosition();
final double widthTitle = ztitle.calculateDimension(stringBounder).getWidth();
final double widthTitle = clusterHeader.getTitle().calculateDimension(stringBounder).getWidth();
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(xyTitle.x)));
clusterHeader.getTitle().drawU(ug.apply(UTranslate.dx(xyTitle.x)));
final ULine line = ULine.vline(clusterPosition.getHeight());
ug = ug.apply(borderColor);
@ -425,55 +404,27 @@ public class Cluster implements Moveable {
}
// GroupPngMakerState
private Style getStyleStateHeader() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.header)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
private Style getStyleState() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
private Style getStyleStateBody() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.stateBody)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
// GroupPngMakerState
private void drawUState(UGraphic ug, UmlDiagramType umlDiagramType, double rounded, double shadowing) {
final XDimension2D total = clusterPosition.getDimension();
final double suppY;
if (ztitle == null)
suppY = 0;
else
suppY = ztitle.calculateDimension(ug.getStringBounder()).getHeight() + IEntityImage.MARGIN;
final Style styleGroup = getDefaultStyleDefinitionStateGroup(group.getStereotype())
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final double suppY = clusterHeader.getTitle().calculateDimension(ug.getStringBounder()).getHeight()
+ IEntityImage.MARGIN;
HColor borderColor = group.getColors().getColor(ColorType.LINE);
if (borderColor == null)
borderColor = getStyleState().value(PName.LineColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
borderColor = EntityImageStateCommon.getStyleState(group, skinParam).value(PName.LineColor)
.asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
HColor backColor = group.getColors().getColor(ColorType.BACK);
if (backColor == null)
backColor = getStyleState().value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
backColor = EntityImageStateCommon.getStyleState(group, skinParam).value(PName.BackGroundColor)
.asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
// final HColor imgBackcolor = HColorUtils.transparent();
final HColor imgBackcolor = EntityImageStateCommon.getStyleStateBody(group, skinParam)
.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
final HColor imgBackcolor = getStyleStateBody().value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
// final HColor imgBackcolor = getBackColor(umlDiagramType, styleGroup);
// final Style style = getStyle(FontParam.STATE_ATTRIBUTE, skinParam2);
final TextBlock attribute = GeneralImageBuilder.stateHeader(group, styleGroup, skinParam);
final TextBlock attribute = ((EntityImpl) group).getStateHeader(skinParam);
final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight();
if (total.getWidth() == 0) {
System.err.println("Cluster::drawUState issue");
@ -482,15 +433,14 @@ public class Cluster implements Moveable {
UStroke stroke = group.getColors().getSpecificLineStroke();
if (stroke == null)
stroke = getStyleState().getStroke();
stroke = EntityImageStateCommon.getStyleState(group, skinParam).getStroke();
final RoundedContainer r = new RoundedContainer(total, suppY,
attributeHeight + (attributeHeight > 0 ? IEntityImage.MARGIN : 0), borderColor, backColor, imgBackcolor,
stroke, rounded, shadowing);
r.drawU(ug.apply(clusterPosition.getPosition()));
if (ztitle != null)
ztitle.drawU(ug.apply(new UTranslate(xyTitle)));
clusterHeader.getTitle().drawU(ug.apply(new UTranslate(xyTitle)));
if (attributeHeight > 0)
attribute.drawU(ug.apply(new UTranslate(clusterPosition.getMinX() + IEntityImage.MARGIN,
@ -671,10 +621,8 @@ public class Cluster implements Moveable {
double checkFolderPosition(XPoint2D pt, StringBounder stringBounder) {
if (getClusterPosition().isPointJustUpper(pt)) {
if (ztitle == null)
return 0;
final XDimension2D dimTitle = ztitle.calculateDimension(stringBounder);
final XDimension2D dimTitle = clusterHeader.getTitle().calculateDimension(stringBounder);
if (pt.getX() < getClusterPosition().getMinX() + dimTitle.getWidth())
return 0;
@ -693,9 +641,7 @@ public class Cluster implements Moveable {
}
public XDimension2D getTitleDimension(StringBounder stringBounder) {
if (ztitle == null)
return null;
return ztitle.calculateDimension(stringBounder);
return clusterHeader.getTitle().calculateDimension(stringBounder);
}
// public XPoint2D projection(double x, double y) {

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class ClusterDecoration {

View File

@ -0,0 +1,177 @@
/* ========================================================================
* 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
* Contribution : Hisashi Miyashita
* Contribution : Serge Wenger
*
*
*/
package net.sourceforge.plantuml.svek;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.PortionShower;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbols;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
public final class ClusterHeader {
private int titleAndAttributeWidth = 0;
private int titleAndAttributeHeight = 0;
final private TextBlock title;
final private TextBlock stereo;
public ClusterHeader(EntityImpl g, ISkinParam skinParam, PortionShower portionShower, StringBounder stringBounder) {
this.title = getTitleBlock(g, skinParam);
this.stereo = getStereoBlock(g, skinParam, portionShower);
final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
final XDimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
if (dimLabel.getWidth() > 0) {
final XDimension2D dimAttribute = ((EntityImpl) g).getStateHeader(skinParam)
.calculateDimension(stringBounder);
final double attributeHeight = dimAttribute.getHeight();
final double attributeWidth = dimAttribute.getWidth();
final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0;
final USymbol uSymbol = g.getUSymbol();
final int suppHeightBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppHeightBecauseOfShape();
final int suppWidthBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppWidthBecauseOfShape();
this.titleAndAttributeWidth = (int) Math.max(dimLabel.getWidth(), attributeWidth) + suppWidthBecauseOfShape;
this.titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields
+ suppHeightBecauseOfShape);
}
}
public final int getTitleAndAttributeWidth() {
return titleAndAttributeWidth;
}
public final int getTitleAndAttributeHeight() {
return titleAndAttributeHeight;
}
public final TextBlock getTitle() {
return title;
}
public final TextBlock getStereo() {
return stereo;
}
private TextBlock getTitleBlock(EntityImpl g, ISkinParam skinParam) {
final Display label = g.getDisplay();
if (label == null)
return TextBlockUtils.empty(0, 0);
final SName sname = skinParam.getUmlDiagramType().getStyleName();
final StyleSignatureBasic signature;
final USymbol uSymbol = g.getUSymbol();
if (g.getGroupType() == GroupType.STATE)
signature = StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state,
SName.composite, SName.title);
else if (uSymbol != null)
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, uSymbol.getSName(), SName.composite,
SName.title);
else
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, SName.composite, SName.title);
final Style style = signature //
.withTOBECHANGED(g.getStereotype()) //
.with(g.getStereostyles()) //
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet(), g.getColors());
final HorizontalAlignment alignment = HorizontalAlignment.CENTER;
return label.create(fontConfiguration, alignment, skinParam);
}
private TextBlock getStereoBlock(EntityImpl g, ISkinParam skinParam, PortionShower portionShower) {
final TextBlock stereo = getStereoBlockWithoutLegend(g, portionShower, skinParam);
final DisplayPositioned legend = g.getLegend();
if (legend == null || legend.isNull())
return stereo;
final TextBlock legendBlock = EntityImageLegend.create(legend.getDisplay(), skinParam);
return DecorateEntityImage.add(legendBlock, stereo, legend.getHorizontalAlignment(),
legend.getVerticalAlignment());
}
private TextBlock getStereoBlockWithoutLegend(EntityImpl g, PortionShower portionShower, ISkinParam skinParam) {
final Stereotype stereotype = g.getStereotype();
// final DisplayPositionned legend = g.getLegend();
if (stereotype == null)
return TextBlockUtils.empty(0, 0);
final TextBlock tmp = stereotype.getSprite(skinParam);
if (tmp != null)
return tmp;
final List<String> stereos = stereotype.getLabels(skinParam.guillemet());
if (stereos == null)
return TextBlockUtils.empty(0, 0);
final boolean show = portionShower.showPortion(EntityPortion.STEREOTYPE, g);
if (show == false)
return TextBlockUtils.empty(0, 0);
final Style style = Cluster
.getDefaultStyleDefinition(skinParam.getUmlDiagramType().getStyleName(), g.getUSymbol())
.forStereotypeItself(g.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
return Display.create(stereos).create(fontConfiguration, HorizontalAlignment.CENTER, skinParam);
}
}

View File

@ -468,10 +468,8 @@ public class DotStringFactory implements Moveable {
return idx;
}
public void openCluster(int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title, TextBlock stereo,
IGroup g) {
this.current = current.createChild(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo,
colorSequence, skinParam, g);
public void openCluster(IGroup g, ClusterHeader clusterHeader) {
this.current = current.createChild(clusterHeader, colorSequence, skinParam, g);
bibliotekon.addCluster(this.current);
}

View File

@ -47,7 +47,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.BaseFile;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
@ -57,13 +56,9 @@ import net.sourceforge.plantuml.Pragma;
import net.sourceforge.plantuml.SkinParamSameClassWidth;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.GroupType;
@ -81,22 +76,17 @@ import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.descdiagram.EntityImageDesignedDomain;
import net.sourceforge.plantuml.descdiagram.EntityImageDomain;
import net.sourceforge.plantuml.descdiagram.EntityImageMachine;
import net.sourceforge.plantuml.descdiagram.EntityImageRequirement;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbolHexagon;
import net.sourceforge.plantuml.graphic.USymbolInterface;
import net.sourceforge.plantuml.graphic.USymbols;
import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.security.SecurityProfile;
import net.sourceforge.plantuml.security.SecurityUtils;
@ -169,7 +159,7 @@ public final class GeneralImageBuilder {
if (leaf.getLeafType() == LeafType.ACTIVITY)
return new EntityImageActivity(leaf, skinParam, bibliotekon);
if (/*(leaf.getLeafType() == LeafType.PORT) || */leaf.getLeafType() == LeafType.PORTIN
if (/* (leaf.getLeafType() == LeafType.PORT) || */leaf.getLeafType() == LeafType.PORTIN
|| leaf.getLeafType() == LeafType.PORTOUT) {
final Cluster parent = bibliotekon.getCluster(leaf.getParentContainer());
return new EntityImagePort(leaf, skinParam, parent, bibliotekon, umlDiagramType.getStyleName());
@ -617,29 +607,10 @@ public final class GeneralImageBuilder {
return;
}
}
int titleAndAttributeWidth = 0;
int titleAndAttributeHeight = 0;
final TextBlock title = getTitleBlock(g);
final TextBlock stereo = getStereoBlock(g);
final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
final XDimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
if (dimLabel.getWidth() > 0) {
final XDimension2D dimAttribute = stateHeader((IEntity) g, getStyleState(FontParam.STATE_ATTRIBUTE),
dotData.getSkinParam()).calculateDimension(stringBounder);
final double attributeHeight = dimAttribute.getHeight();
final double attributeWidth = dimAttribute.getWidth();
final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0;
final USymbol uSymbol = g.getUSymbol();
final int suppHeightBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppHeightBecauseOfShape();
final int suppWidthBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppWidthBecauseOfShape();
titleAndAttributeWidth = (int) Math.max(dimLabel.getWidth(), attributeWidth) + suppWidthBecauseOfShape;
titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields
+ suppHeightBecauseOfShape);
}
dotStringFactory.openCluster(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo, g);
final ClusterHeader clusterHeader = new ClusterHeader((EntityImpl) g, dotData.getSkinParam(), dotData,
stringBounder);
dotStringFactory.openCluster(g, clusterHeader);
this.printEntities(dotStringFactory, g.getLeafsDirect());
printGroups(dotStringFactory, g);
@ -647,106 +618,6 @@ public final class GeneralImageBuilder {
dotStringFactory.closeCluster();
}
public static TextBlock stateHeader(IEntity group, Style style, ISkinParam skinParam) {
final List<CharSequence> details = group.getBodier().getRawBody();
if (details.size() == 0)
return new TextBlockEmpty();
final FontConfiguration fontConfiguration;
if (style == null)
fontConfiguration = FontConfiguration.create(skinParam, FontParam.STATE_ATTRIBUTE, null);
else
fontConfiguration = FontConfiguration.create(skinParam, style);
Display display = null;
for (CharSequence s : details)
if (display == null)
display = Display.getWithNewlines(s.toString());
else
display = display.addAll(Display.getWithNewlines(s.toString()));
return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
}
private Style getStyleState(FontParam fontParam) {
return fontParam.getStyleDefinition(SName.stateDiagram)
.getMergedStyle(dotData.getSkinParam().getCurrentStyleBuilder());
}
private TextBlock getTitleBlock(IGroup g) {
final Display label = g.getDisplay();
if (label == null)
return TextBlockUtils.empty(0, 0);
final ISkinParam skinParam = dotData.getSkinParam();
final SName sname = dotData.getUmlDiagramType().getStyleName();
final StyleSignatureBasic signature;
final USymbol uSymbol = g.getUSymbol();
if (g.getGroupType() == GroupType.STATE)
signature = StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state,
SName.header);
else if (uSymbol == USymbols.RECTANGLE)
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, uSymbol.getSName(), SName.title);
else
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, SName.title);
final Style style = signature //
.withTOBECHANGED(g.getStereotype()) //
.with(g.getStereostyles()) //
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet(), g.getColors());
final HorizontalAlignment alignment = HorizontalAlignment.CENTER;
return label.create(fontConfiguration, alignment, dotData.getSkinParam());
}
private TextBlock addLegend(TextBlock original, DisplayPositioned legend) {
if (legend == null || legend.isNull())
return original;
final TextBlock legendBlock = EntityImageLegend.create(legend.getDisplay(), dotData.getSkinParam());
return DecorateEntityImage.add(legendBlock, original, legend.getHorizontalAlignment(),
legend.getVerticalAlignment());
}
private TextBlock getStereoBlock(IGroup g) {
final DisplayPositioned legend = g.getLegend();
return addLegend(getStereoBlockWithoutLegend(g), legend);
}
private TextBlock getStereoBlockWithoutLegend(IGroup g) {
final Stereotype stereotype = g.getStereotype();
// final DisplayPositionned legend = g.getLegend();
if (stereotype == null)
return TextBlockUtils.empty(0, 0);
final TextBlock tmp = stereotype.getSprite(dotData.getSkinParam());
if (tmp != null)
return tmp;
final List<String> stereos = stereotype.getLabels(dotData.getSkinParam().guillemet());
if (stereos == null)
return TextBlockUtils.empty(0, 0);
final boolean show = dotData.showPortion(EntityPortion.STEREOTYPE, g);
if (show == false)
return TextBlockUtils.empty(0, 0);
final Style style = Cluster
.getDefaultStyleDefinition(dotData.getUmlDiagramType().getStyleName(), g.getUSymbol())
.forStereotypeItself(g.getStereotype()).getMergedStyle(dotData.getSkinParam().getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(dotData.getSkinParam().getThemeStyle(),
dotData.getSkinParam().getIHtmlColorSet());
return Display.create(stereos).create(fontConfiguration, HorizontalAlignment.CENTER, dotData.getSkinParam());
}
public String getWarningOrError(int warningOrError) {
if (maxX == null)
return "";

View File

@ -84,11 +84,11 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
public static List<String> anErrorHasOccured(Throwable exception, String text) {
final List<String> strings = new ArrayList<>();
if (exception == null) {
if (exception == null)
strings.add("An error has occured!");
} else {
else
strings.add("An error has occured : " + exception);
}
final String quote = StringUtils.rot(QuoteUtils.getSomeQuote());
strings.add("<i>" + quote);
strings.add(" ");
@ -99,11 +99,10 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
private static int lines(String text) {
int result = 0;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == BackSlash.CHAR_NEWLINE) {
for (int i = 0; i < text.length(); i++)
if (text.charAt(i) == BackSlash.CHAR_NEWLINE)
result++;
}
}
return result;
}
@ -139,9 +138,9 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
strings.add("For some reason, dot/GraphViz has crashed.");
strings.add("");
strings.add("RootCause " + rootCause);
if (rootCause != null) {
if (rootCause != null)
strings.addAll(CommandExecutionResult.getStackTrace(rootCause));
}
strings.add("");
strings.add("This has been generated with PlantUML (" + Version.versionString() + ").");
checkOldVersionWarning(strings);
@ -156,9 +155,8 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
}
pleaseGoTo(strings);
youShouldSendThisDiagram(strings);
if (flashCode != null) {
if (flashCode != null)
addDecodeHint(strings);
}
return strings;
}

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.LeafType;
@ -54,6 +53,7 @@ import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.SuperGroup;
import net.sourceforge.plantuml.cucadiagram.dot.DotData;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -62,8 +62,8 @@ import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.image.EntityImageState;
import net.sourceforge.plantuml.svek.image.EntityImageStateCommon;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -118,30 +118,21 @@ public final class GroupPngMakerState {
return result;
}
private Style getStyleStateHeader() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.header)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
}
private Style getStyleState() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
}
private Style getStyleStateBody() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.stateBody)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
}
public IEntityImage getImage() {
final Display display = group.getDisplay();
final ISkinParam skinParam = diagram.getSkinParam();
final double rounded = getStyleState().value(PName.RoundCorner).asDouble();
final double shadowing = getStyleState().value(PName.Shadowing).asDouble();
final FontConfiguration fontConfiguration = getStyleStateHeader()
.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
final TextBlock title = display.create(fontConfiguration, HorizontalAlignment.CENTER, diagram.getSkinParam());
final Style style = EntityImageStateCommon.getStyleState(group, skinParam);
// final Style styleHeader = EntityImageStateCommon.getStyleStateHeader(group, skinParam);
final Style styleTitle = EntityImageStateCommon.getStyleStateTitle(group, skinParam);
final Style styleBody = EntityImageStateCommon.getStyleStateBody(group, skinParam);
final double rounded = style.value(PName.RoundCorner).asDouble();
final double shadowing = style.value(PName.Shadowing).asDouble();
final FontConfiguration titleFontConfiguration = styleTitle.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
final TextBlock title = display.create(titleFontConfiguration, HorizontalAlignment.CENTER,
diagram.getSkinParam());
if (group.size() == 0 && group.getChildren().size() == 0)
return new EntityImageState(group, diagram.getSkinParam());
@ -164,20 +155,19 @@ public final class GroupPngMakerState {
HColor borderColor = group.getColors().getColor(ColorType.LINE);
if (borderColor == null)
borderColor = getStyleState().value(PName.LineColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
final Stereotype stereo = group.getStereotype();
HColor backColor = group.getColors().getColor(ColorType.BACK);
if (backColor == null)
backColor = getStyleState().value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
UStroke stroke = group.getColors().getSpecificLineStroke();
if (stroke == null)
stroke = getStyleState().getStroke();
stroke = style.getStroke();
final TextBlock attribute = GeneralImageBuilder.stateHeader((IEntity) group, null, skinParam);
final TextBlock attribute = ((EntityImpl) group).getStateHeader(skinParam);
final Stereotype stereotype = group.getStereotype();
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
@ -186,7 +176,7 @@ public final class GroupPngMakerState {
final IEntityImage image = containsOnlyConcurrentStates ? buildImageForConcurrentState(dotData)
: svek2.buildImage(null, new String[0]);
final HColor bodyColor = getStyleStateBody().value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
final HColor bodyColor = styleBody.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
return new InnerStateAutonom(image, title, attribute, borderColor, backColor, group.getUrl99(), withSymbol,
stroke, rounded, shadowing, bodyColor);

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public final class RoundedNorth implements UDrawable {
@ -64,7 +63,7 @@ public final class RoundedNorth implements UDrawable {
}
public void drawU(UGraphic ug) {
if (HColors.isTransparent(backColor))
if (backColor.isTransparent())
return;
final UShape header;

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public final class RoundedSouth implements UDrawable {
@ -64,7 +63,7 @@ public final class RoundedSouth implements UDrawable {
}
public void drawU(UGraphic ug) {
if (HColors.isTransparent(backColor))
if (backColor.isTransparent())
return;
final UShape header;

View File

@ -129,30 +129,31 @@ public class EntityImageDescription extends AbstractEntityImage {
final Colors colors = entity.getColors();
final StyleSignatureBasic tmp = StyleSignatureBasic.of(SName.root, SName.element, styleName, symbol.getSName());
final StyleSignatureBasic tmp = StyleSignatureBasic.of(SName.root, SName.element, styleName, symbol.getSName(),
SName.title);
final Stereotype stereotype = entity.getStereotype();
final Style style = tmp.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
final Style styleTitle = tmp.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
.eventuallyOverride(colors);
final Style styleStereo = tmp.forStereotypeItself(stereotype)
.getMergedStyle(getSkinParam().getCurrentStyleBuilder());
final HColor forecolor = style.value(PName.LineColor).asColor(getSkinParam().getThemeStyle(),
final HColor forecolor = styleTitle.value(PName.LineColor).asColor(getSkinParam().getThemeStyle(),
getSkinParam().getIHtmlColorSet());
HColor backcolor = colors.getColor(ColorType.BACK);
if (backcolor == null)
backcolor = style.value(PName.BackGroundColor).asColor(getSkinParam().getThemeStyle(),
backcolor = styleTitle.value(PName.BackGroundColor).asColor(getSkinParam().getThemeStyle(),
getSkinParam().getIHtmlColorSet());
final double roundCorner = style.value(PName.RoundCorner).asDouble();
final double diagonalCorner = style.value(PName.DiagonalCorner).asDouble();
final double deltaShadow = style.value(PName.Shadowing).asDouble();
final UStroke stroke = style.getStroke(colors);
final FontConfiguration fcTitle = style.getFontConfiguration(getSkinParam().getThemeStyle(),
final double roundCorner = styleTitle.value(PName.RoundCorner).asDouble();
final double diagonalCorner = styleTitle.value(PName.DiagonalCorner).asDouble();
final double deltaShadow = styleTitle.value(PName.Shadowing).asDouble();
final UStroke stroke = styleTitle.getStroke(colors);
final FontConfiguration fcTitle = styleTitle.getFontConfiguration(getSkinParam().getThemeStyle(),
getSkinParam().getIHtmlColorSet());
final FontConfiguration fcStereo = styleStereo.getFontConfiguration(getSkinParam().getThemeStyle(),
getSkinParam().getIHtmlColorSet());
final HorizontalAlignment defaultAlign = style.getHorizontalAlignment();
final HorizontalAlignment defaultAlign = styleTitle.getHorizontalAlignment();
assert getStereo() == stereotype;
@ -165,7 +166,7 @@ public class EntityImageDescription extends AbstractEntityImage {
desc = TextBlockUtils.empty(getSkinParam().minClassWidth(), 0);
else
desc = BodyFactory.create3(entity.getDisplay(), getSkinParam(), defaultAlign, fcTitle,
getSkinParam().wrapWidth(), style);
getSkinParam().wrapWidth(), styleTitle);
stereo = TextBlockUtils.empty(0, 0);
@ -177,7 +178,7 @@ public class EntityImageDescription extends AbstractEntityImage {
HorizontalAlignment.CENTER, getSkinParam());
name = BodyFactory.create2(getSkinParam().getDefaultTextAlignment(HorizontalAlignment.CENTER), codeDisplay,
getSkinParam(), stereotype, entity, style);
getSkinParam(), stereotype, entity, styleTitle);
if (hideText)
asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),

View File

@ -86,11 +86,8 @@ public class EntityImageEmptyPackage extends AbstractEntityImage {
private final HColor back;
private Style getStyle() {
return getStyleSignature().getMergedStyle(getSkinParam().getCurrentStyleBuilder());
}
private StyleSignature getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.package_).withTOBECHANGED(stereotype);
return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.package_, SName.title)
.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder());
}
public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam, PortionShower portionShower, SName sname) {

View File

@ -75,16 +75,17 @@ public class EntityImageState extends EntityImageStateCommon {
this.withSymbol = stereotype != null && stereotype.isWithOOSymbol();
final Display list = Display.create(entity.getBodier().getRawBody());
final FontConfiguration fontConfiguration = getStyleState().getFontConfiguration(getSkinParam().getThemeStyle(),
getSkinParam().getIHtmlColorSet());
this.fields = list.create8(fontConfiguration, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL,
final FontConfiguration fieldsFontConfiguration = getStyleStateHeader()
.getFontConfiguration(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet());
this.fields = list.create8(fieldsFontConfiguration, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL,
skinParam.wrapWidth());
}
public XDimension2D calculateDimension(StringBounder stringBounder) {
final XDimension2D dim = XDimension2D.mergeTB(desc.calculateDimension(stringBounder),
final XDimension2D dim = XDimension2D.mergeTB(title.calculateDimension(stringBounder),
fields.calculateDimension(stringBounder));
double heightSymbol = 0;
if (withSymbol)
@ -101,7 +102,7 @@ public class EntityImageState extends EntityImageStateCommon {
final StringBounder stringBounder = ug.getStringBounder();
final XDimension2D dimTotal = calculateDimension(stringBounder);
final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
final XDimension2D dimDesc = title.calculateDimension(stringBounder);
final UStroke stroke = getStyleState().getStroke(lineConfig.getColors());
@ -120,7 +121,7 @@ public class EntityImageState extends EntityImageStateCommon {
final double xDesc = (dimTotal.getWidth() - dimDesc.getWidth()) / 2;
final double yDesc = MARGIN;
desc.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
title.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
final double xFields = MARGIN;
final double yFields = yLine + MARGIN_LINE;

View File

@ -58,7 +58,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public abstract class EntityImageStateCommon extends AbstractEntityImage {
final protected TextBlock desc;
final protected TextBlock title;
final protected Url url;
final protected LineConfigurable lineConfig;
@ -68,31 +68,41 @@ public abstract class EntityImageStateCommon extends AbstractEntityImage {
this.lineConfig = entity;
final FontConfiguration fontConfiguration = getStyleStateHeader().getFontConfiguration(
final FontConfiguration titleFontConfiguration = getStyleStateTitle(entity, skinParam).getFontConfiguration(
getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet(), entity.getColors());
this.desc = entity.getDisplay().create8(fontConfiguration, HorizontalAlignment.CENTER, skinParam,
this.title = entity.getDisplay().create8(titleFontConfiguration, HorizontalAlignment.CENTER, skinParam,
CreoleMode.FULL, skinParam.wrapWidth());
this.url = entity.getUrl99();
}
private Style getStyleStateHeader() {
public static Style getStyleStateTitle(IEntity group, ISkinParam skinParam) {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.title)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
public static Style getStyleStateHeader(IEntity group, ISkinParam skinParam) {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.header)
.withTOBECHANGED(getEntity().getStereotype()).getMergedStyle(getSkinParam().getCurrentStyleBuilder());
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
public static Style getStyleState(IEntity group, ISkinParam skinParam) {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
public static Style getStyleStateBody(IEntity group, ISkinParam skinParam) {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.stateBody)
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
}
final protected Style getStyleState() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state)
.withTOBECHANGED(getEntity().getStereotype()).getMergedStyle(getSkinParam().getCurrentStyleBuilder());
return getStyleState(getEntity(), getSkinParam());
}
private UStroke getStrokeWIP() {
UStroke stroke = lineConfig.getColors().getSpecificLineStroke();
if (stroke == null) {
stroke = new UStroke(1.5);
}
return stroke;
final protected Style getStyleStateHeader() {
return getStyleStateHeader(getEntity(), getSkinParam());
}
final public ShapeType getShapeType() {

View File

@ -54,7 +54,7 @@ public class EntityImageStateEmptyDescription extends EntityImageStateCommon {
}
public XDimension2D calculateDimension(StringBounder stringBounder) {
final XDimension2D dim = desc.calculateDimension(stringBounder);
final XDimension2D dim = title.calculateDimension(stringBounder);
final XDimension2D result = XDimension2D.delta(dim, MARGIN * 2);
return XDimension2D.atLeast(result, MIN_WIDTH, MIN_HEIGHT);
}
@ -65,7 +65,7 @@ public class EntityImageStateEmptyDescription extends EntityImageStateCommon {
final StringBounder stringBounder = ug.getStringBounder();
final XDimension2D dimTotal = calculateDimension(stringBounder);
final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
final XDimension2D dimDesc = title.calculateDimension(stringBounder);
final UStroke stroke = getStyleState().getStroke(lineConfig.getColors());
@ -76,7 +76,7 @@ public class EntityImageStateEmptyDescription extends EntityImageStateCommon {
final double xDesc = (dimTotal.getWidth() - dimDesc.getWidth()) / 2;
final double yDesc = (dimTotal.getHeight() - dimDesc.getHeight()) / 2;
desc.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
title.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
if (url != null)
ug.closeUrl();

View File

@ -259,7 +259,7 @@ public class SvgGraphics {
private Element pendingBackground;
public void paintBackcolorGradient(ColorMapper mapper, HColorGradient gr) {
final String id = createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), gr.getPolicy());
final String id = createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper), gr.getPolicy());
setFillColor("url(#" + id + ")");
setStrokeColor(null);
pendingBackground = createRectangleInternal(0, 0, 0, 0);

View File

@ -109,7 +109,7 @@ public class TikzGraphics {
}
private String getColorName(HColor hcolor) {
final Color color = mapper.toColor(hcolor);
final Color color = hcolor.toColor(mapper);
if (color.equals(Color.WHITE))
return "white";
@ -124,10 +124,10 @@ public class TikzGraphics {
if (fillcolor == null)
return false;
if (HColors.isTransparent(fillcolor))
if (fillcolor.isTransparent())
return false;
if (mapper.toColor(fillcolor).getAlpha() == 0)
if (fillcolor.toColor(mapper).getAlpha() == 0)
return false;
return true;
@ -646,7 +646,7 @@ public class TikzGraphics {
private void addColor(HColor hcolor) {
if (hcolor == null)
return;
final Color color = mapper.toColor(hcolor);
final Color color = hcolor.toColor(mapper);
if (color == null)
return;

View File

@ -93,7 +93,6 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorGradient;
import net.sourceforge.plantuml.ugraphic.color.HColorNone;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors;
import net.sourceforge.plantuml.ugraphic.debug.UGraphicDebug;
@ -445,21 +444,18 @@ public class ImageBuilder {
}
private UGraphic createUGraphicPNG(double scaleFactor, final XDimension2D dim, Animation affineTransforms, double dx,
double dy, String watermark) {
Color backColor = getDefaultBackColor();
private UGraphic createUGraphicPNG(double scaleFactor, final XDimension2D dim, Animation affineTransforms,
double dx, double dy, String watermark) {
Color pngBackColor = new Color(0, 0, 0, 0);
if (this.backcolor instanceof HColorSimple)
backColor = colorMapper.toColor(this.backcolor);
else if (this.backcolor instanceof HColorNone)
backColor = null;
pngBackColor = this.backcolor.toColor(colorMapper);
if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && backColor != null
&& backColor.equals(Color.WHITE))
backColor = new Color(0, 0, 0, 0);
if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && Color.WHITE.equals(pngBackColor))
pngBackColor = new Color(0, 0, 0, 0);
final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor),
(int) (dim.getHeight() * scaleFactor), backColor, stringBounder);
(int) (dim.getHeight() * scaleFactor), pngBackColor, stringBounder);
final Graphics2D graphics2D = builder.getGraphics2D();
final UGraphicG2d ug = new UGraphicG2d(backcolor, colorMapper, stringBounder, graphics2D, scaleFactor,
@ -473,10 +469,6 @@ public class ImageBuilder {
return ug;
}
static private Color getDefaultBackColor() {
return Color.WHITE;
}
static private HColor getDefaultHBackColor() {
return HColors.WHITE;
}
@ -487,7 +479,7 @@ public class ImageBuilder {
} else if (skinParam != null) {
final HColor color = skinParam.hoverPathColor();
if (color != null)
return colorMapper.toRGB(color);
return color.toRGB(colorMapper);
}
return null;

View File

@ -1,57 +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;
public class ColorChangerMonochrome {
public Color getChangedColor(Color color) {
if (color == null)
return null;
final int grayScale = ColorUtils.getGrayScale(color);
return new Color(grayScale, grayScale, grayScale);
}
public Color getChangedColor(HColor color) {
if (color == null)
return null;
return getChangedColor(((HColorSimple) color).getColor999());
}
}

View File

@ -37,44 +37,8 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color;
import net.sourceforge.plantuml.StringUtils;
public abstract class ColorMapper {
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 abstract Color fromColorSimple(HColorSimple simple);
}

View File

@ -40,26 +40,8 @@ import java.awt.Color;
public class ColorMapperForceDark extends ColorMapper {
@Override
public Color toColor(HColor color) {
if (color == null)
throw new IllegalArgumentException();
if (color instanceof HColorNone)
return new Color(0, 0, 0, 0);
if (color instanceof HColorGradient)
return toColor(((HColorGradient) color).getColor1());
if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this);
if (color instanceof HColorScheme)
throw new IllegalStateException();
if (color instanceof HColorAutomagic)
throw new IllegalStateException();
final HColor tmp = ((HColorSimple) color).darkSchemeTheme();
return ((HColorSimple) tmp).getColor999();
public Color fromColorSimple(HColorSimple simple) {
return ((HColorSimple) simple.darkSchemeTheme()).getColor999();
}
}

View File

@ -40,25 +40,8 @@ import java.awt.Color;
public class ColorMapperIdentity extends ColorMapper {
@Override
public Color toColor(HColor color) {
if (color == null)
throw new IllegalArgumentException();
if (color instanceof HColorNone)
return new Color(0, 0, 0, 0);
if (color instanceof HColorGradient)
return toColor(((HColorGradient) color).getColor1());
if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this);
if (color instanceof HColorScheme)
throw new IllegalStateException();
if (color instanceof HColorAutomagic)
throw new IllegalStateException();
return ((HColorSimple) color).getColor999();
public Color fromColorSimple(HColorSimple simple) {
return simple.getColor999();
}
}

View File

@ -40,21 +40,8 @@ import java.awt.Color;
public class ColorMapperLightnessInverse extends ColorMapper {
@Override
public Color toColor(HColor color) {
if (color == null)
throw new IllegalArgumentException();
if (color instanceof HColorGradient)
return toColor(((HColorGradient) color).getColor1());
if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this);
if (color instanceof HColorNone)
return ColorUtils.getReversed((new Color(0, 0, 0, 0)));
// return ColorUtils.reverseHsluv(((HColorSimple) color).getColor999());
return ColorUtils.getReversed(((HColorSimple) color).getColor999());
public Color fromColorSimple(HColorSimple simple) {
return ColorUtils.getReversed(simple.getColor999());
}
}

View File

@ -45,18 +45,19 @@ public class ColorMapperMonochrome extends ColorMapper {
this.reverse = reverse;
}
@Override
public Color toColor(HColor htmlColor) {
if (htmlColor == null)
throw new IllegalArgumentException();
final Color color = new ColorMapperIdentity().toColor(htmlColor);
if (HColors.isTransparent(htmlColor))
return color;
if (reverse)
return ColorUtils.getGrayScaleColorReverse(color);
return ColorUtils.getGrayScaleColor(color);
private boolean isReverse() {
return reverse;
}
@Override
public Color fromColorSimple(HColorSimple simple) {
if (simple.isTransparent())
return simple.getColor999();
if (isReverse())
return ColorUtils.getGrayScaleColorReverse(simple.getColor999());
return ColorUtils.getGrayScaleColor(simple.getColor999());
}
}

View File

@ -45,22 +45,13 @@ public class ColorMapperReverse extends ColorMapper {
this.order = order;
}
@Override
public Color toColor(HColor color) {
if (color == null)
throw new IllegalArgumentException();
if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this);
if (color instanceof HColorNone)
return new Color(0, 0, 0, 0);
return getReverse(((HColorSimple) color).getColor999());
}
private Color getReverse(Color color) {
return order.getReverse(color);
}
@Override
public Color fromColorSimple(HColorSimple simple) {
return getReverse(simple.getColor999());
}
}

View File

@ -34,6 +34,9 @@
*/
package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.ugraphic.UBackground;
import net.sourceforge.plantuml.ugraphic.UChange;
@ -47,6 +50,31 @@ public abstract class HColor implements UChange {
};
}
public Color toColor(ColorMapper mapper) {
throw new UnsupportedOperationException();
}
final public String toRGB(ColorMapper mapper) {
final Color color = toColor(mapper);
return StringUtils.sharp000000(color.getRGB());
}
final public String toSvg(ColorMapper mapper) {
if (this.isTransparent())
return "#00000000";
final Color color = toColor(mapper);
final int alpha = color.getAlpha();
if (alpha == 255)
return toRGB(mapper);
String s = "0" + Integer.toHexString(alpha).toUpperCase();
s = s.substring(s.length() - 2);
return toRGB(mapper) + s;
}
public HColor lighten(int ratio) {
return this;
}
@ -87,4 +115,9 @@ public abstract class HColor implements UChange {
throw new UnsupportedOperationException();
}
public boolean isTransparent() {
return false;
}
}

View File

@ -67,8 +67,8 @@ public class HColorGradient extends HColor {
if (coeff > 1 || coeff < 0)
throw new IllegalArgumentException("c=" + coeff);
final Color c1 = mapper.toColor(color1);
final Color c2 = mapper.toColor(color2);
final Color c1 = color1.toColor(mapper);
final Color c2 = color2.toColor(mapper);
final int vred = c2.getRed() - c1.getRed();
final int vgreen = c2.getGreen() - c1.getGreen();
final int vblue = c2.getBlue() - c1.getBlue();
@ -85,4 +85,9 @@ public class HColorGradient extends HColor {
return policy;
}
@Override
public Color toColor(ColorMapper mapper) {
return color1.toColor(mapper);
}
}

View File

@ -47,9 +47,18 @@ public class HColorMiddle extends HColor {
this.color2 = c2;
}
public Color getMappedColor(ColorMapper colorMapper) {
final Color cc1 = colorMapper.toColor(color1);
final Color cc2 = colorMapper.toColor(color2);
public final HColor getColor1() {
return color1;
}
public final HColor getColor2() {
return color2;
}
@Override
public Color toColor(ColorMapper mapper) {
final Color cc1 = color1.toColor(mapper);
final Color cc2 = color2.toColor(mapper);
final int r1 = cc1.getRed();
final int g1 = cc1.getGreen();
final int b1 = cc1.getBlue();
@ -63,12 +72,4 @@ public class HColorMiddle extends HColor {
return new Color(r, g, b);
}
public final HColor getColor1() {
return color1;
}
public final HColor getColor2() {
return color2;
}
}

View File

@ -1,53 +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;
public class HColorNone extends HColor {
HColorNone() {
}
@Override
public UBackground bg() {
return new UBackground() {
public HColor getBackColor() {
return HColors.none();
}
};
}
}

View File

@ -34,6 +34,8 @@
*/
package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color;
class HColorScheme extends HColor {
private final HColor colorForLight;
@ -48,7 +50,7 @@ class HColorScheme extends HColor {
@Override
public HColor getAppropriateColor(HColor back) {
if (HColors.isTransparent(back)) {
if (back.isTransparent()) {
if (colorForTransparent != null)
return colorForTransparent;

View File

@ -362,7 +362,7 @@ public class HColorSet {
s = removeFirstDieseAndgoLowerCase(s);
final Color color;
if (s.equalsIgnoreCase("transparent") || s.equalsIgnoreCase("background")) {
return HColors.generalBackground();
return HColors.none();
} else if (s.equalsIgnoreCase("automatic")) {
return new HColorAutomagic();
} else if (s.matches("[0-9A-Fa-f]")) {

View File

@ -105,6 +105,7 @@ public class HColorSimple extends HColor {
return ColorUtils.getGrayScale(color) < 128;
}
@Override
public boolean isTransparent() {
return color.getAlpha() == 0;
}
@ -132,11 +133,11 @@ public class HColorSimple extends HColor {
}
public HColor asMonochrome() {
return new HColorSimple(new ColorChangerMonochrome().getChangedColor(color));
return new HColorSimple(ColorUtils.getGrayScaleColor(color));
}
public HColor asMonochrome(HColorSimple colorForMonochrome, double minGray, double maxGray) {
final Color tmp = new ColorChangerMonochrome().getChangedColor(color);
final Color tmp = ColorUtils.getGrayScaleColor(color);
final int gray = tmp.getGreen();
assert gray == tmp.getBlue();
assert gray == tmp.getRed();
@ -148,7 +149,7 @@ public class HColorSimple extends HColor {
@Override
public HColor opposite() {
final Color mono = new ColorChangerMonochrome().getChangedColor(color);
final Color mono = ColorUtils.getGrayScaleColor(color);
final int grayScale = 255 - mono.getGreen() > 127 ? 255 : 0;
return new HColorSimple(new Color(grayScale, grayScale, grayScale));
}
@ -201,4 +202,9 @@ public class HColorSimple extends HColor {
return dark;
}
@Override
public Color toColor(ColorMapper mapper) {
return mapper.fromColorSimple(this);
}
}

View File

@ -133,29 +133,14 @@ public class HColors {
return color.bg();
}
private static final HColorSimple TRANSPARENT = new HColorSimple(new Color(0, 0, 0, 0));
public static HColor transparent() {
return new HColorNone();
return TRANSPARENT;
}
public static HColor none() {
return new HColorNone();
}
public static HColor generalBackground() {
return new HColorNone();
}
public static boolean isTransparent(HColor back) {
if (back == null)
return true;
if (back instanceof HColorNone)
return true;
if (back instanceof HColorSimple && ((HColorSimple) back).isTransparent())
return true;
return false;
return TRANSPARENT;
}
public static HColor unlinear(HColor color1, HColor color2, int completion) {

View File

@ -255,7 +255,7 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
}
private String colorToString(HColor color) {
if (HColors.isTransparent(color))
if (color == null || color.isTransparent())
return "NULL_COLOR";
if (color instanceof HColorSimple) {

View File

@ -57,7 +57,7 @@ public class DriverCenteredCharacterEps implements UDriver<UCenteredCharacter, E
final double ypos = y - unusedSpace.getCenterY() - 0.5;
final TextLayout t = createTextLayout(font, "" + c);
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null));
}

View File

@ -40,15 +40,14 @@ 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);
if (HColors.isTransparent(param.getColor()) == false) {
eps.setStrokeColor(mapper.toColor(param.getColor()));
if (param.getColor().isTransparent() == false) {
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(),
param.getStroke().getDashSpace());
shape.draw(eps, x, y);

View File

@ -69,8 +69,8 @@ public class DriverEllipseEps implements UDriver<UEllipse, EpsGraphics> {
eps.epsEllipseShadow(x + width / 2, y + height / 2, width / 2, height / 2, shape.getDeltaShadow());
}
eps.setFillColor(mapper.toColor(param.getBackcolor()));
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setFillColor(param.getBackcolor().toColor(mapper));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
.getDashSpace());

View File

@ -61,7 +61,7 @@ public class DriverImageEps implements UDriver<UImage, EpsGraphics> {
}
}
eps.drawImage(shape.muteTransparentColor(mapper.toColor(param.getBackcolor())).getImage(1), x, y);
eps.drawImage(shape.muteTransparentColor(param.getBackcolor().toColor(mapper)).getImage(1), x, y);
}
}

View File

@ -68,7 +68,7 @@ public class DriverLineEps implements UDriver<ULine, EpsGraphics> {
y2 = line.y2;
}
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
.getDashSpace());
eps.epsLine(x, y, x2, y2);

View File

@ -43,8 +43,8 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
public class DriverPathEps implements UDriver<UPath, EpsGraphics> {
public void draw(UPath shape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setFillColor(mapper.toColor(param.getBackcolor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.setFillColor(param.getBackcolor().toColor(mapper));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
.getStroke().getDashSpace());

View File

@ -77,12 +77,12 @@ public class DriverPolygonEps implements UDriver<UPolygon, EpsGraphics> {
final HColor back = param.getBackcolor();
if (back instanceof HColorGradient) {
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.epsPolygon((HColorGradient) back, mapper, points);
} else {
eps.setFillColor(mapper.toColor(back));
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setFillColor(back.toColor(mapper));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.epsPolygon(points);
}
}

View File

@ -81,11 +81,11 @@ public class DriverRectangleEps implements UDriver<URectangle, EpsGraphics> {
final HColor back = param.getBackcolor();
if (back instanceof HColorGradient) {
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HColorGradient) back, mapper);
} else {
eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setFillColor(mapper.toColor(param.getBackcolor()));
eps.setStrokeColor(param.getColor().toColor(mapper));
eps.setFillColor(param.getBackcolor().toColor(mapper));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
.getStroke().getDashSpace());
eps.epsRectangle(x, y, width, height, rx / 2, ry / 2);

View File

@ -56,7 +56,6 @@ import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class DriverTextEps implements UDriver<UText, EpsGraphics> {
@ -75,7 +74,7 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
}
final FontConfiguration fontConfiguration = shape.getFontConfiguration();
if (HColors.isTransparent(fontConfiguration.getColor())) {
if (fontConfiguration.getColor().isTransparent()) {
return;
}
@ -89,7 +88,7 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
MinMax dim = null;
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final Color extended = mapper.toColor(fontConfiguration.getExtendedColor());
final Color extended = fontConfiguration.getExtendedColor().toColor(mapper);
if (extended != null) {
eps.setStrokeColor(extended);
eps.setFillColor(extended);
@ -101,13 +100,13 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
}
}
eps.setStrokeColor(mapper.toColor(fontConfiguration.getColor()));
eps.setStrokeColor(fontConfiguration.getColor().toColor(mapper));
drawPathIterator(eps, x, y, getOutline(textLayout));
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
eps.setStrokeColor(mapper.toColor(extended));
eps.setStrokeColor(extended.toColor(mapper));
}
if (dim == null) {
dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null));
@ -123,7 +122,7 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
final int ypos = (int) (y + 2.5) - 1;
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
eps.setStrokeColor(mapper.toColor(extended));
eps.setStrokeColor(extended.toColor(mapper));
}
eps.setStrokeWidth(1.1, 0, 0);
for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
@ -135,7 +134,7 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
eps.setStrokeColor(mapper.toColor(extended));
eps.setStrokeColor(extended.toColor(mapper));
}
if (dim == null) {
dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null));
@ -160,7 +159,7 @@ public class DriverTextEps implements UDriver<UText, EpsGraphics> {
// final double ypos = y - fm.getDescent() + 0.5;
final double ypos = y - 1;
eps.setStrokeColor(mapper.toColor(fontConfiguration.getColor()));
eps.setStrokeColor(fontConfiguration.getColor().toColor(mapper));
((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
}

View File

@ -51,7 +51,7 @@ public class DriverCenteredCharacterG2d implements UDriver<UCenteredCharacter, G
final UFont font = characterCircled.getFont();
final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
g2d.setColor(mapper.toColor(param.getColor()));
g2d.setColor(param.getColor().toColor(mapper));
final double xpos = x - unusedSpace.getCenterX();
final double ypos = y - unusedSpace.getCenterY() - 0.5;

View File

@ -42,7 +42,6 @@ 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> {
@ -55,8 +54,8 @@ 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 (HColors.isTransparent(param.getColor()) == false) {
g2d.setColor(mapper.toColor(param.getColor()));
if (param.getColor().isTransparent() == false) {
g2d.setColor(param.getColor().toColor(mapper));
shape.draw(g2d, x, y);
shape.manageEnsureVisible(x, y, visible);
}

View File

@ -49,7 +49,6 @@ 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> {
@ -82,20 +81,20 @@ public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<UElli
g2d.fill(shape);
DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y);
} else {
if (HColors.isTransparent(back) == false) {
g2d.setColor(mapper.toColor(param.getBackcolor()));
if (back.isTransparent() == false) {
g2d.setColor(param.getBackcolor().toColor(mapper));
DriverRectangleG2d.managePattern(param, g2d);
g2d.fill(shape);
}
if (HColors.isTransparent(color) == false && color.equals(param.getBackcolor()) == false)
if (color.isTransparent() == 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 (HColors.isTransparent(color) == false) {
g2d.setColor(mapper.toColor(color));
if (color.isTransparent() == false) {
g2d.setColor(color.toColor(mapper));
g2d.draw(arc);
}
}

View File

@ -47,7 +47,6 @@ import net.sourceforge.plantuml.ugraphic.USegmentType;
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 DriverPathG2d extends DriverShadowedG2d implements UDriver<UPath, Graphics2D> {
@ -86,14 +85,14 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<UPath, G
if (shape.isOpenIconic()) {
p.closePath();
g2d.setColor(mapper.toColor(param.getColor()));
g2d.setColor(param.getColor().toColor(mapper));
g2d.fill(p);
return;
}
// Shadow
if (shape.getDeltaShadow() != 0)
if (back == null || HColors.isTransparent(back))
if (back == null || back.isTransparent())
drawOnlyLineShadowSpecial(g2d, p, shape.getDeltaShadow(), dpiFactor);
else
drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
@ -104,30 +103,30 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<UPath, G
final GradientPaint paint;
if (policy == '|') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
mapper.toColor(gr.getColor2()));
gr.getColor1().toColor(mapper), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
gr.getColor2().toColor(mapper));
} else if (policy == '\\') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(),
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(),
mapper.toColor(gr.getColor2()));
gr.getColor1().toColor(mapper), (float) minMax.getMaxX(), (float) minMax.getMinY(),
gr.getColor2().toColor(mapper));
} else if (policy == '-') {
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
mapper.toColor(gr.getColor2()));
gr.getColor1().toColor(mapper), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
gr.getColor2().toColor(mapper));
} else {
// for /
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
paint = new GradientPaint((float) x, (float) y, gr.getColor1().toColor(mapper),
(float) minMax.getMaxX(), (float) minMax.getMaxY(), gr.getColor2().toColor(mapper));
}
g2d.setPaint(paint);
g2d.fill(p);
} else if (HColors.isTransparent(back) == false) {
g2d.setColor(mapper.toColor(back));
} else if (back.isTransparent() == false) {
g2d.setColor(back.toColor(mapper));
g2d.fill(p);
}
if (HColors.isTransparent(param.getColor()) == false) {
g2d.setColor(mapper.toColor(param.getColor()));
if (param.getColor().isTransparent() == false) {
g2d.setColor(param.getColor().toColor(mapper));
g2d.draw(p);
}
}

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
public class DriverPixelG2d implements UDriver<UPixel, Graphics2D> {
public void draw(UPixel pixel, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
g2d.setColor(mapper.toColor(param.getColor()));
g2d.setColor(param.getColor().toColor(mapper));
g2d.fillRect((int) x, (int) y, 1, 1);
}

View File

@ -48,7 +48,6 @@ import net.sourceforge.plantuml.ugraphic.UPolygon;
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 DriverPolygonG2d extends DriverShadowedG2d implements UDriver<UPolygon, Graphics2D> {
@ -84,7 +83,7 @@ public class DriverPolygonG2d extends DriverShadowedG2d implements UDriver<UPoly
path.closePath();
if (shape.getDeltaShadow() != 0)
if (HColors.isTransparent(back))
if (back.isTransparent())
drawOnlyLineShadowSpecial(g2d, path, shape.getDeltaShadow(), dpiFactor);
else
drawShadow(g2d, path, shape.getDeltaShadow(), dpiFactor);
@ -95,31 +94,31 @@ public class DriverPolygonG2d extends DriverShadowedG2d implements UDriver<UPoly
final GradientPaint paint;
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()));
gr.getColor1().toColor(mapper), (float) (x + shape.getWidth()),
(float) (y + shape.getHeight()) / 2, gr.getColor2().toColor(mapper));
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()));
paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), gr.getColor1().toColor(mapper),
(float) (x + shape.getWidth()), (float) y, gr.getColor2().toColor(mapper));
else if (policy == '-')
paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.toColor(gr.getColor1()),
paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, gr.getColor1().toColor(mapper),
(float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
mapper.toColor(gr.getColor2()));
gr.getColor2().toColor(mapper));
else
// for /
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
paint = new GradientPaint((float) x, (float) y, gr.getColor1().toColor(mapper),
(float) (x + shape.getWidth()), (float) (y + shape.getHeight()),
mapper.toColor(gr.getColor2()));
gr.getColor2().toColor(mapper));
g2d.setPaint(paint);
g2d.fill(path);
} else if (HColors.isTransparent(back) == false) {
g2d.setColor(mapper.toColor(back));
} else if (back.isTransparent() == false) {
g2d.setColor(back.toColor(mapper));
DriverRectangleG2d.managePattern(param, g2d);
g2d.fill(path);
}
if (HColors.isTransparent(param.getColor()) == false) {
g2d.setColor(mapper.toColor(param.getColor()));
if (param.getColor().isTransparent() == false) {
g2d.setColor(param.getColor().toColor(mapper));
DriverLineG2d.manageStroke(param, g2d);
g2d.draw(path);
}

View File

@ -55,7 +55,6 @@ 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.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URectangle, Graphics2D> {
@ -84,7 +83,7 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
// Shadow
if (rect.getDeltaShadow() != 0) {
if (HColors.isTransparent(back))
if (back.isTransparent())
drawOnlyLineShadowSpecial(g2d, shape, rect.getDeltaShadow(), dpiFactor);
else
drawShadow(g2d, shape, rect.getDeltaShadow(), dpiFactor);
@ -100,8 +99,8 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
g2d.fill(shape);
drawBorder(param, color, mapper, rect, shape, g2d, x, y);
} else {
if (HColors.isTransparent(param.getBackcolor()) == false) {
g2d.setColor(mapper.toColor(param.getBackcolor()));
if (param.getBackcolor().isTransparent() == false) {
g2d.setColor(param.getBackcolor().toColor(mapper));
DriverLineG2d.manageStroke(param, g2d);
managePattern(param, g2d);
g2d.fill(shape);
@ -114,14 +113,14 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
public static void drawBorder(UParam param, HColor color, ColorMapper mapper, UShapeSized sized, Shape shape,
Graphics2D g2d, double x, double y) {
if (HColors.isTransparent(color))
if (color.isTransparent())
return;
if (color instanceof HColorGradient) {
final GradientPaint paint = getPaintGradient(x, y, mapper, sized.getWidth(), sized.getHeight(), color);
g2d.setPaint(paint);
} else {
g2d.setColor(mapper.toColor(color));
g2d.setColor(color.toColor(mapper));
}
DriverLineG2d.manageStroke(param, g2d);
g2d.draw(shape);
@ -133,18 +132,18 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<URe
final char policy = gr.getPolicy();
final GradientPaint paint;
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()));
paint = new GradientPaint((float) x, (float) (y + height) / 2, gr.getColor1().toColor(mapper),
(float) (x + width), (float) (y + height) / 2, gr.getColor2().toColor(mapper));
else if (policy == '\\')
paint = new GradientPaint((float) x, (float) (y + height), mapper.toColor(gr.getColor1()),
(float) (x + width), (float) y, mapper.toColor(gr.getColor2()));
paint = new GradientPaint((float) x, (float) (y + height), gr.getColor1().toColor(mapper),
(float) (x + width), (float) y, gr.getColor2().toColor(mapper));
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()));
paint = new GradientPaint((float) (x + width) / 2, (float) y, gr.getColor1().toColor(mapper),
(float) (x + width) / 2, (float) (y + height), gr.getColor2().toColor(mapper));
else
// for /
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()), (float) (x + width),
(float) (y + height), mapper.toColor(gr.getColor2()));
paint = new GradientPaint((float) x, (float) y, gr.getColor1().toColor(mapper), (float) (x + width),
(float) (y + height), gr.getColor2().toColor(mapper));
return paint;
}

View File

@ -87,7 +87,7 @@ public class DriverTextAsPathG2d implements UDriver<UText, Graphics2D> {
final double width = dim.getWidth();
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final Color extended = mapper.toColor(fontConfiguration.getExtendedColor());
final Color extended = fontConfiguration.getExtendedColor().toColor(mapper);
if (extended != null) {
g2d.setColor(extended);
g2d.setBackground(extended);
@ -98,7 +98,7 @@ public class DriverTextAsPathG2d implements UDriver<UText, Graphics2D> {
visible.ensureVisible(x + width, y + 1.5);
g2d.setFont(font.getUnderlayingFont());
g2d.setColor(mapper.toColor(fontConfiguration.getColor()));
g2d.setColor(fontConfiguration.getColor().toColor(mapper));
final TextLayout t = createTextLayout(font, shape.getText());
g2d.translate(x, y);
g2d.fill(t.getOutline(null));
@ -107,7 +107,7 @@ public class DriverTextAsPathG2d implements UDriver<UText, Graphics2D> {
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
final int ypos = (int) (y + 2.5);
g2d.setStroke(new BasicStroke((float) 1));
@ -118,7 +118,7 @@ public class DriverTextAsPathG2d implements UDriver<UText, Graphics2D> {
final int ypos = (int) (y + 2.5) - 1;
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
for (int i = (int) x; i < x + width - 5; i += 6) {
g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
@ -130,7 +130,7 @@ public class DriverTextAsPathG2d implements UDriver<UText, Graphics2D> {
final int ypos = (int) (y - fm.getDescent() - 0.5);
final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
g2d.setStroke(new BasicStroke((float) 1.5));
g2d.drawLine((int) x, ypos, (int) (x + width), ypos);

View File

@ -60,7 +60,6 @@ import net.sourceforge.plantuml.ugraphic.UText;
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 DriverTextG2d implements UDriver<UText, Graphics2D> {
@ -75,7 +74,7 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
final FontConfiguration fontConfiguration = shape.getFontConfiguration();
if (HColors.isTransparent(fontConfiguration.getColor())) {
if (fontConfiguration.getColor().isTransparent()) {
return;
}
final String text = shape.getText();
@ -103,7 +102,7 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
if (orientation == 90) {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setFont(font.getUnderlayingFont());
g2d.setColor(mapper.toColor(fontConfiguration.getColor()));
g2d.setColor(fontConfiguration.getColor().toColor(mapper));
final AffineTransform orig = g2d.getTransform();
g2d.translate(x, y);
g2d.rotate(Math.PI / 2);
@ -119,7 +118,7 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
g2d.setPaint(paint);
g2d.fill(area);
} else {
final Color backColor = mapper.toColor(extended);
final Color backColor = extended.toColor(mapper);
if (backColor != null) {
g2d.setColor(backColor);
g2d.setBackground(backColor);
@ -132,12 +131,12 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setFont(font.getUnderlayingFont());
g2d.setColor(mapper.toColor(fontConfiguration.getColor()));
g2d.setColor(fontConfiguration.getColor().toColor(mapper));
g2d.drawString(text, (float) x, (float) y);
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
final int ypos = (int) (y + 2.5);
g2d.setStroke(new BasicStroke((float) 1));
@ -147,7 +146,7 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
final int ypos = (int) (y + 2.5) - 1;
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
for (int i = (int) x; i < x + width - 5; i += 6) {
g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
@ -158,7 +157,7 @@ public class DriverTextG2d implements UDriver<UText, Graphics2D> {
final FontMetrics fm = g2d.getFontMetrics(font.getUnderlayingFont());
final int ypos = (int) (y - fm.getDescent() - 0.5);
if (extended != null) {
g2d.setColor(mapper.toColor(extended));
g2d.setColor(extended.toColor(mapper));
}
g2d.setStroke(new BasicStroke((float) 1.5));
g2d.drawLine((int) x, ypos, (int) (x + width), ypos);

View File

@ -67,7 +67,7 @@ public class DriverLineHtml5 implements UDriver<ULine, Html5Drawer> {
y2 = line.y2;
}
final String color = param.getColor() == null ? null : mapper.toRGB(param.getColor());
final String color = param.getColor() == null ? null : param.getColor().toRGB(mapper);
html.setStrokeColor(color);
html.htmlLine(x, y, x2, y2, 0);

View File

@ -79,8 +79,8 @@ public class DriverRectangleHtml5 implements UDriver<URectangle, Html5Drawer> {
// eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
// eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
} else {
final String color = param.getColor() == null ? null : mapper.toRGB(param.getColor());
final String backcolor = param.getColor() == null ? null : mapper.toRGB(param.getBackcolor());
final String color = param.getColor() == null ? null : param.getColor().toRGB(mapper);
final String backcolor = param.getColor() == null ? null : param.getBackcolor().toRGB(mapper);
html.setStrokeColor(color);
html.setFillColor(backcolor);

View File

@ -62,9 +62,9 @@ public class DriverCenteredCharacterSvg implements UDriver<UCenteredCharacter, S
final HColor textColor = param.getColor();
final HColor dark = textColor == null ? null : textColor.darkSchemeTheme();
if (dark == textColor)
svg.setFillColor(mapper.toSvg(textColor));
svg.setFillColor(textColor.toSvg(mapper));
else
svg.setFillColor(mapper.toSvg(textColor), mapper.toSvg(dark));
svg.setFillColor(textColor.toSvg(mapper), dark.toSvg(mapper));
svg.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null));
}

View File

@ -40,14 +40,13 @@ 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 (HColors.isTransparent(param.getColor()) == false) {
if (param.getColor().isTransparent() == false) {
DriverRectangleSvg.applyStrokeColor(svg, mapper, param);
svg.setFillColor(null);

View File

@ -78,13 +78,13 @@ public class DriverLineSvg implements UDriver<ULine, SvgGraphics> {
final HColor color = param.getColor();
if (color instanceof HColorGradient) {
final HColorGradient gr = (HColorGradient) color;
svg.setStrokeColor(mapper.toSvg(gr.getColor1()));
svg.setStrokeColor(gr.getColor1().toSvg(mapper));
} else {
final HColor dark = color == null ? null : color.darkSchemeTheme();
if (dark == color)
svg.setStrokeColor(mapper.toSvg(color));
svg.setStrokeColor(color.toSvg(mapper));
else
svg.setStrokeColor(mapper.toSvg(color), mapper.toSvg(dark));
svg.setStrokeColor(color.toSvg(mapper), dark.toSvg(mapper));
}
svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
svg.svgLine(x, y, x2, y2, shape.getDeltaShadow());

View File

@ -61,9 +61,9 @@ public class DriverPathSvg extends DriverShadowedG2d implements UDriver<UPath, S
final HColor color = param.getColor();
final HColor dark = color == null ? null : color.darkSchemeTheme();
if (dark == color)
svg.setFillColor(mapper.toSvg(color));
svg.setFillColor(color.toSvg(mapper));
else
svg.setFillColor(mapper.toSvg(color), mapper.toSvg(dark));
svg.setFillColor(color.toSvg(mapper), dark.toSvg(mapper));
svg.setStrokeColor("");
svg.setStrokeWidth(0, "");
} else {

View File

@ -48,9 +48,9 @@ public class DriverPixelSvg implements UDriver<UPixel, SvgGraphics> {
final HColor color = param.getColor();
if (color instanceof HColorGradient) {
final HColorGradient gr = (HColorGradient) color;
svg.setStrokeColor(mapper.toSvg(gr.getColor1()));
svg.setStrokeColor(gr.getColor1().toSvg(mapper));
} else {
svg.setStrokeColor(mapper.toSvg(color));
svg.setStrokeColor(color.toSvg(mapper));
}
svg.setStrokeWidth(0.5, "");

View File

@ -84,15 +84,15 @@ public class DriverRectangleSvg implements UDriver<URectangle, SvgGraphics> {
final HColor background = param.getBackcolor();
if (background instanceof HColorGradient) {
final HColorGradient gr = (HColorGradient) background;
final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()),
final String id = svg.createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper),
gr.getPolicy());
svg.setFillColor("url(#" + id + ")");
} else {
final HColor dark = background == null ? null : background.darkSchemeTheme();
if (dark == background)
svg.setFillColor(mapper.toSvg(background));
svg.setFillColor(background.toSvg(mapper));
else
svg.setFillColor(mapper.toSvg(background), mapper.toSvg(dark));
svg.setFillColor(background.toSvg(mapper), dark.toSvg(mapper));
}
}
@ -100,15 +100,15 @@ public class DriverRectangleSvg implements UDriver<URectangle, SvgGraphics> {
final HColor color = param.getColor();
if (color instanceof HColorGradient) {
final HColorGradient gr = (HColorGradient) color;
final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()),
final String id = svg.createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper),
gr.getPolicy());
svg.setStrokeColor("url(#" + id + ")");
} else {
final HColor dark = color == null ? null : color.darkSchemeTheme();
if (dark == color)
svg.setStrokeColor(mapper.toSvg(color));
svg.setStrokeColor(color.toSvg(mapper));
else
svg.setStrokeColor(mapper.toSvg(color), mapper.toSvg(dark));
svg.setStrokeColor(color.toSvg(mapper), dark.toSvg(mapper));
}
}

View File

@ -50,7 +50,6 @@ import net.sourceforge.plantuml.ugraphic.UText;
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 DriverTextSvg implements UDriver<UText, SvgGraphics> {
@ -69,7 +68,7 @@ public class DriverTextSvg implements UDriver<UText, SvgGraphics> {
}
final FontConfiguration fontConfiguration = shape.getFontConfiguration();
if (HColors.isTransparent(fontConfiguration.getColor())) {
if (fontConfiguration.getColor().isTransparent()) {
return;
}
final UFont font = fontConfiguration.getFont();
@ -114,7 +113,7 @@ public class DriverTextSvg implements UDriver<UText, SvgGraphics> {
final HColor back = fontConfiguration.getExtendedColor();
if (back instanceof HColorGradient) {
final HColorGradient gr = (HColorGradient) back;
final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()),
final String id = svg.createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper),
gr.getPolicy());
svg.setFillColor("url(#" + id + ")");
svg.setStrokeColor(null);
@ -122,16 +121,16 @@ public class DriverTextSvg implements UDriver<UText, SvgGraphics> {
svg.svgRectangle(x, y - height + deltaPatch, width, height, 0, 0, 0, null, null);
} else {
backColor = mapper.toRGB(back);
backColor = back.toRGB(mapper);
}
}
final HColor textColor = fontConfiguration.getColor();
final HColor dark = textColor == null ? null : textColor.darkSchemeTheme();
if (dark == textColor)
svg.setFillColor(mapper.toSvg(textColor));
svg.setFillColor(textColor.toSvg(mapper));
else
svg.setFillColor(mapper.toSvg(textColor), mapper.toSvg(dark));
svg.setFillColor(textColor.toSvg(mapper), dark.toSvg(mapper));
svg.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), fontWeight, fontStyle, textDecoration,
width, fontConfiguration.getAttributes(), backColor);

View File

@ -93,7 +93,7 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
boolean textAsPath, double scale, String linkTarget, String hover, long seed, String preserveAspectRatio,
StringBounder stringBounder, LengthAdjust lengthAdjust, boolean interactive) {
this(defaultBackground, minDim, colorMapper,
new SvgGraphics(colorMapper.toSvg(defaultBackground), svgDimensionStyle, minDim, scale, hover, seed,
new SvgGraphics(defaultBackground.toSvg(colorMapper), svgDimensionStyle, minDim, scale, hover, seed,
preserveAspectRatio, lengthAdjust, DarkStrategy.IGNORE_DARK_COLOR, interactive),
textAsPath, linkTarget, stringBounder, interactive);
if (defaultBackground instanceof HColorGradient) {

View File

@ -81,7 +81,7 @@ public class Version {
}
public static int beta() {
final int beta = 6;
final int beta = 7;
return beta;
}