version 1.2020.8

This commit is contained in:
Arnaud Roques 2020-04-26 20:31:41 +02:00
parent 9077d971d7
commit 138cfb900a
130 changed files with 973 additions and 616 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId> <groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId> <artifactId>plantuml</artifactId>
<version>1.2020.8-SNAPSHOT</version> <version>1.2020.9-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PlantUML</name> <name>PlantUML</name>

View File

@ -303,7 +303,7 @@ public class ConfigParameters {
static private HColorSet colors = HColorSet.instance(); static private HColorSet colors = HColorSet.instance();
private Color decodeInternal(String value) { private Color decodeInternal(String value) {
if (colors.getColorIfValid(value)!=null) { if (colors.getColorIfValid(value)!=null) {
return new ColorMapperIdentity().getMappedColor(colors.getColorIfValid(value)); return new ColorMapperIdentity().toColor(colors.getColorIfValid(value));
} }
return Color.decode(value); return Color.decode(value);
} }

View File

@ -97,9 +97,9 @@ public class AnnotatedWorker {
final double y1 = 10; final double y1 = 10;
final double y2 = 10; final double y2 = 10;
final SymbolContext symbolContext = new SymbolContext(getSkinParam().getBackgroundColor(), HColorUtils.BLACK) final SymbolContext symbolContext = new SymbolContext(getSkinParam().getBackgroundColor(false), HColorUtils.BLACK)
.withShadow(getSkinParam().shadowing(null) ? 3 : 0); .withShadow(getSkinParam().shadowing(null) ? 3 : 0);
final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder); final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder, false);
final TextBlock title = mainFrame.create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null), final TextBlock title = mainFrame.create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
HorizontalAlignment.CENTER, getSkinParam()); HorizontalAlignment.CENTER, getSkinParam());
final Dimension2D dimTitle = title.calculateDimension(stringBounder); final Dimension2D dimTitle = title.calculateDimension(stringBounder);
@ -118,7 +118,7 @@ public class AnnotatedWorker {
} }
public MinMax getMinMax(StringBounder stringBounder) { public MinMax getMinMax(StringBounder stringBounder) {
return TextBlockUtils.getMinMax(this, stringBounder); return TextBlockUtils.getMinMax(this, stringBounder, false);
} }
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {

View File

@ -86,6 +86,7 @@ public enum ColorParam {
interfaceBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), interfaceBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK),
interfaceBorder(HColorUtils.MY_RED, ColorType.LINE), interfaceBorder(HColorUtils.MY_RED, ColorType.LINE),
arrow(HColorUtils.MY_RED, ColorType.ARROW), arrow(HColorUtils.MY_RED, ColorType.ARROW),
arrowHead(HColorUtils.MY_RED, null),
stateBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), stateBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK),
stateBorder(HColorUtils.MY_RED, ColorType.LINE), stateBorder(HColorUtils.MY_RED, ColorType.LINE),

View File

@ -36,9 +36,14 @@
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
import java.awt.Color; import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
@ -50,11 +55,11 @@ public class EmptyImageBuilder {
private final BufferedImage im; private final BufferedImage im;
private final Graphics2D g2d; private final Graphics2D g2d;
public EmptyImageBuilder(double width, double height, Color background) { public EmptyImageBuilder(String watermark, double width, double height, Color background) {
this((int) width, (int) height, background); this(watermark, (int) width, (int) height, background);
} }
public EmptyImageBuilder(int width, int height, Color background) { public EmptyImageBuilder(String watermark, int width, int height, Color background) {
if (width > GraphvizUtils.getenvImageLimit()) { if (width > GraphvizUtils.getenvImageLimit()) {
Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE"); Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE");
width = GraphvizUtils.getenvImageLimit(); width = GraphvizUtils.getenvImageLimit();
@ -64,18 +69,84 @@ public class EmptyImageBuilder {
height = GraphvizUtils.getenvImageLimit(); height = GraphvizUtils.getenvImageLimit();
} }
Log.info("Creating image " + width + "x" + height); Log.info("Creating image " + width + "x" + height);
im = new BufferedImage(width, height, background == null ? BufferedImage.TYPE_INT_ARGB im = new BufferedImage(width, height, getType(background));
: BufferedImage.TYPE_INT_RGB);
g2d = im.createGraphics(); g2d = im.createGraphics();
UAntiAliasing.ANTI_ALIASING_ON.apply(g2d); UAntiAliasing.ANTI_ALIASING_ON.apply(g2d);
if (background != null) { if (background != null) {
g2d.setColor(background); g2d.setColor(background);
g2d.fillRect(0, 0, width, height); g2d.fillRect(0, 0, width, height);
} }
if (watermark != null) {
final int gray = 200;
g2d.setColor(new Color(gray, gray, gray));
printWatermark(watermark, width, height);
}
} }
public EmptyImageBuilder(int width, int height, Color background, double dpiFactor) { private int getType(Color background) {
this(width * dpiFactor, height * dpiFactor, background); if (background == null) {
return BufferedImage.TYPE_INT_ARGB;
}
if (background.getAlpha() != 255) {
return BufferedImage.TYPE_INT_ARGB;
}
return BufferedImage.TYPE_INT_RGB;
}
private void printWatermark(String watermark, int maxWidth, int maxHeight) {
final Font javaFont = g2d.getFont();
final FontMetrics fm = g2d.getFontMetrics(javaFont);
final Rectangle2D rect = fm.getStringBounds(watermark, g2d);
final int height = (int) rect.getHeight();
final int width = (int) rect.getWidth();
if (height < 2 || width < 2) {
return;
}
if (width <= maxWidth)
for (int y = height; y < maxHeight; y += height + 1) {
for (int x = 0; x < maxWidth; x += width + 10) {
g2d.drawString(watermark, x, y);
}
}
else {
final List<String> withBreaks = withBreaks(watermark, javaFont, fm, maxWidth);
int y = 0;
while (y < maxHeight) {
for (String s : withBreaks) {
g2d.drawString(s, 0, y);
y += (int) fm.getStringBounds(s, g2d).getHeight();
}
y += 10;
}
}
}
private int getWidth(String line, Font javaFont, FontMetrics fm) {
final Rectangle2D rect = fm.getStringBounds(line, g2d);
return (int) rect.getWidth();
}
private List<String> withBreaks(String watermark, Font javaFont, FontMetrics fm, int maxWidth) {
final String[] words = watermark.split("\\s+");
final List<String> result = new ArrayList<String>();
String pending = "";
for (String word : words) {
final String candidate = pending.length() == 0 ? word : pending + " " + word;
if (getWidth(candidate, javaFont, fm) < maxWidth) {
pending = candidate;
} else {
result.add(pending);
pending = word;
}
}
if (pending.length() > 0) {
result.add(pending);
}
return result;
}
public EmptyImageBuilder(String watermark, int width, int height, Color background, double dpiFactor) {
this(watermark, width * dpiFactor, height * dpiFactor, background);
if (dpiFactor != 1.0) { if (dpiFactor != 1.0) {
g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor)); g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor));
} }

View File

@ -58,13 +58,38 @@ public final class FileFormatOption implements Serializable {
private final TikzFontDistortion tikzFontDistortion; private final TikzFontDistortion tikzFontDistortion;
private final double scale; private final double scale;
private final String preserveAspectRatio; private final String preserveAspectRatio;
private final String watermark;
public double getScaleCoef() { public double getScaleCoef() {
return scale; return scale;
} }
public FileFormatOption(FileFormat fileFormat) { public FileFormatOption(FileFormat fileFormat) {
this(fileFormat, null, true, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none"); this(fileFormat, null, true, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none", null);
}
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, withMetadata, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none",
null);
}
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError,
String svgLinkTarget, boolean debugsvek, String hoverColor, TikzFontDistortion tikzFontDistortion,
double scale, String preserveAspectRatio, String watermark) {
this.hoverColor = hoverColor;
this.watermark = watermark;
this.fileFormat = fileFormat;
this.affineTransform = at;
this.withMetadata = withMetadata;
this.useRedForError = useRedForError;
this.svgLinkTarget = svgLinkTarget;
this.debugsvek = debugsvek;
this.tikzFontDistortion = tikzFontDistortion;
this.scale = scale;
this.preserveAspectRatio = preserveAspectRatio;
if (tikzFontDistortion == null) {
throw new IllegalArgumentException();
}
} }
public StringBounder getDefaultStringBounder() { public StringBounder getDefaultStringBounder() {
@ -83,56 +108,39 @@ public final class FileFormatOption implements Serializable {
return preserveAspectRatio; return preserveAspectRatio;
} }
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, withMetadata, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none");
}
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError,
String svgLinkTarget, boolean debugsvek, String hoverColor, TikzFontDistortion tikzFontDistortion,
double scale, String preserveAspectRatio) {
this.hoverColor = hoverColor;
this.fileFormat = fileFormat;
this.affineTransform = at;
this.withMetadata = withMetadata;
this.useRedForError = useRedForError;
this.svgLinkTarget = svgLinkTarget;
this.debugsvek = debugsvek;
this.tikzFontDistortion = tikzFontDistortion;
this.scale = scale;
this.preserveAspectRatio = preserveAspectRatio;
if (tikzFontDistortion == null) {
throw new IllegalArgumentException();
}
}
public FileFormatOption withUseRedForError() { public FileFormatOption withUseRedForError() {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek, return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
public FileFormatOption withTikzFontDistortion(TikzFontDistortion tikzFontDistortion) { public FileFormatOption withTikzFontDistortion(TikzFontDistortion tikzFontDistortion) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek, return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
public FileFormatOption withSvgLinkTarget(String svgLinkTarget) { public FileFormatOption withSvgLinkTarget(String svgLinkTarget) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
public FileFormatOption withPreserveAspectRatio(String preserveAspectRatio) { public FileFormatOption withPreserveAspectRatio(String preserveAspectRatio) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
public FileFormatOption withHoverColor(String hoverColor) { public FileFormatOption withHoverColor(String hoverColor) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
public FileFormatOption withScale(double scale) { public FileFormatOption withScale(double scale) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio); hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
}
public FileFormatOption withWartermark(String watermark) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
} }
@Override @Override
@ -174,4 +182,8 @@ public final class FileFormatOption implements Serializable {
return tikzFontDistortion; return tikzFontDistortion;
} }
public final String getWatermark() {
return watermark;
}
} }

View File

@ -63,7 +63,7 @@ public interface ISkinParam extends ISkinSimple {
public boolean useUnderlineForHyperlink(); public boolean useUnderlineForHyperlink();
public HColor getBackgroundColor(); public HColor getBackgroundColor(boolean replaceTransparentByWhite);
public HColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable); public HColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable);

View File

@ -263,11 +263,14 @@ public class SkinParam implements ISkinParam {
return result; return result;
} }
public HColor getBackgroundColor() { public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
final HColor result = getHtmlColor(ColorParam.background, null, false); final HColor result = getHtmlColor(ColorParam.background, null, false);
if (result == null) { if (result == null) {
return HColorUtils.WHITE; return HColorUtils.WHITE;
} }
if (replaceTransparentByWhite && HColorUtils.transparent().equals(result)) {
return HColorUtils.WHITE;
}
return result; return result;
} }
@ -310,8 +313,9 @@ public class SkinParam implements ISkinParam {
if (value == null) { if (value == null) {
return null; return null;
} }
if (param == ColorParam.background && value.equalsIgnoreCase("transparent")) { if ((param == ColorParam.background || param == ColorParam.arrowHead)
return null; && (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none"))) {
return HColorUtils.transparent();
} }
if (param == ColorParam.background) { if (param == ColorParam.background) {
return getIHtmlColorSet().getColorIfValid(value); return getIHtmlColorSet().getColorIfValid(value);
@ -319,7 +323,7 @@ public class SkinParam implements ISkinParam {
assert param != ColorParam.background; assert param != ColorParam.background;
// final boolean acceptTransparent = param == ColorParam.background // final boolean acceptTransparent = param == ColorParam.background
// || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground; // || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground;
return getIHtmlColorSet().getColorIfValid(value, getBackgroundColor()); return getIHtmlColorSet().getColorIfValid(value, getBackgroundColor(false));
} }
public char getCircledCharacter(Stereotype stereotype) { public char getCircledCharacter(Stereotype stereotype) {

View File

@ -73,11 +73,11 @@ public class SkinParamBackcolored extends SkinParamDelegator {
} }
@Override @Override
public HColor getBackgroundColor() { public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
if (backColorGeneral != null) { if (backColorGeneral != null) {
return backColorGeneral; return backColorGeneral;
} }
return super.getBackgroundColor(); return super.getBackgroundColor(replaceTransparentByWhite);
} }
@Override @Override

View File

@ -71,8 +71,8 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.getHyperlinkColor(); return skinParam.getHyperlinkColor();
} }
public HColor getBackgroundColor() { public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
return skinParam.getBackgroundColor(); return skinParam.getBackgroundColor(replaceTransparentByWhite);
} }
public int getCircledCharacterRadius() { public int getCircledCharacterRadius() {

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.svek.DotStringFactory;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
@ -385,30 +386,6 @@ public class StringUtils {
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
public static String getAsHtml(Color color) {
if (color == null) {
return null;
}
return getAsHtml(color.getRGB());
}
public static String getAsSvg(ColorMapper mapper, HColor color) {
if (color == null) {
return "none";
}
if (color instanceof HColorBackground) {
return ((HColorBackground) color).getSvg(mapper);
}
return getAsHtml(mapper.getMappedColor(color));
}
public static String getAsHtml(int color) {
final int v = 0xFFFFFF & color;
String s = "000000" + Integer.toHexString(v).toUpperCase();
s = s.substring(s.length() - 6);
return "#" + s;
}
public static String getUid(String uid1, int uid2) { public static String getUid(String uid1, int uid2) {
return uid1 + String.format("%04d", uid2); return uid1 + String.format("%04d", uid2);
} }

View File

@ -189,8 +189,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio()); fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion()); fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (hover != null) { if (hover != null) {
fileFormatOption = fileFormatOption.withHoverColor(StringUtils.getAsHtml(getSkinParam().getColorMapper() fileFormatOption = fileFormatOption
.getMappedColor(hover))); .withHoverColor(getSkinParam().getColorMapper().toHtml(hover));
} }
if (fileFormatOption.getFileFormat() == FileFormat.PDF) { if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
@ -227,8 +227,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
strings.addAll(CommandExecutionResult.getStackTrace(exception)); strings.addAll(CommandExecutionResult.getStackTrace(exception));
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HColorUtils.WHITE, metadata,
metadata, null, 0, 0, null, false); null, 0, 0, null, false);
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE); final BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE);
@ -316,7 +316,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
final double coef = (nb - 1 - i) * 1.0 / nb; final double coef = (nb - 1 - i) * 1.0 / nb;
at.setToShear(coef, coef); at.setToShear(coef, coef);
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
// exportDiagramTOxxBEREMOVED(baos, null, 0, new FileFormatOption(FileFormat.PNG, at)); // exportDiagramTOxxBEREMOVED(baos, null, 0, new
// FileFormatOption(FileFormat.PNG, at));
baos.close(); baos.close();
final BufferedImage im = ImageIO.read(new ByteArrayInputStream(baos.toByteArray())); final BufferedImage im = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
m.addImage(im); m.addImage(im);
@ -411,7 +412,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
// final String res = "/skin/" + filename + ".skin"; // final String res = "/skin/" + filename + ".skin";
// final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res); // final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res);
// if (internalIs != null) { // if (internalIs != null) {
// final BlocLines lines2 = BlocLines.load(internalIs, new LineLocationImpl(filename, null)); // final BlocLines lines2 = BlocLines.load(internalIs, new
// LineLocationImpl(filename, null));
// return loadSkinInternal(lines2); // return loadSkinInternal(lines2);
// } // }
// if (OptionFlags.ALLOW_INCLUDE == false) { // if (OptionFlags.ALLOW_INCLUDE == false) {
@ -421,7 +423,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
// if (f == null || f.exists() == false || f.canRead() == false) { // if (f == null || f.exists() == false || f.canRead() == false) {
// return CommandExecutionResult.error("Cannot load skin from " + filename); // return CommandExecutionResult.error("Cannot load skin from " + filename);
// } // }
// final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), null)); // final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(),
// null));
// return loadSkinInternal(lines); // return loadSkinInternal(lines);
} }

