1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-01 08:00:48 +00:00
plantuml/src/net/sourceforge/plantuml/SkinParam.java

729 lines
21 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2016-01-09 12:15:40 +00:00
* (C) Copyright 2009-2017, Arnaud Roques
2010-11-15 20:35:36 +00:00
*
* Project Info: http://plantuml.sourceforge.net
*
* 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
2013-12-10 19:36:50 +00:00
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2010-11-15 20:35:36 +00:00
* 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.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
2016-01-30 12:20:07 +00:00
* Revision $Revision: 18309 $
2010-11-15 20:35:36 +00:00
*
*/
package net.sourceforge.plantuml;
import java.awt.Font;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
2011-01-05 18:23:06 +00:00
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2010-11-15 20:35:36 +00:00
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.command.regex.MyPattern;
2015-09-06 17:28:59 +00:00
import net.sourceforge.plantuml.creole.CommandCreoleMonospaced;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
2011-03-26 12:37:27 +00:00
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.graphic.HtmlColor;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
2015-05-03 15:36:36 +00:00
import net.sourceforge.plantuml.graphic.SkinParameter;
2015-09-28 20:42:17 +00:00
import net.sourceforge.plantuml.graphic.color.Colors;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ColorMapperMonochrome;
import net.sourceforge.plantuml.ugraphic.UFont;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.ugraphic.UStroke;
2016-01-30 12:20:07 +00:00
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage;
2010-11-15 20:35:36 +00:00
public class SkinParam implements ISkinParam {
private final Map<String, String> params = new HashMap<String, String>();
2015-04-07 18:18:37 +00:00
private Rankdir rankdir = Rankdir.TOP_TO_BOTTOM;
2010-11-15 20:35:36 +00:00
public void setParam(String key, String value) {
2015-05-31 18:56:03 +00:00
params.put(cleanForKey(key), StringUtils.trin(value));
2011-01-05 18:23:06 +00:00
}
private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
2015-04-07 18:18:37 +00:00
private static final Pattern stereoPattern = MyPattern.cmpile(stereoPatternString);
2011-01-05 18:23:06 +00:00
2015-04-07 18:18:37 +00:00
public static SkinParam noShadowing() {
final SkinParam result = new SkinParam();
result.setParam("shadowing", "false");
return result;
2011-09-07 20:41:58 +00:00
}
2011-01-05 18:23:06 +00:00
static String cleanForKey(String key) {
2015-05-31 18:56:03 +00:00
key = StringUtils.trin(StringUtils.goLowerCase(key));
2011-01-05 18:23:06 +00:00
key = key.replaceAll("_|\\.|\\s", "");
2015-04-07 18:18:37 +00:00
key = replaceSmart(key, "partition", "package");
key = replaceSmart(key, "sequenceparticipant", "participant");
key = replaceSmart(key, "sequenceactor", "actor");
if (key.contains("arrow")) {
key = key.replaceAll("activityarrow|objectarrow|classarrow|componentarrow|statearrow|usecasearrow",
"genericarrow");
}
// // key = key.replaceAll("activityarrow", "genericarrow");
// // key = key.replaceAll("objectarrow", "genericarrow");
// // key = key.replaceAll("classarrow", "genericarrow");
// // key = key.replaceAll("componentarrow", "genericarrow");
// // key = key.replaceAll("statearrow", "genericarrow");
// // key = key.replaceAll("usecasearrow", "genericarrow");
2011-01-05 18:23:06 +00:00
final Matcher m = stereoPattern.matcher(key);
if (m.find()) {
final String s = m.group(1);
key = key.replaceAll(stereoPatternString, "");
key += "<<" + s + ">>";
}
return key;
2010-11-15 20:35:36 +00:00
}
2015-04-07 18:18:37 +00:00
private static String replaceSmart(String s, String src, String target) {
if (s.contains(src) == false) {
return s;
}
return s.replaceAll(src, target);
}
public HtmlColor getHyperlinkColor() {
final HtmlColor result = getHtmlColor(ColorParam.hyperlink, null, false);
if (result == null) {
return HtmlColorUtils.BLUE;
}
return result;
}
2010-11-15 20:35:36 +00:00
public HtmlColor getBackgroundColor() {
2013-12-10 19:36:50 +00:00
final HtmlColor result = getHtmlColor(ColorParam.background, null, false);
2010-11-15 20:35:36 +00:00
if (result == null) {
2013-12-10 19:36:50 +00:00
return HtmlColorUtils.WHITE;
2010-11-15 20:35:36 +00:00
}
return result;
}
public String getValue(String key) {
2011-01-05 18:23:06 +00:00
return params.get(cleanForKey(key));
2010-11-15 20:35:36 +00:00
}
static String humanName(String key) {
final StringBuilder sb = new StringBuilder();
boolean upper = true;
for (int i = 0; i < key.length(); i++) {
final char c = key.charAt(i);
if (c == '_') {
upper = true;
} else {
2015-04-07 18:18:37 +00:00
sb.append(upper ? StringUtils.goUpperCase(c) : StringUtils.goLowerCase(c));
2010-11-15 20:35:36 +00:00
upper = false;
}
}
return sb.toString();
}
2015-04-07 18:18:37 +00:00
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
2011-01-05 18:23:06 +00:00
if (stereotype != null) {
checkStereotype(stereotype);
2015-04-07 18:18:37 +00:00
final String value2 = getValue(param.name() + "color" + stereotype.getLabel(false));
if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) {
return getIHtmlColorSet().getColorIfValid(value2);
2011-01-05 18:23:06 +00:00
}
}
2013-12-10 19:36:50 +00:00
final String value = getValue(getParamName(param, clickable));
if (value == null) {
2010-11-15 20:35:36 +00:00
return null;
}
2015-09-28 20:42:17 +00:00
final boolean acceptTransparent = param == ColorParam.background;
2015-04-07 18:18:37 +00:00
return getIHtmlColorSet().getColorIfValid(value, acceptTransparent);
2013-12-10 19:36:50 +00:00
}
2015-09-28 20:42:17 +00:00
public Colors getColors(ColorParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "color" + stereotype.getLabel(false));
if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) {
return new Colors(value2, getIHtmlColorSet(), param.getColorType());
}
}
final String value = getValue(getParamName(param, false));
if (value == null) {
return Colors.empty();
}
return new Colors(value, getIHtmlColorSet(), param.getColorType());
}
2013-12-10 19:36:50 +00:00
private String getParamName(ColorParam param, boolean clickable) {
String n = param.name();
if (clickable && n.endsWith("Background")) {
n = n.replaceAll("Background", "ClickableBackground");
} else if (clickable && n.endsWith("Border")) {
n = n.replaceAll("Border", "ClickableBorder");
}
return n + "color";
2010-11-15 20:35:36 +00:00
}
2015-04-07 18:18:37 +00:00
private void checkStereotype(Stereotype stereotype) {
// if (stereotype.startsWith("<<") == false || stereotype.endsWith(">>") == false) {
// throw new IllegalArgumentException();
// }
2011-01-05 18:23:06 +00:00
}
2016-01-09 12:15:40 +00:00
private int getFontSize(Stereotype stereotype, FontParam... param) {
2011-01-05 18:23:06 +00:00
if (stereotype != null) {
checkStereotype(stereotype);
2016-01-09 12:15:40 +00:00
final String value2 = getFirstValueNonNullWithSuffix("fontsize" + stereotype.getLabel(false), param);
2011-01-05 18:23:06 +00:00
if (value2 != null && value2.matches("\\d+")) {
return Integer.parseInt(value2);
}
}
2016-01-09 12:15:40 +00:00
String value = getFirstValueNonNullWithSuffix("fontsize", param);
2010-11-15 20:35:36 +00:00
if (value == null || value.matches("\\d+") == false) {
value = getValue("defaultfontsize");
}
if (value == null || value.matches("\\d+") == false) {
2016-01-09 12:15:40 +00:00
return param[0].getDefaultSize(this);
2010-11-15 20:35:36 +00:00
}
return Integer.parseInt(value);
}
2016-01-09 12:15:40 +00:00
private String getFontFamily(Stereotype stereotype, FontParam... param) {
2011-01-05 18:23:06 +00:00
if (stereotype != null) {
checkStereotype(stereotype);
2016-01-09 12:15:40 +00:00
final String value2 = getFirstValueNonNullWithSuffix("fontname" + stereotype.getLabel(false), param);
2011-01-05 18:23:06 +00:00
if (value2 != null) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value2);
}
}
2010-11-15 20:35:36 +00:00
// Times, Helvetica, Courier or Symbol
2016-01-09 12:15:40 +00:00
String value = getFirstValueNonNullWithSuffix("fontname", param);
2010-11-15 20:35:36 +00:00
if (value != null) {
2011-01-05 18:23:06 +00:00
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
2010-11-15 20:35:36 +00:00
}
2016-01-09 12:15:40 +00:00
if (param[0] != FontParam.CIRCLED_CHARACTER) {
2010-11-15 20:35:36 +00:00
value = getValue("defaultfontname");
if (value != null) {
2011-01-05 18:23:06 +00:00
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
2010-11-15 20:35:36 +00:00
}
}
2016-01-09 12:15:40 +00:00
return param[0].getDefaultFamily();
2010-11-15 20:35:36 +00:00
}
2016-01-09 12:15:40 +00:00
public HtmlColor getFontHtmlColor(Stereotype stereotype, FontParam... param) {
2011-01-05 18:23:06 +00:00
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
2016-01-09 12:15:40 +00:00
value = getFirstValueNonNullWithSuffix("fontcolor" + stereotype.getLabel(false), param);
2011-01-05 18:23:06 +00:00
}
2015-04-07 18:18:37 +00:00
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
2016-01-09 12:15:40 +00:00
value = getFirstValueNonNullWithSuffix("fontcolor", param);
2011-01-05 18:23:06 +00:00
}
2015-04-07 18:18:37 +00:00
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
2010-11-15 20:35:36 +00:00
value = getValue("defaultfontcolor");
}
2015-04-07 18:18:37 +00:00
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
2016-01-09 12:15:40 +00:00
value = param[0].getDefaultColor();
2010-11-15 20:35:36 +00:00
}
2015-04-07 18:18:37 +00:00
return getIHtmlColorSet().getColorIfValid(value);
2010-11-15 20:35:36 +00:00
}
2016-01-09 12:15:40 +00:00
private String getFirstValueNonNullWithSuffix(String suffix, FontParam... param) {
for (FontParam p : param) {
final String v = getValue(p.name() + suffix);
if (v != null) {
return v;
}
}
return null;
}
private int getFontStyle(Stereotype stereotype, boolean inPackageTitle, FontParam... param) {
2011-01-05 18:23:06 +00:00
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
2016-01-09 12:15:40 +00:00
value = getFirstValueNonNullWithSuffix("fontstyle" + stereotype.getLabel(false), param);
2011-01-05 18:23:06 +00:00
}
if (value == null) {
2016-01-09 12:15:40 +00:00
value = getFirstValueNonNullWithSuffix("fontstyle", param);
2011-01-05 18:23:06 +00:00
}
2010-11-15 20:35:36 +00:00
if (value == null) {
value = getValue("defaultfontstyle");
}
if (value == null) {
2016-01-09 12:15:40 +00:00
return param[0].getDefaultFontStyle(this, inPackageTitle);
2010-11-15 20:35:36 +00:00
}
int result = Font.PLAIN;
2015-04-07 18:18:37 +00:00
if (StringUtils.goLowerCase(value).contains("bold")) {
2010-11-15 20:35:36 +00:00
result = result | Font.BOLD;
}
2015-04-07 18:18:37 +00:00
if (StringUtils.goLowerCase(value).contains("italic")) {
2010-11-15 20:35:36 +00:00
result = result | Font.ITALIC;
}
return result;
}
2016-01-09 12:15:40 +00:00
public UFont getFont(Stereotype stereotype, boolean inPackageTitle, FontParam... fontParam) {
2011-01-05 18:23:06 +00:00
if (stereotype != null) {
checkStereotype(stereotype);
}
2016-01-09 12:15:40 +00:00
final String fontFamily = getFontFamily(stereotype, fontParam);
final int fontStyle = getFontStyle(stereotype, inPackageTitle, fontParam);
final int fontSize = getFontSize(stereotype, fontParam);
2015-04-07 18:18:37 +00:00
return new UFont(fontFamily, fontStyle, fontSize);
2010-11-15 20:35:36 +00:00
}
public int getCircledCharacterRadius() {
final String value = getValue("circledcharacterradius");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
// return 11;
2013-12-10 19:36:50 +00:00
// Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER));
// Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER)/3);
2016-01-09 12:15:40 +00:00
return getFontSize(null, FontParam.CIRCLED_CHARACTER) / 3 + 6;
2010-11-15 20:35:36 +00:00
}
public int classAttributeIconSize() {
final String value = getValue("classAttributeIconSize");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 10;
}
2011-08-08 17:48:29 +00:00
private boolean isMonochrome() {
2010-11-15 20:35:36 +00:00
return "true".equals(getValue("monochrome"));
}
public static Collection<String> getPossibleValues() {
final Set<String> result = new TreeSet<String>();
result.add("Monochrome");
2011-04-19 16:50:40 +00:00
// result.add("BackgroundColor");
2010-11-15 20:35:36 +00:00
result.add("CircledCharacterRadius");
result.add("ClassAttributeIconSize");
result.add("DefaultFontName");
result.add("DefaultFontStyle");
result.add("DefaultFontSize");
result.add("DefaultFontColor");
for (FontParam p : EnumSet.allOf(FontParam.class)) {
final String h = humanName(p.name());
result.add(h + "FontStyle");
result.add(h + "FontName");
result.add(h + "FontSize");
result.add(h + "FontColor");
}
2011-04-19 16:50:40 +00:00
for (ColorParam p : EnumSet.allOf(ColorParam.class)) {
final String h = capitalize(p.name());
result.add(h + "Color");
}
2015-04-07 18:18:37 +00:00
for (LineParam p : EnumSet.allOf(LineParam.class)) {
final String h = capitalize(p.name());
result.add(h + "Thickness");
}
2010-11-15 20:35:36 +00:00
return Collections.unmodifiableSet(result);
}
2011-04-19 16:50:40 +00:00
private static String capitalize(String name) {
2015-04-07 18:18:37 +00:00
return StringUtils.goUpperCase(name.substring(0, 1)) + name.substring(1);
2011-04-19 16:50:40 +00:00
}
2011-01-05 18:23:06 +00:00
public int getDpi() {
final String value = getValue("dpi");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 96;
}
2011-03-26 12:37:27 +00:00
public DotSplines getDotSplines() {
final String value = getValue("linetype");
if ("polyline".equalsIgnoreCase(value)) {
return DotSplines.POLYLINE;
}
if ("ortho".equalsIgnoreCase(value)) {
return DotSplines.ORTHO;
}
return DotSplines.SPLINES;
2011-02-23 21:14:39 +00:00
}
2011-04-19 16:50:40 +00:00
2011-03-26 12:37:27 +00:00
public GraphvizLayoutStrategy getStrategy() {
final String value = getValue("layout");
if ("neato".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.NEATO;
}
if ("circo".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.CIRCO;
}
if ("fdp".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.FDP;
}
if ("twopi".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.TWOPI;
}
return GraphvizLayoutStrategy.DOT;
}
2013-12-10 19:36:50 +00:00
public HorizontalAlignment getHorizontalAlignment(AlignParam param) {
final String value;
switch (param) {
case SEQUENCE_MESSAGE_ALIGN:
value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 0);
break;
case SEQUENCE_MESSAGETEXT_ALIGN:
value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 1);
break;
default:
value = getValue(param.name());
}
final HorizontalAlignment result = HorizontalAlignment.fromString(value);
2011-08-08 17:48:29 +00:00
if (result == null) {
return param.getDefaultValue();
}
return result;
}
2015-04-07 18:18:37 +00:00
public HorizontalAlignment getDefaultTextAlignment() {
final String value = getValue("defaulttextalignment");
final HorizontalAlignment result = HorizontalAlignment.fromString(value);
if (result == null) {
return HorizontalAlignment.CENTER;
}
return result;
}
2013-12-10 19:36:50 +00:00
private String getArg(String value, int i) {
if (value == null) {
return null;
}
final String[] split = value.split(":");
if (i >= split.length) {
return split[0];
}
return split[i];
}
2011-08-08 17:48:29 +00:00
public ColorMapper getColorMapper() {
if (isMonochrome()) {
return new ColorMapperMonochrome();
}
return new ColorMapperIdentity();
}
2013-12-10 19:36:50 +00:00
public boolean shadowing() {
final String value = getValue("shadowing");
2015-05-03 15:36:36 +00:00
if ("false".equalsIgnoreCase(value)) {
return false;
}
if ("true".equalsIgnoreCase(value)) {
return true;
}
if (strictUmlStyle()) {
return false;
}
return true;
}
2015-11-01 18:37:20 +00:00
public boolean shadowingForNote(Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue("note" + "shadowing" + stereotype.getLabel(false));
if (value2 != null) {
return value2.equalsIgnoreCase("true");
}
}
final String value2 = getValue("note" + "shadowing");
if (value2 != null) {
return value2.equalsIgnoreCase("true");
}
return shadowing();
}
2015-05-03 15:36:36 +00:00
public boolean shadowing2(SkinParameter skinParameter) {
if (skinParameter == null) {
throw new IllegalArgumentException();
}
final String name = skinParameter.getUpperCaseName();
final String value = getValue(name + "shadowing");
if (value == null) {
return shadowing();
}
2013-12-10 19:36:50 +00:00
if ("false".equalsIgnoreCase(value)) {
return false;
2011-09-07 20:41:58 +00:00
}
2015-04-07 18:18:37 +00:00
if ("true".equalsIgnoreCase(value)) {
return true;
}
if (strictUmlStyle()) {
return false;
}
2013-12-10 19:36:50 +00:00
return true;
2011-09-07 20:41:58 +00:00
}
2013-12-10 19:36:50 +00:00
public PackageStyle getPackageStyle() {
final String value = getValue("packageStyle");
final PackageStyle p = PackageStyle.fromString(value);
if (p == null) {
return PackageStyle.FOLDER;
}
return p;
}
private final Map<String, Sprite> sprites = new HashMap<String, Sprite>();
public void addSprite(String name, Sprite sprite) {
sprites.put(name, sprite);
}
public Sprite getSprite(String name) {
2016-01-09 12:15:40 +00:00
Sprite result = sprites.get(name);
if (result == null) {
result = SpriteImage.fromInternal(name);
}
return result;
2013-12-10 19:36:50 +00:00
}
public boolean useUml2ForComponent() {
if (strictUmlStyle()) {
return true;
}
final String value = getValue("componentstyle");
return "uml2".equalsIgnoreCase(value);
}
public boolean stereotypePositionTop() {
final String value = getValue("stereotypePosition");
if ("bottom".equalsIgnoreCase(value)) {
2011-09-08 10:42:27 +00:00
return false;
}
return true;
}
2015-04-07 18:18:37 +00:00
public boolean useSwimlanes(UmlDiagramType type) {
2013-12-10 19:36:50 +00:00
if (type != UmlDiagramType.ACTIVITY) {
return false;
}
if ("true".equalsIgnoreCase(getValue("swimlane"))) {
return true;
}
if ("true".equalsIgnoreCase(getValue("swimlanes"))) {
return true;
}
return false;
}
public double getNodesep() {
final String value = getValue("nodesep");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public double getRanksep() {
final String value = getValue("ranksep");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public double getRoundCorner() {
final String value = getValue("roundcorner");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
2015-04-07 18:18:37 +00:00
public UStroke getThickness(LineParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "thickness" + stereotype.getLabel(false));
if (value2 != null && value2.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value2));
}
}
2013-12-10 19:36:50 +00:00
final String value = getValue(param.name() + "thickness");
if (value != null && value.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value));
}
return null;
}
public double maxMessageSize() {
final String value = getValue("maxmessagesize");
if (value != null && value.matches("-?\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public boolean strictUmlStyle() {
final String value = getValue("style");
if ("strictuml".equalsIgnoreCase(value)) {
return true;
}
return false;
}
public boolean forceSequenceParticipantUnderlined() {
final String value = getValue("sequenceParticipant");
if ("underline".equalsIgnoreCase(value)) {
return true;
}
return false;
}
public ConditionStyle getConditionStyle() {
final String value = getValue("conditionStyle");
final ConditionStyle p = ConditionStyle.fromString(value);
if (p == null) {
return ConditionStyle.INSIDE;
}
return p;
}
public double minClassWidth() {
final String value = getValue("minclasswidth");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 0;
}
public boolean sameClassWidth() {
return "true".equals(getValue("sameclasswidth"));
}
2015-04-07 18:18:37 +00:00
public final Rankdir getRankdir() {
return rankdir;
}
public final void setRankdir(Rankdir rankdir) {
this.rankdir = rankdir;
}
public boolean useOctagonForActivity(Stereotype stereotype) {
String value = getValue("activityshape");
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue("activityshape" + stereotype.getLabel(false));
if (value2 != null) {
value = value2;
}
}
if ("roundedbox".equalsIgnoreCase(value)) {
return false;
}
if ("octagon".equalsIgnoreCase(value)) {
return true;
}
return false;
}
private final IHtmlColorSet htmlColorSet = new HtmlColorSetSimple();
public IHtmlColorSet getIHtmlColorSet() {
return htmlColorSet;
}
public boolean useUnderlineForHyperlink() {
final String value = getValue("hyperlinkunderline");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public double getPadding() {
final String value = getValue("padding");
if (value != null && value.matches("\\d+(\\.\\d+)?")) {
return Double.parseDouble(value);
}
return 0;
}
public int groupInheritance() {
final String value = getValue("groupinheritance");
int result = Integer.MAX_VALUE;
if (value != null && value.matches("\\d+")) {
result = Integer.parseInt(value);
}
if (result <= 1) {
result = Integer.MAX_VALUE;
}
return result;
}
public boolean useGuillemet() {
final String value = getValue("guillemet");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public boolean handwritten() {
final String value = getValue("handwritten");
if ("true".equalsIgnoreCase(value)) {
return true;
}
return false;
}
2015-05-31 18:56:03 +00:00
public String getSvgLinkTarget() {
final String value = getValue("svglinktarget");
if (value == null) {
return "_top";
}
return value;
}
2015-09-06 17:28:59 +00:00
public String getMonospacedFamily() {
final String value = getValue("defaultMonospacedFontName");
if (value == null) {
return CommandCreoleMonospaced.MONOSPACED;
}
return value;
}
2015-09-28 20:42:17 +00:00
public int getTabSize() {
final String value = getValue("tabsize");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 8;
}
2010-11-15 20:35:36 +00:00
}