summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java')
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java176
1 files changed, 176 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java
new file mode 100644
index 0000000..81c552a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java
@@ -0,0 +1,176 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+// Created from Luc Trudeau original work
+public enum BoxStyle {
+ PLAIN {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ return new URectangle(width, height, CORNER, CORNER);
+ }
+ },
+ SDL_INPUT('<') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0, 0);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, 0);
+ result.addPoint(width, height / 2);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, height);
+ result.addPoint(0, height);
+ return result;
+ }
+ },
+ SDL_OUTPUT('>') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0.0, 0.0);
+ result.addPoint(width, 0.0);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, height / 2);
+ result.addPoint(width, height);
+ result.addPoint(0.0, height);
+ return result;
+ }
+ },
+ SDL_PROCEDURE('|') {
+ @Override
+ protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle rect = new URectangle(width, height);
+ if (shadowing) {
+ rect.setDeltaShadow(3);
+ }
+ ug.draw(rect);
+ final ULine vline = new ULine(0, height);
+ ug.apply(new UTranslate(PADDING, 0)).draw(vline);
+ ug.apply(new UTranslate(width - PADDING, 0)).draw(vline);
+ }
+ },
+ SDL_SAVE('/') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0.0, 0.0);
+ result.addPoint(width - DELTA_INPUT_OUTPUT, 0.0);
+ result.addPoint(width, height);
+ result.addPoint(DELTA_INPUT_OUTPUT, height);
+ return result;
+ }
+ },
+ SDL_CONTINUOUS('}') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPath result = new UPath();
+ final double c1[] = { DELTA_CONTINUOUS, 0 };
+ final double c2[] = { 0, height / 2 };
+ final double c3[] = { DELTA_CONTINUOUS, height };
+
+ result.add(c1, USegmentType.SEG_MOVETO);
+ result.add(c2, USegmentType.SEG_LINETO);
+ result.add(c3, USegmentType.SEG_LINETO);
+
+ final double c4[] = { width - DELTA_CONTINUOUS, 0 };
+ final double c5[] = { width, height / 2 };
+ final double c6[] = { width - DELTA_CONTINUOUS, height };
+
+ result.add(c4, USegmentType.SEG_MOVETO);
+ result.add(c5, USegmentType.SEG_LINETO);
+ result.add(c6, USegmentType.SEG_LINETO);
+ return result;
+ }
+ },
+ SDL_TASK(']') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ return new URectangle(width, height);
+ }
+ };
+
+ private static final int CORNER = 25;
+ private final char style;
+ private static int DELTA_INPUT_OUTPUT = 10;
+ private static double DELTA_CONTINUOUS = 5.0;
+ private static int PADDING = 5;
+
+ private BoxStyle() {
+ this('\0');
+ }
+
+ private BoxStyle(char style) {
+ this.style = style;
+ }
+
+ public static BoxStyle fromChar(char style) {
+ for (BoxStyle bs : BoxStyle.values()) {
+ if (bs.style == style) {
+ return bs;
+ }
+ }
+ return PLAIN;
+ }
+
+ public final UDrawable getUDrawable(final double width, final double height, final boolean shadowing) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ drawInternal(ug, width, height, shadowing);
+ }
+ };
+ }
+
+ protected Shadowable getShape(double width, double height) {
+ return null;
+ }
+
+ protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) {
+ final Shadowable s = getShape(width, height);
+ if (shadowing) {
+ s.setDeltaShadow(3);
+ }
+ ug.draw(s);
+
+ }
+
+}