View File

@ -65,7 +65,7 @@ public class CommandLink3 extends SingleLineCommand2<ActivityDiagram3> {
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
if (color != null) { if (color != null) {
diagram.setColorNextArrow(Rainbow.fromColor(color)); diagram.setColorNextArrow(Rainbow.fromColor(color, null));
} }
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -325,7 +325,7 @@ public class SwimlanesA extends AbstractTextBlock implements ISwimlanesA, TextBl
@Override @Override
public MinMax getMinMax(StringBounder stringBounder) { public MinMax getMinMax(StringBounder stringBounder) {
if (cachedMinMax == null) { if (cachedMinMax == null) {
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder); cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
} }
return cachedMinMax; return cachedMinMax;
} }

View File

@ -426,7 +426,7 @@ public class SwimlanesAAA extends AbstractTextBlock implements ISwimlanesA, Text
@Override @Override
public MinMax getMinMax(StringBounder stringBounder) { public MinMax getMinMax(StringBounder stringBounder) {
if (cachedMinMax == null) { if (cachedMinMax == null) {
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder); cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
} }
return cachedMinMax; return cachedMinMax;
} }

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode; import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
public class Worm implements Iterable<Point2D.Double> { public class Worm implements Iterable<Point2D.Double> {
@ -69,18 +70,18 @@ public class Worm implements Iterable<Point2D.Double> {
this.ignoreForCompression = true; this.ignoreForCompression = true;
} }
public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle color, double stroke, public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle colorAndStyle,
Direction emphasizeDirection, UPolygon endDecoration) { double stroke, Direction emphasizeDirection, UPolygon endDecoration) {
final HColor color2 = color.getColor(); final HColor arrowColor = colorAndStyle.getArrowColor();
if (color2 == null) { if (arrowColor == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
final LinkStyle style = color.getStyle(); final LinkStyle style = colorAndStyle.getStyle();
if (style.isInvisible()) { if (style.isInvisible()) {
return; return;
} }
ug = ug.apply(color2); ug = ug.apply(arrowColor);
ug = ug.apply(color2.bg()); ug = ug.apply(arrowColor.bg());
if (style.isNormal()) { if (style.isNormal()) {
ug = ug.apply(new UStroke(stroke)); ug = ug.apply(new UStroke(stroke));
} else { } else {
@ -98,6 +99,13 @@ public class Worm implements Iterable<Point2D.Double> {
drawLine(ug, line, null); drawLine(ug, line, null);
} }
} }
final HColor arrowHeadColor = colorAndStyle.getArrowHeadColor();
if (arrowHeadColor != null && arrowHeadColor.equals(HColorUtils.transparent()) == false) {
ug = ug.apply(arrowHeadColor);
ug = ug.apply(arrowHeadColor.bg());
}
if (startDecoration != null) { if (startDecoration != null) {
ug = ug.apply(new UStroke(1.5)); ug = ug.apply(new UStroke(1.5));
final Point2D start = points.get(0); final Point2D start = points.get(0);
@ -350,7 +358,8 @@ public class Worm implements Iterable<Point2D.Double> {
for (int i = 0; i < points.size() - 5; i++) { for (int i = 0; i < points.size() - 5; i++) {
final List<Direction> patternAt = getPatternAt(i); final List<Direction> patternAt = getPatternAt(i);
if (Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.RIGHT).equals(patternAt) if (Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.RIGHT).equals(patternAt)
|| Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.LEFT).equals(patternAt)) { || Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.LEFT)
.equals(patternAt)) {
final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y); final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
points.remove(i + 3); points.remove(i + 3);
points.remove(i + 2); points.remove(i + 2);
@ -398,7 +407,8 @@ public class Worm implements Iterable<Point2D.Double> {
for (int i = 0; i < points.size() - 4; i++) { for (int i = 0; i < points.size() - 4; i++) {
final List<Direction> patternAt = getPatternAt(i); final List<Direction> patternAt = getPatternAt(i);
if (Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.RIGHT).equals(patternAt) if (Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.RIGHT).equals(patternAt)
|| Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.LEFT).equals(patternAt)) { || Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.LEFT)
.equals(patternAt)) {
final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y); final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
points.remove(i + 3); points.remove(i + 3);
points.remove(i + 2); points.remove(i + 2);

View File

@ -271,7 +271,6 @@ class FtileWhile extends AbstractFtile {
snake.emphasizeDirection(Direction.UP); snake.emphasizeDirection(Direction.UP);
ug.draw(snake); ug.draw(snake);
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize)); ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
} }
@ -362,6 +361,7 @@ class FtileWhile extends AbstractFtile {
snake.addPoint(x2, y2); snake.addPoint(x2, y2);
ug.draw(snake); ug.draw(snake);
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
} }
} }

View File

