2010-11-15 20:35:36 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2019-01-16 18:34:41 +00:00
|
|
|
* (C) Copyright 2009-2020, Arnaud Roques
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* 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
|
|
|
|
*
|
2010-11-15 20:35:36 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml;
|
|
|
|
|
|
|
|
import java.awt.Font;
|
|
|
|
|
2015-05-31 18:56:03 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
2019-07-14 20:09:26 +00:00
|
|
|
import net.sourceforge.plantuml.style.SName;
|
2019-08-26 17:07:21 +00:00
|
|
|
import net.sourceforge.plantuml.style.StyleSignature;
|
2015-05-31 18:56:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
interface FontParamConstant {
|
|
|
|
String FAMILY = "SansSerif";
|
|
|
|
String COLOR = "black";
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
public enum FontParam {
|
2018-11-26 18:46:22 +00:00
|
|
|
TIMING(12, Font.PLAIN), //
|
2015-04-07 18:18:37 +00:00
|
|
|
ACTIVITY(12, Font.PLAIN), //
|
|
|
|
ACTIVITY_DIAMOND(11, Font.PLAIN), //
|
2017-02-15 21:34:36 +00:00
|
|
|
// ACTIVITY_ARROW(11, Font.PLAIN), //
|
|
|
|
// GENERIC_ARROW(13, Font.PLAIN), //
|
|
|
|
ARROW(13, Font.PLAIN), //
|
2013-12-10 19:36:50 +00:00
|
|
|
CIRCLED_CHARACTER(17, Font.BOLD, FontParamConstant.COLOR, "Monospaced"), //
|
|
|
|
OBJECT_ATTRIBUTE(10, Font.PLAIN), //
|
|
|
|
OBJECT(12, Font.PLAIN), //
|
|
|
|
OBJECT_STEREOTYPE(12, Font.ITALIC), //
|
|
|
|
CLASS_ATTRIBUTE(10, Font.PLAIN), //
|
|
|
|
CLASS(12, Font.PLAIN), //
|
|
|
|
CLASS_STEREOTYPE(12, Font.ITALIC), //
|
|
|
|
COMPONENT(14, Font.PLAIN), //
|
2015-04-07 18:18:37 +00:00
|
|
|
INTERFACE(14, Font.PLAIN), //
|
|
|
|
INTERFACE_STEREOTYPE(14, Font.ITALIC), //
|
2013-12-10 19:36:50 +00:00
|
|
|
COMPONENT_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
NOTE(13, Font.PLAIN), //
|
|
|
|
PACKAGE(14, Font.PLAIN), //
|
2015-08-05 20:17:01 +00:00
|
|
|
PACKAGE_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
ACTOR(14, Font.PLAIN), //
|
|
|
|
ARTIFACT(14, Font.PLAIN), //
|
|
|
|
CLOUD(14, Font.PLAIN), //
|
|
|
|
FOLDER(14, Font.PLAIN), //
|
2016-11-04 21:39:29 +00:00
|
|
|
FILE(14, Font.PLAIN), //
|
2015-04-07 18:18:37 +00:00
|
|
|
FRAME(14, Font.PLAIN), //
|
|
|
|
STORAGE(14, Font.PLAIN), //
|
|
|
|
BOUNDARY(14, Font.PLAIN), //
|
|
|
|
CONTROL(14, Font.PLAIN), //
|
|
|
|
ENTITY(14, Font.PLAIN), //
|
|
|
|
AGENT(14, Font.PLAIN), //
|
|
|
|
RECTANGLE(14, Font.PLAIN), //
|
2019-05-24 19:59:31 +00:00
|
|
|
ARCHIMATE(14, Font.PLAIN), //
|
2018-04-06 20:36:30 +00:00
|
|
|
CARD(14, Font.PLAIN), //
|
2015-04-07 18:18:37 +00:00
|
|
|
NODE(14, Font.PLAIN), //
|
|
|
|
DATABASE(14, Font.PLAIN), //
|
2015-04-20 19:45:13 +00:00
|
|
|
QUEUE(14, Font.PLAIN), //
|
2017-05-10 19:51:15 +00:00
|
|
|
STACK(14, Font.PLAIN), //
|
2017-02-15 21:34:36 +00:00
|
|
|
// SEQUENCE_ARROW(13, Font.PLAIN), //
|
2013-12-10 19:36:50 +00:00
|
|
|
SEQUENCE_BOX(13, Font.BOLD), //
|
|
|
|
SEQUENCE_DIVIDER(13, Font.BOLD), //
|
|
|
|
SEQUENCE_REFERENCE(13, Font.PLAIN), //
|
|
|
|
SEQUENCE_DELAY(11, Font.PLAIN), //
|
|
|
|
SEQUENCE_GROUP(11, Font.BOLD), //
|
|
|
|
SEQUENCE_GROUP_HEADER(13, Font.BOLD), //
|
2015-04-07 18:18:37 +00:00
|
|
|
PARTICIPANT(14, Font.PLAIN), //
|
2019-03-29 22:14:07 +00:00
|
|
|
PARTICIPANT_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
SEQUENCE_TITLE(14, Font.BOLD), //
|
2013-12-10 19:36:50 +00:00
|
|
|
STATE(14, Font.PLAIN), //
|
|
|
|
STATE_ATTRIBUTE(12, Font.PLAIN), //
|
|
|
|
LEGEND(14, Font.PLAIN), //
|
|
|
|
TITLE(18, Font.PLAIN), //
|
2016-01-30 12:20:07 +00:00
|
|
|
CAPTION(14, Font.PLAIN), //
|
2016-01-09 12:15:40 +00:00
|
|
|
SWIMLANE_TITLE(18, Font.PLAIN), //
|
2013-12-10 19:36:50 +00:00
|
|
|
FOOTER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
|
|
|
|
HEADER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
|
|
|
|
USECASE(14, Font.PLAIN), //
|
|
|
|
USECASE_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
ARTIFACT_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
CLOUD_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
STORAGE_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
BOUNDARY_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
CONTROL_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
ENTITY_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
AGENT_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
RECTANGLE_STEREOTYPE(14, Font.ITALIC), //
|
2019-05-24 19:59:31 +00:00
|
|
|
ARCHIMATE_STEREOTYPE(14, Font.ITALIC), //
|
2018-04-06 20:36:30 +00:00
|
|
|
CARD_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
NODE_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
FOLDER_STEREOTYPE(14, Font.ITALIC), //
|
2016-11-04 21:39:29 +00:00
|
|
|
FILE_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
FRAME_STEREOTYPE(14, Font.ITALIC), //
|
|
|
|
DATABASE_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-20 19:45:13 +00:00
|
|
|
QUEUE_STEREOTYPE(14, Font.ITALIC), //
|
2017-05-10 19:51:15 +00:00
|
|
|
STACK_STEREOTYPE(14, Font.ITALIC), //
|
2015-04-07 18:18:37 +00:00
|
|
|
ACTOR_STEREOTYPE(14, Font.ITALIC), //
|
2016-01-09 12:15:40 +00:00
|
|
|
SEQUENCE_STEREOTYPE(14, Font.ITALIC), //
|
2018-11-26 18:46:22 +00:00
|
|
|
PARTITION(14, Font.PLAIN), DESIGNED_DOMAIN(12, Font.PLAIN), //
|
2018-05-21 19:15:19 +00:00
|
|
|
DESIGNED_DOMAIN_STEREOTYPE(12, Font.ITALIC), //
|
|
|
|
DOMAIN(12, Font.PLAIN), //
|
|
|
|
DOMAIN_STEREOTYPE(12, Font.ITALIC), //
|
|
|
|
MACHINE(12, Font.PLAIN), //
|
|
|
|
MACHINE_STEREOTYPE(12, Font.ITALIC), //
|
|
|
|
REQUIREMENT(12, Font.PLAIN), //
|
|
|
|
REQUIREMENT_STEREOTYPE(12, Font.ITALIC); //
|
2016-01-09 12:15:40 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
private final int defaultSize;
|
|
|
|
private final int fontStyle;
|
|
|
|
private final String defaultColor;
|
|
|
|
private final String defaultFamily;
|
|
|
|
|
|
|
|
private FontParam(int defaultSize, int fontStyle, String defaultColor, String defaultFamily) {
|
|
|
|
this.defaultSize = defaultSize;
|
|
|
|
this.fontStyle = fontStyle;
|
|
|
|
this.defaultColor = defaultColor;
|
|
|
|
this.defaultFamily = defaultFamily;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
private FontParam(int defaultSize, int fontStyle) {
|
|
|
|
this(defaultSize, fontStyle, FontParamConstant.COLOR, FontParamConstant.FAMILY);
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
public final int getDefaultSize(ISkinParam skinParam) {
|
2017-02-15 21:34:36 +00:00
|
|
|
if (this == ARROW && skinParam.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
|
|
|
|
return 11;
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
if (this == CLASS_ATTRIBUTE) {
|
2011-08-08 17:48:29 +00:00
|
|
|
return 11;
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
return defaultSize;
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public final int getDefaultFontStyle(ISkinParam skinParam, boolean inPackageTitle) {
|
|
|
|
if (this == STATE) {
|
|
|
|
return fontStyle;
|
|
|
|
}
|
|
|
|
if (inPackageTitle || this == PACKAGE) {
|
2011-08-08 17:48:29 +00:00
|
|
|
return Font.BOLD;
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
return fontStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getDefaultColor() {
|
|
|
|
return defaultColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDefaultFamily() {
|
|
|
|
return defaultFamily;
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-05-31 18:56:03 +00:00
|
|
|
public FontConfiguration getFontConfiguration(ISkinParam skinParam) {
|
2015-09-28 20:42:17 +00:00
|
|
|
return new FontConfiguration(skinParam, this, null);
|
2015-05-31 18:56:03 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 17:07:21 +00:00
|
|
|
public StyleSignature getStyleDefinition() {
|
2019-07-14 20:09:26 +00:00
|
|
|
if (this == FOOTER) {
|
2019-08-26 17:07:21 +00:00
|
|
|
return StyleSignature.of(SName.root, SName.footer);
|
2019-07-14 20:09:26 +00:00
|
|
|
}
|
|
|
|
if (this == HEADER) {
|
2019-08-26 17:07:21 +00:00
|
|
|
return StyleSignature.of(SName.root, SName.header);
|
2019-07-14 20:09:26 +00:00
|
|
|
}
|
|
|
|
if (this == TITLE) {
|
2019-08-26 17:07:21 +00:00
|
|
|
return StyleSignature.of(SName.root, SName.title);
|
2019-07-14 20:09:26 +00:00
|
|
|
}
|
|
|
|
System.err.println("Warning " + this);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|