mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
version 1.2020.8
This commit is contained in:
parent
9077d971d7
commit
138cfb900a
2
pom.xml
2
pom.xml
@ -35,7 +35,7 @@
|
||||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
<artifactId>plantuml</artifactId>
|
||||
<version>1.2020.8-SNAPSHOT</version>
|
||||
<version>1.2020.9-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PlantUML</name>
|
||||
|
@ -303,7 +303,7 @@ public class ConfigParameters {
|
||||
static private HColorSet colors = HColorSet.instance();
|
||||
private Color decodeInternal(String value) {
|
||||
if (colors.getColorIfValid(value)!=null) {
|
||||
return new ColorMapperIdentity().getMappedColor(colors.getColorIfValid(value));
|
||||
return new ColorMapperIdentity().toColor(colors.getColorIfValid(value));
|
||||
}
|
||||
return Color.decode(value);
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ public class AnnotatedWorker {
|
||||
final double y1 = 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);
|
||||
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),
|
||||
HorizontalAlignment.CENTER, getSkinParam());
|
||||
final Dimension2D dimTitle = title.calculateDimension(stringBounder);
|
||||
@ -118,7 +118,7 @@ public class AnnotatedWorker {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -86,6 +86,7 @@ public enum ColorParam {
|
||||
interfaceBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
interfaceBorder(HColorUtils.MY_RED, ColorType.LINE),
|
||||
arrow(HColorUtils.MY_RED, ColorType.ARROW),
|
||||
arrowHead(HColorUtils.MY_RED, null),
|
||||
|
||||
stateBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
stateBorder(HColorUtils.MY_RED, ColorType.LINE),
|
||||
|
@ -36,9 +36,14 @@
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
|
||||
@ -50,11 +55,11 @@ public class EmptyImageBuilder {
|
||||
private final BufferedImage im;
|
||||
private final Graphics2D g2d;
|
||||
|
||||
public EmptyImageBuilder(double width, double height, Color background) {
|
||||
this((int) width, (int) height, background);
|
||||
public EmptyImageBuilder(String watermark, double width, double height, Color 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()) {
|
||||
Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE");
|
||||
width = GraphvizUtils.getenvImageLimit();
|
||||
@ -64,18 +69,84 @@ public class EmptyImageBuilder {
|
||||
height = GraphvizUtils.getenvImageLimit();
|
||||
}
|
||||
Log.info("Creating image " + width + "x" + height);
|
||||
im = new BufferedImage(width, height, background == null ? BufferedImage.TYPE_INT_ARGB
|
||||
: BufferedImage.TYPE_INT_RGB);
|
||||
im = new BufferedImage(width, height, getType(background));
|
||||
g2d = im.createGraphics();
|
||||
UAntiAliasing.ANTI_ALIASING_ON.apply(g2d);
|
||||
if (background != null) {
|
||||
g2d.setColor(background);
|
||||
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) {
|
||||
this(width * dpiFactor, height * dpiFactor, background);
|
||||
private int getType(Color 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) {
|
||||
g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor));
|
||||
}
|
||||
|
@ -58,13 +58,38 @@ public final class FileFormatOption implements Serializable {
|
||||
private final TikzFontDistortion tikzFontDistortion;
|
||||
private final double scale;
|
||||
private final String preserveAspectRatio;
|
||||
private final String watermark;
|
||||
|
||||
public double getScaleCoef() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -83,56 +108,39 @@ public final class FileFormatOption implements Serializable {
|
||||
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() {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
|
||||
}
|
||||
|
||||
public FileFormatOption withTikzFontDistortion(TikzFontDistortion tikzFontDistortion) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
|
||||
}
|
||||
|
||||
public FileFormatOption withSvgLinkTarget(String svgLinkTarget) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
|
||||
}
|
||||
|
||||
public FileFormatOption withPreserveAspectRatio(String preserveAspectRatio) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
|
||||
}
|
||||
|
||||
public FileFormatOption withHoverColor(String hoverColor) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
|
||||
hoverColor, tikzFontDistortion, scale, preserveAspectRatio, watermark);
|
||||
}
|
||||
|
||||
public FileFormatOption withScale(double scale) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, tikzFontDistortion, scale, preserveAspectRatio);
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, debugsvek,
|
||||
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
|
||||
@ -174,4 +182,8 @@ public final class FileFormatOption implements Serializable {
|
||||
return tikzFontDistortion;
|
||||
}
|
||||
|
||||
public final String getWatermark() {
|
||||
return watermark;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public interface ISkinParam extends ISkinSimple {
|
||||
|
||||
public boolean useUnderlineForHyperlink();
|
||||
|
||||
public HColor getBackgroundColor();
|
||||
public HColor getBackgroundColor(boolean replaceTransparentByWhite);
|
||||
|
||||
public HColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable);
|
||||
|
||||
|
@ -263,11 +263,14 @@ public class SkinParam implements ISkinParam {
|
||||
return result;
|
||||
}
|
||||
|
||||
public HColor getBackgroundColor() {
|
||||
public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
|
||||
final HColor result = getHtmlColor(ColorParam.background, null, false);
|
||||
if (result == null) {
|
||||
return HColorUtils.WHITE;
|
||||
}
|
||||
if (replaceTransparentByWhite && HColorUtils.transparent().equals(result)) {
|
||||
return HColorUtils.WHITE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -310,8 +313,9 @@ public class SkinParam implements ISkinParam {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (param == ColorParam.background && value.equalsIgnoreCase("transparent")) {
|
||||
return null;
|
||||
if ((param == ColorParam.background || param == ColorParam.arrowHead)
|
||||
&& (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none"))) {
|
||||
return HColorUtils.transparent();
|
||||
}
|
||||
if (param == ColorParam.background) {
|
||||
return getIHtmlColorSet().getColorIfValid(value);
|
||||
@ -319,7 +323,7 @@ public class SkinParam implements ISkinParam {
|
||||
assert param != ColorParam.background;
|
||||
// final boolean acceptTransparent = param == ColorParam.background
|
||||
// || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground;
|
||||
return getIHtmlColorSet().getColorIfValid(value, getBackgroundColor());
|
||||
return getIHtmlColorSet().getColorIfValid(value, getBackgroundColor(false));
|
||||
}
|
||||
|
||||
public char getCircledCharacter(Stereotype stereotype) {
|
||||
|
@ -73,11 +73,11 @@ public class SkinParamBackcolored extends SkinParamDelegator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HColor getBackgroundColor() {
|
||||
public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
|
||||
if (backColorGeneral != null) {
|
||||
return backColorGeneral;
|
||||
}
|
||||
return super.getBackgroundColor();
|
||||
return super.getBackgroundColor(replaceTransparentByWhite);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,8 +71,8 @@ public class SkinParamDelegator implements ISkinParam {
|
||||
return skinParam.getHyperlinkColor();
|
||||
}
|
||||
|
||||
public HColor getBackgroundColor() {
|
||||
return skinParam.getBackgroundColor();
|
||||
public HColor getBackgroundColor(boolean replaceTransparentByWhite) {
|
||||
return skinParam.getBackgroundColor(replaceTransparentByWhite);
|
||||
}
|
||||
|
||||
public int getCircledCharacterRadius() {
|
||||
|
@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
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.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
|
||||
@ -385,30 +386,6 @@ public class StringUtils {
|
||||
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) {
|
||||
return uid1 + String.format("%04d", uid2);
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
||||
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
|
||||
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
|
||||
if (hover != null) {
|
||||
fileFormatOption = fileFormatOption.withHoverColor(StringUtils.getAsHtml(getSkinParam().getColorMapper()
|
||||
.getMappedColor(hover)));
|
||||
fileFormatOption = fileFormatOption
|
||||
.withHoverColor(getSkinParam().getColorMapper().toHtml(hover));
|
||||
}
|
||||
|
||||
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
|
||||
@ -227,8 +227,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
||||
|
||||
strings.addAll(CommandExecutionResult.getStackTrace(exception));
|
||||
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HColorUtils.WHITE,
|
||||
metadata, null, 0, 0, null, false);
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HColorUtils.WHITE, metadata,
|
||||
null, 0, 0, null, false);
|
||||
|
||||
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
|
||||
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;
|
||||
at.setToShear(coef, coef);
|
||||
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();
|
||||
final BufferedImage im = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
|
||||
m.addImage(im);
|
||||
@ -411,7 +412,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
||||
// final String res = "/skin/" + filename + ".skin";
|
||||
// final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res);
|
||||
// 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);
|
||||
// }
|
||||
// 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) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class CommandLink3 extends SingleLineCommand2<ActivityDiagram3> {
|
||||
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
|
||||
final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
|
||||
if (color != null) {
|
||||
diagram.setColorNextArrow(Rainbow.fromColor(color));
|
||||
diagram.setColorNextArrow(Rainbow.fromColor(color, null));
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class SwimlanesA extends AbstractTextBlock implements ISwimlanesA, TextBl
|
||||
@Override
|
||||
public MinMax getMinMax(StringBounder stringBounder) {
|
||||
if (cachedMinMax == null) {
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder);
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
|
||||
}
|
||||
return cachedMinMax;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ public class SwimlanesAAA extends AbstractTextBlock implements ISwimlanesA, Text
|
||||
@Override
|
||||
public MinMax getMinMax(StringBounder stringBounder) {
|
||||
if (cachedMinMax == null) {
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder);
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
|
||||
}
|
||||
return cachedMinMax;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
|
||||
|
||||
public class Worm implements Iterable<Point2D.Double> {
|
||||
@ -69,18 +70,18 @@ public class Worm implements Iterable<Point2D.Double> {
|
||||
this.ignoreForCompression = true;
|
||||
}
|
||||
|
||||
public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle color, double stroke,
|
||||
Direction emphasizeDirection, UPolygon endDecoration) {
|
||||
final HColor color2 = color.getColor();
|
||||
if (color2 == null) {
|
||||
public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle colorAndStyle,
|
||||
double stroke, Direction emphasizeDirection, UPolygon endDecoration) {
|
||||
final HColor arrowColor = colorAndStyle.getArrowColor();
|
||||
if (arrowColor == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
final LinkStyle style = color.getStyle();
|
||||
final LinkStyle style = colorAndStyle.getStyle();
|
||||
if (style.isInvisible()) {
|
||||
return;
|
||||
}
|
||||
ug = ug.apply(color2);
|
||||
ug = ug.apply(color2.bg());
|
||||
ug = ug.apply(arrowColor);
|
||||
ug = ug.apply(arrowColor.bg());
|
||||
if (style.isNormal()) {
|
||||
ug = ug.apply(new UStroke(stroke));
|
||||
} else {
|
||||
@ -98,6 +99,13 @@ public class Worm implements Iterable<Point2D.Double> {
|
||||
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) {
|
||||
ug = ug.apply(new UStroke(1.5));
|
||||
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++) {
|
||||
final List<Direction> patternAt = getPatternAt(i);
|
||||
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);
|
||||
points.remove(i + 3);
|
||||
points.remove(i + 2);
|
||||
@ -398,7 +407,8 @@ public class Worm implements Iterable<Point2D.Double> {
|
||||
for (int i = 0; i < points.size() - 4; i++) {
|
||||
final List<Direction> patternAt = getPatternAt(i);
|
||||
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);
|
||||
points.remove(i + 3);
|
||||
points.remove(i + 2);
|
||||
|
@ -271,7 +271,6 @@ class FtileWhile extends AbstractFtile {
|
||||
snake.emphasizeDirection(Direction.UP);
|
||||
|
||||
ug.draw(snake);
|
||||
|
||||
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
|
||||
|
||||
}
|
||||
@ -362,6 +361,7 @@ class FtileWhile extends AbstractFtile {
|
||||
snake.addPoint(x2, y2);
|
||||
|
||||
ug.draw(snake);
|
||||
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class ConditionalBuilder {
|
||||
this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
|
||||
this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
|
||||
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.fontArrow = styleArrow.getFontConfiguration(skinParam.getIHtmlColorSet());
|
||||
} else {
|
||||
|
@ -46,10 +46,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public class CommandScale extends SingleLineCommand2<AbstractPSystem> {
|
||||
|
||||
// public CommandScale() {
|
||||
// super("(?i)^$");
|
||||
// }
|
||||
|
||||
public CommandScale() {
|
||||
super(getRegexConcat());
|
||||
}
|
||||
|
@ -106,8 +106,7 @@ public class AtomMath extends AbstractAtom implements Atom {
|
||||
|
||||
private Color getColor(HColor color, Color defaultValue) {
|
||||
if (color instanceof HColorSimple) {
|
||||
return colorMapper.getMappedColor(color);
|
||||
// return ((HtmlColorSimple) color).getColor999();
|
||||
return colorMapper.toColor(color);
|
||||
}
|
||||
return defaultValue;
|
||||
|
||||
|
@ -128,7 +128,7 @@ public final class EntityFactory {
|
||||
if (g.getColors(skinParam).getColor(ColorType.BACK) == null) {
|
||||
final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack();
|
||||
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 {
|
||||
folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors(skinParam).getColor(ColorType.BACK));
|
||||
}
|
||||
|
@ -71,25 +71,25 @@ public class PSystemDonors extends AbstractPSystem {
|
||||
private static final int COLS = 6;
|
||||
private static final int FREE_LINES = 6;
|
||||
|
||||
public static final String DONORS = "6_eA02mFU3XMJYceJdotTlPGzS6YgH0ylZFbdo3X7Mo0347DLH8jYjmdkzS0GG5q3HqzvlQT7lSRwI-Y"
|
||||
+ "AztxfXdHbh_c-7d6K0m4FPw_hePj_hS7Zwa_zqxZk-ioVNvpXqL918Z8CYV51XeoyFvcECytZOzUUWOi"
|
||||
+ "eUgdwBxsVvUkikvULOLPkbkrJf-kK3UsOexfygF0XLEm4rJHe91ZEfLp7GvLZVBgWQyjDCYaSEUtystN"
|
||||
+ "P5QCVeYKJ6riGKPlZD2TazOloOACsd_K9z2YOxgcH2u9nTPB93h_h7HuMK3tQoI-0iaG2pODpA6K8pf1"
|
||||
+ "iNCZXYGfWeREKOp6rX_PyYG4GnvQs8T_r9CZxYcPCGmjafHhe23ZPXo0j4hTcd2skXbGdITR36kIgelZ"
|
||||
+ "8Tnt7AQdd3feU0GiKYoe1QeXo9lG2P_ciruokFIBeeQ__3R9jLa2r5ss1DWtC_eM7aqIvNzwromGTvMo"
|
||||
+ "UKfZgTVU7sDto5rJPXx-Hs-Zb2suryr22XOlBO0VWPwhYKhoyrVMZOKuX6ifVI5TvxOhrr64IpPag5YN"
|
||||
+ "psB9QyuTNN9ZqsAP3XRZ4_ovs8GCjD2LojNG3LfrsQtpXPBKrBX-oAj3-tN0DNLczuxHUY-Ri_p_8gpC"
|
||||
+ "Z8e3TBh4AEX6GC4SJQkXOW4Hc1QwEkGcG2v0kPhSYjNgG_pQ9mZUJ7eW2XiXFH2lFvURN8Gm3MkwFSKC"
|
||||
+ "OFgGKYT9seG8JTe4FOagnKXPXDuEavPXqyRKTT86ZzC6On37T5nz4ZvR2Dp2i4urcft5skSOGt2BxsK-"
|
||||
+ "FUz36LVndMxXFUz9QloG0JlJWXwHAYFgorBsad3JG64MRyb9GtnNsCx5G_S5vvaisi3CsUOuP3PKBYMf"
|
||||
+ "gNzY-A59zxS2MTjURKNUWFGIc8GmCxh1wQt98pMvH98qdEd4s04WgnQVs6-AS6TGTSlBpk8wXCaZLYz2"
|
||||
+ "Xlmk-GIMAhhmT65xT_VZ6SEZo3wSzyAigN7fKdmieERi9YXA2wLwIb6apGaov5Y3dlNMmFQxEXR8rc_L"
|
||||
+ "iEbGUDj4fvKRJ4mXmrMY_sYqI3GguXAz-2GnWB_nyfHwnbW77T_XPODnWAmX2O4gZER8WTFIMDswbh7U"
|
||||
+ "ely_QsspSlxytskooAaddl6g0kWECk8_I57dw6BM3RmDyzNOC0VOO0OJtTdXoWDBxmOI5kp3EwkeAzEC"
|
||||
+ "v4eCbbkKYrPnVAYwhtGFBcP3R5XnKKnHT9_YfBLD8wWKs_Tz4KvoOCv_YYgpKhWgTMfYn8JOxb6SmjXx"
|
||||
+ "ByLTrwn0W-guJE3jgTUtYsckqkTuGQbXk0RafoDooAPvQ45DJPlwH62R6EjxSziXcUQ_IOz-YjREVbOF"
|
||||
+ "GplRlybLeE7R7qAxeISOBX8t3F2xnvpSmCqt5FB6r1rbkPYsSz4zmouHhB3Vz5ra8U6LPQqo4SRSt5ek"
|
||||
+ "F2t4Czk67Bo5xDFLAFg2g2fk80SMctKEOb4fnoDI98Nc72sR4v6s0m00";
|
||||
public static final String DONORS = "6nmB0AmFkBcp0hHmgCOwx9qzUsNuYPYXIV3upfH_WeHti04o13LNIRGeSf_iNWC41T0rTFIOstTwt6-a"
|
||||
+ "luYkTE-RPaHR_fhZvnb3CH3qUFww6hRvtnuyvfxff-Ixcz4JPiBaVmA4fYcNj0L8bI6ba87tDyDvlcaC"
|
||||
+ "lVGCM1vLFqNtjV-xT9LrzwfEcBReReNpfn6gCqUZc6Ew_wF0XIZO2QfeKCWndSgv3eUg3dAs4trL54X2"
|
||||
+ "nJk_dTzsJLR5P2wH4gkDRSICpe3kdFH-IGvajFwZVe0F7TCr9RWd59TU8kZyizhXPG73hv7uDHGEiU38"
|
||||
+ "m1nAEoesA6Lk91J22L3eNCLiRFt1aITUM5H12_lmZqPou9wIh65eKOXu00Knp-02IM_KhKdEJXq6LEUP"
|
||||
+ "BOOrITUjyH3fcuU95AsBXll18iA2Ma0DGzw4RlXqd_MIeNk_A1huos-JNBlbG1so9K3RhEXRU3H9LF-d"
|
||||
+ "csUUkCkKpLEQZdhj_J5sXzmrPURqFteVXLp0SsuMKcJnyWBvCUYvcgWbFvVpO24DuJfANqZtkUtYCOjm"
|
||||
+ "oOOCDUlopIoZHb_iIdGsBSPsif0Vy-TM4n9iuQkKHw0djUfeqVb28JKrhX_oUcg_3d9DdGNUCLeV5NEL"
|
||||
+ "_r-4LPYXE46douoYhb-e6BDvDLGiKGHdZ2uFkGaa5-1SJMx7QlKXVkqJH6yb8n3Bng07ulMlbIwNGbWT"
|
||||
+ "wxezpGfW-R1IDuMeBGAQj1jw4bVoaR88lHqcZMKpnj9pqWOVfut6A4xejCOcShCGfCkmJbNDT8dsEQrX"
|
||||
+ "U3M_b_dql1_9UHNNwIRlUH_IwoSPg3Cjw9XK6l5ObhANHBe6gipYB7NL4DyLjlFmq7t1UHQBDZ1pjhaE"
|
||||
+ "MHOQ5vBKr3yn-Q59npj9sQnzjHLx1_4lWtc8P4OHND-UF5AJonJ2bZET09j0LAh59_PRqhWpg8VbP7Eu"
|
||||
+ "3c7beTMBa2I_Ipv1hAfOE5rO6-v-UOOW2lR9UI_CsXgNBYNN0chE7eAyj51LJocEj3b91kQQzAot3hRV"
|
||||
+ "rRd0jtwhZcr0yPqGdTRSO7CAZ3HHVb6WHDAGbV9BJn8J-5y_Jxb7vZha-2ul6na7oIb93Ac2TCSlN3sD"
|
||||
+ "rSlG2jPR_FsprZOhvy__lIOhEVN4irvD41qWed-J0hYSqnZ1sy1VjuyaRqxCi57GsEJAWrel0ea8zk6T"
|
||||
+ "NTIJoupy8aQMMvIBLd5zgBgluXwvM0snOUiYd-BeFiMLrZODKILZt_T5kCZ1EFyjginAuQgMriA8JR7T"
|
||||
+ "ipYviLilnTFMRY23whX3uEoft-wckKgVwmjBJSFJH7uwa4EskaiBQthQD3O3syJOtrlR3acw_oOT_v9U"
|
||||
+ "q_sk7ePsTlucJuF6RtSO_OQHO41axPXWjymvYS2JRoJaZNauoUrYwPEBxYcxKB32VjClayM4LrQqoaIq"
|
||||
+ "vkRMS-vj8Svk6tFO5hPFLwFu5qKr4O5CBZRhdiH2AU21L9A2EMVBL86qdIPDymc9Inq0";
|
||||
|
||||
/*
|
||||
* Special thanks to our sponsors and donors:
|
||||
|
@ -68,7 +68,7 @@ public class GraphicsPath {
|
||||
}
|
||||
|
||||
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 Graphics2D g2d = builder.getGraphics2D();
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class PSystemWelcome extends AbstractPSystem {
|
||||
strings.add(" ");
|
||||
strings.add("\"\"class Example\"\"");
|
||||
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) {
|
||||
strings.add(" ");
|
||||
strings.add(" ");
|
||||
|
@ -330,7 +330,7 @@ public class EpsGraphics {
|
||||
|
||||
public void epsPolygon(HColorGradient gr, ColorMapper mapper, double... points) {
|
||||
assert points.length % 2 == 0;
|
||||
setFillColor(mapper.getMappedColor(gr.getColor1()));
|
||||
setFillColor(mapper.toColor(gr.getColor1()));
|
||||
epsPolygon(points);
|
||||
}
|
||||
|
||||
@ -410,8 +410,8 @@ public class EpsGraphics {
|
||||
|
||||
if (rx == 0 && ry == 0) {
|
||||
simplerectUsed = true;
|
||||
appendColorShort(mapper.getMappedColor(gr.getColor1()));
|
||||
appendColorShort(mapper.getMappedColor(gr.getColor2()));
|
||||
appendColorShort(mapper.toColor(gr.getColor1()));
|
||||
appendColorShort(mapper.toColor(gr.getColor2()));
|
||||
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y), true);
|
||||
append("100 -1 1 {", true);
|
||||
append("100 div", true);
|
||||
@ -433,8 +433,8 @@ public class EpsGraphics {
|
||||
append("initclip", true);
|
||||
} else {
|
||||
roundrectUsed = true;
|
||||
appendColorShort(mapper.getMappedColor(gr.getColor1()));
|
||||
appendColorShort(mapper.getMappedColor(gr.getColor2()));
|
||||
appendColorShort(mapper.toColor(gr.getColor1()));
|
||||
appendColorShort(mapper.toColor(gr.getColor2()));
|
||||
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " "
|
||||
+ format((rx + ry) / 2), true);
|
||||
append("100 -1 1 {", true);
|
||||
|
@ -65,9 +65,9 @@ class EntityImageActivityBranch extends AbstractEntityImage {
|
||||
p.addPoint(size, size * 2);
|
||||
p.addPoint(0, size);
|
||||
|
||||
g2d.setColor(colorMapper.getMappedColor(getYellow()));
|
||||
g2d.setColor(colorMapper.toColor(getYellow()));
|
||||
g2d.fill(p);
|
||||
g2d.setColor(colorMapper.getMappedColor(getRed()));
|
||||
g2d.setColor(colorMapper.toColor(getRed()));
|
||||
g2d.draw(p);
|
||||
}
|
||||
}
|
||||
|
@ -47,28 +47,34 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||
|
||||
public class HtmlColorAndStyle {
|
||||
|
||||
private final HColor color;
|
||||
private final HColor arrowHeadColor;
|
||||
private final HColor arrowColor;
|
||||
private final LinkStyle style;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return color + " " + style;
|
||||
return arrowColor + " " + style;
|
||||
}
|
||||
|
||||
public HtmlColorAndStyle(HColor color) {
|
||||
this(color, LinkStyle.NORMAL());
|
||||
public HtmlColorAndStyle(HColor color, HColor arrowHeadColor) {
|
||||
this(color, LinkStyle.NORMAL(), arrowHeadColor);
|
||||
}
|
||||
|
||||
public HtmlColorAndStyle(HColor color, LinkStyle style) {
|
||||
if (color == null) {
|
||||
public HtmlColorAndStyle(HColor arrowColor, LinkStyle style, HColor arrowHeadColor) {
|
||||
if (arrowColor == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.color = color;
|
||||
this.arrowHeadColor = arrowHeadColor;
|
||||
this.arrowColor = arrowColor;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public HColor getColor() {
|
||||
return color;
|
||||
public HColor getArrowColor() {
|
||||
return arrowColor;
|
||||
}
|
||||
|
||||
public HColor getArrowHeadColor() {
|
||||
return arrowHeadColor;
|
||||
}
|
||||
|
||||
public LinkStyle getStyle() {
|
||||
@ -80,12 +86,14 @@ public class HtmlColorAndStyle {
|
||||
}
|
||||
|
||||
public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) {
|
||||
HColor color;
|
||||
HColor arrowColor;
|
||||
HColor arrowHeadColor = null;
|
||||
if (SkinParam.USE_STYLES()) {
|
||||
final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||
color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
|
||||
arrowColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
|
||||
} 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();
|
||||
final HColorSet set = skinParam.getIHtmlColorSet();
|
||||
@ -97,10 +105,10 @@ public class HtmlColorAndStyle {
|
||||
}
|
||||
final HColor tmpColor = set.getColorIfValid(s);
|
||||
if (tmpColor != null) {
|
||||
color = tmpColor;
|
||||
arrowColor = tmpColor;
|
||||
}
|
||||
}
|
||||
return new HtmlColorAndStyle(color, style);
|
||||
return new HtmlColorAndStyle(arrowColor, style, arrowHeadColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,28 +67,28 @@ public class Rainbow {
|
||||
public static Rainbow none() {
|
||||
return new Rainbow(0);
|
||||
}
|
||||
|
||||
public static Rainbow fromColor(HColor color) {
|
||||
if (color == null) {
|
||||
|
||||
public static Rainbow fromColor(HColor arrowColor, HColor arrowHeadColor) {
|
||||
if (arrowColor == null) {
|
||||
return Rainbow.none();
|
||||
}
|
||||
return Rainbow.build(new HtmlColorAndStyle(color));
|
||||
return Rainbow.build(new HtmlColorAndStyle(arrowColor, arrowHeadColor));
|
||||
}
|
||||
|
||||
public static Rainbow build(ISkinParam skinParam) {
|
||||
if (SkinParam.USE_STYLES()) {
|
||||
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) {
|
||||
final HColor color = style.value(PName.LineColor).asColor(set);
|
||||
return fromColor(color);
|
||||
return fromColor(color, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Rainbow withDefault(Rainbow defaultColor) {
|
||||
if (this.size() == 0) {
|
||||
return defaultColor;
|
||||
@ -130,7 +130,7 @@ public class Rainbow {
|
||||
}
|
||||
|
||||
public HColor getColor() {
|
||||
return colors.get(0).getColor();
|
||||
return colors.get(0).getArrowColor();
|
||||
}
|
||||
|
||||
public int getColorArrowSeparationSpace() {
|
||||
|
@ -67,13 +67,13 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
|
||||
public class TextBlockUtils {
|
||||
|
||||
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor,
|
||||
HColor backgroundColor, double cornersize) {
|
||||
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, HColor backgroundColor,
|
||||
double cornersize) {
|
||||
return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize);
|
||||
}
|
||||
|
||||
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor,
|
||||
HColor backgroundColor, double cornersize, double marginX, double marginY) {
|
||||
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, HColor backgroundColor,
|
||||
double cornersize, double marginX, double 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());
|
||||
// }
|
||||
|
||||
public static MinMax getMinMax(TextBlock tb, StringBounder stringBounder) {
|
||||
final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
|
||||
public static MinMax getMinMax(UDrawable tb, StringBounder stringBounder, boolean initToZero) {
|
||||
final LimitFinder limitFinder = new LimitFinder(stringBounder, initToZero);
|
||||
tb.drawU(limitFinder);
|
||||
return limitFinder.getMinMax();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PSystemLogo extends AbstractPSystem {
|
||||
throws IOException {
|
||||
final int width = 640;
|
||||
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 UGraphic ug = new UGraphicG2d(new ColorMapperIdentity(), builder.getGraphics2D(), 1.0);
|
||||
((UGraphicG2d) ug).setBufferedImage(im);
|
||||
@ -82,7 +82,8 @@ public class PSystemLogo extends AbstractPSystem {
|
||||
|
||||
// private GraphicStrings getGraphicStrings() throws IOException {
|
||||
// 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,
|
||||
// GraphicPosition.BOTTOM, false);
|
||||
// result.setMinWidth(200);
|
||||
|
@ -111,7 +111,7 @@ public class PSystemMath extends AbstractPSystem {
|
||||
|
||||
private Color getColor(final String col) {
|
||||
final HColor col2 = HColorSet.instance().getColorIfValid(col);
|
||||
final Color col3 = new ColorMapperIdentity().getMappedColor(col2);
|
||||
final Color col3 = new ColorMapperIdentity().toColor(col2);
|
||||
return col3;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class MindMapDiagram extends UmlDiagram {
|
||||
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
|
||||
final ISkinParam skinParam = getSkinParam();
|
||||
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());
|
||||
TextBlock result = getTextBlock();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
package net.sourceforge.plantuml.nwdiag;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
@ -45,8 +46,11 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.AnnotatedWorker;
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.Scale;
|
||||
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||
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.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.InnerStrategy;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||
import net.sourceforge.plantuml.ugraphic.UEmpty;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
@ -176,19 +184,38 @@ public class NwDiagram extends UmlDiagram {
|
||||
final Scale scale = getScale();
|
||||
|
||||
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,
|
||||
null, false);
|
||||
final UDrawable result = getUDrawable();
|
||||
TextBlock result = getTextBlock();
|
||||
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result);
|
||||
imageBuilder.setUDrawable(result);
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os);
|
||||
}
|
||||
|
||||
private UDrawable getUDrawable() {
|
||||
return new UDrawable() {
|
||||
private TextBlockBackcolored getTextBlock() {
|
||||
return new TextBlockBackcolored() {
|
||||
public void drawU(UGraphic 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);
|
||||
}
|
||||
|
||||
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) {
|
||||
final double margin = 5;
|
||||
ug = ug.apply(new UTranslate(margin, margin));
|
||||
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
@ -252,12 +288,11 @@ public class NwDiagram extends UmlDiagram {
|
||||
deltaX += 5;
|
||||
|
||||
grid.drawU(ug.apply(ColorParam.activityBorder.getDefaultValue())
|
||||
.apply(ColorParam.activityBackground.getDefaultValue().bg())
|
||||
.apply(new UTranslate(deltaX, deltaY)));
|
||||
.apply(ColorParam.activityBackground.getDefaultValue().bg()).apply(new UTranslate(deltaX, deltaY)));
|
||||
final Dimension2D dimGrid = grid.calculateDimension(stringBounder);
|
||||
|
||||
ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin)).draw(
|
||||
new UEmpty(1, 1));
|
||||
ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin))
|
||||
.draw(new UEmpty(1, 1));
|
||||
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,11 @@ public class PostItDiagram extends UmlDiagram {
|
||||
|
||||
private UGraphic createImage(FileFormatOption fileFormatOption) {
|
||||
final Color backColor = getSkinParam().getColorMapper()
|
||||
.getMappedColor(this.getSkinParam().getBackgroundColor());
|
||||
.toColor(this.getSkinParam().getBackgroundColor(false));
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
if (fileFormat == FileFormat.PNG) {
|
||||
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 double dpiFactor = this.getScaleCoef(fileFormatOption);
|
||||
|
@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.CommandNope;
|
||||
import net.sourceforge.plantuml.command.CommandScale;
|
||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
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.CommandGanttArrow2;
|
||||
import net.sourceforge.plantuml.project.command.CommandPage;
|
||||
@ -87,6 +88,7 @@ public class GanttDiagramFactory extends UmlDiagramFactory {
|
||||
cmds.addAll(getLanguageCommands());
|
||||
cmds.add(new CommandGanttArrow());
|
||||
cmds.add(new CommandGanttArrow2());
|
||||
cmds.add(new CommandColorTask());
|
||||
cmds.add(new CommandSeparator());
|
||||
|
||||
cmds.add(new CommandPrintScale());
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -54,7 +54,9 @@ public class CommandPrintScale extends SingleLineCommand2<GanttDiagram> {
|
||||
|
||||
static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandPrintScale.class.getName(), RegexLeaf.start(), //
|
||||
new RegexLeaf("printscale"), //
|
||||
new RegexOr(new RegexLeaf("projectscale"), //
|
||||
new RegexLeaf("ganttscale"), //
|
||||
new RegexLeaf("printscale")), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexOr("SCALE", //
|
||||
new RegexLeaf("monthly"), //
|
||||
|
@ -92,7 +92,7 @@ public class LinkAnchor {
|
||||
final double ymax = Math.max(y1, y2);
|
||||
|
||||
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 Display display = Display.getWithNewlines(message);
|
||||
|
@ -75,7 +75,7 @@ public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
|
||||
final HColor backColorElement = diagram.getSkinParam().getIHtmlColorSet()
|
||||
.getColorIfValid(arg.get("COLORS", 0));
|
||||
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);
|
||||
final GroupingType groupingType = GroupingType.getType(type);
|
||||
if ("group".equals(type)) {
|
||||
|
@ -70,7 +70,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
|
||||
if (SkinParam.USE_STYLES()) {
|
||||
if (spriteContainer instanceof SkinParamBackcolored) {
|
||||
style = style.eventuallyOverride(PName.BackGroundColor,
|
||||
((SkinParamBackcolored) spriteContainer).getBackgroundColor());
|
||||
((SkinParamBackcolored) spriteContainer).getBackgroundColor(false));
|
||||
}
|
||||
this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet());
|
||||
this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
|
@ -243,14 +243,14 @@ public class Rose {
|
||||
smallFont = smallFont.changeColor(smallColor);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (type == ComponentType.GROUPING_ELSE) {
|
||||
return new ComponentRoseGroupingElse(styles == null ? null : styles[0],
|
||||
getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder),
|
||||
getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param,
|
||||
param.getBackgroundColor());
|
||||
param.getBackgroundColor(true));
|
||||
}
|
||||
if (type == ComponentType.GROUPING_SPACE) {
|
||||
return new ComponentRoseGroupingSpace(7);
|
||||
|
@ -61,6 +61,9 @@ public class StatsUtilsIncrement {
|
||||
final private static FormatCounter formatCounterEver = StatsUtils.formatCounterEver;
|
||||
|
||||
public static void onceMoreParse(long duration, Class<? extends Diagram> type) {
|
||||
if (StatsUtils.fullEver == null || StatsUtils.historicalData == null) {
|
||||
return;
|
||||
}
|
||||
getByTypeCurrent(type).parsed().addValue(duration);
|
||||
final ParsedGenerated byTypeEver = getByTypeEver(type);
|
||||
byTypeEver.parsed().addValue(duration);
|
||||
@ -74,6 +77,12 @@ public class StatsUtilsIncrement {
|
||||
}
|
||||
|
||||
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);
|
||||
final ParsedGenerated byTypeEver = getByTypeEver(type);
|
||||
byTypeEver.generated().addValue(duration);
|
||||
|
@ -102,7 +102,7 @@ public class GraphicsSudoku {
|
||||
}
|
||||
|
||||
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 Graphics2D g3d = builder.getGraphics2D();
|
||||
|
||||
|
@ -56,7 +56,6 @@ import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.SkinParam;
|
||||
import net.sourceforge.plantuml.SkinParamUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
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.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
import net.sourceforge.plantuml.utils.UniqueSequence;
|
||||
|
||||
public class Cluster implements Moveable {
|
||||
@ -757,7 +757,7 @@ public class Cluster implements Moveable {
|
||||
}
|
||||
sb.append("subgraph " + getClusterId() + " {");
|
||||
sb.append("style=solid;");
|
||||
sb.append("color=\"" + StringUtils.getAsHtml(color) + "\";");
|
||||
sb.append("color=\"" + DotStringFactory.sharp000000(color) + "\";");
|
||||
|
||||
final String label;
|
||||
if (isLabel()) {
|
||||
@ -889,8 +889,8 @@ public class Cluster implements Moveable {
|
||||
if (backColor == null) {
|
||||
backColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
|
||||
}
|
||||
if (backColor == null /* || stateBack instanceof HtmlColorTransparent */) {
|
||||
backColor = new HColorBackground(skinParam.getBackgroundColor());
|
||||
if (backColor == null || backColor.equals(HColorUtils.transparent()) /* || stateBack instanceof HtmlColorTransparent */) {
|
||||
backColor = new HColorBackground(skinParam.getBackgroundColor(true));
|
||||
}
|
||||
return backColor;
|
||||
}
|
||||
@ -900,8 +900,8 @@ public class Cluster implements Moveable {
|
||||
if (backColor == null) {
|
||||
backColor = skinParam.getHtmlColor(ColorParam.background, stereotype, false);
|
||||
}
|
||||
if (backColor == null /* || stateBack instanceof HtmlColorTransparent */) {
|
||||
backColor = new HColorBackground(skinParam.getBackgroundColor());
|
||||
if (backColor == null || backColor.equals(HColorUtils.transparent()) /* || stateBack instanceof HtmlColorTransparent */) {
|
||||
backColor = new HColorBackground(skinParam.getBackgroundColor(true));
|
||||
}
|
||||
return backColor;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public final class ConcurrentStateImage extends AbstractTextBlock implements IEn
|
||||
HColor backColor) {
|
||||
this.separator = Separator.fromChar(concurrentSeparator);
|
||||
this.skinParam = skinParam;
|
||||
this.backColor = skinParam.getBackgroundColor();
|
||||
this.backColor = skinParam.getBackgroundColor(false);
|
||||
this.inners.addAll(images);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBl
|
||||
}
|
||||
|
||||
public HColor getBackcolor() {
|
||||
return skinParam.getBackgroundColor();
|
||||
return skinParam.getBackgroundColor(false);
|
||||
}
|
||||
|
||||
public double getOverscanX(StringBounder stringBounder) {
|
||||
|
@ -454,7 +454,7 @@ public class DotStringFactory implements Moveable {
|
||||
}
|
||||
|
||||
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 + "\"";
|
||||
int idx = svg.indexOf(keyTitle1);
|
||||
if (idx == -1) {
|
||||
@ -467,6 +467,20 @@ public class DotStringFactory implements Moveable {
|
||||
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,
|
||||
IGroup g) {
|
||||
this.current = current.createChild(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo,
|
||||
|
@ -51,7 +51,6 @@ import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.Pragma;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.command.Position;
|
||||
@ -246,7 +245,7 @@ public class Line implements Moveable, Hideable {
|
||||
skinParam = link.getColors().mute(skinParam);
|
||||
labelFont = labelFont.mute(link.getColors());
|
||||
}
|
||||
this.backgroundColor = skinParam.getBackgroundColor();
|
||||
this.backgroundColor = skinParam.getBackgroundColor(false);
|
||||
this.defaultThickness = skinParam.getThickness(LineParam.arrow, null);
|
||||
this.arrowLollipopColor = skinParam.getHtmlColor(ColorParam.arrowLollipop, null, false);
|
||||
if (arrowLollipopColor == null) {
|
||||
@ -405,7 +404,7 @@ public class Line implements Moveable, Hideable {
|
||||
sb.append("minlen=" + (length - 1));
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\"");
|
||||
sb.append("color=\"" + DotStringFactory.sharp000000(lineColor) + "\"");
|
||||
if (labelText != null || link.getLinkConstraint() != null) {
|
||||
sb.append(",");
|
||||
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) {
|
||||
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("<TR");
|
||||
sb.append(">");
|
||||
|
@ -42,7 +42,6 @@ import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.Hideable;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
|
||||
import net.sourceforge.plantuml.cucadiagram.IGroup;
|
||||
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
||||
@ -155,7 +154,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
|
||||
sb.append(",");
|
||||
sb.append("height=" + SvekUtils.pixelToInches(getHeight()));
|
||||
sb.append(",");
|
||||
sb.append("color=\"" + StringUtils.getAsHtml(color) + "\"");
|
||||
sb.append("color=\"" + DotStringFactory.sharp000000(color) + "\"");
|
||||
sb.append("];");
|
||||
SvekUtils.println(sb);
|
||||
}
|
||||
@ -182,7 +181,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
|
||||
sb.append("</TR>");
|
||||
sb.append("<TR>");
|
||||
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(" PORT=\"h\">");
|
||||
sb.append("</TD>");
|
||||
@ -204,7 +203,7 @@ public class Node implements Positionable, IShapePseudo, Hideable {
|
||||
sb.append("shape=plaintext,");
|
||||
// sb.append("color=\"" + StringUtils.getAsHtml(color) + "\",");
|
||||
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\">");
|
||||
double position = 0;
|
||||
for (Map.Entry<String, PortGeometry> ent : ports.getAllWithEncodedPortId().entrySet()) {
|
||||
|
@ -137,7 +137,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage,
|
||||
}
|
||||
|
||||
public HColor getBackcolor() {
|
||||
return dotData.getSkinParam().getBackgroundColor();
|
||||
return dotData.getSkinParam().getBackgroundColor(false);
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
|
@ -73,17 +73,17 @@ public class SvgResult {
|
||||
}
|
||||
|
||||
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);
|
||||
if (idx != -1) {
|
||||
return idx;
|
||||
}
|
||||
s = ";stroke:" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + ";";
|
||||
s = ";stroke:" + StringUtils.goLowerCase(DotStringFactory.sharp000000(color)) + ";";
|
||||
idx = svg.indexOf(s);
|
||||
if (idx != -1) {
|
||||
return idx;
|
||||
}
|
||||
s = "fill=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
|
||||
s = "fill=\"" + StringUtils.goLowerCase(DotStringFactory.sharp000000(color)) + "\"";
|
||||
idx = svg.indexOf(s);
|
||||
if (idx != -1) {
|
||||
return idx;
|
||||
|
@ -175,8 +175,8 @@ public class SvgGraphics {
|
||||
private Element pendingBackground;
|
||||
|
||||
public void paintBackcolorGradient(ColorMapper mapper, HColorGradient gr) {
|
||||
final String id = createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
|
||||
StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
|
||||
final String id = createSvgGradient(mapper.toHtml(gr.getColor1()),
|
||||
mapper.toHtml(gr.getColor2()), gr.getPolicy());
|
||||
setFillColor("url(#" + id + ")");
|
||||
setStrokeColor(null);
|
||||
pendingBackground = createRectangleInternal(0, 0, 0, 0);
|
||||
|
@ -44,20 +44,25 @@ import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.graphic.color.Colors;
|
||||
import net.sourceforge.plantuml.timingdiagram.graphic.PlayerFrame;
|
||||
|
||||
public abstract class Player implements TimeProjected {
|
||||
|
||||
protected final ISkinParam skinParam;
|
||||
protected final TimingRuler ruler;
|
||||
private final boolean compact;
|
||||
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.compact = compact;
|
||||
this.ruler = ruler;
|
||||
this.title = Display.getWithNewlines(title);
|
||||
}
|
||||
|
||||
public boolean isCompact() {
|
||||
return compact;
|
||||
}
|
||||
|
||||
final protected FontConfiguration getFontConfiguration() {
|
||||
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 PlayerFrame getPlayerFrame();
|
||||
|
||||
public abstract TextBlock getPart1();
|
||||
public abstract TextBlock getPart1(double fullAvailableWidth, double specialVSpace);
|
||||
|
||||
public abstract UDrawable getPart2();
|
||||
|
||||
public abstract double getFullHeight(StringBounder stringBounder);
|
||||
|
||||
// public abstract void drawFrameTitle(UGraphic ug);
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
package net.sourceforge.plantuml.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
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.color.Colors;
|
||||
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.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
@ -62,21 +61,26 @@ public class PlayerBinary extends Player {
|
||||
|
||||
private static final int HEIGHT = 30;
|
||||
private final SortedMap<TimeTick, Boolean> values = new TreeMap<TimeTick, Boolean>();
|
||||
private Boolean initialState;
|
||||
|
||||
public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler) {
|
||||
super(code, skinParam, ruler);
|
||||
public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact) {
|
||||
super(code, skinParam, ruler, compact);
|
||||
}
|
||||
|
||||
public double getFullHeight(StringBounder stringBounder) {
|
||||
return HEIGHT;
|
||||
}
|
||||
|
||||
public void drawFrameTitle(UGraphic ug) {
|
||||
}
|
||||
|
||||
private SymbolContext getContext() {
|
||||
return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5));
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -89,7 +93,11 @@ public class PlayerBinary extends Player {
|
||||
|
||||
public void setState(TimeTick now, String comment, Colors color, String... states) {
|
||||
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) {
|
||||
@ -102,15 +110,11 @@ public class PlayerBinary extends Player {
|
||||
|
||||
private final double ymargin = 8;
|
||||
|
||||
public PlayerFrame getPlayerFrame() {
|
||||
return new PlayerFrameEmpty();
|
||||
}
|
||||
|
||||
private double getYpos(boolean state) {
|
||||
return state ? ymargin : HEIGHT - ymargin;
|
||||
}
|
||||
|
||||
public TextBlock getPart1() {
|
||||
public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
|
||||
return new AbstractTextBlock() {
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
@ -133,7 +137,7 @@ public class PlayerBinary extends Player {
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = getContext().apply(ug);
|
||||
double lastx = 0;
|
||||
boolean lastValue = false;
|
||||
boolean lastValue = initialState == null ? false : initialState;
|
||||
for (Map.Entry<TimeTick, Boolean> ent : values.entrySet()) {
|
||||
final double x = ruler.getPosInPixel(ent.getKey());
|
||||
ug.apply(new UTranslate(lastx, getYpos(lastValue))).draw(ULine.hline(x - lastx));
|
||||
|
@ -46,8 +46,6 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.graphic.color.Colors;
|
||||
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.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
@ -58,9 +56,10 @@ public class PlayerClock extends Player {
|
||||
|
||||
private final int period;
|
||||
private final int pulse;
|
||||
private final double ymargin = 8;
|
||||
|
||||
public PlayerClock(ISkinParam skinParam, TimingRuler ruler, int period, int pulse) {
|
||||
super("", skinParam, ruler);
|
||||
public PlayerClock(ISkinParam skinParam, TimingRuler ruler, int period, int pulse, boolean compact) {
|
||||
super("", skinParam, ruler, compact);
|
||||
this.period = period;
|
||||
this.pulse = pulse;
|
||||
}
|
||||
@ -69,6 +68,9 @@ public class PlayerClock extends Player {
|
||||
return 30;
|
||||
}
|
||||
|
||||
public void drawFrameTitle(UGraphic ug) {
|
||||
}
|
||||
|
||||
private SymbolContext getContext() {
|
||||
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();
|
||||
}
|
||||
|
||||
private final double ymargin = 8;
|
||||
|
||||
public PlayerFrame getPlayerFrame() {
|
||||
return new PlayerFrameEmpty();
|
||||
}
|
||||
|
||||
private double getPulseCoef() {
|
||||
if (pulse == 0) {
|
||||
return 0.5;
|
||||
@ -110,7 +106,7 @@ public class PlayerClock extends Player {
|
||||
return period;
|
||||
}
|
||||
|
||||
public TextBlock getPart1() {
|
||||
public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,8 @@ import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.graphic.color.Colors;
|
||||
import net.sourceforge.plantuml.timingdiagram.graphic.Histogram;
|
||||
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.PlayerFrame2;
|
||||
import net.sourceforge.plantuml.timingdiagram.graphic.Ribbon;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
@ -68,38 +67,38 @@ public final class PlayerRobustConcise extends Player {
|
||||
private final TimingStyle type;
|
||||
|
||||
private String initialState;
|
||||
private PlayerDrawing cached;
|
||||
private PDrawing cached;
|
||||
private Colors initialColors;
|
||||
|
||||
public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler) {
|
||||
super(full, skinParam, ruler);
|
||||
public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler,
|
||||
boolean compact) {
|
||||
super(full, skinParam, ruler, compact);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private PlayerDrawing buildPlayerDrawing() {
|
||||
private PDrawing buildPDrawing() {
|
||||
if (type == TimingStyle.CONCISE) {
|
||||
return new Ribbon(ruler, skinParam, notes);
|
||||
return new Ribbon(ruler, skinParam, notes, isCompact(), getTitle());
|
||||
}
|
||||
if (type == TimingStyle.ROBUST) {
|
||||
return new Histogram(ruler, skinParam, statesLabel.values());
|
||||
return new Histogram(ruler, skinParam, statesLabel.values(), isCompact(), getTitle());
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public final PlayerFrame getPlayerFrame() {
|
||||
return new PlayerFrame2(getTitle());
|
||||
}
|
||||
|
||||
public final TextBlock getPart1() {
|
||||
public final TextBlock getPart1(final double fullAvailableWidth, final double specialVSpace) {
|
||||
return new AbstractTextBlock() {
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder()));
|
||||
getTimeDrawing().getPart1().drawU(ug);
|
||||
if (isCompact() == false) {
|
||||
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) {
|
||||
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) {
|
||||
if (isCompact()) {
|
||||
return 6;
|
||||
}
|
||||
return getTitle().calculateDimension(stringBounder).getHeight() + 6;
|
||||
}
|
||||
|
||||
private PlayerDrawing getTimeDrawing() {
|
||||
private PDrawing getTimeDrawing() {
|
||||
if (cached == null) {
|
||||
cached = computeTimeDrawing();
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
private PlayerDrawing computeTimeDrawing() {
|
||||
final PlayerDrawing result = buildPlayerDrawing();
|
||||
private PDrawing computeTimeDrawing() {
|
||||
final PDrawing result = buildPDrawing();
|
||||
result.setInitialState(initialState, initialColors);
|
||||
for (ChangeState change : changes) {
|
||||
result.addChange(change);
|
||||
|
@ -85,6 +85,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
private TimeTick now;
|
||||
private Player lastPlayer;
|
||||
private boolean drawTimeAxis = true;
|
||||
private boolean compactByDefault = false;
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
return new DiagramDescription("(Timing Diagram)");
|
||||
@ -142,22 +143,36 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
private void drawInternal(UGraphic ug) {
|
||||
ruler.ensureNotEmpty();
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
final UTranslate beforeRuler = UTranslate.dx(getPart1MaxWidth(stringBounder));
|
||||
drawBorder(ug);
|
||||
|
||||
final double part1MaxWidth = getPart1MaxWidth(stringBounder);
|
||||
final UTranslate widthPart1 = UTranslate.dx(part1MaxWidth);
|
||||
if (compactByDefault == false) {
|
||||
drawBorder(ug);
|
||||
}
|
||||
ug = ug.apply(UTranslate.dx(marginX1));
|
||||
|
||||
drawHighlightsBack(ug.apply(beforeRuler));
|
||||
ruler.draw0(ug.apply(beforeRuler), getHeightInner(stringBounder));
|
||||
drawHighlightsBack(ug.apply(widthPart1));
|
||||
ruler.draw0(ug.apply(widthPart1), getHeightInner(stringBounder));
|
||||
boolean first = true;
|
||||
|
||||
for (Player player : players.values()) {
|
||||
drawHorizontalSeparator(ug.apply(getUTranslateForFrame(player, stringBounder)));
|
||||
player.getPlayerFrame().drawFrameTitle(ug.apply(getUTranslateForFrame(player, stringBounder)));
|
||||
final UGraphic ug2 = ug.apply(getUTranslateForPlayer(player, stringBounder));
|
||||
player.getPart2().drawU(ug2.apply(beforeRuler));
|
||||
player.getPart1().drawU(ug2);
|
||||
final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder));
|
||||
final double caption = getHeightForCaptions(stringBounder);
|
||||
if (first) {
|
||||
if (player.isCompact() == false) {
|
||||
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) {
|
||||
ruler.drawTimeAxis(ug.apply(getLastTranslate(stringBounder)));
|
||||
}
|
||||
@ -188,7 +203,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
}
|
||||
|
||||
private UTranslate getLastTranslate(final StringBounder stringBounder) {
|
||||
return getUTranslateForPlayer(null, stringBounder);
|
||||
return getUTranslateForPlayer(null, stringBounder).compose(UTranslate.dy(getHeightForCaptions(stringBounder)));
|
||||
}
|
||||
|
||||
private void drawHighlightsBack(UGraphic ug) {
|
||||
@ -215,7 +230,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
return getLastTranslate(stringBounder).getDy();
|
||||
}
|
||||
|
||||
private double getHeightHighlights(StringBounder stringBounder) {
|
||||
private double getHeightForCaptions(StringBounder stringBounder) {
|
||||
double result = 0;
|
||||
for (Highlight highlight : highlights) {
|
||||
final TextBlock caption = highlight.getCaption(getSkinParam());
|
||||
@ -231,7 +246,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
private double getPart1MaxWidth(StringBounder stringBounder) {
|
||||
double width = 0;
|
||||
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;
|
||||
@ -241,11 +256,14 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
final Player player1 = message.getPlayer1();
|
||||
final Player player2 = message.getPlayer2();
|
||||
|
||||
final UTranslate translate1 = getUTranslateForPlayer(player1, ug.getStringBounder());
|
||||
final UTranslate translate2 = getUTranslateForPlayer(player2, ug.getStringBounder());
|
||||
final StringBounder stringBounder = 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 pt2 = player2.getTimeProjection(ug.getStringBounder(), message.getTick2());
|
||||
final IntricatedPoint pt1 = player1.getTimeProjection(stringBounder, message.getTick1());
|
||||
final IntricatedPoint pt2 = player2.getTimeProjection(stringBounder, message.getTick2());
|
||||
|
||||
if (pt1 == null || pt2 == null) {
|
||||
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;
|
||||
for (Player player : players.values()) {
|
||||
if (candidat == player) {
|
||||
return UTranslate.dy(y);
|
||||
}
|
||||
if (y == 0) {
|
||||
y += getHeightHighlights(stringBounder);
|
||||
}
|
||||
// if (y == 0) {
|
||||
// y += getHeightHighlights(stringBounder);
|
||||
// }
|
||||
y += player.getFullHeight(stringBounder);
|
||||
}
|
||||
if (candidat == null) {
|
||||
@ -274,29 +292,15 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public UTranslate getUTranslateForPlayer(Player candidat, StringBounder stringBounder) {
|
||||
double y = getHeightHighlights(stringBounder);
|
||||
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);
|
||||
public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type, boolean compact) {
|
||||
final Player player = new PlayerRobustConcise(type, full, getSkinParam(), ruler, compactByDefault || compact);
|
||||
players.put(code, player);
|
||||
lastPlayer = player;
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
public CommandExecutionResult createClock(String code, String full, int period, int pulse) {
|
||||
final PlayerClock player = new PlayerClock(getSkinParam(), ruler, period, pulse);
|
||||
public CommandExecutionResult createClock(String code, String full, int period, int pulse, boolean compact) {
|
||||
final PlayerClock player = new PlayerClock(getSkinParam(), ruler, period, pulse, compactByDefault);
|
||||
players.put(code, player);
|
||||
clocks.put(code, player);
|
||||
final TimeTick tick = new TimeTick(new BigDecimal(period), TimingFormat.DECIMAL);
|
||||
@ -304,8 +308,8 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
public CommandExecutionResult createBinary(String code, String full) {
|
||||
final Player player = new PlayerBinary(code, getSkinParam(), ruler);
|
||||
public CommandExecutionResult createBinary(String code, String full, boolean compact) {
|
||||
final Player player = new PlayerBinary(full, getSkinParam(), ruler, compactByDefault);
|
||||
players.put(code, player);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
@ -372,4 +376,8 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
|
||||
}
|
||||
|
||||
public void goCompactMode() {
|
||||
this.compactByDefault = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import net.sourceforge.plantuml.timingdiagram.command.CommandDefineStateLong;
|
||||
import net.sourceforge.plantuml.timingdiagram.command.CommandDefineStateShort;
|
||||
import net.sourceforge.plantuml.timingdiagram.command.CommandHideTimeAxis;
|
||||
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.CommandNoteLong;
|
||||
import net.sourceforge.plantuml.timingdiagram.command.CommandRobustConcise;
|
||||
@ -88,6 +89,7 @@ public class TimingDiagramFactory extends UmlDiagramFactory {
|
||||
cmds.add(new CommandScalePixel());
|
||||
cmds.add(new CommandHideTimeAxis());
|
||||
cmds.add(new CommandHighlight());
|
||||
cmds.add(new CommandModeCompact());
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ 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.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
|
||||
|
||||
@ -52,6 +53,10 @@ public class CommandBinary extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
private static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandBinary.class.getName(), RegexLeaf.start(), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
new RegexLeaf("COMPACT", "(compact)"), //
|
||||
RegexLeaf.spaceOneOrMore())), //
|
||||
new RegexLeaf("binary"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
|
||||
@ -63,9 +68,10 @@ public class CommandBinary extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
@Override
|
||||
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 full = arg.get("FULL", 0);
|
||||
return diagram.createBinary(code, full);
|
||||
return diagram.createBinary(code, full, compact != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
private static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandClock.class.getName(), RegexLeaf.start(), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
new RegexLeaf("COMPACT", "(compact)"), //
|
||||
RegexLeaf.spaceOneOrMore())), //
|
||||
new RegexLeaf("TYPE", "clock"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
|
||||
@ -63,15 +67,16 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("PERIOD", "([0-9]+)"), //
|
||||
new RegexOptional(new RegexConcat( //
|
||||
RegexLeaf.spaceOneOrMore(),//
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("pulse"), //
|
||||
RegexLeaf.spaceOneOrMore(),//
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("PULSE", "([0-9]+)") //
|
||||
)), RegexLeaf.end());
|
||||
)), RegexLeaf.end());
|
||||
}
|
||||
|
||||
@Override
|
||||
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 int period = Integer.parseInt(arg.get("PERIOD", 0));
|
||||
final String pulseString = arg.get("PULSE", 0);
|
||||
@ -79,7 +84,7 @@ public class CommandClock extends SingleLineCommand2<TimingDiagram> {
|
||||
if (pulseString != null) {
|
||||
pulse = Integer.parseInt(pulseString);
|
||||
}
|
||||
return diagram.createClock(code, code, period, pulse);
|
||||
return diagram.createClock(code, code, period, pulse, compact != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ 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.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingDiagram;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingStyle;
|
||||
@ -53,6 +54,10 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
private static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandRobustConcise.class.getName(), RegexLeaf.start(), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
new RegexLeaf("COMPACT", "(compact)"), //
|
||||
RegexLeaf.spaceOneOrMore())), //
|
||||
new RegexLeaf("TYPE", "(robust|concise)"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
|
||||
@ -64,10 +69,11 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
@Override
|
||||
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 full = arg.get("FULL", 0);
|
||||
final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase());
|
||||
return diagram.createRobustConcise(code, full, type);
|
||||
return diagram.createRobustConcise(code, full, type, compact != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
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<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
|
||||
@ -75,12 +75,17 @@ public class Histogram implements PlayerDrawing {
|
||||
|
||||
private final ISkinParam skinParam;
|
||||
private final TimingRuler ruler;
|
||||
private final boolean compact;
|
||||
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.skinParam = skinParam;
|
||||
this.allStates = new ArrayList<String>(someStates);
|
||||
this.compact = compact;
|
||||
this.title = title;
|
||||
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));
|
||||
}
|
||||
|
||||
public TextBlock getPart1() {
|
||||
public TextBlock getPart1(final double fullAvailableWidth) {
|
||||
return new AbstractTextBlock() {
|
||||
public void drawU(UGraphic ug) {
|
||||
drawPart1(ug);
|
||||
drawPart1(ug, fullAvailableWidth);
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
@ -209,18 +214,45 @@ public class Histogram implements PlayerDrawing {
|
||||
if (initialState != null) {
|
||||
width += getInitialWidth();
|
||||
}
|
||||
if (compact) {
|
||||
width += title.calculateDimension(stringBounder).getWidth() + 15;
|
||||
}
|
||||
return new Dimension2DDouble(width, getFullHeight(stringBounder));
|
||||
}
|
||||
|
||||
private void drawPart1(UGraphic ug) {
|
||||
ug = ug.apply(UTranslate.dy(getHeightForConstraints(ug.getStringBounder())));
|
||||
private void drawPart1(UGraphic ug, double fullAvailableWidth) {
|
||||
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) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (changes.size() == 0) {
|
||||
return;
|
||||
|
@ -42,13 +42,13 @@ import net.sourceforge.plantuml.timingdiagram.ChangeState;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimeConstraint;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimeProjected;
|
||||
|
||||
public interface PlayerDrawing extends TimeProjected {
|
||||
public interface PDrawing extends TimeProjected {
|
||||
|
||||
public double getFullHeight(StringBounder stringBounder);
|
||||
|
||||
public void addChange(ChangeState change);
|
||||
|
||||
public TextBlock getPart1();
|
||||
public TextBlock getPart1(double fullAvailableWidth);
|
||||
|
||||
public UDrawable getPart2();
|
||||
|
@ -34,12 +34,41 @@
|
||||
*/
|
||||
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.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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -64,7 +64,7 @@ import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
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<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
|
||||
@ -74,11 +74,15 @@ public class Ribbon implements PlayerDrawing {
|
||||
private String initialState;
|
||||
private Colors initialColors;
|
||||
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.skinParam = skinParam;
|
||||
this.notes = notes;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
|
||||
@ -110,16 +114,25 @@ public class Ribbon implements PlayerDrawing {
|
||||
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
public TextBlock getPart1() {
|
||||
if (initialState == null) {
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
public TextBlock getPart1(double fullAvailableWidth) {
|
||||
// if (initialState == null) {
|
||||
// return TextBlockUtils.empty(0, 0);
|
||||
// }
|
||||
return new AbstractTextBlock() {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
|
@ -65,7 +65,6 @@ import net.sourceforge.plantuml.FileUtils;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.anim.AffineTransformation;
|
||||
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,
|
||||
double margin2, Animation 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,
|
||||
@ -390,7 +389,8 @@ public class ImageBuilder {
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
switch (fileFormat) {
|
||||
case PNG:
|
||||
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy);
|
||||
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy,
|
||||
fileFormatOption.getWatermark());
|
||||
case SVG:
|
||||
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(),
|
||||
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) {
|
||||
Color backColor = Color.WHITE;
|
||||
if (mybackcolor instanceof HColorSimple) {
|
||||
backColor = colorMapper.getMappedColor(mybackcolor);
|
||||
HColor backColor = HColorUtils.WHITE;
|
||||
if (suggested instanceof HColorSimple) {
|
||||
backColor = suggested;
|
||||
}
|
||||
final UGraphicSvg ug;
|
||||
if (mybackcolor instanceof HColorGradient) {
|
||||
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) mybackcolor, false, scale,
|
||||
if (suggested instanceof HColorGradient) {
|
||||
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) suggested, false, scale,
|
||||
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,
|
||||
preserveAspectRatio);
|
||||
} 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);
|
||||
}
|
||||
return ug;
|
||||
@ -438,10 +438,10 @@ public class ImageBuilder {
|
||||
}
|
||||
|
||||
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;
|
||||
if (mybackcolor instanceof HColorSimple) {
|
||||
backColor = colorMapper.getMappedColor(mybackcolor);
|
||||
backColor = colorMapper.toColor(mybackcolor);
|
||||
} else if (mybackcolor instanceof HColorBackground) {
|
||||
backColor = null;
|
||||
}
|
||||
@ -452,7 +452,7 @@ public class ImageBuilder {
|
||||
* builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2);
|
||||
* 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);
|
||||
final Graphics2D graphics2D = builder.getGraphics2D();
|
||||
|
||||
@ -462,8 +462,7 @@ public class ImageBuilder {
|
||||
ug.setBufferedImage(builder.getBufferedImage());
|
||||
final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
|
||||
if (mybackcolor instanceof HColorGradient) {
|
||||
ug.apply(mybackcolor.bg())
|
||||
.draw(new URectangle(im.getWidth() / dpiFactor, im.getHeight() / dpiFactor));
|
||||
ug.apply(mybackcolor.bg()).draw(new URectangle(im.getWidth() / dpiFactor, im.getHeight() / dpiFactor));
|
||||
}
|
||||
|
||||
return ug;
|
||||
|
@ -44,7 +44,6 @@ import java.io.OutputStream;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.eps.EpsStrategy;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.png.PngIO;
|
||||
@ -60,12 +59,12 @@ public abstract class UGraphicUtils {
|
||||
ColorMapper colorMapper, HColor background, TextBlock image) throws IOException {
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
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);
|
||||
} else if (fileFormat == FileFormat.SVG) {
|
||||
final Dimension2D size = computeSize(colorMapper, background, image);
|
||||
final UGraphicSvg svg = new UGraphicSvg(true, size, colorMapper, StringUtils.getAsHtml(colorMapper
|
||||
.getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(),
|
||||
final UGraphicSvg svg = new UGraphicSvg(true, size, colorMapper,
|
||||
colorMapper.toHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(),
|
||||
fileFormatOption.getHoverColor(), seed, fileFormatOption.getPreserveAspectRatio());
|
||||
image.drawU(svg);
|
||||
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 EmptyImageBuilder builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(),
|
||||
colorMapper.getMappedColor(background));
|
||||
final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, size.getWidth(), size.getHeight(),
|
||||
colorMapper.toColor(background));
|
||||
final BufferedImage im = builder.getBufferedImage();
|
||||
final Graphics2D g2d = builder.getGraphics2D();
|
||||
|
||||
@ -97,7 +97,7 @@ public abstract class UGraphicUtils {
|
||||
}
|
||||
|
||||
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 UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
|
||||
|
@ -30,19 +30,41 @@
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.timingdiagram.graphic;
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import java.awt.Color;
|
||||
|
||||
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) {
|
||||
return 0;
|
||||
final public String toSvg(HColor hcolor) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -39,5 +39,9 @@ import java.awt.Color;
|
||||
|
||||
public interface ColorMapper {
|
||||
|
||||
Color getMappedColor(HColor color);
|
||||
public Color toColor(HColor color);
|
||||
|
||||
public String toSvg(HColor color);
|
||||
|
||||
public String toHtml(HColor color);
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ package net.sourceforge.plantuml.ugraphic.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) {
|
||||
return null;
|
||||
}
|
||||
@ -51,13 +51,11 @@ public class ColorMapperIdentity implements ColorMapper {
|
||||
return Color.WHITE;
|
||||
}
|
||||
if (color instanceof HColorGradient) {
|
||||
return getMappedColor(((HColorGradient) color).getColor1());
|
||||
return toColor(((HColorGradient) color).getColor1());
|
||||
}
|
||||
if (color instanceof HColorMiddle) {
|
||||
return ((HColorMiddle) color).getMappedColor(this);
|
||||
}
|
||||
// return ColorUtils.getReversed(((HColorSimple) color).getColor999());
|
||||
//return ColorOrder.RGB.getReverse(((HColorSimple) color).getColor999());
|
||||
return ((HColorSimple) color).getColor999();
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ package net.sourceforge.plantuml.ugraphic.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) {
|
||||
return null;
|
||||
}
|
||||
@ -51,13 +51,11 @@ public class ColorMapperLightnessInverse implements ColorMapper {
|
||||
return Color.WHITE;
|
||||
}
|
||||
if (color instanceof HColorGradient) {
|
||||
return getMappedColor(((HColorGradient) color).getColor1());
|
||||
return toColor(((HColorGradient) color).getColor1());
|
||||
}
|
||||
if (color instanceof HColorMiddle) {
|
||||
return ((HColorMiddle) color).getMappedColor(this);
|
||||
}
|
||||
return ColorUtils.getReversed(((HColorSimple) color).getColor999());
|
||||
//return ColorOrder.RGB.getReverse(((HColorSimple) color).getColor999());
|
||||
// return ((HColorSimple) color).getColor999();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperMonochrome implements ColorMapper {
|
||||
public class ColorMapperMonochrome extends AbstractColorMapper implements ColorMapper {
|
||||
|
||||
private final boolean reverse;
|
||||
|
||||
@ -45,11 +45,11 @@ public class ColorMapperMonochrome implements ColorMapper {
|
||||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
public Color getMappedColor(HColor htmlColor) {
|
||||
public Color toColor(HColor htmlColor) {
|
||||
if (htmlColor == null) {
|
||||
return null;
|
||||
}
|
||||
final Color color = new ColorMapperIdentity().getMappedColor(htmlColor);
|
||||
final Color color = new ColorMapperIdentity().toColor(htmlColor);
|
||||
if (reverse) {
|
||||
return ColorUtils.getGrayScaleColorReverse(color);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperReverse implements ColorMapper {
|
||||
public class ColorMapperReverse extends AbstractColorMapper implements ColorMapper {
|
||||
|
||||
private final ColorOrder order;
|
||||
|
||||
@ -45,7 +45,7 @@ public class ColorMapperReverse implements ColorMapper {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public Color getMappedColor(HColor color) {
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorMapperTransparentWrapper implements ColorMapper {
|
||||
public class ColorMapperTransparentWrapper extends AbstractColorMapper implements ColorMapper {
|
||||
|
||||
private final ColorMapper mapper;
|
||||
|
||||
@ -48,14 +48,15 @@ public class ColorMapperTransparentWrapper implements ColorMapper {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Color getMappedColor(HColor color) {
|
||||
public Color toColor(HColor color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,8 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||
import net.sourceforge.plantuml.ugraphic.UBackground;
|
||||
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||
|
||||
public interface HColor extends UChange {
|
||||
|
||||
|
@ -34,10 +34,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class HColorBackground extends HColorAbstract implements HColor {
|
||||
|
||||
private final HColor back;
|
||||
@ -47,19 +43,14 @@ public class HColorBackground extends HColorAbstract implements HColor {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.back = back;
|
||||
|
||||
}
|
||||
|
||||
public String getSvg(ColorMapper mapper) {
|
||||
return StringUtils.getAsHtml(((HColorSimple) back).getColor999());
|
||||
}
|
||||
|
||||
public HColor getNull() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Color getActualColor(ColorMapper mapper) {
|
||||
return mapper.getMappedColor(back);
|
||||
final HColor getBack() {
|
||||
return back;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class HColorGradient extends HColorAbstract implements HColor {
|
||||
if (coeff > 1 || coeff < 0) {
|
||||
throw new IllegalArgumentException("c=" + coeff);
|
||||
}
|
||||
final Color c1 = mapper.getMappedColor(color1);
|
||||
final Color c2 = mapper.getMappedColor(color2);
|
||||
final Color c1 = mapper.toColor(color1);
|
||||
final Color c2 = mapper.toColor(color2);
|
||||
final int vred = c2.getRed() - c1.getRed();
|
||||
final int vgreen = c2.getGreen() - c1.getGreen();
|
||||
final int vblue = c2.getBlue() - c1.getBlue();
|
||||
|
@ -48,8 +48,8 @@ public class HColorMiddle extends HColorAbstract implements HColor {
|
||||
}
|
||||
|
||||
public Color getMappedColor(ColorMapper colorMapper) {
|
||||
final Color cc1 = colorMapper.getMappedColor(c1);
|
||||
final Color cc2 = colorMapper.getMappedColor(c2);
|
||||
final Color cc1 = colorMapper.toColor(c1);
|
||||
final Color cc2 = colorMapper.toColor(c2);
|
||||
final int r1 = cc1.getRed();
|
||||
final int g1 = cc1.getGreen();
|
||||
final int b1 = cc1.getBlue();
|
||||
|
@ -269,6 +269,9 @@ public class HColorSet {
|
||||
color = new Color(Integer.parseInt(s, 16));
|
||||
} else if (s.matches("[0-9A-Fa-f]{6}")) {
|
||||
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 {
|
||||
final String value = htmlNames.get(s);
|
||||
if (value == null) {
|
||||
@ -287,6 +290,9 @@ public class HColorSet {
|
||||
if (s.matches("[0-9A-Fa-f]{6}")) {
|
||||
return true;
|
||||
}
|
||||
if (s.matches("[0-9A-Fa-f]{8}")) {
|
||||
return true;
|
||||
}
|
||||
if (s.equalsIgnoreCase("automatic")) {
|
||||
return true;
|
||||
}
|
||||
|
@ -47,6 +47,14 @@ public class HColorSimple extends HColorAbstract implements HColor {
|
||||
return color.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (color.getAlpha() == 0) {
|
||||
return "transparent";
|
||||
}
|
||||
return color.toString() + " alpha=" + color.getAlpha() + " monochrome=" + monochrome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof HColorSimple == false) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.color;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
|
||||
@ -131,4 +133,8 @@ public class HColorUtils {
|
||||
return color.bg();
|
||||
}
|
||||
|
||||
public static HColor transparent() {
|
||||
return new HColorSimple(new Color(0, 0, 0, 0), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class PiecewiseAffineOnXorYBuilder extends AbstractTextBlock implements T
|
||||
@Override
|
||||
public MinMax getMinMax(StringBounder stringBounder) {
|
||||
if (cachedMinMax == null) {
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder);
|
||||
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false);
|
||||
}
|
||||
return cachedMinMax;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class DriverCenteredCharacterEps implements UDriver<EpsGraphics> {
|
||||
final double ypos = y - unusedSpace.getCenterY() - 0.5;
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class DriverDotPathEps implements UDriver<EpsGraphics> {
|
||||
//DriverLineG2d.manageStroke(param, g2d);
|
||||
|
||||
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()
|
||||
.getDashSpace());
|
||||
shape.draw(eps, x, y);
|
||||
|
@ -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.setFillColor(mapper.getMappedColor(param.getBackcolor()));
|
||||
eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
|
||||
eps.setFillColor(mapper.toColor(param.getBackcolor()));
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
|
||||
.getDashSpace());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class DriverLineEps implements UDriver<EpsGraphics> {
|
||||
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()
|
||||
.getDashSpace());
|
||||
eps.epsLine(x, y, x2, y2);
|
||||
|
@ -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) {
|
||||
final UPath shape = (UPath) ushape;
|
||||
|
||||
eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
|
||||
eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.setFillColor(mapper.toColor(param.getBackcolor()));
|
||||
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
|
||||
.getStroke().getDashSpace());
|
||||
|
||||
|
@ -81,12 +81,12 @@ public class DriverPolygonEps implements UDriver<EpsGraphics> {
|
||||
|
||||
final HColor back = param.getBackcolor();
|
||||
if (back instanceof HColorGradient) {
|
||||
eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.epsPolygon((HColorGradient) back, mapper, points);
|
||||
} else {
|
||||
|
||||
eps.setFillColor(mapper.getMappedColor(back));
|
||||
eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
|
||||
eps.setFillColor(mapper.toColor(back));
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.epsPolygon(points);
|
||||
}
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class DriverRectangleEps implements UDriver<EpsGraphics> {
|
||||
|
||||
final HColor back = param.getBackcolor();
|
||||
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);
|
||||
} else {
|
||||
eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
|
||||
eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
|
||||
eps.setStrokeColor(mapper.toColor(param.getColor()));
|
||||
eps.setFillColor(mapper.toColor(param.getBackcolor()));
|
||||
eps.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
|
||||
.getStroke().getDashSpace());
|
||||
eps.epsRectangle(x, y, width, height, rx / 2, ry / 2);
|
||||
|
@ -99,7 +99,7 @@ public class DriverTextEps implements UDriver<EpsGraphics> {
|
||||
MinMax dim = null;
|
||||
|
||||
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
|
||||
final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
|
||||
final Color extended = mapper.toColor(fontConfiguration.getExtendedColor());
|
||||
if (extended != null) {
|
||||
eps.setStrokeColor(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));
|
||||
|
||||
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
|
||||
final HColor extended = fontConfiguration.getExtendedColor();
|
||||
if (extended != null) {
|
||||
eps.setStrokeColor(mapper.getMappedColor(extended));
|
||||
eps.setStrokeColor(mapper.toColor(extended));
|
||||
}
|
||||
if (dim == 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 HColor extended = fontConfiguration.getExtendedColor();
|
||||
if (extended != null) {
|
||||
eps.setStrokeColor(mapper.getMappedColor(extended));
|
||||
eps.setStrokeColor(mapper.toColor(extended));
|
||||
}
|
||||
eps.setStrokeWidth(1.1, 0, 0);
|
||||
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)) {
|
||||
final HColor extended = fontConfiguration.getExtendedColor();
|
||||
if (extended != null) {
|
||||
eps.setStrokeColor(mapper.getMappedColor(extended));
|
||||
eps.setStrokeColor(mapper.toColor(extended));
|
||||
}
|
||||
if (dim == 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 - 1;
|
||||
|
||||
eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
|
||||
eps.setStrokeColor(mapper.toColor(fontConfiguration.getColor()));
|
||||
((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class DriverCenteredCharacterG2d implements UDriver<Graphics2D> {
|
||||
final UFont font = characterCircled.getFont();
|
||||
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 ypos = y - unusedSpace.getCenterY() - 0.5;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class DriverDotPathG2d implements UDriver<Graphics2D> {
|
||||
DriverLineG2d.manageStroke(param, g2d);
|
||||
|
||||
if (param.getColor() != null) {
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
shape.draw(g2d, x, y);
|
||||
shape.manageEnsureVisible(x, y, visible);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<Graph
|
||||
DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y);
|
||||
} else {
|
||||
if (back != null) {
|
||||
g2d.setColor(mapper.getMappedColor(param.getBackcolor()));
|
||||
g2d.setColor(mapper.toColor(param.getBackcolor()));
|
||||
DriverRectangleG2d.managePattern(param, g2d);
|
||||
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(),
|
||||
round(ellipse.getStart()), round(ellipse.getExtend()), Arc2D.OPEN);
|
||||
if (color != null) {
|
||||
g2d.setColor(mapper.getMappedColor(color));
|
||||
g2d.setColor(mapper.toColor(color));
|
||||
g2d.draw(arc);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics
|
||||
|
||||
if (shape.isOpenIconic()) {
|
||||
p.closePath();
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.fill(p);
|
||||
return;
|
||||
}
|
||||
@ -131,30 +131,30 @@ public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics
|
||||
final GradientPaint paint;
|
||||
if (policy == '|') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '\\') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
|
||||
.getColor2()));
|
||||
} else if (policy == '-') {
|
||||
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else {
|
||||
// for /
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
|
||||
}
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(p);
|
||||
} else if (back != null) {
|
||||
g2d.setColor(mapper.getMappedColor(back));
|
||||
g2d.setColor(mapper.toColor(back));
|
||||
g2d.fill(p);
|
||||
}
|
||||
|
||||
if (param.getColor() != null) {
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.draw(p);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Gr
|
||||
|
||||
if (shape.isOpenIconic()) {
|
||||
p.closePath();
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.fill(p);
|
||||
return;
|
||||
}
|
||||
@ -126,30 +126,30 @@ public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Gr
|
||||
final GradientPaint paint;
|
||||
if (policy == '|') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '\\') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
|
||||
.getColor2()));
|
||||
} else if (policy == '-') {
|
||||
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else {
|
||||
// for /
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
|
||||
}
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(p);
|
||||
} else if (back != null) {
|
||||
g2d.setColor(mapper.getMappedColor(back));
|
||||
g2d.setColor(mapper.toColor(back));
|
||||
g2d.fill(p);
|
||||
}
|
||||
|
||||
if (param.getColor() != null) {
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.draw(p);
|
||||
}
|
||||
}
|
||||
|
@ -126,30 +126,30 @@ public class DriverPathOldG2d extends DriverShadowedG2d implements UDriver<Graph
|
||||
final GradientPaint paint;
|
||||
if (policy == '|') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else if (policy == '\\') {
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
|
||||
paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.toColor(gr
|
||||
.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.toColor(gr
|
||||
.getColor2()));
|
||||
} else if (policy == '-') {
|
||||
paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
|
||||
mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.getMappedColor(gr.getColor2()));
|
||||
mapper.toColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
|
||||
mapper.toColor(gr.getColor2()));
|
||||
} else {
|
||||
// for /
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
|
||||
paint = new GradientPaint((float) x, (float) y, mapper.toColor(gr.getColor1()),
|
||||
(float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.toColor(gr.getColor2()));
|
||||
}
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(p);
|
||||
} else if (back != null) {
|
||||
g2d.setColor(mapper.getMappedColor(back));
|
||||
g2d.setColor(mapper.toColor(back));
|
||||
g2d.fill(p);
|
||||
}
|
||||
|
||||
if (param.getColor() != null) {
|
||||
g2d.setColor(mapper.getMappedColor(param.getColor()));
|
||||
g2d.setColor(mapper.toColor(param.getColor()));
|
||||
g2d.draw(p);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
public class DriverPixelG2d implements UDriver<Graphics2D> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user