@ -112,7 +112,7 @@ public class ConditionalBuilder {
this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
this.arrowColor = Rainbow this.arrowColor = Rainbow
.fromColor(styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet())); .fromColor(styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()), null);
this.fontTest = styleDiamond.getFontConfiguration(skinParam.getIHtmlColorSet()); this.fontTest = styleDiamond.getFontConfiguration(skinParam.getIHtmlColorSet());
this.fontArrow = styleArrow.getFontConfiguration(skinParam.getIHtmlColorSet()); this.fontArrow = styleArrow.getFontConfiguration(skinParam.getIHtmlColorSet());
} else { } else {

View File

@ -46,10 +46,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScale extends SingleLineCommand2<AbstractPSystem> { public class CommandScale extends SingleLineCommand2<AbstractPSystem> {
// public CommandScale() {
// super("(?i)^$");
// }
public CommandScale() { public CommandScale() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -106,8 +106,7 @@ public class AtomMath extends AbstractAtom implements Atom {
private Color getColor(HColor color, Color defaultValue) { private Color getColor(HColor color, Color defaultValue) {
if (color instanceof HColorSimple) { if (color instanceof HColorSimple) {
return colorMapper.getMappedColor(color); return colorMapper.toColor(color);
// return ((HtmlColorSimple) color).getColor999();
} }
return defaultValue; return defaultValue;

View File

@ -128,7 +128,7 @@ public final class EntityFactory {
if (g.getColors(skinParam).getColor(ColorType.BACK) == null) { if (g.getColors(skinParam).getColor(ColorType.BACK) == null) {
final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack(); final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack();
final HColor c1 = skinParam.getHtmlColor(param, g.getStereotype(), false); final HColor c1 = skinParam.getHtmlColor(param, g.getStereotype(), false);
folder.setSpecificColorTOBEREMOVED(ColorType.BACK, c1 == null ? skinParam.getBackgroundColor() : c1); folder.setSpecificColorTOBEREMOVED(ColorType.BACK, c1 == null ? skinParam.getBackgroundColor(false) : c1);
} else { } else {
folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors(skinParam).getColor(ColorType.BACK)); folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors(skinParam).getColor(ColorType.BACK));
} }

View File

@ -71,25 +71,25 @@ public class PSystemDonors extends AbstractPSystem {
private static final int COLS = 6; private static final int COLS = 6;
private static final int FREE_LINES = 6; private static final int FREE_LINES = 6;
public static final String DONORS = "6_eA02mFU3XMJYceJdotTlPGzS6YgH0ylZFbdo3X7Mo0347DLH8jYjmdkzS0GG5q3HqzvlQT7lSRwI-Y" public static final String DONORS = "6nmB0AmFkBcp0hHmgCOwx9qzUsNuYPYXIV3upfH_WeHti04o13LNIRGeSf_iNWC41T0rTFIOstTwt6-a"
+ "AztxfXdHbh_c-7d6K0m4FPw_hePj_hS7Zwa_zqxZk-ioVNvpXqL918Z8CYV51XeoyFvcECytZOzUUWOi" + "luYkTE-RPaHR_fhZvnb3CH3qUFww6hRvtnuyvfxff-Ixcz4JPiBaVmA4fYcNj0L8bI6ba87tDyDvlcaC"
+ "eUgdwBxsVvUkikvULOLPkbkrJf-kK3UsOexfygF0XLEm4rJHe91ZEfLp7GvLZVBgWQyjDCYaSEUtystN" + "lVGCM1vLFqNtjV-xT9LrzwfEcBReReNpfn6gCqUZc6Ew_wF0XIZO2QfeKCWndSgv3eUg3dAs4trL54X2"
+ "P5QCVeYKJ6riGKPlZD2TazOloOACsd_K9z2YOxgcH2u9nTPB93h_h7HuMK3tQoI-0iaG2pODpA6K8pf1" + "nJk_dTzsJLR5P2wH4gkDRSICpe3kdFH-IGvajFwZVe0F7TCr9RWd59TU8kZyizhXPG73hv7uDHGEiU38"
+ "iNCZXYGfWeREKOp6rX_PyYG4GnvQs8T_r9CZxYcPCGmjafHhe23ZPXo0j4hTcd2skXbGdITR36kIgelZ" + "m1nAEoesA6Lk91J22L3eNCLiRFt1aITUM5H12_lmZqPou9wIh65eKOXu00Knp-02IM_KhKdEJXq6LEUP"
+ "8Tnt7AQdd3feU0GiKYoe1QeXo9lG2P_ciruokFIBeeQ__3R9jLa2r5ss1DWtC_eM7aqIvNzwromGTvMo" + "BOOrITUjyH3fcuU95AsBXll18iA2Ma0DGzw4RlXqd_MIeNk_A1huos-JNBlbG1so9K3RhEXRU3H9LF-d"
+ "UKfZgTVU7sDto5rJPXx-Hs-Zb2suryr22XOlBO0VWPwhYKhoyrVMZOKuX6ifVI5TvxOhrr64IpPag5YN" + "csUUkCkKpLEQZdhj_J5sXzmrPURqFteVXLp0SsuMKcJnyWBvCUYvcgWbFvVpO24DuJfANqZtkUtYCOjm"
+ "psB9QyuTNN9ZqsAP3XRZ4_ovs8GCjD2LojNG3LfrsQtpXPBKrBX-oAj3-tN0DNLczuxHUY-Ri_p_8gpC" + "oOOCDUlopIoZHb_iIdGsBSPsif0Vy-TM4n9iuQkKHw0djUfeqVb28JKrhX_oUcg_3d9DdGNUCLeV5NEL"
+ "Z8e3TBh4AEX6GC4SJQkXOW4Hc1QwEkGcG2v0kPhSYjNgG_pQ9mZUJ7eW2XiXFH2lFvURN8Gm3MkwFSKC" + "_r-4LPYXE46douoYhb-e6BDvDLGiKGHdZ2uFkGaa5-1SJMx7QlKXVkqJH6yb8n3Bng07ulMlbIwNGbWT"
+ "OFgGKYT9seG8JTe4FOagnKXPXDuEavPXqyRKTT86ZzC6On37T5nz4ZvR2Dp2i4urcft5skSOGt2BxsK-" + "wxezpGfW-R1IDuMeBGAQj1jw4bVoaR88lHqcZMKpnj9pqWOVfut6A4xejCOcShCGfCkmJbNDT8dsEQrX"
+ "FUz36LVndMxXFUz9QloG0JlJWXwHAYFgorBsad3JG64MRyb9GtnNsCx5G_S5vvaisi3CsUOuP3PKBYMf" + "U3M_b_dql1_9UHNNwIRlUH_IwoSPg3Cjw9XK6l5ObhANHBe6gipYB7NL4DyLjlFmq7t1UHQBDZ1pjhaE"
+ "gNzY-A59zxS2MTjURKNUWFGIc8GmCxh1wQt98pMvH98qdEd4s04WgnQVs6-AS6TGTSlBpk8wXCaZLYz2" + "MHOQ5vBKr3yn-Q59npj9sQnzjHLx1_4lWtc8P4OHND-UF5AJonJ2bZET09j0LAh59_PRqhWpg8VbP7Eu"
+ "Xlmk-GIMAhhmT65xT_VZ6SEZo3wSzyAigN7fKdmieERi9YXA2wLwIb6apGaov5Y3dlNMmFQxEXR8rc_L" + "3c7beTMBa2I_Ipv1hAfOE5rO6-v-UOOW2lR9UI_CsXgNBYNN0chE7eAyj51LJocEj3b91kQQzAot3hRV"
+ "iEbGUDj4fvKRJ4mXmrMY_sYqI3GguXAz-2GnWB_nyfHwnbW77T_XPODnWAmX2O4gZER8WTFIMDswbh7U" + "rRd0jtwhZcr0yPqGdTRSO7CAZ3HHVb6WHDAGbV9BJn8J-5y_Jxb7vZha-2ul6na7oIb93Ac2TCSlN3sD"
+ "ely_QsspSlxytskooAaddl6g0kWECk8_I57dw6BM3RmDyzNOC0VOO0OJtTdXoWDBxmOI5kp3EwkeAzEC" + "rSlG2jPR_FsprZOhvy__lIOhEVN4irvD41qWed-J0hYSqnZ1sy1VjuyaRqxCi57GsEJAWrel0ea8zk6T"
+ "v4eCbbkKYrPnVAYwhtGFBcP3R5XnKKnHT9_YfBLD8wWKs_Tz4KvoOCv_YYgpKhWgTMfYn8JOxb6SmjXx" + "NTIJoupy8aQMMvIBLd5zgBgluXwvM0snOUiYd-BeFiMLrZODKILZt_T5kCZ1EFyjginAuQgMriA8JR7T"
+ "ByLTrwn0W-guJE3jgTUtYsckqkTuGQbXk0RafoDooAPvQ45DJPlwH62R6EjxSziXcUQ_IOz-YjREVbOF" + "ipYviLilnTFMRY23whX3uEoft-wckKgVwmjBJSFJH7uwa4EskaiBQthQD3O3syJOtrlR3acw_oOT_v9U"
+ "GplRlybLeE7R7qAxeISOBX8t3F2xnvpSmCqt5FB6r1rbkPYsSz4zmouHhB3Vz5ra8U6LPQqo4SRSt5ek" + "q_sk7ePsTlucJuF6RtSO_OQHO41axPXWjymvYS2JRoJaZNauoUrYwPEBxYcxKB32VjClayM4LrQqoaIq"
+ "F2t4Czk67Bo5xDFLAFg2g2fk80SMctKEOb4fnoDI98Nc72sR4v6s0m00"; + "vkRMS-vj8Svk6tFO5hPFLwFu5qKr4O5CBZRhdiH2AU21L9A2EMVBL86qdIPDymc9Inq0";
/* /*
* Special thanks to our sponsors and donors: * Special thanks to our sponsors and donors:

View File

@ -68,7 +68,7 @@ public class GraphicsPath {
} }
private BufferedImage createImage() { private BufferedImage createImage() {
final EmptyImageBuilder builder = new EmptyImageBuilder(50, 50, Color.WHITE); final EmptyImageBuilder builder = new EmptyImageBuilder(null, 50, 50, Color.WHITE);
final BufferedImage im = builder.getBufferedImage(); final BufferedImage im = builder.getBufferedImage();
final Graphics2D g2d = builder.getGraphics2D(); final Graphics2D g2d = builder.getGraphics2D();

View File

@ -71,7 +71,7 @@ public class PSystemWelcome extends AbstractPSystem {
strings.add(" "); strings.add(" ");
strings.add("\"\"class Example\"\""); strings.add("\"\"class Example\"\"");
strings.add(" "); strings.add(" ");
strings.add("You will find more information about PlantUML syntax on <u>http://plantuml.com</u>"); strings.add("You will find more information about PlantUML syntax on <u>https://plantuml.com</u>");
if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) { if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
strings.add(" "); strings.add(" ");
strings.add(" "); strings.add(" ");

View File

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

View File

@ -65,9 +65,9 @@ class EntityImageActivityBranch extends AbstractEntityImage {
p.addPoint(size, size * 2); p.addPoint(size, size * 2);
p.addPoint(0, size); p.addPoint(0, size);
g2d.setColor(colorMapper.getMappedColor(getYellow())); g2d.setColor(colorMapper.toColor(getYellow()));
g2d.fill(p); g2d.fill(p);
g2d.setColor(colorMapper.getMappedColor(getRed())); g2d.setColor(colorMapper.toColor(getRed()));
g2d.draw(p); g2d.draw(p);
} }
} }

View File

@ -47,28 +47,34 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet;
public class HtmlColorAndStyle { public class HtmlColorAndStyle {
private final HColor color; private final HColor arrowHeadColor;
private final HColor arrowColor;
private final LinkStyle style; private final LinkStyle style;
@Override @Override
public String toString() { public String toString() {
return color + " " + style; return arrowColor + " " + style;
} }
public HtmlColorAndStyle(HColor color) { public HtmlColorAndStyle(HColor color, HColor arrowHeadColor) {
this(color, LinkStyle.NORMAL()); this(color, LinkStyle.NORMAL(), arrowHeadColor);
} }
public HtmlColorAndStyle(HColor color, LinkStyle style) { public HtmlColorAndStyle(HColor arrowColor, LinkStyle style, HColor arrowHeadColor) {
if (color == null) { if (arrowColor == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.color = color; this.arrowHeadColor = arrowHeadColor;
this.arrowColor = arrowColor;
this.style = style; this.style = style;
} }
public HColor getColor() { public HColor getArrowColor() {
return color; return arrowColor;
}
public HColor getArrowHeadColor() {
return arrowHeadColor;
} }
public LinkStyle getStyle() { public LinkStyle getStyle() {
@ -80,12 +86,14 @@ public class HtmlColorAndStyle {
} }
public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) { public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) {
HColor color; HColor arrowColor;
HColor arrowHeadColor = null;
if (SkinParam.USE_STYLES()) { if (SkinParam.USE_STYLES()) {
final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder());
color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); arrowColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
} else { } else {
color = Rainbow.build(skinParam).getColors().get(0).color; arrowColor = Rainbow.build(skinParam).getColors().get(0).arrowColor;
arrowColor = Rainbow.build(skinParam).getColors().get(0).arrowHeadColor;
} }
LinkStyle style = LinkStyle.NORMAL(); LinkStyle style = LinkStyle.NORMAL();
final HColorSet set = skinParam.getIHtmlColorSet(); final HColorSet set = skinParam.getIHtmlColorSet();
@ -97,10 +105,10 @@ public class HtmlColorAndStyle {
} }
final HColor tmpColor = set.getColorIfValid(s); final HColor tmpColor = set.getColorIfValid(s);
if (tmpColor != null) { if (tmpColor != null) {
color = tmpColor; arrowColor = tmpColor;
} }
} }
return new HtmlColorAndStyle(color, style); return new HtmlColorAndStyle(arrowColor, style, arrowHeadColor);
} }
} }

View File

@ -67,28 +67,28 @@ public class Rainbow {
public static Rainbow none() { public static Rainbow none() {
return new Rainbow(0); return new Rainbow(0);
} }
public static Rainbow fromColor(HColor color) { public static Rainbow fromColor(HColor arrowColor, HColor arrowHeadColor) {
if (color == null) { if (arrowColor == null) {
return Rainbow.none(); return Rainbow.none();
} }
return Rainbow.build(new HtmlColorAndStyle(color)); return Rainbow.build(new HtmlColorAndStyle(arrowColor, arrowHeadColor));
} }
public static Rainbow build(ISkinParam skinParam) { public static Rainbow build(ISkinParam skinParam) {
if (SkinParam.USE_STYLES()) { if (SkinParam.USE_STYLES()) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
return fromColor(rose.getHtmlColor(skinParam, ColorParam.arrow)); final HColor arrow = rose.getHtmlColor(skinParam, ColorParam.arrow);
final HColor arrowHead = rose.getHtmlColor(skinParam, null, ColorParam.arrowHead, ColorParam.arrow);
return fromColor(arrow, arrowHead);
} }
public static Rainbow build(Style style, HColorSet set) { public static Rainbow build(Style style, HColorSet set) {
final HColor color = style.value(PName.LineColor).asColor(set); final HColor color = style.value(PName.LineColor).asColor(set);
return fromColor(color); return fromColor(color, null);
} }
public Rainbow withDefault(Rainbow defaultColor) { public Rainbow withDefault(Rainbow defaultColor) {
if (this.size() == 0) { if (this.size() == 0) {
return defaultColor; return defaultColor;
@ -130,7 +130,7 @@ public class Rainbow {
} }
public HColor getColor() { public HColor getColor() {
return colors.get(0).getColor(); return colors.get(0).getArrowColor();
} }
public int getColorArrowSeparationSpace() { public int getColorArrowSeparationSpace() {

View File

@ -67,13 +67,13 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class TextBlockUtils { public class TextBlockUtils {
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, HColor backgroundColor,
HColor backgroundColor, double cornersize) { double cornersize) {
return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize); return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize);
} }
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, HColor backgroundColor,
HColor backgroundColor, double cornersize, double marginX, double marginY) { double cornersize, double marginX, double marginY) {
return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize, marginX, marginY); return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize, marginX, marginY);
} }
@ -146,8 +146,8 @@ public class TextBlockUtils {
// return addBackcolor(mergeTB(b1, b2, horizontalAlignment), b1.getBackcolor()); // return addBackcolor(mergeTB(b1, b2, horizontalAlignment), b1.getBackcolor());
// } // }
public static MinMax getMinMax(TextBlock tb, StringBounder stringBounder) { public static MinMax getMinMax(UDrawable tb, StringBounder stringBounder, boolean initToZero) {
final LimitFinder limitFinder = new LimitFinder(stringBounder, false); final LimitFinder limitFinder = new LimitFinder(stringBounder, initToZero);
tb.drawU(limitFinder); tb.drawU(limitFinder);
return limitFinder.getMinMax(); return limitFinder.getMinMax();
} }

View File

@ -65,7 +65,7 @@ public class PSystemLogo extends AbstractPSystem {
throws IOException { throws IOException {
final int width = 640; final int width = 640;
final int height = 480; final int height = 480;
final EmptyImageBuilder builder = new EmptyImageBuilder(width, height, Color.WHITE); final EmptyImageBuilder builder = new EmptyImageBuilder(fileFormat.getWatermark(), width, height, Color.WHITE);
final BufferedImage im = builder.getBufferedImage(); final BufferedImage im = builder.getBufferedImage();
final UGraphic ug = new UGraphicG2d(new ColorMapperIdentity(), builder.getGraphics2D(), 1.0); final UGraphic ug = new UGraphicG2d(new ColorMapperIdentity(), builder.getGraphics2D(), 1.0);
((UGraphicG2d) ug).setBufferedImage(im); ((UGraphicG2d) ug).setBufferedImage(im);
@ -82,7 +82,8 @@ public class PSystemLogo extends AbstractPSystem {
// private GraphicStrings getGraphicStrings() throws IOException { // private GraphicStrings getGraphicStrings() throws IOException {
// final UFont font = new UFont("SansSerif", Font.PLAIN, 12); // final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
// final GraphicStrings result = new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, // final GraphicStrings result = new GraphicStrings(strings, font,
// HtmlColorUtils.BLACK, HtmlColorUtils.WHITE,
// image, // image,
// GraphicPosition.BOTTOM, false); // GraphicPosition.BOTTOM, false);
// result.setMinWidth(200); // result.setMinWidth(200);

View File

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

View File

@ -91,7 +91,7 @@ public class MindMapDiagram extends UmlDiagram {
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor, final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor,
skinParam.getBackgroundColor(), fileFormatOption.isWithMetadata() ? getMetadata() : null, "", 10, 10, skinParam.getBackgroundColor(false), fileFormatOption.isWithMetadata() ? getMetadata() : null, "", 10, 10,
null, skinParam.handwritten()); null, skinParam.handwritten());
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();

View File

@ -35,6 +35,7 @@
package net.sourceforge.plantuml.nwdiag; package net.sourceforge.plantuml.nwdiag;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -45,8 +46,11 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
@ -57,10 +61,14 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -176,19 +184,38 @@ public class NwDiagram extends UmlDiagram {
final Scale scale = getScale(); final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), dpiFactor, null, "", "", 0, 0, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), dpiFactor, null, "", "", 0, 0,
null, false); null, false);
final UDrawable result = getUDrawable(); TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os);
} }
private UDrawable getUDrawable() { private TextBlockBackcolored getTextBlock() {
return new UDrawable() { return new TextBlockBackcolored() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
drawMe(ug); drawMe(ug);
} }
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return null;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getTotalDimension(stringBounder);
}
public MinMax getMinMax(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
public HColor getBackcolor() {
return null;
}
}; };
} }
@ -205,8 +232,17 @@ public class NwDiagram extends UmlDiagram {
return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false);
} }
private Dimension2D getTotalDimension(StringBounder stringBounder) {
return TextBlockUtils.getMinMax(new UDrawable() {
public void drawU(UGraphic ug) {
drawMe(ug);
}
}, stringBounder, true).getDimension();
}
private final double margin = 5;
private void drawMe(UGraphic ug) { private void drawMe(UGraphic ug) {
final double margin = 5;
ug = ug.apply(new UTranslate(margin, margin)); ug = ug.apply(new UTranslate(margin, margin));
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
@ -252,12 +288,11 @@ public class NwDiagram extends UmlDiagram {
deltaX += 5; deltaX += 5;
grid.drawU(ug.apply(ColorParam.activityBorder.getDefaultValue()) grid.drawU(ug.apply(ColorParam.activityBorder.getDefaultValue())
.apply(ColorParam.activityBackground.getDefaultValue().bg()) .apply(ColorParam.activityBackground.getDefaultValue().bg()).apply(new UTranslate(deltaX, deltaY)));
.apply(new UTranslate(deltaX, deltaY)));
final Dimension2D dimGrid = grid.calculateDimension(stringBounder); final Dimension2D dimGrid = grid.calculateDimension(stringBounder);
ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin)).draw( ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin))
new UEmpty(1, 1)); .draw(new UEmpty(1, 1));
} }

View File

@ -116,11 +116,11 @@ public class PostItDiagram extends UmlDiagram {
private UGraphic createImage(FileFormatOption fileFormatOption) { private UGraphic createImage(FileFormatOption fileFormatOption) {
final Color backColor = getSkinParam().getColorMapper() final Color backColor = getSkinParam().getColorMapper()
.getMappedColor(this.getSkinParam().getBackgroundColor()); .toColor(this.getSkinParam().getBackgroundColor(false));
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) { if (fileFormat == FileFormat.PNG) {
final double height = getDefaultArea().heightWhenWidthIs(width, fileFormatOption.getDefaultStringBounder()); final double height = getDefaultArea().heightWhenWidthIs(width, fileFormatOption.getDefaultStringBounder());
final EmptyImageBuilder builder = new EmptyImageBuilder(width, height, backColor); final EmptyImageBuilder builder = new EmptyImageBuilder(fileFormatOption.getWatermark(), width, height, backColor);
final Graphics2D graphics2D = builder.getGraphics2D(); final Graphics2D graphics2D = builder.getGraphics2D();
final double dpiFactor = this.getScaleCoef(fileFormatOption); final double dpiFactor = this.getScaleCoef(fileFormatOption);

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.CommandNope;
import net.sourceforge.plantuml.command.CommandScale; import net.sourceforge.plantuml.command.CommandScale;
import net.sourceforge.plantuml.command.UmlDiagramFactory; import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.project.command.CommandColorTask;
import net.sourceforge.plantuml.project.command.CommandGanttArrow; import net.sourceforge.plantuml.project.command.CommandGanttArrow;
import net.sourceforge.plantuml.project.command.CommandGanttArrow2; import net.sourceforge.plantuml.project.command.CommandGanttArrow2;
import net.sourceforge.plantuml.project.command.CommandPage; import net.sourceforge.plantuml.project.command.CommandPage;
@ -87,6 +88,7 @@ public class GanttDiagramFactory extends UmlDiagramFactory {
cmds.addAll(getLanguageCommands()); cmds.addAll(getLanguageCommands());
cmds.add(new CommandGanttArrow()); cmds.add(new CommandGanttArrow());
cmds.add(new CommandGanttArrow2()); cmds.add(new CommandGanttArrow2());
cmds.add(new CommandColorTask());
cmds.add(new CommandSeparator()); cmds.add(new CommandSeparator());
cmds.add(new CommandPrintScale()); cmds.add(new CommandPrintScale());

View File

@ -0,0 +1,87 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, 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.project.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.project.Failable;
import net.sourceforge.plantuml.project.GanttConstraint;
import net.sourceforge.plantuml.project.GanttDiagram;
import net.sourceforge.plantuml.project.core.Task;
import net.sourceforge.plantuml.project.core.TaskAttribute;
import net.sourceforge.plantuml.project.core.TaskInstant;
import net.sourceforge.plantuml.project.lang.Complement;
import net.sourceforge.plantuml.project.lang.ComplementColors;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class CommandColorTask extends SingleLineCommand2<GanttDiagram> {
public CommandColorTask() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandColorTask.class.getName(), RegexLeaf.start(), //
new RegexLeaf("CODE", "\\[([\\p{L}0-9_.]+)\\]"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("COLORS", "#(\\w+)(?:/(#?\\w+))?"), //
RegexLeaf.spaceZeroOrMore(), RegexLeaf.end());
}
@Override
protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) {
final String code = arg.get("CODE", 0);
final Task task = diagram.getExistingTask(code);
if (task == null) {
return CommandExecutionResult.error("No such task " + code);
}
final String color1 = arg.get("COLORS", 0);
final String color2 = arg.get("COLORS", 1);
final HColor col1 = diagram.getIHtmlColorSet().getColorIfValid(color1);
final HColor col2 = diagram.getIHtmlColorSet().getColorIfValid(color2);
task.setColors(new ComplementColors(col1, col2));
return CommandExecutionResult.ok();
}
}

View File

@ -54,7 +54,9 @@ public class CommandPrintScale extends SingleLineCommand2<GanttDiagram> {
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandPrintScale.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandPrintScale.class.getName(), RegexLeaf.start(), //
new RegexLeaf("printscale"), // new RegexOr(new RegexLeaf("projectscale"), //
new RegexLeaf("ganttscale"), //
new RegexLeaf("printscale")), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr("SCALE", // new RegexOr("SCALE", //
new RegexLeaf("monthly"), // new RegexLeaf("monthly"), //

View File

@ -92,7 +92,7 @@ public class LinkAnchor {
final double ymax = Math.max(y1, y2); final double ymax = Math.max(y1, y2);
final HColor color = new Rose().getHtmlColor(param, ColorParam.arrow); final HColor color = new Rose().getHtmlColor(param, ColorParam.arrow);
final Rainbow rainbow = Rainbow.fromColor(color); final Rainbow rainbow = Rainbow.fromColor(color, null);
final Snake snake = new Snake(Arrows.asToUp(), HorizontalAlignment.CENTER, rainbow, Arrows.asToDown()); final Snake snake = new Snake(Arrows.asToUp(), HorizontalAlignment.CENTER, rainbow, Arrows.asToDown());
final Display display = Display.getWithNewlines(message); final Display display = Display.getWithNewlines(message);

View File

@ -75,7 +75,7 @@ public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
final HColor backColorElement = diagram.getSkinParam().getIHtmlColorSet() final HColor backColorElement = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("COLORS", 0)); .getColorIfValid(arg.get("COLORS", 0));
final HColor backColorGeneral = diagram.getSkinParam().getIHtmlColorSet() final HColor backColorGeneral = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("COLORS", 1), diagram.getSkinParam().getBackgroundColor()); .getColorIfValid(arg.get("COLORS", 1), diagram.getSkinParam().getBackgroundColor(true));
String comment = arg.get("COMMENT", 0); String comment = arg.get("COMMENT", 0);
final GroupingType groupingType = GroupingType.getType(type); final GroupingType groupingType = GroupingType.getType(type);
if ("group".equals(type)) { if ("group".equals(type)) {

View File

@ -70,7 +70,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
if (SkinParam.USE_STYLES()) { if (SkinParam.USE_STYLES()) {
if (spriteContainer instanceof SkinParamBackcolored) { if (spriteContainer instanceof SkinParamBackcolored) {
style = style.eventuallyOverride(PName.BackGroundColor, style = style.eventuallyOverride(PName.BackGroundColor,
((SkinParamBackcolored) spriteContainer).getBackgroundColor()); ((SkinParamBackcolored) spriteContainer).getBackgroundColor(false));
} }
this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet());
this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());

View File

@ -243,14 +243,14 @@ public class Rose {
smallFont = smallFont.changeColor(smallColor); smallFont = smallFont.changeColor(smallColor);
} }
return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1], return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1],
param.getBackgroundColor(), getSymbolContext(stereotype, param, ColorParam.sequenceGroupBorder), param.getBackgroundColor(true), getSymbolContext(stereotype, param, ColorParam.sequenceGroupBorder),
bigFont, smallFont, stringsToDisplay, param, roundCorner); bigFont, smallFont, stringsToDisplay, param, roundCorner);
} }
if (type == ComponentType.GROUPING_ELSE) { if (type == ComponentType.GROUPING_ELSE) {
return new ComponentRoseGroupingElse(styles == null ? null : styles[0], return new ComponentRoseGroupingElse(styles == null ? null : styles[0],
getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder), getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder),
getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param, getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param,
param.getBackgroundColor()); param.getBackgroundColor(true));
} }
if (type == ComponentType.GROUPING_SPACE) { if (type == ComponentType.GROUPING_SPACE) {
return new ComponentRoseGroupingSpace(7); return new ComponentRoseGroupingSpace(7);

View File

@ -61,6 +61,9 @@ public class StatsUtilsIncrement {
final private static FormatCounter formatCounterEver = StatsUtils.formatCounterEver; final private static FormatCounter formatCounterEver = StatsUtils.formatCounterEver;
public static void onceMoreParse(long duration, Class<? extends Diagram> type) { public static void onceMoreParse(long duration, Class<? extends Diagram> type) {
if (StatsUtils.fullEver == null || StatsUtils.historicalData == null) {
return;
}
getByTypeCurrent(type).parsed().addValue(duration); getByTypeCurrent(type).parsed().addValue(duration);
final ParsedGenerated byTypeEver = getByTypeEver(type); final ParsedGenerated byTypeEver = getByTypeEver(type);
byTypeEver.parsed().addValue(duration); byTypeEver.parsed().addValue(duration);
@ -74,6 +77,12 @@ public class StatsUtilsIncrement {
} }
public static void onceMoreGenerate(long duration, Class<? extends Diagram> type, FileFormat fileFormat) { public static void onceMoreGenerate(long duration, Class<? extends Diagram> type, FileFormat fileFormat) {
if (StatsUtils.fullEver == null || StatsUtils.historicalData == null) {
return;
}
if (formatCounterCurrent == null || formatCounterEver == null) {
return;
}
getByTypeCurrent(type).generated().addValue(duration); getByTypeCurrent(type).generated().addValue(duration);
final ParsedGenerated byTypeEver = getByTypeEver(type); final ParsedGenerated byTypeEver = getByTypeEver(type);
byTypeEver.generated().addValue(duration); byTypeEver.generated().addValue(duration);

View File

@ -102,7 +102,7 @@ public class GraphicsSudoku {
} }
public ImageData writeImagePng(OutputStream os) throws IOException { public ImageData writeImagePng(OutputStream os) throws IOException {
final EmptyImageBuilder builder = new EmptyImageBuilder(sudoWidth, sudoHeight + textTotalHeight, Color.WHITE); final EmptyImageBuilder builder = new EmptyImageBuilder(null, sudoWidth, sudoHeight + textTotalHeight, Color.WHITE);
final BufferedImage im = builder.getBufferedImage(); final BufferedImage im = builder.getBufferedImage();
final Graphics2D g3d = builder.getGraphics2D(); final Graphics2D g3d = builder.getGraphics2D();

View File

@ -56,7 +56,6 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityPosition;
@ -90,6 +89,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.utils.UniqueSequence; import net.sourceforge.plantuml.utils.UniqueSequence;
public class Cluster implements Moveable { public class Cluster implements Moveable {
@ -757,7 +757,7 @@ public class Cluster implements Moveable {
} }
sb.append("subgraph " + getClusterId() + " {"); sb.append("subgraph " + getClusterId() + " {");
sb.append("style=solid;"); sb.append("style=solid;");
sb.append("color=\"" + StringUtils.getAsHtml(color) + "\";"); sb.append("color=\"" + DotStringFactory.sharp000000(color) + "\";");
final String label; final String label;
if (isLabel()) { if (isLabel()) {
@ -889,8 +889,8 @@ public class Cluster implements Moveable {
if (backColor == null) { if (backColor == null) {
backColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); backColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
} }
if (backColor == null /* || stateBack instanceof HtmlColorTransparent */) { if (backColor == null || backColor.equals(HColorUtils.transparent()) /* || stateBack instanceof HtmlColorTransparent */) {
backColor = new HColorBackground(skinParam.getBackgroundColor()); backColor = new HColorBackground(skinParam.getBackgroundColor(true));
} }
return backColor; return backColor;
} }
@ -900,8 +900,8 @@ public class Cluster implements Moveable {
if (backColor == null) { if (backColor == null) {
backColor = skinParam.getHtmlColor(ColorParam.background, stereotype, false); backColor = skinParam.getHtmlColor(ColorParam.background, stereotype, false);
} }
if (backColor == null /* || stateBack instanceof HtmlColorTransparent */) { if (backColor == null || backColor.equals(HColorUtils.transparent()) /* || stateBack instanceof HtmlColorTransparent */) {
backColor = new HColorBackground(skinParam.getBackgroundColor()); backColor = new HColorBackground(skinParam.getBackgroundColor(true));
} }
return backColor; return backColor;
} }

View File

@ -109,7 +109,7 @@ public final class ConcurrentStateImage extends AbstractTextBlock implements IEn
HColor backColor) { HColor backColor) {
this.separator = Separator.fromChar(concurrentSeparator); this.separator = Separator.fromChar(concurrentSeparator);
this.skinParam = skinParam; this.skinParam = skinParam;
this.backColor = skinParam.getBackgroundColor(); this.backColor = skinParam.getBackgroundColor(false);
this.inners.addAll(images); this.inners.addAll(images);
} }

View File

@ -139,7 +139,7 @@ public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBl
} }
public HColor getBackcolor() { public HColor getBackcolor() {
return skinParam.getBackgroundColor(); return skinParam.getBackgroundColor(false);
} }
public double getOverscanX(StringBounder stringBounder) { public double getOverscanX(StringBounder stringBounder) {

View File

@ -454,7 +454,7 @@ public class DotStringFactory implements Moveable {
} }
private int getClusterIndex(final String svg, int colorInt) { private int getClusterIndex(final String svg, int colorInt) {
final String colorString = StringUtils.goLowerCase(StringUtils.getAsHtml(colorInt)); final String colorString = StringUtils.goLowerCase(DotStringFactory.sharp000000(colorInt));
final String keyTitle1 = "=\"" + colorString + "\""; final String keyTitle1 = "=\"" + colorString + "\"";
int idx = svg.indexOf(keyTitle1); int idx = svg.indexOf(keyTitle1);
if (idx == -1) { if (idx == -1) {
@ -467,6 +467,20 @@ public class DotStringFactory implements Moveable {
return idx; return idx;
} }
public static String sharp000000(int color) {
final int v = 0xFFFFFF & color;
String s = "000000" + Integer.toHexString(v).toUpperCase();
s = s.substring(s.length() - 6);
return "#" + s;
}
public static String sharpAlpha(int color) {
final int v = color;
String s = "00000000" + Integer.toHexString(v).toUpperCase();
s = s.substring(s.length() - 8);
return "#" + s;
}
public void openCluster(int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title, TextBlock stereo, public void openCluster(int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title, TextBlock stereo,
IGroup g) { IGroup g) {
this.current = current.createChild(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo, this.current = current.createChild(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo,

View File

@ -51,7 +51,6 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.Pragma; import net.sourceforge.plantuml.Pragma;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.command.Position;
@ -246,7 +245,7 @@ public class Line implements Moveable, Hideable {
skinParam = link.getColors().mute(skinParam); skinParam = link.getColors().mute(skinParam);
labelFont = labelFont.mute(link.getColors()); labelFont = labelFont.mute(link.getColors());
} }
this.backgroundColor = skinParam.getBackgroundColor(); this.backgroundColor = skinParam.getBackgroundColor(false);
this.defaultThickness = skinParam.getThickness(LineParam.arrow, null); this.defaultThickness = skinParam.getThickness(LineParam.arrow, null);
this.arrowLollipopColor = skinParam.getHtmlColor(ColorParam.arrowLollipop, null, false); this.arrowLollipopColor = skinParam.getHtmlColor(ColorParam.arrowLollipop, null, false);
if (arrowLollipopColor == null) { if (arrowLollipopColor == null) {
@ -405,7 +404,7 @@ public class Line implements Moveable, Hideable {
sb.append("minlen=" + (length - 1)); sb.append("minlen=" + (length - 1));
sb.append(","); sb.append(",");
} }
sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\""); sb.append("color=\"" + DotStringFactory.sharp000000(lineColor) + "\"");
if (labelText != null || link.getLinkConstraint() != null) { if (labelText != null || link.getLinkConstraint() != null) {
sb.append(","); sb.append(",");
if (graphvizVersion.useXLabelInsteadOfLabel() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL) { if (graphvizVersion.useXLabelInsteadOfLabel() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
@ -475,7 +474,7 @@ public class Line implements Moveable, Hideable {
public static void appendTable(StringBuilder sb, int w, int h, int col) { public static void appendTable(StringBuilder sb, int w, int h, int col) {
sb.append("<TABLE "); sb.append("<TABLE ");
sb.append("BGCOLOR=\"" + StringUtils.getAsHtml(col) + "\" "); sb.append("BGCOLOR=\"" + DotStringFactory.sharp000000(col) + "\" ");
sb.append("FIXEDSIZE=\"TRUE\" WIDTH=\"" + w + "\" HEIGHT=\"" + h + "\">"); sb.append("FIXEDSIZE=\"TRUE\" WIDTH=\"" + w + "\" HEIGHT=\"" + h + "\">");
sb.append("<TR"); sb.append("<TR");
sb.append(">"); sb.append(">");

View File

@ -42,7 +42,6 @@ import java.util.Map;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -155,7 +154,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
sb.append(","); sb.append(",");
sb.append("height=" + SvekUtils.pixelToInches(getHeight())); sb.append("height=" + SvekUtils.pixelToInches(getHeight()));
sb.append(","); sb.append(",");
sb.append("color=\"" + StringUtils.getAsHtml(color) + "\""); sb.append("color=\"" + DotStringFactory.sharp000000(color) + "\"");
sb.append("];"); sb.append("];");
SvekUtils.println(sb); SvekUtils.println(sb);
} }
@ -182,7 +181,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
sb.append("</TR>"); sb.append("</TR>");
sb.append("<TR>"); sb.append("<TR>");
appendTd(sb, shield.getX1(), 1); appendTd(sb, shield.getX1(), 1);
sb.append("<TD BGCOLOR=\"" + StringUtils.getAsHtml(color) + "\""); sb.append("<TD BGCOLOR=\"" + DotStringFactory.sharp000000(color) + "\"");
sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + getWidth() + "\" HEIGHT=\"" + getHeight() + "\""); sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + getWidth() + "\" HEIGHT=\"" + getHeight() + "\"");
sb.append(" PORT=\"h\">"); sb.append(" PORT=\"h\">");
sb.append("</TD>"); sb.append("</TD>");
@ -204,7 +203,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
sb.append("shape=plaintext,"); sb.append("shape=plaintext,");
// sb.append("color=\"" + StringUtils.getAsHtml(color) + "\","); // sb.append("color=\"" + StringUtils.getAsHtml(color) + "\",");
sb.append("label=<"); sb.append("label=<");
sb.append("<TABLE BGCOLOR=\"" + StringUtils.getAsHtml(color) sb.append("<TABLE BGCOLOR=\"" + DotStringFactory.sharp000000(color)
+ "\" BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">"); + "\" BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">");
double position = 0; double position = 0;
for (Map.Entry<String, PortGeometry> ent : ports.getAllWithEncodedPortId().entrySet()) { for (Map.Entry<String, PortGeometry> ent : ports.getAllWithEncodedPortId().entrySet()) {

View File

@ -137,7 +137,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage,
} }
public HColor getBackcolor() { public HColor getBackcolor() {
return dotData.getSkinParam().getBackgroundColor(); return dotData.getSkinParam().getBackgroundColor(false);
} }
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {

View File

@ -73,17 +73,17 @@ public class SvgResult {
} }
public int getIndexFromColor(int color) { public int getIndexFromColor(int color) {
String s = "stroke=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\""; String s = "stroke=\"" + StringUtils.goLowerCase(DotStringFactory.sharp000000(color)) + "\"";
int idx = svg.indexOf(s); int idx = svg.indexOf(s);
if (idx != -1) { if (idx != -1) {
return idx; return idx;
} }
s = ";stroke:" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + ";"; s = ";stroke:" + StringUtils.goLowerCase(DotStringFactory.sharp000000(color)) + ";";
idx = svg.indexOf(s); idx = svg.indexOf(s);
if (idx != -1) { if (idx != -1) {
return idx; return idx;
} }
s = "fill=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\""; s = "fill=\"" + StringUtils.goLowerCase(DotStringFactory.sharp000000(color)) + "\"";
idx = svg.indexOf(s); idx = svg.indexOf(s);
if (idx != -1) { if (idx != -1) {
return idx; return idx;

View File

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

View File

@ -44,20 +44,25 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame;
public abstract class Player implements TimeProjected { public abstract class Player implements TimeProjected {
protected final ISkinParam skinParam; protected final ISkinParam skinParam;
protected final TimingRuler ruler; protected final TimingRuler ruler;
private final boolean compact;
private final Display title; private final Display title;
public Player(String title, ISkinParam skinParam, TimingRuler ruler) { public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact) {
this.skinParam = skinParam; this.skinParam = skinParam;
this.compact = compact;
this.ruler = ruler; this.ruler = ruler;
this.title = Display.getWithNewlines(title); this.title = Display.getWithNewlines(title);
} }
public boolean isCompact() {
return compact;
}
final protected FontConfiguration getFontConfiguration() { final protected FontConfiguration getFontConfiguration() {
return new FontConfiguration(skinParam, FontParam.TIMING, null); return new FontConfiguration(skinParam, FontParam.TIMING, null);
} }
@ -74,12 +79,12 @@ public abstract class Player implements TimeProjected {
public abstract void createConstraint(TimeTick tick1, TimeTick tick2, String message); public abstract void createConstraint(TimeTick tick1, TimeTick tick2, String message);
public abstract PlayerFrame getPlayerFrame(); public abstract TextBlock getPart1(double fullAvailableWidth, double specialVSpace);
public abstract TextBlock getPart1();
public abstract UDrawable getPart2(); public abstract UDrawable getPart2();
public abstract double getFullHeight(StringBounder stringBounder); public abstract double getFullHeight(StringBounder stringBounder);
// public abstract void drawFrameTitle(UGraphic ug);
} }

View File

@ -35,6 +35,7 @@
package net.sourceforge.plantuml.timingdiagram; package net.sourceforge.plantuml.timingdiagram;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
@ -50,8 +51,6 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint; import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrameEmpty;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -62,21 +61,26 @@ public class PlayerBinary extends Player {
private static final int HEIGHT = 30; private static final int HEIGHT = 30;
private final SortedMap<TimeTick, Boolean> values = new TreeMap<TimeTick, Boolean>(); private final SortedMap<TimeTick, Boolean> values = new TreeMap<TimeTick, Boolean>();
private Boolean initialState;
public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler) { public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact) {
super(code, skinParam, ruler); super(code, skinParam, ruler, compact);
} }
public double getFullHeight(StringBounder stringBounder) { public double getFullHeight(StringBounder stringBounder) {
return HEIGHT; return HEIGHT;
} }
public void drawFrameTitle(UGraphic ug) {
}
private SymbolContext getContext() { private SymbolContext getContext() {
return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5)); return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5));
} }
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
throw new UnsupportedOperationException(); final double x = ruler.getPosInPixel(tick);
return new IntricatedPoint(new Point2D.Double(x, getYpos(false)), new Point2D.Double(x, getYpos(true)));
} }
public void addNote(TimeTick now, Display note, Position position) { public void addNote(TimeTick now, Display note, Position position) {
@ -89,7 +93,11 @@ public class PlayerBinary extends Player {
public void setState(TimeTick now, String comment, Colors color, String... states) { public void setState(TimeTick now, String comment, Colors color, String... states) {
final boolean state = getState(states[0]); final boolean state = getState(states[0]);
this.values.put(now, state); if (now == null) {
this.initialState = state;
} else {
this.values.put(now, state);
}
} }
private boolean getState(String value) { private boolean getState(String value) {
@ -102,15 +110,11 @@ public class PlayerBinary extends Player {
private final double ymargin = 8; private final double ymargin = 8;
public PlayerFrame getPlayerFrame() {
return new PlayerFrameEmpty();
}
private double getYpos(boolean state) { private double getYpos(boolean state) {
return state ? ymargin : HEIGHT - ymargin; return state ? ymargin : HEIGHT - ymargin;
} }
public TextBlock getPart1() { public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
return new AbstractTextBlock() { return new AbstractTextBlock() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
@ -133,7 +137,7 @@ public class PlayerBinary extends Player {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
ug = getContext().apply(ug); ug = getContext().apply(ug);
double lastx = 0; double lastx = 0;
boolean lastValue = false; boolean lastValue = initialState == null ? false : initialState;
for (Map.Entry<TimeTick, Boolean> ent : values.entrySet()) { for (Map.Entry<TimeTick, Boolean> ent : values.entrySet()) {
final double x = ruler.getPosInPixel(ent.getKey()); final double x = ruler.getPosInPixel(ent.getKey());
ug.apply(new UTranslate(lastx, getYpos(lastValue))).draw(ULine.hline(x - lastx)); ug.apply(new UTranslate(lastx, getYpos(lastValue))).draw(ULine.hline(x - lastx));

View File

@ -46,8 +46,6 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint; import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrameEmpty;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -58,9 +56,10 @@ public class PlayerClock extends Player {
private final int period; private final int period;
private final int pulse; private final int pulse;
private final double ymargin = 8;
public PlayerClock(ISkinParam skinParam, TimingRuler ruler, int period, int pulse) { public PlayerClock(ISkinParam skinParam, TimingRuler ruler, int period, int pulse, boolean compact) {
super("", skinParam, ruler); super("", skinParam, ruler, compact);
this.period = period; this.period = period;
this.pulse = pulse; this.pulse = pulse;
} }
@ -69,6 +68,9 @@ public class PlayerClock extends Player {
return 30; return 30;
} }
public void drawFrameTitle(UGraphic ug) {
}
private SymbolContext getContext() { private SymbolContext getContext() {
return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5)); return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5));
} }
@ -93,12 +95,6 @@ public class PlayerClock extends Player {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
private final double ymargin = 8;
public PlayerFrame getPlayerFrame() {
return new PlayerFrameEmpty();
}
private double getPulseCoef() { private double getPulseCoef() {
if (pulse == 0) { if (pulse == 0) {
return 0.5; return 0.5;
@ -110,7 +106,7 @@ public class PlayerClock extends Player {
return period; return period;
} }
public TextBlock getPart1() { public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
return TextBlockUtils.empty(0, 0); return TextBlockUtils.empty(0, 0);
} }

View File

@ -52,9 +52,8 @@ import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.timingdiagram.graphic.Histogram; import net.sourceforge.plantuml.timingdiagram.graphic.Histogram;
import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint; import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerDrawing; import net.sourceforge.plantuml.timingdiagram.graphic.PDrawing;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame; import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame;
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame2;
import net.sourceforge.plantuml.timingdiagram.graphic.Ribbon; import net.sourceforge.plantuml.timingdiagram.graphic.Ribbon;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -68,38 +67,38 @@ public final class PlayerRobustConcise extends Player {
private final TimingStyle type; private final TimingStyle type;
private String initialState; private String initialState;
private PlayerDrawing cached; private PDrawing cached;
private Colors initialColors; private Colors initialColors;
public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler) { public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler,
super(full, skinParam, ruler); boolean compact) {
super(full, skinParam, ruler, compact);
this.type = type; this.type = type;
} }
private PlayerDrawing buildPlayerDrawing() { private PDrawing buildPDrawing() {
if (type == TimingStyle.CONCISE) { if (type == TimingStyle.CONCISE) {
return new Ribbon(ruler, skinParam, notes); return new Ribbon(ruler, skinParam, notes, isCompact(), getTitle());
} }
if (type == TimingStyle.ROBUST) { if (type == TimingStyle.ROBUST) {
return new Histogram(ruler, skinParam, statesLabel.values()); return new Histogram(ruler, skinParam, statesLabel.values(), isCompact(), getTitle());
} }
throw new IllegalStateException(); throw new IllegalStateException();
} }
public final PlayerFrame getPlayerFrame() { public final TextBlock getPart1(final double fullAvailableWidth, final double specialVSpace) {
return new PlayerFrame2(getTitle());
}
public final TextBlock getPart1() {
return new AbstractTextBlock() { return new AbstractTextBlock() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())); if (isCompact() == false) {
getTimeDrawing().getPart1().drawU(ug); new PlayerFrame(getTitle()).drawFrameTitle(ug);
}
ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())).apply(UTranslate.dy(specialVSpace));
getTimeDrawing().getPart1(fullAvailableWidth).drawU(ug);
} }
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {
return getTimeDrawing().getPart1().calculateDimension(stringBounder); return getTimeDrawing().getPart1(fullAvailableWidth).calculateDimension(stringBounder);
} }
}; };
} }
@ -122,18 +121,21 @@ public final class PlayerRobustConcise extends Player {
} }
private double getTitleHeight(StringBounder stringBounder) { private double getTitleHeight(StringBounder stringBounder) {
if (isCompact()) {
return 6;
}
return getTitle().calculateDimension(stringBounder).getHeight() + 6; return getTitle().calculateDimension(stringBounder).getHeight() + 6;
} }
private PlayerDrawing getTimeDrawing() { private PDrawing getTimeDrawing() {
if (cached == null) { if (cached == null) {
cached = computeTimeDrawing(); cached = computeTimeDrawing();
} }
return cached; return cached;
} }
private PlayerDrawing computeTimeDrawing() { private PDrawing computeTimeDrawing() {
final PlayerDrawing result = buildPlayerDrawing(); final PDrawing result = buildPDrawing();
result.setInitialState(initialState, initialColors); result.setInitialState(initialState, initialColors);
for (ChangeState change : changes) { for (ChangeState change : changes) {
result.addChange(change); result.addChange(change);

View File

@ -85,6 +85,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
private TimeTick now; private TimeTick now;
private Player lastPlayer; private Player lastPlayer;
private boolean drawTimeAxis = true; private boolean drawTimeAxis = true;
private boolean compactByDefault = false;
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
return new DiagramDescription("(Timing Diagram)"); return new DiagramDescription("(Timing Diagram)");
@ -142,22 +143,36 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
private void drawInternal(UGraphic ug) { private void drawInternal(UGraphic ug) {
ruler.ensureNotEmpty(); ruler.ensureNotEmpty();
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
final UTranslate beforeRuler = UTranslate.dx(getPart1MaxWidth(stringBounder)); final double part1MaxWidth = getPart1MaxWidth(stringBounder);
drawBorder(ug); final UTranslate widthPart1 = UTranslate.dx(part1MaxWidth);
if (compactByDefault == false) {
drawBorder(ug);
}
ug = ug.apply(UTranslate.dx(marginX1)); ug = ug.apply(UTranslate.dx(marginX1));
drawHighlightsBack(ug.apply(beforeRuler)); drawHighlightsBack(ug.apply(widthPart1));
ruler.draw0(ug.apply(beforeRuler), getHeightInner(stringBounder)); ruler.draw0(ug.apply(widthPart1), getHeightInner(stringBounder));
boolean first = true;
for (Player player : players.values()) { for (Player player : players.values()) {
drawHorizontalSeparator(ug.apply(getUTranslateForFrame(player, stringBounder))); final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder));
player.getPlayerFrame().drawFrameTitle(ug.apply(getUTranslateForFrame(player, stringBounder))); final double caption = getHeightForCaptions(stringBounder);
final UGraphic ug2 = ug.apply(getUTranslateForPlayer(player, stringBounder)); if (first) {
player.getPart2().drawU(ug2.apply(beforeRuler)); if (player.isCompact() == false) {
player.getPart1().drawU(ug2); drawHorizontalSeparator(ugPlayer);
}
player.getPart1(part1MaxWidth, caption).drawU(ugPlayer);
player.getPart2().drawU(ugPlayer.apply(widthPart1).apply(UTranslate.dy(caption)));
} else {
if (player.isCompact() == false) {
drawHorizontalSeparator(ugPlayer.apply(UTranslate.dy(caption)));
}
player.getPart1(part1MaxWidth, 0).drawU(ugPlayer.apply(UTranslate.dy(caption)));
player.getPart2().drawU(ugPlayer.apply(widthPart1).apply(UTranslate.dy(caption)));
}
first = false;
} }
ug = ug.apply(beforeRuler); ug = ug.apply(widthPart1);
if (this.drawTimeAxis) { if (this.drawTimeAxis) {
ruler.drawTimeAxis(ug.apply(getLastTranslate(stringBounder))); ruler.drawTimeAxis(ug.apply(getLastTranslate(stringBounder)));
} }
@ -188,7 +203,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
} }
private UTranslate getLastTranslate(final StringBounder stringBounder) { private UTranslate getLastTranslate(final StringBounder stringBounder) {
return getUTranslateForPlayer(null, stringBounder); return getUTranslateForPlayer(null, stringBounder).compose(UTranslate.dy(getHeightForCaptions(stringBounder)));
} }
private void drawHighlightsBack(UGraphic ug) { private void drawHighlightsBack(UGraphic ug) {
@ -215,7 +230,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
return getLastTranslate(stringBounder).getDy(); return getLastTranslate(stringBounder).getDy();
} }
private double getHeightHighlights(StringBounder stringBounder) { private double getHeightForCaptions(StringBounder stringBounder) {
double result = 0; double result = 0;
for (Highlight highlight : highlights) { for (Highlight highlight : highlights) {
final TextBlock caption = highlight.getCaption(getSkinParam()); final TextBlock caption = highlight.getCaption(getSkinParam());
@ -231,7 +246,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
private double getPart1MaxWidth(StringBounder stringBounder) { private double getPart1MaxWidth(StringBounder stringBounder) {
double width = 0; double width = 0;
for (Player player : players.values()) { for (Player player : players.values()) {
width = Math.max(width, player.getPart1().calculateDimension(stringBounder).getWidth()); width = Math.max(width, player.getPart1(0, 0).calculateDimension(stringBounder).getWidth());
} }
return width; return width;
@ -241,11 +256,14 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
final Player player1 = message.getPlayer1(); final Player player1 = message.getPlayer1();
final Player player2 = message.getPlayer2(); final Player player2 = message.getPlayer2();
final UTranslate translate1 = getUTranslateForPlayer(player1, ug.getStringBounder()); final StringBounder stringBounder = ug.getStringBounder();
final UTranslate translate2 = getUTranslateForPlayer(player2, ug.getStringBounder()); final UTranslate translate1 = getUTranslateForPlayer(player1, stringBounder)
.compose(UTranslate.dy(getHeightForCaptions(stringBounder)));
final UTranslate translate2 = getUTranslateForPlayer(player2, stringBounder)
.compose(UTranslate.dy(getHeightForCaptions(stringBounder)));
final IntricatedPoint pt1 = player1.getTimeProjection(ug.getStringBounder(), message.getTick1()); final IntricatedPoint pt1 = player1.getTimeProjection(stringBounder, message.getTick1());
final IntricatedPoint pt2 = player2.getTimeProjection(ug.getStringBounder(), message.getTick2()); final IntricatedPoint pt2 = player2.getTimeProjection(stringBounder, message.getTick2());
if (pt1 == null || pt2 == null) { if (pt1 == null || pt2 == null) {
return; return;
@ -257,15 +275,15 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
} }
private UTranslate getUTranslateForFrame(Player candidat, StringBounder stringBounder) { private UTranslate getUTranslateForPlayer(Player candidat, StringBounder stringBounder) {
double y = 0; double y = 0;
for (Player player : players.values()) { for (Player player : players.values()) {
if (candidat == player) { if (candidat == player) {
return UTranslate.dy(y); return UTranslate.dy(y);
} }
if (y == 0) { // if (y == 0) {
y += getHeightHighlights(stringBounder); // y += getHeightHighlights(stringBounder);
} // }
y += player.getFullHeight(stringBounder); y += player.getFullHeight(stringBounder);
} }
if (candidat == null) { if (candidat == null) {
@ -274,29 +292,15 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
public UTranslate getUTranslateForPlayer(Player candidat, StringBounder stringBounder) { public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type, boolean compact) {
double y = getHeightHighlights(stringBounder); final Player player = new PlayerRobustConcise(type, full, getSkinParam(), ruler, compactByDefault || compact);
for (Player player : players.values()) {
if (candidat == player) {
return UTranslate.dy(y);
}
y += player.getFullHeight(stringBounder);
}
if (candidat == null) {
return UTranslate.dy(y);
}
throw new IllegalArgumentException();
}
public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type) {
final Player player = new PlayerRobustConcise(type, full, getSkinParam(), ruler);
players.put(code, player); players.put(code, player);
lastPlayer = player; lastPlayer = player;
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
public CommandExecutionResult createClock(String code, String full, int period, int pulse) { public CommandExecutionResult createClock(String code, String full, int period, int pulse, boolean compact) {
final PlayerClock player = new PlayerClock(getSkinParam(), ruler, period, pulse); final PlayerClock player = new PlayerClock(getSkinParam(), ruler, period, pulse, compactByDefault);
players.put(code, player); players.put(code, player);
clocks.put(code, player); clocks.put(code, player);
final TimeTick tick = new TimeTick(new BigDecimal(period), TimingFormat.DECIMAL); final TimeTick tick = new TimeTick(new BigDecimal(period), TimingFormat.DECIMAL);
@ -304,8 +308,8 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
public CommandExecutionResult createBinary(String code, String full) { public CommandExecutionResult createBinary(String code, String full, boolean compact) {
final Player player = new PlayerBinary(code, getSkinParam(), ruler); final Player player = new PlayerBinary(full, getSkinParam(), ruler, compactByDefault);
players.put(code, player); players.put(code, player);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
@ -372,4 +376,8 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
} }
public void goCompactMode() {
this.compactByDefault = true;
}
} }

View File

@ -52,6 +52,7 @@ import net.sourceforge.plantuml.timingdiagram.command.CommandDefineStateLong;
import net.sourceforge.plantuml.timingdiagram.command.CommandDefineStateShort; import net.sourceforge.plantuml.timingdiagram.command.CommandDefineStateShort;
import net.sourceforge.plantuml.timingdiagram.command.CommandHideTimeAxis; import net.sourceforge.plantuml.timingdiagram.command.CommandHideTimeAxis;
import net.sourceforge.plantuml.timingdiagram.command.CommandHighlight; import net.sourceforge.plantuml.timingdiagram.command.CommandHighlight;
import net.sourceforge.plantuml.timingdiagram.command.CommandModeCompact;
import net.sourceforge.plantuml.timingdiagram.command.CommandNote; import net.sourceforge.plantuml.timingdiagram.command.CommandNote;
import net.sourceforge.plantuml.timingdiagram.command.CommandNoteLong; import net.sourceforge.plantuml.timingdiagram.command.CommandNoteLong;
import net.sourceforge.plantuml.timingdiagram.command.CommandRobustConcise; import net.sourceforge.plantuml.timingdiagram.command.CommandRobustConcise;
@ -88,6 +89,7 @@ public class TimingDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandScalePixel()); cmds.add(new CommandScalePixel());
cmds.add(new CommandHideTimeAxis()); cmds.add(new CommandHideTimeAxis());
cmds.add(new CommandHighlight()); cmds.add(new CommandHighlight());
cmds.add(new CommandModeCompact());
return cmds; return cmds;
} }

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.timingdiagram.TimingDiagram; import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
@ -52,6 +53,10 @@ public class CommandBinary extends SingleLineCommand2<TimingDiagram> {
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandBinary.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandBinary.class.getName(), RegexLeaf.start(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("COMPACT", "(compact)"), //
RegexLeaf.spaceOneOrMore())), //
new RegexLeaf("binary"), // new RegexLeaf("binary"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
@ -63,9 +68,10 @@ public class CommandBinary extends SingleLineCommand2<TimingDiagram> {
@Override @Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) {
final String compact = arg.get("COMPACT", 0);
final String code = arg.get("CODE", 0); final String code = arg.get("CODE", 0);
final String full = arg.get("FULL", 0); final String full = arg.get("FULL", 0);
return diagram.createBinary(code, full); return diagram.createBinary(code, full, compact != null);
} }
} }

View File

@ -53,6 +53,10 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandClock.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandClock.class.getName(), RegexLeaf.start(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("COMPACT", "(compact)"), //
RegexLeaf.spaceOneOrMore())), //
new RegexLeaf("TYPE", "clock"), // new RegexLeaf("TYPE", "clock"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), // new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
@ -63,15 +67,16 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("PERIOD", "([0-9]+)"), // new RegexLeaf("PERIOD", "([0-9]+)"), //
new RegexOptional(new RegexConcat( // new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(),// RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("pulse"), // new RegexLeaf("pulse"), //
RegexLeaf.spaceOneOrMore(),// RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("PULSE", "([0-9]+)") // new RegexLeaf("PULSE", "([0-9]+)") //
)), RegexLeaf.end()); )), RegexLeaf.end());
} }
@Override @Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) {
final String compact = arg.get("COMPACT", 0);
final String code = arg.get("CODE", 0); final String code = arg.get("CODE", 0);
final int period = Integer.parseInt(arg.get("PERIOD", 0)); final int period = Integer.parseInt(arg.get("PERIOD", 0));
final String pulseString = arg.get("PULSE", 0); final String pulseString = arg.get("PULSE", 0);
@ -79,7 +84,7 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
if (pulseString != null) { if (pulseString != null) {
pulse = Integer.parseInt(pulseString); pulse = Integer.parseInt(pulseString);
} }
return diagram.createClock(code, code, period, pulse); return diagram.createClock(code, code, period, pulse, compact != null);
} }
} }

View File

@ -0,0 +1,67 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, 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.timingdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
public class CommandModeCompact extends SingleLineCommand2<TimingDiagram> {
public CommandModeCompact() {
super(getRegexConcat());
}
private static IRegex getRegexConcat() {
return RegexConcat.build(CommandModeCompact.class.getName(), RegexLeaf.start(), //
new RegexLeaf("mode"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("compact"), //
RegexLeaf.end());
}
@Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) {
diagram.goCompactMode();
return CommandExecutionResult.ok();
}
}

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.timingdiagram.TimingDiagram; import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
import net.sourceforge.plantuml.timingdiagram.TimingStyle; import net.sourceforge.plantuml.timingdiagram.TimingStyle;
@ -53,6 +54,10 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandRobustConcise.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandRobustConcise.class.getName(), RegexLeaf.start(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("COMPACT", "(compact)"), //
RegexLeaf.spaceOneOrMore())), //
new RegexLeaf("TYPE", "(robust|concise)"), // new RegexLeaf("TYPE", "(robust|concise)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
@ -64,10 +69,11 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
@Override @Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) {
final String compact = arg.get("COMPACT", 0);
final String code = arg.get("CODE", 0); final String code = arg.get("CODE", 0);
final String full = arg.get("FULL", 0); final String full = arg.get("FULL", 0);
final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase()); final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase());
return diagram.createRobustConcise(code, full, type); return diagram.createRobustConcise(code, full, type, compact != null);
} }
} }

View File

@ -65,7 +65,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class Histogram implements PlayerDrawing { public class Histogram implements PDrawing {
private final List<ChangeState> changes = new ArrayList<ChangeState>(); private final List<ChangeState> changes = new ArrayList<ChangeState>();
private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>(); private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
@ -75,12 +75,17 @@ public class Histogram implements PlayerDrawing {
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final TimingRuler ruler; private final TimingRuler ruler;
private final boolean compact;
private String initialState; private String initialState;
private final TextBlock title;
public Histogram(TimingRuler ruler, ISkinParam skinParam, Collection<String> someStates) { public Histogram(TimingRuler ruler, ISkinParam skinParam, Collection<String> someStates, boolean compact,
TextBlock title) {
this.ruler = ruler; this.ruler = ruler;
this.skinParam = skinParam; this.skinParam = skinParam;
this.allStates = new ArrayList<String>(someStates); this.allStates = new ArrayList<String>(someStates);
this.compact = compact;
this.title = title;
Collections.reverse(allStates); Collections.reverse(allStates);
} }
@ -179,10 +184,10 @@ public class Histogram implements PlayerDrawing {
return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5)); return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5));
} }
public TextBlock getPart1() { public TextBlock getPart1(final double fullAvailableWidth) {
return new AbstractTextBlock() { return new AbstractTextBlock() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
drawPart1(ug); drawPart1(ug, fullAvailableWidth);
} }
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {
@ -209,18 +214,45 @@ public class Histogram implements PlayerDrawing {
if (initialState != null) { if (initialState != null) {
width += getInitialWidth(); width += getInitialWidth();
} }
if (compact) {
width += title.calculateDimension(stringBounder).getWidth() + 15;
}
return new Dimension2DDouble(width, getFullHeight(stringBounder)); return new Dimension2DDouble(width, getFullHeight(stringBounder));
} }
private void drawPart1(UGraphic ug) { private void drawPart1(UGraphic ug, double fullAvailableWidth) {
ug = ug.apply(UTranslate.dy(getHeightForConstraints(ug.getStringBounder()))); final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(UTranslate.dy(getHeightForConstraints(stringBounder)));
if (compact) {
final double titleHeight = title.calculateDimension(stringBounder).getHeight();
final double dy = (getFullHeight(stringBounder) - titleHeight) / 2;
title.drawU(ug.apply(UTranslate.dy(dy)));
}
double width = getStatesWidth(stringBounder);
if (initialState != null) {
width += getInitialWidth();
}
if (fullAvailableWidth > width + 5)
ug = ug.apply(UTranslate.dx(fullAvailableWidth - width - 5));
else
ug = ug.apply(UTranslate.dx(fullAvailableWidth - width));
for (String state : allStates) { for (String state : allStates) {
final TextBlock label = getTextBlock(state); final TextBlock label = getTextBlock(state);
final Dimension2D dim = label.calculateDimension(ug.getStringBounder()); final Dimension2D dim = label.calculateDimension(stringBounder);
label.drawU(ug.apply(UTranslate.dy(yOfState(state) - dim.getHeight() / 2 + 1))); label.drawU(ug.apply(UTranslate.dy(yOfState(state) - dim.getHeight() / 2 + 1)));
} }
} }
private double getStatesWidth(StringBounder stringBounder) {
double result = 0;
for (String state : allStates) {
final TextBlock label = getTextBlock(state);
final Dimension2D dim = label.calculateDimension(stringBounder);
result = Math.max(result, dim.getWidth());
}
return result;
}
private void drawPart2(UGraphic ug) { private void drawPart2(UGraphic ug) {
if (changes.size() == 0) { if (changes.size() == 0) {
return; return;

View File

@ -42,13 +42,13 @@ import net.sourceforge.plantuml.timingdiagram.ChangeState;
import net.sourceforge.plantuml.timingdiagram.TimeConstraint; import net.sourceforge.plantuml.timingdiagram.TimeConstraint;
import net.sourceforge.plantuml.timingdiagram.TimeProjected; import net.sourceforge.plantuml.timingdiagram.TimeProjected;
public interface PlayerDrawing extends TimeProjected { public interface PDrawing extends TimeProjected {
public double getFullHeight(StringBounder stringBounder); public double getFullHeight(StringBounder stringBounder);
public void addChange(ChangeState change); public void addChange(ChangeState change);
public TextBlock getPart1(); public TextBlock getPart1(double fullAvailableWidth);
public UDrawable getPart2(); public UDrawable getPart2();

View File

@ -34,12 +34,41 @@
*/ */
package net.sourceforge.plantuml.timingdiagram.graphic; package net.sourceforge.plantuml.timingdiagram.graphic;
import net.sourceforge.plantuml.graphic.StringBounder; import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public interface PlayerFrame { public class PlayerFrame {
public void drawFrameTitle(UGraphic ug); private final TextBlock title;
public PlayerFrame(TextBlock title) {
this.title = title;
}
public void drawFrameTitle(UGraphic ug) {
title.drawU(ug);
final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
ug = ug.apply(HColorUtils.BLACK).apply(new UStroke(1.0));
final double widthTmp = dimTitle.getWidth() + 1;
final double height = title.calculateDimension(ug.getStringBounder()).getHeight() + 1;
drawLine(ug, -TimingDiagram.marginX1, height, widthTmp, height, widthTmp + 10, 0);
}
private void drawLine(UGraphic ug, double... coord) {
for (int i = 0; i < coord.length - 2; i += 2) {
final double x1 = coord[i];
final double y1 = coord[i + 1];
final double x2 = coord[i + 2];
final double y2 = coord[i + 3];
ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1));
}
}
public double getHeight(StringBounder stringBounder);
} }

View File

@ -1,80 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, 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.timingdiagram.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PlayerFrame2 implements PlayerFrame {
private final TextBlock title;
public PlayerFrame2(TextBlock title) {
this.title = title;
}
public void drawFrameTitle(UGraphic ug) {
title.drawU(ug);
final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
ug = ug.apply(HColorUtils.BLACK).apply(new UStroke(1.0));
final double widthTmp = dimTitle.getWidth() + 1;
final double height = getHeight(ug.getStringBounder());
drawLine(ug, -TimingDiagram.marginX1, height, widthTmp, height, widthTmp + 10, 0);
}
private void drawLine(UGraphic ug, double... coord) {
for (int i = 0; i < coord.length - 2; i += 2) {
final double x1 = coord[i];
final double y1 = coord[i + 1];
final double x2 = coord[i + 2];
final double y2 = coord[i + 3];
ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1));
}
}
public double getHeight(StringBounder stringBounder) {
final Dimension2D dimTitle = title.calculateDimension(stringBounder);
return dimTitle.getHeight() + 1;
}
}

View File

@ -64,7 +64,7 @@ import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
public class Ribbon implements PlayerDrawing { public class Ribbon implements PDrawing {
private final List<ChangeState> changes = new ArrayList<ChangeState>(); private final List<ChangeState> changes = new ArrayList<ChangeState>();
private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>(); private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
@ -74,11 +74,15 @@ public class Ribbon implements PlayerDrawing {
private String initialState; private String initialState;
private Colors initialColors; private Colors initialColors;
private final List<TimingNote> notes; private final List<TimingNote> notes;
private final boolean compact;
private final TextBlock title;
public Ribbon(TimingRuler ruler, ISkinParam skinParam, List<TimingNote> notes) { public Ribbon(TimingRuler ruler, ISkinParam skinParam, List<TimingNote> notes, boolean compact, TextBlock title) {
this.compact = compact;
this.ruler = ruler; this.ruler = ruler;
this.skinParam = skinParam; this.skinParam = skinParam;
this.notes = notes; this.notes = notes;
this.title = title;
} }
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
@ -110,16 +114,25 @@ public class Ribbon implements PlayerDrawing {
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
} }
public TextBlock getPart1() { public TextBlock getPart1(double fullAvailableWidth) {
if (initialState == null) { // if (initialState == null) {
return TextBlockUtils.empty(0, 0); // return TextBlockUtils.empty(0, 0);
} // }
return new AbstractTextBlock() { return new AbstractTextBlock() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
if (compact) {
final double titleHeight = title.calculateDimension(ug.getStringBounder()).getHeight();
final double dy = (getRibbonHeight() - titleHeight) / 2;
title.drawU(ug.apply(UTranslate.dy(dy)));
}
} }
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(getInitialWidth(stringBounder), getRibbonHeight()); double width = getInitialWidth(stringBounder);
if (compact) {
width += title.calculateDimension(stringBounder).getWidth() + 10;
}
return new Dimension2DDouble(width, getRibbonHeight());
} }
}; };
} }
@ -142,7 +155,10 @@ public class Ribbon implements PlayerDrawing {
} }
private double getInitialWidth(final StringBounder stringBounder) { private double getInitialWidth(final StringBounder stringBounder) {
return createTextBlock(initialState).calculateDimension(stringBounder).getWidth() + getRibbonHeight(); if (initialState == null) {
return 0;
}
return createTextBlock(initialState).calculateDimension(stringBounder).getWidth() + 24;
} }
private void drawHexa(UGraphic ug, double len, ChangeState change) { private void drawHexa(UGraphic ug, double len, ChangeState change) {

View File

@ -65,7 +65,6 @@ import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.anim.AffineTransformation; import net.sourceforge.plantuml.anim.AffineTransformation;
import net.sourceforge.plantuml.anim.Animation; import net.sourceforge.plantuml.anim.Animation;
@ -139,7 +138,7 @@ public class ImageBuilder {
public ImageBuilder(ISkinParam skinParam, double dpiFactor, String metadata, String warningOrError, double margin1, public ImageBuilder(ISkinParam skinParam, double dpiFactor, String metadata, String warningOrError, double margin1,
double margin2, Animation animation) { double margin2, Animation animation) {
this(skinParam, dpiFactor, metadata, warningOrError, margin1, margin2, animation, this(skinParam, dpiFactor, metadata, warningOrError, margin1, margin2, animation,
skinParam.getBackgroundColor()); skinParam.getBackgroundColor(false));
} }
public ImageBuilder(ISkinParam skinParam, double dpiFactor, String metadata, String warningOrError, double margin1, public ImageBuilder(ISkinParam skinParam, double dpiFactor, String metadata, String warningOrError, double margin1,
@ -390,7 +389,8 @@ public class ImageBuilder {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
switch (fileFormat) { switch (fileFormat) {
case PNG: case PNG:
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy); return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy,
fileFormatOption.getWatermark());
case SVG: case SVG:
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(), return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed, fileFormatOption.getPreserveAspectRatio()); fileFormatOption.getHoverColor(), seed, fileFormatOption.getPreserveAspectRatio());
@ -416,21 +416,21 @@ public class ImageBuilder {
} }
} }
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HColor mybackcolor, private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, final HColor suggested,
String svgLinkTarget, String hover, long seed, String preserveAspectRatio) { String svgLinkTarget, String hover, long seed, String preserveAspectRatio) {
Color backColor = Color.WHITE; HColor backColor = HColorUtils.WHITE;
if (mybackcolor instanceof HColorSimple) { if (suggested instanceof HColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor); backColor = suggested;
} }
final UGraphicSvg ug; final UGraphicSvg ug;
if (mybackcolor instanceof HColorGradient) { if (suggested instanceof HColorGradient) {
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) mybackcolor, false, scale, ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) suggested, false, scale,
svgLinkTarget, hover, seed, preserveAspectRatio); svgLinkTarget, hover, seed, preserveAspectRatio);
} else if (backColor == null || backColor.equals(Color.WHITE)) { } else if (backColor == null || colorMapper.toColor(backColor).equals(Color.WHITE)) {
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, false, scale, svgLinkTarget, hover, seed, ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, false, scale, svgLinkTarget, hover, seed,
preserveAspectRatio); preserveAspectRatio);
} else { } else {
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, StringUtils.getAsHtml(backColor), false, scale, ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, colorMapper.toSvg(backColor), false, scale,
svgLinkTarget, hover, seed, preserveAspectRatio); svgLinkTarget, hover, seed, preserveAspectRatio);
} }
return ug; return ug;
@ -438,10 +438,10 @@ public class ImageBuilder {
} }
private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim, private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HColor mybackcolor, Animation affineTransforms, double dx, double dy) { HColor mybackcolor, Animation affineTransforms, double dx, double dy, String watermark) {
Color backColor = Color.WHITE; Color backColor = Color.WHITE;
if (mybackcolor instanceof HColorSimple) { if (mybackcolor instanceof HColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor); backColor = colorMapper.toColor(mybackcolor);
} else if (mybackcolor instanceof HColorBackground) { } else if (mybackcolor instanceof HColorBackground) {
backColor = null; backColor = null;
} }
@ -452,7 +452,7 @@ public class ImageBuilder {
* builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2); * builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2);
* graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else { * graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else {
*/ */
final EmptyImageBuilder builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * dpiFactor),
(int) (dim.getHeight() * dpiFactor), backColor); (int) (dim.getHeight() * dpiFactor), backColor);
final Graphics2D graphics2D = builder.getGraphics2D(); final Graphics2D graphics2D = builder.getGraphics2D();
@ -462,8 +462,7 @@ public class ImageBuilder {
ug.setBufferedImage(builder.getBufferedImage()); ug.setBufferedImage(builder.getBufferedImage());
final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage(); final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
if (mybackcolor instanceof HColorGradient) { if (mybackcolor instanceof HColorGradient) {
ug.apply(mybackcolor.bg()) ug.apply(mybackcolor.bg()).draw(new URectangle(im.getWidth() / dpiFactor, im.getHeight() / dpiFactor));
.draw(new URectangle(im.getWidth() / dpiFactor, im.getHeight() / dpiFactor));
} }
return ug; return ug;

View File

@ -44,7 +44,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.eps.EpsStrategy; import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.png.PngIO; import net.sourceforge.plantuml.png.PngIO;
@ -60,12 +59,12 @@ public abstract class UGraphicUtils {
ColorMapper colorMapper, HColor background, TextBlock image) throws IOException { ColorMapper colorMapper, HColor background, TextBlock image) throws IOException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) { if (fileFormat == FileFormat.PNG) {
final BufferedImage im = createImage(colorMapper, background, image); final BufferedImage im = createImage(fileFormatOption.getWatermark(), colorMapper, background, image);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final Dimension2D size = computeSize(colorMapper, background, image); final Dimension2D size = computeSize(colorMapper, background, image);
final UGraphicSvg svg = new UGraphicSvg(true, size, colorMapper, StringUtils.getAsHtml(colorMapper final UGraphicSvg svg = new UGraphicSvg(true, size, colorMapper,
.getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(), colorMapper.toHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed, fileFormatOption.getPreserveAspectRatio()); fileFormatOption.getHoverColor(), seed, fileFormatOption.getPreserveAspectRatio());
image.drawU(svg); image.drawU(svg);
svg.createXml(os, fileFormatOption.isWithMetadata() ? metadata : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? metadata : null);
@ -82,11 +81,12 @@ public abstract class UGraphicUtils {
} }
} }
private static BufferedImage createImage(ColorMapper colorMapper, HColor background, TextBlock image) { private static BufferedImage createImage(String watermark, ColorMapper colorMapper, HColor background,
TextBlock image) {
final Dimension2D size = computeSize(colorMapper, background, image); final Dimension2D size = computeSize(colorMapper, background, image);
final EmptyImageBuilder builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(), final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, size.getWidth(), size.getHeight(),
colorMapper.getMappedColor(background)); colorMapper.toColor(background));
final BufferedImage im = builder.getBufferedImage(); final BufferedImage im = builder.getBufferedImage();
final Graphics2D g2d = builder.getGraphics2D(); final Graphics2D g2d = builder.getGraphics2D();
@ -97,7 +97,7 @@ public abstract class UGraphicUtils {
} }
private static Dimension2D computeSize(ColorMapper colorMapper, HColor background, TextBlock image) { private static Dimension2D computeSize(ColorMapper colorMapper, HColor background, TextBlock image) {
final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background)); final EmptyImageBuilder builder = new EmptyImageBuilder(null, 10, 10, colorMapper.toColor(background));
final Graphics2D g2d = builder.getGraphics2D(); final Graphics2D g2d = builder.getGraphics2D();
final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0); final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);

View File

@ -30,19 +30,41 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
*
* *
*/ */
package net.sourceforge.plantuml.timingdiagram.graphic; package net.sourceforge.plantuml.ugraphic.color;
import net.sourceforge.plantuml.graphic.StringBounder; import java.awt.Color;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class PlayerFrameEmpty implements PlayerFrame { import net.sourceforge.plantuml.svek.DotStringFactory;
public void drawFrameTitle(UGraphic ug) { public abstract class AbstractColorMapper implements ColorMapper {
final public String toHtml(HColor hcolor) {
if (hcolor == null) {
return null;
}
final Color color = toColor(hcolor);
return DotStringFactory.sharp000000(color.getRGB());
} }
public double getHeight(StringBounder stringBounder) { final public String toSvg(HColor hcolor) {
return 0; if (hcolor == null) {
return "none";
}
if (hcolor instanceof HColorBackground) {
final HColor result = ((HColorBackground) hcolor).getBack();
// Thread.dumpStack();
// System.exit(0);
// return toHtml(result);
}
final Color color = toColor(hcolor);
final int alpha = color.getAlpha();
if (alpha != 255) {
return DotStringFactory.sharpAlpha(color.getRGB());
}
return toHtml(hcolor);
} }
} }

View File

@ -39,5 +39,9 @@ import java.awt.Color;
public interface ColorMapper { public interface ColorMapper {
Color getMappedColor(HColor color); public Color toColor(HColor color);
public String toSvg(HColor color);
public String toHtml(HColor color);
} }

View File

@ -37,9 +37,9 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color; import java.awt.Color;
public class ColorMapperIdentity implements ColorMapper { public class ColorMapperIdentity extends AbstractColorMapper implements ColorMapper {
public Color getMappedColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null) {
return null; return null;
} }
@ -51,13 +51,11 @@ public class ColorMapperIdentity implements ColorMapper {
return Color.WHITE; return Color.WHITE;
} }
if (color instanceof HColorGradient) { if (color instanceof HColorGradient) {
return getMappedColor(((HColorGradient) color).getColor1()); return toColor(((HColorGradient) color).getColor1());
} }
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle) {
return ((HColorMiddle) color).getMappedColor(this); return ((HColorMiddle) color).getMappedColor(this);
} }
// return ColorUtils.getReversed(((HColorSimple) color).getColor999());
//return ColorOrder.RGB.getReverse(((HColorSimple) color).getColor999());
return ((HColorSimple) color).getColor999(); return ((HColorSimple) color).getColor999();
} }
} }

View File

@ -37,9 +37,9 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color; import java.awt.Color;
public class ColorMapperLightnessInverse implements ColorMapper { public class ColorMapperLightnessInverse extends AbstractColorMapper implements ColorMapper {
public Color getMappedColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null) {
return null; return null;
} }
@ -51,13 +51,11 @@ public class ColorMapperLightnessInverse implements ColorMapper {
return Color.WHITE; return Color.WHITE;
} }
if (color instanceof HColorGradient) { if (color instanceof HColorGradient) {
return getMappedColor(((HColorGradient) color).getColor1()); return toColor(((HColorGradient) color).getColor1());
} }
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle) {
return ((HColorMiddle) color).getMappedColor(this); return ((HColorMiddle) color).getMappedColor(this);
} }
return ColorUtils.getReversed(((HColorSimple) color).getColor999()); return ColorUtils.getReversed(((HColorSimple) color).getColor999());
//return ColorOrder.RGB.getReverse(((HColorSimple) color).getColor999());
// return ((HColorSimple) color).getColor999();
} }
} }

View File

@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color; import java.awt.Color;
public class ColorMapperMonochrome implements ColorMapper { public class ColorMapperMonochrome extends AbstractColorMapper implements ColorMapper {
private final boolean reverse; private final boolean reverse;
@ -45,11 +45,11 @@ public class ColorMapperMonochrome implements ColorMapper {
this.reverse = reverse; this.reverse = reverse;
} }
public Color getMappedColor(HColor htmlColor) { public Color toColor(HColor htmlColor) {
if (htmlColor == null) { if (htmlColor == null) {
return null; return null;
} }
final Color color = new ColorMapperIdentity().getMappedColor(htmlColor); final Color color = new ColorMapperIdentity().toColor(htmlColor);
if (reverse) { if (reverse) {
return ColorUtils.getGrayScaleColorReverse(color); return ColorUtils.getGrayScaleColorReverse(color);
} }

View File

@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color; import java.awt.Color;
public class ColorMapperReverse implements ColorMapper { public class ColorMapperReverse extends AbstractColorMapper implements ColorMapper {
private final ColorOrder order; private final ColorOrder order;
@ -45,7 +45,7 @@ public class ColorMapperReverse implements ColorMapper {
this.order = order; this.order = order;
} }
public Color getMappedColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null) {
return null; return null;
} }

View File

@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color; import java.awt.Color;
public class ColorMapperTransparentWrapper implements ColorMapper { public class ColorMapperTransparentWrapper extends AbstractColorMapper implements ColorMapper {
private final ColorMapper mapper; private final ColorMapper mapper;
@ -48,14 +48,15 @@ public class ColorMapperTransparentWrapper implements ColorMapper {
this.mapper = mapper; this.mapper = mapper;
} }
public Color getMappedColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null) {
return null; return null;
} }
if (color instanceof HColorBackground) { if (color instanceof HColorBackground) {
return ((HColorBackground) color).getActualColor(mapper); final HColor back = ((HColorBackground) color).getBack();
return mapper.toColor(back);
} }
return mapper.getMappedColor(color); return mapper.toColor(color);
} }
} }

View File

@ -35,8 +35,8 @@
*/ */
package net.sourceforge.plantuml.ugraphic.color; package net.sourceforge.plantuml.ugraphic.color;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UBackground; import net.sourceforge.plantuml.ugraphic.UBackground;
import net.sourceforge.plantuml.ugraphic.UChange;
public interface HColor extends UChange { public interface HColor extends UChange {

View File

@ -34,10 +34,6 @@
*/ */
package net.sourceforge.plantuml.ugraphic.color; package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color;
import net.sourceforge.plantuml.StringUtils;
public class HColorBackground extends HColorAbstract implements HColor { public class HColorBackground extends HColorAbstract implements HColor {
private final HColor back; private final HColor back;
@ -47,19 +43,14 @@ public class HColorBackground extends HColorAbstract implements HColor {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.back = back; this.back = back;
}
public String getSvg(ColorMapper mapper) {
return StringUtils.getAsHtml(((HColorSimple) back).getColor999());
} }
public HColor getNull() { public HColor getNull() {
return null; return null;
} }
public Color getActualColor(ColorMapper mapper) { final HColor getBack() {
return mapper.getMappedColor(back); return back;
} }
} }

View File

@ -69,8 +69,8 @@ public class HColorGradient extends HColorAbstract implements HColor {
if (coeff > 1 || coeff < 0) { if (coeff > 1 || coeff < 0) {
throw new IllegalArgumentException("c=" + coeff); throw new IllegalArgumentException("c=" + coeff);
} }
final Color c1 = mapper.getMappedColor(color1); final Color c1 = mapper.toColor(color1);
final Color c2 = mapper.getMappedColor(color2); final Color c2 = mapper.toColor(color2);
final int vred = c2.getRed() - c1.getRed(); final int vred = c2.getRed() - c1.getRed();
final int vgreen = c2.getGreen() - c1.getGreen(); final int vgreen = c2.getGreen() - c1.getGreen();
final int vblue = c2.getBlue() - c1.getBlue(); final int vblue = c2.getBlue() - c1.getBlue();

View File

@ -48,8 +48,8 @@ public class HColorMiddle extends HColorAbstract implements HColor {
} }
public Color getMappedColor(ColorMapper colorMapper) { public Color getMappedColor(ColorMapper colorMapper) {
final Color cc1 = colorMapper.getMappedColor(c1); final Color cc1 = colorMapper.toColor(c1);
final Color cc2 = colorMapper.getMappedColor(c2); final Color cc2 = colorMapper.toColor(c2);
final int r1 = cc1.getRed(); final int r1 = cc1.getRed();
final int g1 = cc1.getGreen(); final int g1 = cc1.getGreen();
final int b1 = cc1.getBlue(); final int b1 = cc1.getBlue();

View File

@ -269,6 +269,9 @@ public class HColorSet {
color = new Color(Integer.parseInt(s, 16)); color = new Color(Integer.parseInt(s, 16));
} else if (s.matches("[0-9A-Fa-f]{6}")) { } else if (s.matches("[0-9A-Fa-f]{6}")) {
color = new Color(Integer.parseInt(s, 16)); color = new Color(Integer.parseInt(s, 16));
} else if (s.matches("[0-9A-Fa-f]{8}")) {
final long parse = Long.parseLong(s, 16);
color = new Color((int) parse, true);
} else { } else {
final String value = htmlNames.get(s); final String value = htmlNames.get(s);
if (value == null) { if (value == null) {
@ -287,6 +290,9 @@ public class HColorSet {
if (s.matches("[0-9A-Fa-f]{6}")) { if (s.matches("[0-9A-Fa-f]{6}")) {
return true; return true;
} }
if (s.matches("[0-9A-Fa-f]{8}")) {
return true;
}
if (s.equalsIgnoreCase("automatic")) { if (s.equalsIgnoreCase("automatic")) {
return true; return true;
} }

View File

@ -47,6 +47,14 @@ public class HColorSimple extends HColorAbstract implements HColor {
return color.hashCode(); return color.hashCode();
} }
@Override
public String toString() {
if (color.getAlpha() == 0) {
return "transparent";
}
return color.toString() + " alpha=" + color.getAlpha() + " monochrome=" + monochrome;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof HColorSimple == false) { if (other instanceof HColorSimple == false) {

View File

@ -35,6 +35,8 @@
*/ */
package net.sourceforge.plantuml.ugraphic.color; package net.sourceforge.plantuml.ugraphic.color;
import java.awt.Color;
import net.sourceforge.plantuml.ugraphic.UChange; import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -131,4 +133,8 @@ public class HColorUtils {
return color.bg(); return color.bg();
} }
public static HColor transparent() {
return new HColorSimple(new Color(0, 0, 0, 0), false);
}
} }

View File

@ -74,7 +74,7 @@ public class PiecewiseAffineOnXorYBuilder extends AbstractTextBlock implements T
@Override @Override
public MinMax getMinMax(StringBounder stringBounder) { public MinMax getMinMax(StringBounder stringBounder) {
if (cachedMinMax == null) { if (cachedMinMax == null) {
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder); cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
} }
return cachedMinMax; return cachedMinMax;
} }

View File

@ -58,7 +58,7 @@ public class DriverCenteredCharacterEps implements UDriver<EpsGraphics> {
final double ypos = y - unusedSpace.getCenterY() - 0.5; final double ypos = y - unusedSpace.getCenterY() - 0.5;
final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
eps.setStrokeColor(mapper.getMappedColor(param.getColor())); eps.setStrokeColor(mapper.toColor(param.getColor()));
DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null)); DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null));
} }

View File

@ -49,7 +49,7 @@ public class DriverDotPathEps implements UDriver<EpsGraphics> {
//DriverLineG2d.manageStroke(param, g2d); //DriverLineG2d.manageStroke(param, g2d);
if (param.getColor() != null) { if (param.getColor() != null) {
eps.setStrokeColor(mapper.getMappedColor(param.getColor())); eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke() eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
.getDashSpace()); .getDashSpace());
shape.draw(eps, x, y); shape.draw(eps, x, y);

View File

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

View File

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

View File

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

View File

@ -46,8 +46,8 @@ public class DriverPathEps implements UDriver<EpsGraphics> {
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) { public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
final UPath shape = (UPath) ushape; final UPath shape = (UPath) ushape;
eps.setStrokeColor(mapper.getMappedColor(param.getColor())); eps.setStrokeColor(mapper.toColor(param.getColor()));
eps.setFillColor(mapper.getMappedColor(param.getBackcolor())); eps.setFillColor(mapper.toColor(param.getBackcolor()));
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
.getStroke().getDashSpace()); .getStroke().getDashSpace());

View File

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

View File

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

View File

@ -99,7 +99,7 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
MinMax dim = null; MinMax dim = null;
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor()); final Color extended = mapper.toColor(fontConfiguration.getExtendedColor());
if (extended != null) { if (extended != null) {
eps.setStrokeColor(extended); eps.setStrokeColor(extended);
eps.setFillColor(extended); eps.setFillColor(extended);
@ -111,13 +111,13 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
} }
} }
eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor())); eps.setStrokeColor(mapper.toColor(fontConfiguration.getColor()));
drawPathIterator(eps, x, y, getOutline(textLayout)); drawPathIterator(eps, x, y, getOutline(textLayout));
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
final HColor extended = fontConfiguration.getExtendedColor(); final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) { if (extended != null) {
eps.setStrokeColor(mapper.getMappedColor(extended)); eps.setStrokeColor(mapper.toColor(extended));
} }
if (dim == null) { if (dim == null) {
dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null));
@ -133,7 +133,7 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
final int ypos = (int) (y + 2.5) - 1; final int ypos = (int) (y + 2.5) - 1;
final HColor extended = fontConfiguration.getExtendedColor(); final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) { if (extended != null) {
eps.setStrokeColor(mapper.getMappedColor(extended)); eps.setStrokeColor(mapper.toColor(extended));
} }
eps.setStrokeWidth(1.1, 0, 0); eps.setStrokeWidth(1.1, 0, 0);
for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) { for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
@ -145,7 +145,7 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
final HColor extended = fontConfiguration.getExtendedColor(); final HColor extended = fontConfiguration.getExtendedColor();
if (extended != null) { if (extended != null) {
eps.setStrokeColor(mapper.getMappedColor(extended)); eps.setStrokeColor(mapper.toColor(extended));
} }
if (dim == null) { if (dim == null) {
dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null));
@ -169,7 +169,7 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
// final double ypos = y - fm.getDescent() + 0.5; // final double ypos = y - fm.getDescent() + 0.5;
final double ypos = y - 1; final double ypos = y - 1;
eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor())); eps.setStrokeColor(mapper.toColor(fontConfiguration.getColor()));
((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos); ((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
} }

View File

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

View File

@ -57,7 +57,7 @@ public class DriverDotPathG2d implements UDriver<Graphics2D> {
DriverLineG2d.manageStroke(param, g2d); DriverLineG2d.manageStroke(param, g2d);
if (param.getColor() != null) { if (param.getColor() != null) {
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
shape.draw(g2d, x, y); shape.draw(g2d, x, y);
shape.manageEnsureVisible(x, y, visible); shape.manageEnsureVisible(x, y, visible);
} }

View File

@ -84,7 +84,7 @@ public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<Graph
DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y); DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y);
} else { } else {
if (back != null) { if (back != null) {
g2d.setColor(mapper.getMappedColor(param.getBackcolor())); g2d.setColor(mapper.toColor(param.getBackcolor()));
DriverRectangleG2d.managePattern(param, g2d); DriverRectangleG2d.managePattern(param, g2d);
g2d.fill(shape); g2d.fill(shape);
} }
@ -96,7 +96,7 @@ public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<Graph
final Shape arc = new Arc2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight(), final Shape arc = new Arc2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight(),
round(ellipse.getStart()), round(ellipse.getExtend()), Arc2D.OPEN); round(ellipse.getStart()), round(ellipse.getExtend()), Arc2D.OPEN);
if (color != null) { if (color != null) {
g2d.setColor(mapper.getMappedColor(color)); g2d.setColor(mapper.toColor(color));
g2d.draw(arc); g2d.draw(arc);
} }
} }

View File

@ -90,7 +90,7 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics
if (shape.isOpenIconic()) { if (shape.isOpenIconic()) {
p.closePath(); p.closePath();
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
g2d.fill(p); g2d.fill(p);
return; return;
} }
@ -131,30 +131,30 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics
final GradientPaint paint; final GradientPaint paint;
if (policy == '|') { if (policy == '|') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2, paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2, mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else if (policy == '\\') { } else if (policy == '\\') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
.getColor2())); .getColor2()));
} else if (policy == '-') { } else if (policy == '-') {
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(), paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(), mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else { } else {
// for / // for /
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
} }
g2d.setPaint(paint); g2d.setPaint(paint);
g2d.fill(p); g2d.fill(p);
} else if (back != null) { } else if (back != null) {
g2d.setColor(mapper.getMappedColor(back)); g2d.setColor(mapper.toColor(back));
g2d.fill(p); g2d.fill(p);
} }
if (param.getColor() != null) { if (param.getColor() != null) {
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
g2d.draw(p); g2d.draw(p);
} }
} }

View File

@ -88,7 +88,7 @@ public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Gr
if (shape.isOpenIconic()) { if (shape.isOpenIconic()) {
p.closePath(); p.closePath();
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
g2d.fill(p); g2d.fill(p);
return; return;
} }
@ -126,30 +126,30 @@ public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Gr
final GradientPaint paint; final GradientPaint paint;
if (policy == '|') { if (policy == '|') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2, paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2, mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else if (policy == '\\') { } else if (policy == '\\') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
.getColor2())); .getColor2()));
} else if (policy == '-') { } else if (policy == '-') {
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(), paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(), mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else { } else {
// for / // for /
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
} }
g2d.setPaint(paint); g2d.setPaint(paint);
g2d.fill(p); g2d.fill(p);
} else if (back != null) { } else if (back != null) {
g2d.setColor(mapper.getMappedColor(back)); g2d.setColor(mapper.toColor(back));
g2d.fill(p); g2d.fill(p);
} }
if (param.getColor() != null) { if (param.getColor() != null) {
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
g2d.draw(p); g2d.draw(p);
} }
} }

View File

@ -126,30 +126,30 @@ public class DriverPathOldG2d extends DriverShadowedG2d implements UDriver<Graph
final GradientPaint paint; final GradientPaint paint;
if (policy == '|') { if (policy == '|') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2, paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2, mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else if (policy == '\\') { } else if (policy == '\\') {
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
.getColor2())); .getColor2()));
} else if (policy == '-') { } else if (policy == '-') {
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(), paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(), mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
mapper.getMappedColor(gr.getColor2())); mapper.toColor(gr.getColor2()));
} else { } else {
// for / // for /
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
} }
g2d.setPaint(paint); g2d.setPaint(paint);
g2d.fill(p); g2d.fill(p);
} else if (back != null) { } else if (back != null) {
g2d.setColor(mapper.getMappedColor(back)); g2d.setColor(mapper.toColor(back));
g2d.fill(p); g2d.fill(p);
} }
if (param.getColor() != null) { if (param.getColor() != null) {
g2d.setColor(mapper.getMappedColor(param.getColor())); g2d.setColor(mapper.toColor(param.getColor()));
g2d.draw(p); g2d.draw(p);
} }
} }

View File

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

Some files were not shown because too many files have changed in this diff Show More