diff --git a/src/net/sourceforge/plantuml/AnimatedGifEncoder.java b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java
new file mode 100644
index 000000000..b81860e9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java
@@ -0,0 +1,1334 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 13805 $
+ *
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Class AnimatedGifEncoder - Encodes a GIF file consisting of one or more
+ * frames.
+ *
+ *
+ *
+ * No copyright asserted on the source code of this class. May be used for any
+ * purpose, however, refer to the Unisys LZW patent for restrictions on use of
+ * the associated LZWEncoder class. Please forward any corrections to
+ * kweiner@fmsware.com.
+ *
+ * @author Kevin Weiner, FM Software
+ * @version 1.03 November 2003
+ *
+ */
+
+public class AnimatedGifEncoder {
+
+ protected int width; // image size
+
+ protected int height;
+
+ protected Color transparent = null; // transparent color if given
+
+ protected int transIndex; // transparent index in color table
+
+ protected int repeat = -1; // no repeat
+
+ protected int delay = 0; // frame delay (hundredths)
+
+ protected boolean started = false; // ready to output frames
+
+ protected OutputStream out;
+
+ protected BufferedImage image; // current frame
+
+ protected byte[] pixels; // BGR byte array from frame
+
+ protected byte[] indexedPixels; // converted frame indexed to palette
+
+ protected int colorDepth; // number of bit planes
+
+ protected byte[] colorTab; // RGB palette
+
+ protected boolean[] usedEntry = new boolean[256]; // active palette
+ // entries
+
+ protected int palSize = 7; // color table size (bits-1)
+
+ protected int dispose = -1; // disposal code (-1 = use default)
+
+ protected boolean closeStream = false; // close stream when finished
+
+ protected boolean firstFrame = true;
+
+ protected boolean sizeSet = false; // if false, get size from first frame
+
+ protected int sample = 10; // default sample interval for quantizer
+
+ /**
+ * Sets the delay time between each frame, or changes it for subsequent
+ * frames (applies to last frame added).
+ *
+ * @param ms
+ * int delay time in milliseconds
+ */
+ public void setDelay(int ms) {
+ delay = Math.round(ms / 10.0f);
+ }
+
+ /**
+ * Sets the GIF frame disposal code for the last added frame and any
+ * subsequent frames. Default is 0 if no transparent color has been set,
+ * otherwise 2.
+ *
+ * @param code
+ * int disposal code.
+ */
+ public void setDispose(int code) {
+ if (code >= 0) {
+ dispose = code;
+ }
+ }
+
+ /**
+ * Sets the number of times the set of GIF frames should be played. Default
+ * is 1; 0 means play indefinitely. Must be invoked before the first image
+ * is added.
+ *
+ * @param iter
+ * int number of iterations.
+ * @return
+ */
+ public void setRepeat(int iter) {
+ if (iter >= 0) {
+ repeat = iter;
+ }
+ }
+
+ /**
+ * Sets the transparent color for the last added frame and any subsequent
+ * frames. Since all colors are subject to modification in the quantization
+ * process, the color in the final palette for each frame closest to the
+ * given color becomes the transparent color for that frame. May be set to
+ * null to indicate no transparent color.
+ *
+ * @param c
+ * Color to be treated as transparent on display.
+ */
+ public void setTransparent(Color c) {
+ transparent = c;
+ }
+
+ /**
+ * Adds next GIF frame. The frame is not written immediately, but is
+ * actually deferred until the next frame is received so that timing data
+ * can be inserted. Invoking finish() flushes all frames. If
+ * setSize was not invoked, the size of the first image is
+ * used for all subsequent frames.
+ *
+ * @param im
+ * BufferedImage containing frame to write.
+ * @return true if successful.
+ */
+ public boolean addFrame(BufferedImage im) {
+ if ((im == null) || !started) {
+ return false;
+ }
+ boolean ok = true;
+ try {
+ if (!sizeSet) {
+ // use first frame's size
+ setSize(im.getWidth(), im.getHeight());
+ }
+ image = im;
+ getImagePixels(); // convert to correct format if necessary
+ analyzePixels(); // build color table & map pixels
+ if (firstFrame) {
+ writeLSD(); // logical screen descriptior
+ writePalette(); // global color table
+ if (repeat >= 0) {
+ // use NS app extension to indicate reps
+ writeNetscapeExt();
+ }
+ }
+ writeGraphicCtrlExt(); // write graphic control extension
+ writeImageDesc(); // image descriptor
+ if (!firstFrame) {
+ writePalette(); // local color table
+ }
+ writePixels(); // encode and write pixel data
+ firstFrame = false;
+ } catch (IOException e) {
+ ok = false;
+ }
+
+ return ok;
+ }
+
+ /**
+ * Flushes any pending data and closes output file. If writing to an
+ * OutputStream, the stream is not closed.
+ */
+ public boolean finish() {
+ if (!started)
+ return false;
+ boolean ok = true;
+ started = false;
+ try {
+ out.write(0x3b); // gif trailer
+ out.flush();
+ if (closeStream) {
+ out.close();
+ }
+ } catch (IOException e) {
+ ok = false;
+ }
+
+ // reset for subsequent use
+ transIndex = 0;
+ out = null;
+ image = null;
+ pixels = null;
+ indexedPixels = null;
+ colorTab = null;
+ closeStream = false;
+ firstFrame = true;
+
+ return ok;
+ }
+
+ /**
+ * Sets frame rate in frames per second. Equivalent to
+ * setDelay(1000/fps).
+ *
+ * @param fps
+ * float frame rate (frames per second)
+ */
+ public void setFrameRate(float fps) {
+ if (fps != 0f) {
+ delay = Math.round(100f / fps);
+ }
+ }
+
+ /**
+ * Sets quality of color quantization (conversion of images to the maximum
+ * 256 colors allowed by the GIF specification). Lower values (minimum = 1)
+ * produce better colors, but slow processing significantly. 10 is the
+ * default, and produces good color mapping at reasonable speeds. Values
+ * greater than 20 do not yield significant improvements in speed.
+ *
+ * @param quality
+ * int greater than 0.
+ * @return
+ */
+ public void setQuality(int quality) {
+ if (quality < 1)
+ quality = 1;
+ sample = quality;
+ }
+
+ /**
+ * Sets the GIF frame size. The default size is the size of the first frame
+ * added if this method is not invoked.
+ *
+ * @param w
+ * int frame width.
+ * @param h
+ * int frame width.
+ */
+ public void setSize(int w, int h) {
+ if (started && !firstFrame)
+ return;
+ width = w;
+ height = h;
+ if (width < 1)
+ width = 320;
+ if (height < 1)
+ height = 240;
+ sizeSet = true;
+ }
+
+ /**
+ * Initiates GIF file creation on the given stream. The stream is not closed
+ * automatically.
+ *
+ * @param os
+ * OutputStream on which GIF images are written.
+ * @return false if initial write failed.
+ */
+ public boolean start(OutputStream os) {
+ if (os == null)
+ return false;
+ boolean ok = true;
+ closeStream = false;
+ out = os;
+ try {
+ writeString("GIF89a"); // header
+ } catch (IOException e) {
+ ok = false;
+ }
+ return started = ok;
+ }
+
+ /**
+ * Initiates writing of a GIF file with the specified name.
+ *
+ * @param file
+ * String containing output file name.
+ * @return false if open or initial write failed.
+ */
+ public boolean start(String file) {
+ boolean ok = true;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ ok = start(out);
+ closeStream = true;
+ } catch (IOException e) {
+ ok = false;
+ }
+ return started = ok;
+ }
+
+ /**
+ * Analyzes image colors and creates color map.
+ */
+ protected void analyzePixels() {
+ int len = pixels.length;
+ int nPix = len / 3;
+ indexedPixels = new byte[nPix];
+ NeuQuant nq = new NeuQuant(pixels, len, sample);
+ // initialize quantizer
+ colorTab = nq.process(); // create reduced palette
+ // convert map from BGR to RGB
+ for (int i = 0; i < colorTab.length; i += 3) {
+ byte temp = colorTab[i];
+ colorTab[i] = colorTab[i + 2];
+ colorTab[i + 2] = temp;
+ usedEntry[i / 3] = false;
+ }
+ // map image pixels to new palette
+ int k = 0;
+ for (int i = 0; i < nPix; i++) {
+ int index = nq.map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff);
+ usedEntry[index] = true;
+ indexedPixels[i] = (byte) index;
+ }
+ pixels = null;
+ colorDepth = 8;
+ palSize = 7;
+ // get closest match to transparent color if specified
+ if (transparent != null) {
+ transIndex = findClosest(transparent);
+ }
+ }
+
+ /**
+ * Returns index of palette color closest to c
+ *
+ */
+ protected int findClosest(Color c) {
+ if (colorTab == null)
+ return -1;
+ int r = c.getRed();
+ int g = c.getGreen();
+ int b = c.getBlue();
+ int minpos = 0;
+ int dmin = 256 * 256 * 256;
+ int len = colorTab.length;
+ for (int i = 0; i < len;) {
+ int dr = r - (colorTab[i++] & 0xff);
+ int dg = g - (colorTab[i++] & 0xff);
+ int db = b - (colorTab[i] & 0xff);
+ int d = dr * dr + dg * dg + db * db;
+ int index = i / 3;
+ if (usedEntry[index] && (d < dmin)) {
+ dmin = d;
+ minpos = index;
+ }
+ i++;
+ }
+ return minpos;
+ }
+
+ /**
+ * Extracts image pixels into byte array "pixels"
+ */
+ protected void getImagePixels() {
+ int w = image.getWidth();
+ int h = image.getHeight();
+ int type = image.getType();
+ if ((w != width) || (h != height) || (type != BufferedImage.TYPE_3BYTE_BGR)) {
+ // create new image with right size/format
+ BufferedImage temp = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+ Graphics2D g = temp.createGraphics();
+ g.drawImage(image, 0, 0, null);
+ image = temp;
+ }
+ pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
+ }
+
+ /**
+ * Writes Graphic Control Extension
+ */
+ protected void writeGraphicCtrlExt() throws IOException {
+ out.write(0x21); // extension introducer
+ out.write(0xf9); // GCE label
+ out.write(4); // data block size
+ int transp, disp;
+ if (transparent == null) {
+ transp = 0;
+ disp = 0; // dispose = no action
+ } else {
+ transp = 1;
+ disp = 2; // force clear if using transparent color
+ }
+ if (dispose >= 0) {
+ disp = dispose & 7; // user override
+ }
+ disp <<= 2;
+
+ // packed fields
+ out.write(0 | // 1:3 reserved
+ disp | // 4:6 disposal
+ 0 | // 7 user input - 0 = none
+ transp); // 8 transparency flag
+
+ writeShort(delay); // delay x 1/100 sec
+ out.write(transIndex); // transparent color index
+ out.write(0); // block terminator
+ }
+
+ /**
+ * Writes Image Descriptor
+ */
+ protected void writeImageDesc() throws IOException {
+ out.write(0x2c); // image separator
+ writeShort(0); // image position x,y = 0,0
+ writeShort(0);
+ writeShort(width); // image size
+ writeShort(height);
+ // packed fields
+ if (firstFrame) {
+ // no LCT - GCT is used for first (or only) frame
+ out.write(0);
+ } else {
+ // specify normal LCT
+ out.write(0x80 | // 1 local color table 1=yes
+ 0 | // 2 interlace - 0=no
+ 0 | // 3 sorted - 0=no
+ 0 | // 4-5 reserved
+ palSize); // 6-8 size of color table
+ }
+ }
+
+ /**
+ * Writes Logical Screen Descriptor
+ */
+ protected void writeLSD() throws IOException {
+ // logical screen size
+ writeShort(width);
+ writeShort(height);
+ // packed fields
+ out.write((0x80 | // 1 : global color table flag = 1 (gct used)
+ 0x70 | // 2-4 : color resolution = 7
+ 0x00 | // 5 : gct sort flag = 0
+ palSize)); // 6-8 : gct size
+
+ out.write(0); // background color index
+ out.write(0); // pixel aspect ratio - assume 1:1
+ }
+
+ /**
+ * Writes Netscape application extension to define repeat count.
+ */
+ protected void writeNetscapeExt() throws IOException {
+ out.write(0x21); // extension introducer
+ out.write(0xff); // app extension label
+ out.write(11); // block size
+ writeString("NETSCAPE" + "2.0"); // app id + auth code
+ out.write(3); // sub-block size
+ out.write(1); // loop sub-block id
+ writeShort(repeat); // loop count (extra iterations, 0=repeat forever)
+ out.write(0); // block terminator
+ }
+
+ /**
+ * Writes color table
+ */
+ protected void writePalette() throws IOException {
+ out.write(colorTab, 0, colorTab.length);
+ int n = (3 * 256) - colorTab.length;
+ for (int i = 0; i < n; i++) {
+ out.write(0);
+ }
+ }
+
+ /**
+ * Encodes and writes pixel data
+ */
+ protected void writePixels() throws IOException {
+ LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth);
+ encoder.encode(out);
+ }
+
+ /**
+ * Write 16-bit value to output stream, LSB first
+ */
+ protected void writeShort(int value) throws IOException {
+ out.write(value & 0xff);
+ out.write((value >> 8) & 0xff);
+ }
+
+ /**
+ * Writes string to output stream
+ */
+ protected void writeString(String s) throws IOException {
+ for (int i = 0; i < s.length(); i++) {
+ out.write((byte) s.charAt(i));
+ }
+ }
+}
+
+/*
+ * NeuQuant Neural-Net Quantization Algorithm
+ * ------------------------------------------
+ *
+ * Copyright (c) 1994 Anthony Dekker
+ *
+ * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
+ * "Kohonen neural networks for optimal colour quantization" in "Network:
+ * Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
+ * the algorithm.
+ *
+ * Any party obtaining a copy of these files from the author, directly or
+ * indirectly, is granted, free of charge, a full and unrestricted irrevocable,
+ * world-wide, paid up, royalty-free, nonexclusive right and license to deal in
+ * this software and documentation files (the "Software"), including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons who
+ * receive copies from any such party to do so, with the only requirement being
+ * that this copyright notice remain intact.
+ */
+
+// Ported to Java 12/00 K Weiner
+class NeuQuant {
+
+ protected static final int netsize = 256; /* number of colours used */
+
+ /* four primes near 500 - assume no image has a length so large */
+ /* that it is divisible by all four primes */
+ protected static final int prime1 = 499;
+
+ protected static final int prime2 = 491;
+
+ protected static final int prime3 = 487;
+
+ protected static final int prime4 = 503;
+
+ protected static final int minpicturebytes = (3 * prime4);
+
+ /* minimum size for input image */
+
+ /*
+ * Program Skeleton ---------------- [select samplefac in range 1..30] [read
+ * image from input file] pic = (unsigned char*) malloc(3*width*height);
+ * initnet(pic,3*width*height,samplefac); learn(); unbiasnet(); [write
+ * output image header, using writecolourmap(f)] inxbuild(); write output
+ * image using inxsearch(b,g,r)
+ */
+
+ /*
+ * Network Definitions -------------------
+ */
+
+ protected static final int maxnetpos = (netsize - 1);
+
+ protected static final int netbiasshift = 4; /* bias for colour values */
+
+ protected static final int ncycles = 100; /* no. of learning cycles */
+
+ /* defs for freq and bias */
+ protected static final int intbiasshift = 16; /* bias for fractions */
+
+ protected static final int intbias = (((int) 1) << intbiasshift);
+
+ protected static final int gammashift = 10; /* gamma = 1024 */
+
+ protected static final int gamma = (((int) 1) << gammashift);
+
+ protected static final int betashift = 10;
+
+ protected static final int beta = (intbias >> betashift); /* beta = 1/1024 */
+
+ protected static final int betagamma = (intbias << (gammashift - betashift));
+
+ /* defs for decreasing radius factor */
+ protected static final int initrad = (netsize >> 3); /*
+ * for 256 cols,
+ * radius starts
+ */
+
+ protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */
+
+ protected static final int radiusbias = (((int) 1) << radiusbiasshift);
+
+ protected static final int initradius = (initrad * radiusbias); /*
+ * and
+ * decreases
+ * by a
+ */
+
+ protected static final int radiusdec = 30; /* factor of 1/30 each cycle */
+
+ /* defs for decreasing alpha factor */
+ protected static final int alphabiasshift = 10; /* alpha starts at 1.0 */
+
+ protected static final int initalpha = (((int) 1) << alphabiasshift);
+
+ protected int alphadec; /* biased by 10 bits */
+
+ /* radbias and alpharadbias used for radpower calculation */
+ protected static final int radbiasshift = 8;
+
+ protected static final int radbias = (((int) 1) << radbiasshift);
+
+ protected static final int alpharadbshift = (alphabiasshift + radbiasshift);
+
+ protected static final int alpharadbias = (((int) 1) << alpharadbshift);
+
+ /*
+ * Types and Global Variables --------------------------
+ */
+
+ protected byte[] thepicture; /* the input image itself */
+
+ protected int lengthcount; /* lengthcount = H*W*3 */
+
+ protected int samplefac; /* sampling factor 1..30 */
+
+ // typedef int pixel[4]; /* BGRc */
+ protected int[][] network; /* the network itself - [netsize][4] */
+
+ protected int[] netindex = new int[256];
+
+ /* for network lookup - really 256 */
+
+ protected int[] bias = new int[netsize];
+
+ /* bias and freq arrays for learning */
+ protected int[] freq = new int[netsize];
+
+ protected int[] radpower = new int[initrad];
+
+ /* radpower for precomputation */
+
+ /*
+ * Initialise network in range (0,0,0) to (255,255,255) and set parameters
+ * -----------------------------------------------------------------------
+ */
+ public NeuQuant(byte[] thepic, int len, int sample) {
+
+ int i;
+ int[] p;
+
+ thepicture = thepic;
+ lengthcount = len;
+ samplefac = sample;
+
+ network = new int[netsize][];
+ for (i = 0; i < netsize; i++) {
+ network[i] = new int[4];
+ p = network[i];
+ p[0] = p[1] = p[2] = (i << (netbiasshift + 8)) / netsize;
+ freq[i] = intbias / netsize; /* 1/netsize */
+ bias[i] = 0;
+ }
+ }
+
+ public byte[] colorMap() {
+ byte[] map = new byte[3 * netsize];
+ int[] index = new int[netsize];
+ for (int i = 0; i < netsize; i++)
+ index[network[i][3]] = i;
+ int k = 0;
+ for (int i = 0; i < netsize; i++) {
+ int j = index[i];
+ map[k++] = (byte) (network[j][0]);
+ map[k++] = (byte) (network[j][1]);
+ map[k++] = (byte) (network[j][2]);
+ }
+ return map;
+ }
+
+ /*
+ * Insertion sort of network and building of netindex[0..255] (to do after
+ * unbias)
+ * -------------------------------------------------------------------------------
+ */
+ public void inxbuild() {
+
+ int i, j, smallpos, smallval;
+ int[] p;
+ int[] q;
+ int previouscol, startpos;
+
+ previouscol = 0;
+ startpos = 0;
+ for (i = 0; i < netsize; i++) {
+ p = network[i];
+ smallpos = i;
+ smallval = p[1]; /* index on g */
+ /* find smallest in i..netsize-1 */
+ for (j = i + 1; j < netsize; j++) {
+ q = network[j];
+ if (q[1] < smallval) { /* index on g */
+ smallpos = j;
+ smallval = q[1]; /* index on g */
+ }
+ }
+ q = network[smallpos];
+ /* swap p (i) and q (smallpos) entries */
+ if (i != smallpos) {
+ j = q[0];
+ q[0] = p[0];
+ p[0] = j;
+ j = q[1];
+ q[1] = p[1];
+ p[1] = j;
+ j = q[2];
+ q[2] = p[2];
+ p[2] = j;
+ j = q[3];
+ q[3] = p[3];
+ p[3] = j;
+ }
+ /* smallval entry is now in position i */
+ if (smallval != previouscol) {
+ netindex[previouscol] = (startpos + i) >> 1;
+ for (j = previouscol + 1; j < smallval; j++)
+ netindex[j] = i;
+ previouscol = smallval;
+ startpos = i;
+ }
+ }
+ netindex[previouscol] = (startpos + maxnetpos) >> 1;
+ for (j = previouscol + 1; j < 256; j++)
+ netindex[j] = maxnetpos; /* really 256 */
+ }
+
+ /*
+ * Main Learning Loop ------------------
+ */
+ public void learn() {
+
+ int i, j, b, g, r;
+ int radius, rad, alpha, step, delta, samplepixels;
+ byte[] p;
+ int pix, lim;
+
+ if (lengthcount < minpicturebytes)
+ samplefac = 1;
+ alphadec = 30 + ((samplefac - 1) / 3);
+ p = thepicture;
+ pix = 0;
+ lim = lengthcount;
+ samplepixels = lengthcount / (3 * samplefac);
+ delta = samplepixels / ncycles;
+ alpha = initalpha;
+ radius = initradius;
+
+ rad = radius >> radiusbiasshift;
+ if (rad <= 1)
+ rad = 0;
+ for (i = 0; i < rad; i++)
+ radpower[i] = alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
+
+ // fprintf(stderr,"beginning 1D learning: initial radius=%d\n", rad);
+
+ if (lengthcount < minpicturebytes)
+ step = 3;
+ else if ((lengthcount % prime1) != 0)
+ step = 3 * prime1;
+ else {
+ if ((lengthcount % prime2) != 0)
+ step = 3 * prime2;
+ else {
+ if ((lengthcount % prime3) != 0)
+ step = 3 * prime3;
+ else
+ step = 3 * prime4;
+ }
+ }
+
+ i = 0;
+ while (i < samplepixels) {
+ b = (p[pix + 0] & 0xff) << netbiasshift;
+ g = (p[pix + 1] & 0xff) << netbiasshift;
+ r = (p[pix + 2] & 0xff) << netbiasshift;
+ j = contest(b, g, r);
+
+ altersingle(alpha, j, b, g, r);
+ if (rad != 0)
+ alterneigh(rad, j, b, g, r); /* alter neighbours */
+
+ pix += step;
+ if (pix >= lim)
+ pix -= lengthcount;
+
+ i++;
+ if (delta == 0)
+ delta = 1;
+ if (i % delta == 0) {
+ alpha -= alpha / alphadec;
+ radius -= radius / radiusdec;
+ rad = radius >> radiusbiasshift;
+ if (rad <= 1)
+ rad = 0;
+ for (j = 0; j < rad; j++)
+ radpower[j] = alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
+ }
+ }
+ // fprintf(stderr,"finished 1D learning: final alpha=%f
+ // !\n",((float)alpha)/initalpha);
+ }
+
+ /*
+ * Search for BGR values 0..255 (after net is unbiased) and return colour
+ * index
+ * ----------------------------------------------------------------------------
+ */
+ public int map(int b, int g, int r) {
+
+ int i, j, dist, a, bestd;
+ int[] p;
+ int best;
+
+ bestd = 1000; /* biggest possible dist is 256*3 */
+ best = -1;
+ i = netindex[g]; /* index on g */
+ j = i - 1; /* start at netindex[g] and work outwards */
+
+ while ((i < netsize) || (j >= 0)) {
+ if (i < netsize) {
+ p = network[i];
+ dist = p[1] - g; /* inx key */
+ if (dist >= bestd)
+ i = netsize; /* stop iter */
+ else {
+ i++;
+ if (dist < 0)
+ dist = -dist;
+ a = p[0] - b;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ a = p[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ best = p[3];
+ }
+ }
+ }
+ }
+ if (j >= 0) {
+ p = network[j];
+ dist = g - p[1]; /* inx key - reverse dif */
+ if (dist >= bestd)
+ j = -1; /* stop iter */
+ else {
+ j--;
+ if (dist < 0)
+ dist = -dist;
+ a = p[0] - b;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ a = p[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ best = p[3];
+ }
+ }
+ }
+ }
+ }
+ return (best);
+ }
+
+ public byte[] process() {
+ learn();
+ unbiasnet();
+ inxbuild();
+ return colorMap();
+ }
+
+ /*
+ * Unbias network to give byte values 0..255 and record position i to
+ * prepare for sort
+ * -----------------------------------------------------------------------------------
+ */
+ public void unbiasnet() {
+
+ int i, j;
+
+ for (i = 0; i < netsize; i++) {
+ network[i][0] >>= netbiasshift;
+ network[i][1] >>= netbiasshift;
+ network[i][2] >>= netbiasshift;
+ network[i][3] = i; /* record colour no */
+ }
+ }
+
+ /*
+ * Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in
+ * radpower[|i-j|]
+ * ---------------------------------------------------------------------------------
+ */
+ protected void alterneigh(int rad, int i, int b, int g, int r) {
+
+ int j, k, lo, hi, a, m;
+ int[] p;
+
+ lo = i - rad;
+ if (lo < -1)
+ lo = -1;
+ hi = i + rad;
+ if (hi > netsize)
+ hi = netsize;
+
+ j = i + 1;
+ k = i - 1;
+ m = 1;
+ while ((j < hi) || (k > lo)) {
+ a = radpower[m++];
+ if (j < hi) {
+ p = network[j++];
+ try {
+ p[0] -= (a * (p[0] - b)) / alpharadbias;
+ p[1] -= (a * (p[1] - g)) / alpharadbias;
+ p[2] -= (a * (p[2] - r)) / alpharadbias;
+ } catch (Exception e) {
+ } // prevents 1.3 miscompilation
+ }
+ if (k > lo) {
+ p = network[k--];
+ try {
+ p[0] -= (a * (p[0] - b)) / alpharadbias;
+ p[1] -= (a * (p[1] - g)) / alpharadbias;
+ p[2] -= (a * (p[2] - r)) / alpharadbias;
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ /*
+ * Move neuron i towards biased (b,g,r) by factor alpha
+ * ----------------------------------------------------
+ */
+ protected void altersingle(int alpha, int i, int b, int g, int r) {
+
+ /* alter hit neuron */
+ int[] n = network[i];
+ n[0] -= (alpha * (n[0] - b)) / initalpha;
+ n[1] -= (alpha * (n[1] - g)) / initalpha;
+ n[2] -= (alpha * (n[2] - r)) / initalpha;
+ }
+
+ /*
+ * Search for biased BGR values ----------------------------
+ */
+ protected int contest(int b, int g, int r) {
+
+ /* finds closest neuron (min dist) and updates freq */
+ /* finds best neuron (min dist-bias) and returns position */
+ /*
+ * for frequently chosen neurons, freq[i] is high and bias[i] is
+ * negative
+ */
+ /* bias[i] = gamma*((1/netsize)-freq[i]) */
+
+ int i, dist, a, biasdist, betafreq;
+ int bestpos, bestbiaspos, bestd, bestbiasd;
+ int[] n;
+
+ bestd = ~(((int) 1) << 31);
+ bestbiasd = bestd;
+ bestpos = -1;
+ bestbiaspos = bestpos;
+
+ for (i = 0; i < netsize; i++) {
+ n = network[i];
+ dist = n[0] - b;
+ if (dist < 0)
+ dist = -dist;
+ a = n[1] - g;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ a = n[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ bestpos = i;
+ }
+ biasdist = dist - ((bias[i]) >> (intbiasshift - netbiasshift));
+ if (biasdist < bestbiasd) {
+ bestbiasd = biasdist;
+ bestbiaspos = i;
+ }
+ betafreq = (freq[i] >> betashift);
+ freq[i] -= betafreq;
+ bias[i] += (betafreq << gammashift);
+ }
+ freq[bestpos] += beta;
+ bias[bestpos] -= betagamma;
+ return (bestbiaspos);
+ }
+}
+
+// ==============================================================================
+// Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott.
+// K Weiner 12/00
+
+class LZWEncoder {
+
+ private static final int EOF = -1;
+
+ private int imgW, imgH;
+
+ private byte[] pixAry;
+
+ private int initCodeSize;
+
+ private int remaining;
+
+ private int curPixel;
+
+ // GIFCOMPR.C - GIF Image compression routines
+ //
+ // Lempel-Ziv compression based on 'compress'. GIF modifications by
+ // David Rowley (mgardi@watdcsu.waterloo.edu)
+
+ // General DEFINEs
+
+ static final int BITS = 12;
+
+ static final int HSIZE = 5003; // 80% occupancy
+
+ // GIF Image compression - modified 'compress'
+ //
+ // Based on: compress.c - File compression ala IEEE Computer, June 1984.
+ //
+ // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
+ // Jim McKie (decvax!mcvax!jim)
+ // Steve Davies (decvax!vax135!petsd!peora!srd)
+ // Ken Turkowski (decvax!decwrl!turtlevax!ken)
+ // James A. Woods (decvax!ihnp4!ames!jaw)
+ // Joe Orost (decvax!vax135!petsd!joe)
+
+ int n_bits; // number of bits/code
+
+ int maxbits = BITS; // user settable max # bits/code
+
+ int maxcode; // maximum code, given n_bits
+
+ int maxmaxcode = 1 << BITS; // should NEVER generate this code
+
+ int[] htab = new int[HSIZE];
+
+ int[] codetab = new int[HSIZE];
+
+ int hsize = HSIZE; // for dynamic table sizing
+
+ int free_ent = 0; // first unused entry
+
+ // block compression parameters -- after all codes are used up,
+ // and compression rate changes, start over.
+ boolean clear_flg = false;
+
+ // Algorithm: use open addressing double hashing (no chaining) on the
+ // prefix code / next character combination. We do a variant of Knuth's
+ // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ // secondary probe. Here, the modular division first probe is gives way
+ // to a faster exclusive-or manipulation. Also do block compression with
+ // an adaptive reset, whereby the code table is cleared when the compression
+ // ratio decreases, but after the table fills. The variable-length output
+ // codes are re-sized at this point, and a special CLEAR code is generated
+ // for the decompressor. Late addition: construct the table according to
+ // file size for noticeable speed improvement on small files. Please direct
+ // questions about this implementation to ames!jaw.
+
+ int g_init_bits;
+
+ int ClearCode;
+
+ int EOFCode;
+
+ // output
+ //
+ // Output the given code.
+ // Inputs:
+ // code: A n_bits-bit integer. If == -1, then EOF. This assumes
+ // that n_bits =< wordsize - 1.
+ // Outputs:
+ // Outputs code to the file.
+ // Assumptions:
+ // Chars are 8 bits long.
+ // Algorithm:
+ // Maintain a BITS character long buffer (so that 8 codes will
+ // fit in it exactly). Use the VAX insv instruction to insert each
+ // code in turn. When the buffer fills up empty it and start over.
+
+ int cur_accum = 0;
+
+ int cur_bits = 0;
+
+ int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,
+ 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
+
+ // Number of characters so far in this 'packet'
+ int a_count;
+
+ // Define the storage for the packet accumulator
+ byte[] accum = new byte[256];
+
+ // ----------------------------------------------------------------------------
+ LZWEncoder(int width, int height, byte[] pixels, int color_depth) {
+ imgW = width;
+ imgH = height;
+ pixAry = pixels;
+ initCodeSize = Math.max(2, color_depth);
+ }
+
+ // Add a character to the end of the current packet, and if it is 254
+ // characters, flush the packet to disk.
+ void char_out(byte c, OutputStream outs) throws IOException {
+ accum[a_count++] = c;
+ if (a_count >= 254)
+ flush_char(outs);
+ }
+
+ // Clear out the hash table
+
+ // table clear for block compress
+ void cl_block(OutputStream outs) throws IOException {
+ cl_hash(hsize);
+ free_ent = ClearCode + 2;
+ clear_flg = true;
+
+ output(ClearCode, outs);
+ }
+
+ // reset code table
+ void cl_hash(int hsize) {
+ for (int i = 0; i < hsize; ++i)
+ htab[i] = -1;
+ }
+
+ void compress(int init_bits, OutputStream outs) throws IOException {
+ int fcode;
+ int i /* = 0 */;
+ int c;
+ int ent;
+ int disp;
+ int hsize_reg;
+ int hshift;
+
+ // Set up the globals: g_init_bits - initial number of bits
+ g_init_bits = init_bits;
+
+ // Set up the necessary values
+ clear_flg = false;
+ n_bits = g_init_bits;
+ maxcode = MAXCODE(n_bits);
+
+ ClearCode = 1 << (init_bits - 1);
+ EOFCode = ClearCode + 1;
+ free_ent = ClearCode + 2;
+
+ a_count = 0; // clear packet
+
+ ent = nextPixel();
+
+ hshift = 0;
+ for (fcode = hsize; fcode < 65536; fcode *= 2)
+ ++hshift;
+ hshift = 8 - hshift; // set hash code range bound
+
+ hsize_reg = hsize;
+ cl_hash(hsize_reg); // clear hash table
+
+ output(ClearCode, outs);
+
+ outer_loop: while ((c = nextPixel()) != EOF) {
+ fcode = (c << maxbits) + ent;
+ i = (c << hshift) ^ ent; // xor hashing
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue;
+ } else if (htab[i] >= 0) // non-empty slot
+ {
+ disp = hsize_reg - i; // secondary hash (after G. Knott)
+ if (i == 0)
+ disp = 1;
+ do {
+ if ((i -= disp) < 0)
+ i += hsize_reg;
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue outer_loop;
+ }
+ } while (htab[i] >= 0);
+ }
+ output(ent, outs);
+ ent = c;
+ if (free_ent < maxmaxcode) {
+ codetab[i] = free_ent++; // code -> hashtable
+ htab[i] = fcode;
+ } else
+ cl_block(outs);
+ }
+ // Put out the final code.
+ output(ent, outs);
+ output(EOFCode, outs);
+ }
+
+ // ----------------------------------------------------------------------------
+ void encode(OutputStream os) throws IOException {
+ os.write(initCodeSize); // write "initial code size" byte
+
+ remaining = imgW * imgH; // reset navigation variables
+ curPixel = 0;
+
+ compress(initCodeSize + 1, os); // compress and write the pixel data
+
+ os.write(0); // write block terminator
+ }
+
+ // Flush the packet to disk, and reset the accumulator
+ void flush_char(OutputStream outs) throws IOException {
+ if (a_count > 0) {
+ outs.write(a_count);
+ outs.write(accum, 0, a_count);
+ a_count = 0;
+ }
+ }
+
+ final int MAXCODE(int n_bits) {
+ return (1 << n_bits) - 1;
+ }
+
+ // ----------------------------------------------------------------------------
+ // Return the next pixel from the image
+ // ----------------------------------------------------------------------------
+ private int nextPixel() {
+ if (remaining == 0)
+ return EOF;
+
+ --remaining;
+
+ byte pix = pixAry[curPixel++];
+
+ return pix & 0xff;
+ }
+
+ void output(int code, OutputStream outs) throws IOException {
+ cur_accum &= masks[cur_bits];
+
+ if (cur_bits > 0)
+ cur_accum |= (code << cur_bits);
+ else
+ cur_accum = code;
+
+ cur_bits += n_bits;
+
+ while (cur_bits >= 8) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ // If the next entry is going to be too big for the code size,
+ // then increase it, if possible.
+ if (free_ent > maxcode || clear_flg) {
+ if (clear_flg) {
+ maxcode = MAXCODE(n_bits = g_init_bits);
+ clear_flg = false;
+ } else {
+ ++n_bits;
+ if (n_bits == maxbits)
+ maxcode = maxmaxcode;
+ else
+ maxcode = MAXCODE(n_bits);
+ }
+ }
+
+ if (code == EOFCode) {
+ // At EOF, write the rest of the buffer.
+ while (cur_bits > 0) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ flush_char(outs);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/CounterOutputStream.java b/src/net/sourceforge/plantuml/CounterOutputStream.java
new file mode 100644
index 000000000..4c0c9d9aa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/CounterOutputStream.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4780 $
+ *
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class CounterOutputStream extends OutputStream {
+
+ private int length;
+ private final OutputStream os;
+
+ public CounterOutputStream(OutputStream os) {
+ this.os = os;
+ }
+
+ /**
+ * Writes to nowhere
+ */
+ @Override
+ public void write(int b) throws IOException {
+ os.write(b);
+ length++;
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[]) throws IOException {
+ os.write(b);
+ length += b.length;
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ os.write(b, off, len);
+ length += len;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ @Override
+ public void flush() throws IOException {
+ os.flush();
+ }
+
+
+ @Override
+ public void close() throws IOException {
+ os.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java
new file mode 100644
index 000000000..b422b905d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ISkinSimple.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4236 $
+ *
+ */
+package net.sourceforge.plantuml;
+
+public interface ISkinSimple extends SpriteContainer {
+
+ public String getValue(String key);
+
+ public double getPadding();
+
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java
new file mode 100644
index 000000000..1096d1016
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionGoto extends MonoSwimable implements Instruction {
+
+ private final String name;
+
+ public InstructionGoto(Swimlane swimlane, String name) {
+ super(swimlane);
+ this.name = name;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return new FtileGoto(factory.shadowing(), getSwimlaneIn(), name);
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
new file mode 100644
index 000000000..10aab4510
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
@@ -0,0 +1,165 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionIf implements Instruction {
+
+ private final List thens = new ArrayList();
+ private Branch elseBranch;
+ private final ISkinParam skinParam;
+
+ private final Instruction parent;
+
+ private Branch current;
+ private final LinkRendering inlinkRendering;
+
+ private final Swimlane swimlane;
+
+ public InstructionIf(Swimlane swimlane, Instruction parent, Display labelTest, Display whenThen,
+ LinkRendering inlinkRendering, HtmlColor color, ISkinParam skinParam) {
+ this.parent = parent;
+ this.skinParam = skinParam;
+
+ this.inlinkRendering = inlinkRendering;
+ this.swimlane = swimlane;
+ this.thens.add(new Branch(swimlane, whenThen, labelTest, color));
+ this.current = this.thens.get(0);
+ }
+
+ public void add(Instruction ins) {
+ current.add(ins);
+ }
+
+ private Display note;
+ private NotePosition position;
+
+ public Ftile createFtile(FtileFactory factory) {
+ for (Branch branch : thens) {
+ branch.updateFtile(factory);
+ }
+ if (elseBranch == null) {
+ this.elseBranch = new Branch(swimlane, null, null, null);
+ }
+ elseBranch.updateFtile(factory);
+ Ftile result = factory.createIf(swimlane, thens, elseBranch);
+ if (note != null) {
+ result = new FtileWithNoteOpale(result, note, position, skinParam, false);
+ }
+ return result;
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public boolean swithToElse2(Display whenElse, LinkRendering nextLinkRenderer) {
+ if (elseBranch != null) {
+ return false;
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ this.elseBranch = new Branch(swimlane, whenElse, null, null);
+ this.current = elseBranch;
+ return true;
+ }
+
+ public void elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) {
+ if (elseBranch != null) {
+ throw new IllegalStateException();
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ this.current = new Branch(swimlane, whenThen, test, color);
+ this.thens.add(current);
+
+ }
+
+ public void endif(LinkRendering nextLinkRenderer) {
+ if (elseBranch == null) {
+ this.elseBranch = new Branch(swimlane, null, null, null);
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ }
+
+ final public boolean kill() {
+ return current.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ if (current.isEmpty()) {
+ this.note = note;
+ this.position = position;
+ } else {
+ current.addNote(note, position);
+ }
+ }
+
+ public Set getSwimlanes() {
+ final Set result = new HashSet();
+ if (swimlane != null) {
+ result.add(swimlane);
+ }
+ for (Branch branch : thens) {
+ result.addAll(branch.getSwimlanes());
+ }
+ result.addAll(elseBranch.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java
new file mode 100644
index 000000000..d148035e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionLabel extends MonoSwimable implements Instruction {
+
+ private final String name;
+
+ public InstructionLabel(Swimlane swimlane, String name) {
+ super(swimlane);
+ this.name = name;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return new FtileLabel(factory.shadowing(), getSwimlaneIn(), name);
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java
new file mode 100644
index 000000000..21ad30139
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionPartition implements Instruction {
+
+ private final InstructionList list = new InstructionList();
+ private final Instruction parent;
+
+ public InstructionPartition(Instruction parent, String partitionTitle) {
+ this.parent = parent;
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public Set getSwimlanes() {
+ return list.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return list.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return list.getSwimlaneOut();
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return list.createFtile(factory);
+ }
+
+ public void add(Instruction other) {
+ list.add(other);
+ }
+
+ public boolean kill() {
+ return list.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return list.getInLinkRendering();
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java
new file mode 100644
index 000000000..55e354729
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12235 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandEndPartition3 extends SingleLineCommand {
+
+ public CommandEndPartition3() {
+ super("(?i)^(\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, List arg) {
+// final IEntity currentPackage = diagram.getCurrentGroup();
+// if (currentPackage == null) {
+// return CommandExecutionResult.error("No partition defined");
+// }
+ return diagram.endGroup();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java
new file mode 100644
index 000000000..3be60470a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandGoto extends SingleLineCommand2 {
+
+ public CommandGoto() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("goto"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final String name = arg.get("NAME", 0);
+ return diagram.addGoto(name);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java
new file mode 100644
index 000000000..19545c128
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+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.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandIf2Multilines extends CommandMultilines2 {
+
+ public CommandIf2Multilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^(.*?)\\)[%s]*(?:then[%s]*(?:\\((.+?)\\))?)?;?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("\\("), //
+ new RegexLeaf("TEST", "([^)]*)$"));
+ }
+
+ @Override
+ public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
+
+ final String test = line0.get("TEST", 0);
+ Display testDisplay = Display.getWithNewlines(test);
+ for (int i = 1; i < lines.size() - 1; i++) {
+ testDisplay = testDisplay.add(lines.get(i));
+ }
+ final String trailTest = lineLast.get(0);
+ if (StringUtils.isEmpty(trailTest) == false) {
+ testDisplay = testDisplay.add(trailTest);
+ }
+
+ diagram.startIf(testDisplay, Display.getWithNewlines(lineLast.get(1)), color);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java
new file mode 100644
index 000000000..38f88434f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandLabel extends SingleLineCommand2 {
+
+ public CommandLabel() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("label"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+
+ final String name = arg.get("NAME", 0);
+ return diagram.addLabel(name);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java
new file mode 100644
index 000000000..e4eee1fd7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.cucadiagram.Display;
+
+public class CommandNolink extends SingleLineCommand2 {
+
+ public CommandNolink() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("nolink"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // diagram.setColorNextArrow(color);
+ diagram.setLabelNextArrow(Display.getWithNewlines("NOLINK"));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java
new file mode 100644
index 000000000..63a84cbf9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12235 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandPartition3 extends SingleLineCommand2 {
+
+ public CommandPartition3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("partition"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("BACKCOLOR", "(?:(#\\w+)[%s]+)?"), //
+ new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), //
+ new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
+ new RegexLeaf("[%s]*\\{?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
+ final HtmlColor backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACKCOLOR", 0));
+ final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("TITLECOLOR", 0));
+ diagram.startGroup(Display.getWithNewlines(partitionTitle), backColor, titleColor);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
new file mode 100644
index 000000000..d3141ac20
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileGeometry extends Dimension2D {
+
+ private final double width;
+ private final double height;
+ private final double left;
+ private final double inY;
+ private final double outY;
+
+ public FtileGeometry(Dimension2D dim, double left, double inY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY);
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY) {
+ this(width, height, left, inY, Double.MIN_NORMAL);
+ }
+
+ @Override
+ public String toString() {
+ return "[" + width + "x" + height + " left=" + left + "]";
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY, double outY) {
+ this.left = left;
+ this.inY = inY;
+ this.outY = outY;
+ this.width = width;
+ this.height = height;
+ }
+
+ public FtileGeometry(Dimension2D dim, double left, double inY, double outY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY, outY);
+ }
+
+ public boolean hasPointOut() {
+ return outY != Double.MIN_NORMAL;
+ }
+
+ public Point2D getPointIn() {
+ return new Point2D.Double(left, inY);
+ }
+
+ public Point2D getPointOut() {
+ if (outY == Double.MIN_NORMAL) {
+ throw new UnsupportedOperationException();
+ }
+ return new Point2D.Double(left, outY);
+ }
+
+ public FtileGeometry withoutPointOut() {
+ return new FtileGeometry(width, height, left, inY);
+ }
+
+ public FtileGeometry translate(UTranslate translate) {
+ final double dx = translate.getDx();
+ final double dy = translate.getDy();
+ if (this.outY == Double.MIN_NORMAL) {
+ return new FtileGeometry(width, height, left + dx, inY + dy);
+ }
+ return new FtileGeometry(width, height, left + dx, inY + dy, outY + dy);
+ }
+
+ public final double getInY() {
+ return inY;
+ }
+
+ public final double getLeft() {
+ return left;
+ }
+
+ public double getOutY() {
+ return outY;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public FtileGeometry addDim(double deltaWidth, double deltaHeight) {
+ return new FtileGeometry(width + deltaWidth, height + deltaHeight, left, inY, outY + deltaHeight);
+ }
+
+ public FtileGeometry addMarginX(double marginx) {
+ return new FtileGeometry(width + 2 * marginx, height, left + marginx, inY, outY);
+ }
+
+ public FtileGeometry fixedHeight(double fixedHeight) {
+ return new FtileGeometry(width, fixedHeight, left, inY, outY);
+ }
+
+ public FtileGeometry appendBottom(FtileGeometry other) {
+ return new FtileGeometryMerger(this, other).getResult();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java
new file mode 100644
index 000000000..49046f230
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+public class FtileGeometryMerger {
+
+ private final FtileGeometry result;
+
+ public FtileGeometryMerger(FtileGeometry geo1, FtileGeometry geo2) {
+ final double left = Math.max(geo1.getLeft(), geo2.getLeft());
+ final double dx1 = left - geo1.getLeft();
+ final double dx2 = left - geo2.getLeft();
+ final double width = Math.max(geo1.getWidth() + dx1, geo2.getWidth() + dx2);
+ final double height = geo1.getHeight() + geo2.getHeight();
+
+ if (geo2.hasPointOut()) {
+ result = new FtileGeometry(width, height, left, geo1.getInY(), geo2.getOutY() + geo1.getHeight());
+ } else {
+ result = new FtileGeometry(width, height, left, geo1.getInY());
+ }
+ }
+
+ public final FtileGeometry getResult() {
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java
new file mode 100644
index 000000000..059a6f071
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class FtileGoto extends FtileEmpty {
+
+ private final String name;
+
+ public FtileGoto(boolean shadowing, Swimlane swimlane, String name) {
+ super(shadowing, swimlane);
+ this.name = name;
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return super.calculateDimension(stringBounder).withoutPointOut();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java
new file mode 100644
index 000000000..9f0e6aac6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+public class FtileLabel extends FtileEmpty {
+
+ private final String name;
+
+ public FtileLabel(boolean shadowing, Swimlane swimlane, String name) {
+ super(shadowing, swimlane);
+ this.name = name;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java
new file mode 100644
index 000000000..5a6a4c9ec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileMargedVertically extends FtileDecorate {
+
+ private final double margin1;
+ private final double margin2;
+
+ public FtileMargedVertically(Ftile tile, double margin1, double margin2) {
+ super(tile);
+ this.margin1 = margin1;
+ this.margin2 = margin2;
+ }
+
+ public void drawU(UGraphic ug) {
+ if (margin1 > 0) {
+ ug = ug.apply(new UTranslate(0, margin1));
+ }
+ ug.draw(getFtileDelegated());
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry orig = getFtileDelegated().calculateDimension(stringBounder);
+ return new FtileGeometry(orig.getWidth(), orig.getHeight() + margin1 + margin2, orig.getLeft(), orig.getInY()
+ + margin1, orig.getOutY() + margin1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java
new file mode 100644
index 000000000..e9dd2117f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class FtileWithUrl extends FtileDecorate {
+
+ private final Url url;
+
+ public FtileWithUrl(Ftile ftile, Url url) {
+ super(ftile);
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.startUrl(url);
+ getFtileDelegated().drawU(ug);
+ ug.closeAction();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java
new file mode 100644
index 000000000..7c6430f08
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorGoto;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GotoInterceptor implements TextBlock {
+
+ private final TextBlock swinlanes;
+
+ public GotoInterceptor(TextBlock swinlanes) {
+ this.swinlanes = swinlanes;
+ }
+
+ public void drawU(UGraphic ug) {
+ new UGraphicInterceptorGoto(ug).draw(swinlanes);
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return swinlanes.calculateDimension(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java
new file mode 100644
index 000000000..fa85f770b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 10266 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.util.HashMap;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockInterceptorUDrawable implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockInterceptorUDrawable(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlock.drawU(new UGraphicInterceptorUDrawable2(ug, new HashMap()));
+ ug.flushUg();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return TextBlockUtils.getMinMax(this, stringBounder).getDimension();
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java
new file mode 100644
index 000000000..2f609f472
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 10266 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.svek.UGraphicForSnake;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UGraphicInterceptorUDrawable2 extends UGraphicDelegator {
+
+ private final Map positions;
+
+ public UGraphicInterceptorUDrawable2(UGraphic ug, Map positions) {
+ super(ug);
+ this.positions = positions;
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof Ftile) {
+ final Ftile ftile = (Ftile) shape;
+ // System.err.println("ftile=" + ftile);
+ ftile.drawU(this);
+ if (ftile instanceof FtileLabel) {
+ positions.put(((FtileLabel) ftile).getName(), getPosition());
+ // System.err.println("ug=" + getUg().getClass());
+ }
+ if (ftile instanceof FtileGoto) {
+ // System.err.println("positions=" + positions);
+ drawGoto((FtileGoto) ftile);
+ }
+ } else if (shape instanceof UDrawable) {
+ final UDrawable drawable = (UDrawable) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ private UTranslate getPosition() {
+ return ((UGraphicForSnake) getUg()).getTranslation();
+ }
+
+ private void drawGoto(FtileGoto ftile) {
+ final FtileGeometry geom = ftile.calculateDimension(getStringBounder());
+ final Point2D pt = geom.getPointIn();
+ UGraphic ugGoto = getUg().apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
+ new UChangeBackColor(HtmlColorUtils.GREEN));
+ ugGoto = ugGoto.apply(new UTranslate(pt));
+ final UTranslate posNow = getPosition();
+ final UTranslate dest = positions.get(ftile.getName());
+ final double dx = dest.getDx() - posNow.getDx();
+ final double dy = dest.getDy() - posNow.getDy();
+ ugGoto.draw(new UEllipse(3, 3));
+ ugGoto.apply(new UTranslate(dx, dy)).draw(new UEllipse(3, 3));
+ ugGoto.draw(new ULine(dx, 0));
+ ugGoto.apply(new UTranslate(dx, 0)).draw(new ULine(0, dy));
+ // ugGoto.draw(new ULine(dx, dy));
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorUDrawable2(getUg().apply(change), positions);
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java
new file mode 100644
index 000000000..92122d72f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.Opale;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class FloatingNote implements Stencil, TextBlock {
+
+ private final Opale opale;
+
+ public FloatingNote(Display note, ISkinParam skinParam) {
+
+ final Rose rose = new Rose();
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground);
+ final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder);
+
+ final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note);
+ final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
+ this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(), false);
+
+ // this.text = sheetBlock2;
+
+ }
+
+ public void drawU(UGraphic ug) {
+ opale.drawU(ug);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return opale.calculateDimension(stringBounder);
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return -opale.getMarginX1();
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java
new file mode 100644
index 000000000..9e477e7f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithUrl;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox;
+
+public class FtileFactoryDelegatorAddUrl extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorAddUrl(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile addUrl(Ftile ftile, Url url) {
+ if (ftile instanceof FtileBox) {
+ return new FtileWithUrl(ftile, url);
+ }
+ return ftile;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java
new file mode 100644
index 000000000..9d478c0b5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java
@@ -0,0 +1,318 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfAndStop extends AbstractFtile {
+
+ private final Ftile tile1;
+ private final Ftile diamond1;
+ private final Ftile stop2;
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfAndStop(Ftile diamond1, Ftile tile1, HtmlColor arrowColor, Ftile stopFtile) {
+ super(tile1.shadowing());
+ this.diamond1 = diamond1;
+ this.tile1 = tile1;
+ this.stop2 = stopFtile;
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ public Set getSwimlanes() {
+ final Set result = new HashSet();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ result.addAll(tile1.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamond1.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, UFont fontTest,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch nonStop,
+ ISkinParam skinParam, StringBounder stringBounder, Display labelTest) {
+
+ backColor = HtmlColorUtils.BLUE;
+
+ // final Ftile tileNonStop = new FtileMinWidth(nonStop.getFtile(), 30);
+ final Ftile tileNonStop = nonStop.getFtile();
+
+ final HtmlColor fontColor = skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null);
+
+ final FontConfiguration fcArrow = new FontConfiguration(fontArrow, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+
+ final Ftile stopFtile = ftileFactory.stop(swimlane);
+
+ // final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ // ftileFactory);
+ // final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ // ftileFactory);
+
+ final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
+ final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5));
+
+ final Ftile diamond1;
+ if (conditionStyle == ConditionStyle.INSIDE) {
+ diamond1 = new FtileDiamondInside(tileNonStop.shadowing(), backColor, borderColor, swimlane, tbTest);
+ // .withWest(tb1).withEast(tb2);
+ } else if (conditionStyle == ConditionStyle.DIAMOND) {
+ diamond1 = new FtileDiamond(tileNonStop.shadowing(), backColor, borderColor, swimlane).withNorth(tbTest);
+ // .withWest(tb1).withEast(tb2).withNorth(tbTest);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ // final Ftile diamond2;
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane);
+ // } else {
+ // diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
+ // swimlane, swimlane);
+ // }
+ final FtileIfAndStop result = new FtileIfAndStop(diamond1, tileNonStop, arrowColor, stopFtile);
+
+ final List conns = new ArrayList();
+ conns.add(result.new ConnectionHorizontal(arrowColor));
+ // conns.add(result.new ConnectionHorizontalThenVertical(tile2));
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // conns.add(result.new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor()));
+ // conns.add(result.new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor()));
+ // } else if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut() == false) {
+ // conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor()));
+ // } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor()));
+ // }
+ return FtileUtils.addConnection(result, conns);
+ // return result;
+ }
+
+ private UTranslate getTranslate1(StringBounder stringBounder) {
+ // final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final FtileGeometry dimTotal = calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
+
+ final double x1 = calculateDimension(stringBounder).getLeft() - dim1.getLeft();
+ // final double y1 = (dimTotal.getHeight() - 2 * h - dim1.getHeight()) / 2 + h;
+ final double y1 = dimDiamond1.getHeight() + getSuppHeight();
+ return new UTranslate(x1, y1);
+ }
+
+ private int getSuppHeight() {
+ return 30;
+ }
+
+ private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
+ final double y1 = 0;
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ // final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2;
+ final double x1 = calculateDimension(stringBounder).getLeft() - dimDiamond1.getWidth() / 2;
+ return new UTranslate(x1, y1);
+ }
+
+ private UTranslate getTranslateStop(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimStop = stop2.calculateDimension(stringBounder);
+ final double y1 = (dimDiamond1.getHeight() - dimStop.getHeight()) / 2;
+ final double x1 = calculateDimension(stringBounder).getLeft() + dimDiamond1.getWidth() / 2
+ + getDiamondStopDistance();
+ return new UTranslate(x1, y1);
+ }
+
+ private double getDiamondStopDistance() {
+ return 40;
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(HtmlColor color) {
+ super(diamond1, stop2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
+
+ return getTranslateDiamond1(stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Dimension2D dimStop = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, dimStop.getHeight() / 2);
+ return getTranslateStop(stringBounder).getTranslated(p);
+ }
+
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == diamond1) {
+ return getTranslateDiamond1(stringBounder);
+ }
+ if (child == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ // if (child == tile2) {
+ // return getTranslate2(stringBounder);
+ // }
+ // if (child == diamond2) {
+ // return getTranslateDiamond2(stringBounder);
+ // }
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
+ ug.apply(getTranslate1(stringBounder)).draw(tile1);
+ ug.apply(getTranslateStop(stringBounder)).draw(stop2);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
+ final FtileGeometry dim1 = tile1.calculateDimension(stringBounder).addDim(0,
+ getDiamondStopDistance() + dimStop2.getWidth());
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ return dimDiamond1.appendBottom(dim1).addDim(0, getSuppHeight());
+
+ // final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()) {
+ // return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
+ // }
+ // return new FtileGeometry(dimTotal, getLeft(stringBounder), 0);
+ }
+
+ // private Dimension2D calculateDimensionInternal;
+ //
+ // private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ // if (calculateDimensionInternal == null) {
+ // calculateDimensionInternal = calculateDimensionInternalSlow(stringBounder);
+ // }
+ // return calculateDimensionInternal;
+ // }
+ //
+ // private Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) {
+ // final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
+ // final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ // final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
+ // final double width = Math.max(dim1.getWidth(),
+ // dimDiamond1.getWidth() + getDiamondStopDistance() + dimStop2.getWidth());
+ // return new Dimension2DDouble(width + 30, dim1.getHeight() + dimDiamond1.getHeight() + 40);
+ // }
+ //
+ // private double getLeft(StringBounder stringBounder) {
+ // // return calculateDimension(stringBounder).getLeft();
+ // return tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
+ // // final double left1 =
+ // tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
+ // // // final double left2 =
+ // // // tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
+ // // // return (left1 + left2) / 2;
+ // // return left1;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java
new file mode 100644
index 000000000..a86acd8f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java
@@ -0,0 +1,515 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfLong extends AbstractFtile {
+
+ private final double xSeparation = 20;
+
+ private final List tiles;
+ private final Ftile tile2;
+ private final List diamonds;
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfLong(List diamonds, List tiles, Ftile tile2, HtmlColor arrowColor) {
+ super(tiles.get(0).shadowing() || tile2.shadowing());
+ this.diamonds = diamonds;
+ this.tiles = tiles;
+ this.tile2 = tile2;
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ public Set getSwimlanes() {
+ final Set result = new HashSet();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ for (Ftile tile : tiles) {
+ result.addAll(tile.getSwimlanes());
+ }
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamonds.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List thens,
+ Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final List tiles = new ArrayList();
+
+ for (Branch branch : thens) {
+ tiles.add(new FtileMinWidth(branch.getFtile(), 30));
+ }
+
+ final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
+
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+
+ final List diamonds = new ArrayList();
+ final List conns = new ArrayList();
+ for (Branch branch : thens) {
+ final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ FtileDiamondInside diamond = new FtileDiamondInside(branch.shadowing(), backColor, borderColor, swimlane,
+ tbTest);
+ diamond = diamond.withNorth(tb1);
+ diamonds.add(diamond);
+ }
+
+ final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final int last = diamonds.size() - 1;
+ diamonds.set(last, ((FtileDiamondInside) diamonds.get(last)).withEast(tb2));
+
+ final FtileIfLong result = new FtileIfLong(diamonds, tiles, tile2, arrowColor);
+
+ for (int i = 0; i < thens.size(); i++) {
+ final Ftile ftile = tiles.get(i);
+ final Ftile diam = diamonds.get(i);
+
+ final HtmlColor color = thens.get(i).getInlinkRenderingColor();
+ conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
+ conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
+ }
+
+ for (int i = 0; i < diamonds.size() - 1; i++) {
+ final Ftile diam1 = diamonds.get(i);
+ final Ftile diam2 = diamonds.get(i + 1);
+ conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
+ }
+ conns.add(result.new ConnectionIn(arrowColor));
+ conns.add(result.new ConnectionLastElseIn(arrowColor));
+ conns.add(result.new ConnectionLastElseOut(arrowColor));
+ conns.add(result.new ConnectionHline(arrowColor));
+
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
+ super(diam1, diam2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
+
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, dimDiamond1.getOutY() / 2);
+ return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(HtmlColor arrowColor) {
+ super(null, diamonds.get(0));
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
+ final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D p1 = calculateDimension(ug.getStringBounder()).getPointIn();
+
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionLastElseIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseIn(HtmlColor arrowColor) {
+ super(diamonds.get(diamonds.size() - 1), tile2);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Point2D p1 = getP1(ug.getStringBounder());
+ final UTranslate tr2 = getTranslate2(ug.getStringBounder());
+ final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionLastElseOut extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseOut(HtmlColor arrowColor) {
+ super(tile2, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate tr1 = getTranslate2(stringBounder);
+ final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
+ if (dim.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = tr1.getTranslated(dim.getPointOut());
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionVerticalIn extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
+ super(diamond, tile);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
+ return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionVerticalOut extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
+ super(tile, null);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p1 = getP1(stringBounder);
+ if (p1 == null) {
+ return;
+ }
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return null;
+ }
+ final Point2D p = geo.getPointOut();
+ return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionHline extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionHline(HtmlColor arrowColor) {
+ super(null, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
+
+ final List all = new ArrayList(tiles);
+ all.add(tile2);
+ double minX = totalDim.getWidth() / 2;
+ double maxX = totalDim.getWidth() / 2;
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
+ continue;
+ }
+ final UTranslate ut = getTranslateFor(tmp, stringBounder);
+ final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
+ minX = Math.min(minX, out);
+ maxX = Math.max(maxX, out);
+ }
+
+ final Snake s = new Snake(arrowColor);
+ s.goUnmergeable();
+ final double height = totalDim.getHeight();
+ s.addPoint(minX, height);
+ s.addPoint(maxX, height);
+ ug.draw(s);
+ }
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ if (tiles.contains(child)) {
+ return getTranslate1(child, stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslate2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
+
+ final double x2 = dimTotal.getWidth() - dim2.getWidth();
+
+ final double h = getAllDiamondsHeight(stringBounder);
+ final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
+
+ return new UTranslate(x2, y2);
+
+ }
+
+ private UTranslate getTranslateDiamond1(Ftile diamond1, StringBounder stringBounder) {
+ double x1 = 0;
+
+ for (Ftile diamond : diamonds) {
+ final FtileGeometry dim1 = dimDiamondAndTile(stringBounder, diamond);
+ if (diamond == diamond1) {
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ double xresult = x1 + dim1.getLeft() - dimDiamond.getLeft();
+ return new UTranslate(xresult, 25);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ private UTranslate getTranslate1(Ftile tile1, StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ double x1 = 0;
+
+ for (Ftile tile : tiles) {
+ final Dimension2D dim1 = dimDiamondAndTile(stringBounder, tile);
+ if (tile == tile1) {
+ final Dimension2D dimTile = tile.calculateDimension(stringBounder);
+ final double h = getAllDiamondsHeight(stringBounder);
+ final double y1 = (dimTotal.getHeight() - 2 * h - dimTile.getHeight()) / 2 + h;
+ return new UTranslate(x1 + (dim1.getWidth() - dimTile.getWidth()) / 2, y1);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Ftile tile : tiles) {
+ ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
+ }
+ for (Ftile diamond : diamonds) {
+ ug.apply(getTranslateDiamond1(diamond, stringBounder)).draw(diamond);
+ }
+
+ ug.apply(getTranslate2(stringBounder)).draw(tile2);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final List all = new ArrayList(tiles);
+ all.add(tile2);
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut()) {
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+ }
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
+
+ }
+
+ private FtileGeometry dimDiamondAndTile(StringBounder stringBounder, Ftile tileOrDiamond) {
+ for (int i = 0; i < tiles.size(); i++) {
+ final Ftile tile = tiles.get(i);
+ final Ftile diamond = diamonds.get(i);
+ if (tile != tileOrDiamond && diamond != tileOrDiamond) {
+ continue;
+ }
+ final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ return dimDiamond.appendBottom(dimTile);
+ }
+ throw new UnsupportedOperationException();
+
+ }
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ Dimension2D dimOnlyTiles = new Dimension2DDouble(0, 0);
+ Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
+ Dimension2D dimBoth = new Dimension2DDouble(0, 0);
+ for (int i = 0; i < tiles.size(); i++) {
+ final Ftile tile = tiles.get(i);
+ final Ftile diamond = diamonds.get(i);
+ final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ final FtileGeometry both = dimDiamond.appendBottom(dimTile);
+ dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile);
+ dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
+ dimBoth = Dimension2DDouble.mergeLR(dimBoth, both);
+ }
+ final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
+ dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile2);
+ dimBoth = Dimension2DDouble.mergeLR(dimBoth, dimTile2);
+
+ final Dimension2D result = new Dimension2DDouble(dimBoth.getWidth(), dimOnlyDiamond.getHeight() * 4
+ + dimOnlyTiles.getHeight());
+ return Dimension2DDouble.delta(result, xSeparation * tiles.size(), 40);
+ }
+
+ private double getAllDiamondsHeight(StringBounder stringBounder) {
+ Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
+ for (Ftile diamond : diamonds) {
+ final Dimension2D dimDiamond = diamond.calculateDimension(stringBounder);
+ dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
+ }
+ return dimOnlyDiamond.getHeight();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java
new file mode 100644
index 000000000..2543a445c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java
@@ -0,0 +1,510 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfLong2 extends AbstractFtile {
+
+ private final double xSeparation = 20;
+
+ private final List tiles;
+ private final Ftile tile2;
+ private final List diamonds;
+ private final List couples = new ArrayList();
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfLong2(List diamonds, List tiles, Ftile tile2, HtmlColor arrowColor) {
+ super(tiles.get(0).shadowing() || tile2.shadowing());
+ if (diamonds.size() != tiles.size()) {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < diamonds.size(); i++) {
+ couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i)));
+ }
+ this.tile2 = tile2;
+ this.diamonds = new ArrayList(diamonds);
+ this.tiles = new ArrayList(tiles);
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ private static List alignDiamonds(List diamonds, StringBounder stringBounder) {
+ double maxOutY = 0;
+ for (Ftile diamond : diamonds) {
+ maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
+ }
+ final List result = new ArrayList();
+ for (int i = 0; i < diamonds.size(); i++) {
+ Ftile diamond = diamonds.get(i);
+ final double missing = maxOutY - diamond.calculateDimension(stringBounder).getOutY();
+ assert missing >= 0;
+ diamond = FtileUtils.addVerticalMargin(diamond, missing / 2, 20);
+ result.add(diamond);
+ }
+ return result;
+ }
+
+ public Set getSwimlanes() {
+ final Set result = new HashSet();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ for (Ftile tile : couples) {
+ result.addAll(tile.getSwimlanes());
+ }
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return couples.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List thens,
+ Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final List tiles = new ArrayList();
+
+ for (Branch branch : thens) {
+ tiles.add(new FtileMinWidth(branch.getFtile(), 30));
+ }
+
+ final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
+
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+
+ List diamonds = new ArrayList();
+ final List conns = new ArrayList();
+ for (Branch branch : thens) {
+ final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.shadowing(), backColor, borderColor, swimlane,
+ tbTest);
+ diamond = diamond.withNorth(tb1);
+ diamonds.add(diamond);
+ }
+
+ final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final int last = diamonds.size() - 1;
+ diamonds.set(last, ((FtileDiamondInside2) diamonds.get(last)).withEast(tb2));
+
+ diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder());
+
+ final FtileIfLong2 result = new FtileIfLong2(diamonds, tiles, tile2, arrowColor);
+
+ for (int i = 0; i < thens.size(); i++) {
+ final Ftile ftile = tiles.get(i);
+ final Ftile diam = diamonds.get(i);
+
+ final HtmlColor color = thens.get(i).getInlinkRenderingColor();
+ conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
+ conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
+ }
+
+ for (int i = 0; i < diamonds.size() - 1; i++) {
+ final Ftile diam1 = diamonds.get(i);
+ final Ftile diam2 = diamonds.get(i + 1);
+ conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
+ }
+ conns.add(result.new ConnectionIn(arrowColor));
+ conns.add(result.new ConnectionLastElseIn(arrowColor));
+ conns.add(result.new ConnectionLastElseOut(arrowColor));
+ conns.add(result.new ConnectionHline(arrowColor));
+
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
+ super(diam1, diam2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
+ stringBounder));
+
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, getYdiamontOutToLeft(dimDiamond1, stringBounder));
+ return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ static private double getYdiamontOutToLeft(FtileGeometry dimDiamond1, StringBounder stringBounder) {
+ return (dimDiamond1.getInY() + dimDiamond1.getOutY()) / 2;
+ }
+
+ class ConnectionIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(HtmlColor arrowColor) {
+ super(null, diamonds.get(0));
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
+ final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D p1 = calculateDimensionInternal(ug.getStringBounder()).getPointIn();
+
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionLastElseIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseIn(HtmlColor arrowColor) {
+ super(diamonds.get(diamonds.size() - 1), tile2);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Point2D p1 = getP1(ug.getStringBounder());
+ final UTranslate tr2 = getTranslate2(ug.getStringBounder());
+ final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
+ stringBounder));
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionLastElseOut extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseOut(HtmlColor arrowColor) {
+ super(tile2, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate tr1 = getTranslate2(stringBounder);
+ final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
+ if (dim.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = tr1.getTranslated(dim.getPointOut());
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionVerticalIn extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
+ super(diamond, tile);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
+ return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionVerticalOut extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
+ super(tile, null);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p1 = getP1(stringBounder);
+ if (p1 == null) {
+ return;
+ }
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return null;
+ }
+ final Point2D p = geo.getPointOut();
+ return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionHline extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionHline(HtmlColor arrowColor) {
+ super(null, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
+
+ final List all = new ArrayList(couples);
+ all.add(tile2);
+ double minX = totalDim.getWidth() / 2;
+ double maxX = totalDim.getWidth() / 2;
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
+ continue;
+ }
+ final UTranslate ut = getTranslateFor(tmp, stringBounder);
+ final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
+ minX = Math.min(minX, out);
+ maxX = Math.max(maxX, out);
+ }
+
+ final Snake s = new Snake(arrowColor);
+ s.goUnmergeable();
+ final double height = totalDim.getHeight();
+ s.addPoint(minX, height);
+ s.addPoint(maxX, height);
+ ug.draw(s);
+ }
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ if (couples.contains(child)) {
+ return getTranslateCouple1(child, stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslate2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
+
+ final double x2 = dimTotal.getWidth() - dim2.getWidth();
+
+ final double h = 0; // getAllDiamondsHeight(stringBounder);
+ final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
+
+ return new UTranslate(x2, y2);
+
+ }
+
+ private UTranslate getTranslateDiamond1(Ftile diamond, StringBounder stringBounder) {
+ final int idx = diamonds.indexOf(diamond);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
+ final UTranslate in = couples.get(idx).getTranslateFor(diamond, stringBounder);
+ return trCouple.compose(in);
+ }
+
+ public UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
+ final int idx = tiles.indexOf(tile);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
+ final UTranslate in = couples.get(idx).getTranslateFor(tile, stringBounder);
+ return trCouple.compose(in);
+ }
+
+ private UTranslate getTranslateCouple1(Ftile candidat, StringBounder stringBounder) {
+ double x1 = 0;
+
+ for (Ftile couple : couples) {
+ final FtileGeometry dim1 = couple.calculateDimension(stringBounder);
+ if (couple == candidat) {
+ return new UTranslate(x1, 25);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Ftile couple : couples) {
+ ug.apply(getTranslateCouple1(couple, stringBounder)).draw(couple);
+ }
+
+ ug.apply(getTranslate2(stringBounder)).draw(tile2);
+ }
+
+ private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (Ftile couple : couples) {
+ result = Dimension2DDouble.mergeLR(result, couple.calculateDimension(stringBounder));
+ }
+ final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
+ result = Dimension2DDouble.mergeLR(result, dimTile2);
+ result = Dimension2DDouble.delta(result, xSeparation * couples.size(), 100);
+
+ return new FtileGeometry(result, result.getWidth() / 2, 0);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final List all = new ArrayList(tiles);
+ all.add(tile2);
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut()) {
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+ }
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
+
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java
new file mode 100644
index 000000000..3883bf392
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileSplit1 extends AbstractFtile {
+
+ private final List forks = new ArrayList();
+
+ public FtileSplit1(List forks) {
+ super(forks.get(0).shadowing());
+ for (Ftile ftile : forks) {
+ this.forks.add(ftile);
+ }
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return forks.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return null;
+ // return getSwimlaneIn();
+ }
+
+ public Set getSwimlanes() {
+ return mergeSwimlanes(forks);
+ }
+
+ public static Set mergeSwimlanes(List tiles) {
+ final Set result = new HashSet();
+ for (Ftile tile : tiles) {
+ result.addAll(tile.getSwimlanes());
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ for (Ftile ftile : forks) {
+ ug.apply(getTranslateFor(ftile, stringBounder)).draw(ftile);
+ }
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ double height = 0;
+ double width = 0;
+ for (Ftile ftile : forks) {
+ final Dimension2D dim = ftile.calculateDimension(stringBounder);
+ if (dim.getWidth() > width) {
+ width = dim.getWidth();
+ }
+ if (dim.getHeight() > height) {
+ height = dim.getHeight();
+ }
+ }
+ final Dimension2D dimTotal = new Dimension2DDouble(width, height);
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+
+ public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) {
+ final Dimension2D dim = searched.calculateDimension(stringBounder);
+ final double xpos = calculateDimension(stringBounder).getWidth() - dim.getWidth();
+ return new UTranslate(xpos / 2, 0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java
new file mode 100644
index 000000000..79762e39c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 10266 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorGoto extends UGraphicDelegator {
+
+ public UGraphicInterceptorGoto(UGraphic ug) {
+ super(ug);
+ }
+
+ public void draw(UShape shape) {
+ System.err.println("inter=" + shape.getClass());
+
+ if (shape instanceof Ftile) {
+ final Ftile foo = (Ftile) shape;
+ foo.drawU(this);
+ } else {
+ getUg().draw(shape);
+ System.err.println("Drawing " + shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorGoto(getUg().apply(change));
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java
new file mode 100644
index 000000000..8e06aa263
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5183 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileDiamondInside2 extends AbstractFtile {
+
+ private final HtmlColor backColor;
+ private final HtmlColor borderColor;
+ private final Swimlane swimlane;
+ private final TextBlock label;
+ private final TextBlock west;
+ private final TextBlock east;
+ private final TextBlock north;
+ private final TextBlock south;
+
+ public FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label) {
+ this(shadowing, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
+ TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
+ }
+
+ public FtileDiamondInside2 withNorth(TextBlock north) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withWest(TextBlock west) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withEast(TextBlock east) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withSouth(TextBlock south) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ private FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ this.borderColor = borderColor;
+ this.label = label;
+ this.west = west;
+ this.east = east;
+ this.north = north;
+ this.south = south;
+ }
+
+ public Set getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
+ ug = ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor));
+ ug.draw(Diamond.asPolygon(shadowing(), dimTotal.getWidth(), dimTotal.getHeight()));
+
+ north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+ south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+
+ final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
+ final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
+ label.drawU(ug.apply(new UTranslate(lx, ly)));
+
+ final Dimension2D dimWeat = west.calculateDimension(stringBounder);
+ west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2)));
+
+ final Dimension2D dimEast = east.calculateDimension(stringBounder);
+ east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2)));
+
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D diamond = calculateDimensionAlone(stringBounder);
+ final Dimension2D north = this.north.calculateDimension(stringBounder);
+ final double height = diamond.getHeight() + north.getHeight();
+ final double left = diamond.getWidth() / 2;
+ final double width = north.getWidth() > left ? left + north.getWidth() : diamond.getWidth();
+ return new FtileGeometry(width, height, left, 0, diamond.getHeight());
+ }
+
+ private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dim;
+ if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
+ dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ } else {
+ dim = Dimension2DDouble.delta(
+ Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
+ Diamond.diamondHalfSize * 2, 0);
+ }
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AffineTransformation.java b/src/net/sourceforge/plantuml/anim/AffineTransformation.java
new file mode 100644
index 000000000..a5b327d3b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AffineTransformation.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6170 $
+ *
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+
+public class AffineTransformation {
+
+ static private final Pattern rotate = Pattern.compile("rotate\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern shear = Pattern.compile("shear\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern translate = Pattern.compile("translate\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern scale = Pattern.compile("scale\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern color = Pattern.compile("color\\s+.*");
+
+ private final AffineTransform affineTransform;
+ private Dimension2D dimension;
+
+ private AffineTransformation(AffineTransform affineTransform) {
+ this.affineTransform = affineTransform;
+ if (affineTransform == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ private AffineTransformation compose(AffineTransformation other) {
+ final AffineTransform tmp = new AffineTransform(this.affineTransform);
+ tmp.concatenate(other.affineTransform);
+ return new AffineTransformation(tmp);
+ }
+
+ public static AffineTransformation from(AffineTransform affineTransform) {
+ return new AffineTransformation(affineTransform);
+ }
+
+ static AffineTransformation create(String value) {
+ final StringTokenizer st = new StringTokenizer(value, "|");
+ AffineTransformation result = null;
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ final AffineTransformation tmp = createSimple(s);
+ if (tmp != null) {
+ if (result == null) {
+ result = tmp;
+ } else {
+ result = result.compose(tmp);
+ }
+ }
+ }
+ return result;
+ }
+
+ private static AffineTransformation createSimple(String value) {
+ Matcher m = rotate.matcher(value.trim());
+ if (m.find()) {
+ final double angle = Double.parseDouble(m.group(1));
+ return new AffineTransformation(AffineTransform.getRotateInstance(angle * Math.PI / 180.0));
+ }
+ m = shear.matcher(value);
+ if (m.find()) {
+ final double shx = Double.parseDouble(m.group(1));
+ final double shy = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getShearInstance(shx, shy));
+ }
+ m = translate.matcher(value);
+ if (m.find()) {
+ final double tx = Double.parseDouble(m.group(1));
+ final double ty = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getTranslateInstance(tx, ty));
+ }
+ m = scale.matcher(value);
+ if (m.find()) {
+ final double scalex = Double.parseDouble(m.group(1));
+ final double scaley = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getScaleInstance(scalex, scaley));
+ }
+ m = color.matcher(value);
+ if (m.find()) {
+ return new AffineTransformation(new AffineTransform());
+ }
+ return null;
+ }
+
+ public final AffineTransform getAffineTransform() {
+ return getAffineTransform(dimension);
+ }
+
+ private AffineTransform getAffineTransform(Dimension2D dimension) {
+ if (dimension == null) {
+ throw new IllegalStateException();
+ }
+ final AffineTransform at = AffineTransform.getTranslateInstance(dimension.getWidth() / 2,
+ dimension.getHeight() / 2);
+ at.concatenate(affineTransform);
+ at.translate(-dimension.getWidth() / 2, -dimension.getHeight() / 2);
+
+ return at;
+ }
+
+ public void setDimension(Dimension2D dim) {
+ this.dimension = dim;
+
+ }
+
+ public MinMax getMinMax(Dimension2D rect) {
+ MinMax result = MinMax.getEmpty(false);
+ final AffineTransform tmp = getAffineTransform(rect);
+ result = result.addPoint(tmp.transform(new Point2D.Double(0, 0), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(0, rect.getHeight()), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), 0), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), rect.getHeight()), null));
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/Animation.java b/src/net/sourceforge/plantuml/anim/Animation.java
new file mode 100644
index 000000000..4c36e5960
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/Animation.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6170 $
+ *
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+
+public class Animation {
+
+ private final List all;
+
+ private Animation(List all) {
+ if (all.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.all = all;
+ }
+
+ public static Animation singleton(AffineTransformation affineTransformation) {
+ if (affineTransformation == null) {
+ return null;
+ }
+ return new Animation(Collections.singletonList(affineTransformation));
+ }
+
+ public static Animation create(List descriptions) {
+ final List all = new ArrayList();
+ for (String s : descriptions) {
+ final AffineTransformation tmp = AffineTransformation.create(s);
+ if (tmp != null) {
+ all.add(tmp);
+ }
+ }
+ return new Animation(all);
+ }
+
+ public Collection getAll() {
+ return Collections.unmodifiableCollection(all);
+ }
+
+ public void setDimension(Dimension2D dim) {
+ for (AffineTransformation affineTransform : all) {
+ affineTransform.setDimension(dim);
+ }
+
+ }
+
+ public AffineTransformation getFirst() {
+ return all.get(0);
+ }
+
+ public MinMax getMinMax(Dimension2D dim) {
+ MinMax result = MinMax.getEmpty(false);
+ for (AffineTransformation affineTransform : all) {
+ final MinMax m = affineTransform.getMinMax(dim);
+ result = result.addMinMax(m);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AnimationDecoder.java b/src/net/sourceforge/plantuml/anim/AnimationDecoder.java
new file mode 100644
index 000000000..00acb568d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AnimationDecoder.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6170 $
+ *
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.script.ScriptException;
+
+public class AnimationDecoder {
+
+ private final List result = new ArrayList();
+
+ public AnimationDecoder(List data) throws ScriptException {
+ for (int i = 0; i < data.size(); i++) {
+ String line = data.get(i);
+ if (line.matches("^\\s*\\[script\\]\\s*$")) {
+ final StringBuilder scriptText = new StringBuilder();
+ while (true) {
+ i++;
+ line = data.get(i);
+ if (line.matches("^\\s*\\[/script\\]\\s*$")) {
+ final AnimationScript script = new AnimationScript();
+ final String out = script.eval(scriptText.toString());
+ for (final StringTokenizer st = new StringTokenizer(out, "\n"); st.hasMoreTokens();) {
+ result.add(st.nextToken());
+ }
+ break;
+ } else {
+ scriptText.append(line);
+ scriptText.append("\n");
+ }
+ }
+ } else {
+ result.add(line);
+ }
+ }
+ }
+
+ public List decode() {
+ return Collections.unmodifiableList(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AnimationScript.java b/src/net/sourceforge/plantuml/anim/AnimationScript.java
new file mode 100644
index 000000000..fd677fc63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AnimationScript.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6170 $
+ *
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+public class AnimationScript {
+
+ private final ScriptEngine engine;
+
+ public AnimationScript() {
+
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ engine = manager.getEngineByName("js");
+
+ // ScriptEngineManager manager = new ScriptEngineManager();
+ // List factories = manager.getEngineFactories();
+ // for (ScriptEngineFactory factory : factories) {
+ // System.out.println("Name : " + factory.getEngineName());
+ // System.out.println("Version : " + factory.getEngineVersion());
+ // System.out.println("Language name : " + factory.getLanguageName());
+ // System.out.println("Language version : " + factory.getLanguageVersion());
+ // System.out.println("Extensions : " + factory.getExtensions());
+ // System.out.println("Mime types : " + factory.getMimeTypes());
+ // System.out.println("Names : " + factory.getNames());
+ //
+ // }
+
+ }
+
+ public String eval(String line) throws ScriptException {
+ final ScriptContext context = engine.getContext();
+ final StringWriter sw = new StringWriter();
+ context.setWriter(new PrintWriter(sw));
+ engine.eval(line, context);
+ final String result = sw.toString();
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/CountRate.java b/src/net/sourceforge/plantuml/api/CountRate.java
new file mode 100644
index 000000000..67f907d33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/CountRate.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api;
+
+public final class CountRate {
+
+ private final MagicArray lastMinute = new MagicArray(60);
+ private final MagicArray lastHour = new MagicArray(60);
+ private final MagicArray lastDay = new MagicArray(140);
+
+ public void increment() {
+ final long now = System.currentTimeMillis();
+ lastMinute.incKey(now / 1000L);
+ lastHour.incKey(now / (60 * 1000L));
+ lastDay.incKey(now / (10 * 60 * 1000L));
+ }
+
+ public void increment(int value) {
+ final long now = System.currentTimeMillis();
+ lastMinute.incKey(now / 1000L, value);
+ lastHour.incKey(now / (60 * 1000L), value);
+ lastDay.incKey(now / (10 * 60 * 1000L), value);
+ }
+
+ public long perMinute() {
+ return lastMinute.getSum();
+ }
+
+ public long perHour() {
+ return lastHour.getSum();
+ }
+
+ public long perDay() {
+ return lastDay.getSum();
+ }
+
+ public long perMinuteMax() {
+ return lastMinute.getMaxSum();
+ }
+
+ public long perHourMax() {
+ return lastHour.getMaxSum();
+ }
+
+ public long perDayMax() {
+ return lastDay.getMaxSum();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/INumberAnalyzed.java b/src/net/sourceforge/plantuml/api/INumberAnalyzed.java
new file mode 100644
index 000000000..a4059c05c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/INumberAnalyzed.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * 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
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License aint with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+package net.sourceforge.plantuml.api;
+
+public interface INumberAnalyzed {
+
+ public int getNb();
+
+ public int getSum();
+
+ public int getMin();
+
+ public int getMax();
+
+ public int getMean();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/MagicArray.java b/src/net/sourceforge/plantuml/api/MagicArray.java
new file mode 100644
index 000000000..06cc9bd16
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/MagicArray.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api;
+
+public final class MagicArray {
+
+ private final int data[];
+ private final int size;
+ private long lastUpdatedKey = -1;
+ private int lastUpdatedValue;
+ private long sum;
+ private long maxSum;
+
+ public MagicArray(int size) {
+ this.data = new int[size];
+ this.size = size;
+ }
+
+ synchronized public void incKey(long key) {
+ incKey(key, 1);
+ }
+
+ synchronized public void incKey(long key, int delta) {
+ if (key < lastUpdatedKey) {
+ return;
+ }
+ if (key != lastUpdatedKey) {
+ if (lastUpdatedKey != -1) {
+ setValue(lastUpdatedKey, lastUpdatedValue);
+ for (long i = lastUpdatedKey + 1; i < key; i++) {
+ setValue(i, 0);
+ }
+ }
+ lastUpdatedValue = 0;
+ lastUpdatedKey = key;
+ }
+ lastUpdatedValue += delta;
+ }
+
+ private void setValue(long key, int value) {
+ final int i = (int) (key % size);
+ sum += value - data[i];
+ if (sum > maxSum) {
+ maxSum = sum;
+ }
+ data[i] = value;
+ }
+
+ synchronized public long getSum() {
+ return sum;
+ }
+
+ synchronized public long getMaxSum() {
+ return maxSum;
+ }
+
+ private long getSumSlow() {
+ long tmp = 0;
+ for (int d : data) {
+ tmp += d;
+ }
+ return tmp;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/MyRunnable.java b/src/net/sourceforge/plantuml/api/MyRunnable.java
new file mode 100644
index 000000000..ad4675643
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/MyRunnable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api;
+
+public interface MyRunnable {
+
+ public void runJob() throws InterruptedException;
+
+ public void cancelJob();
+}
diff --git a/src/net/sourceforge/plantuml/api/NiceNumber.java b/src/net/sourceforge/plantuml/api/NiceNumber.java
new file mode 100644
index 000000000..63bedf55f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/NiceNumber.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+public class NiceNumber {
+
+ public static int getNicer(final int value) {
+ if (value <= 18) {
+ return value;
+ }
+ if (value < 93) {
+ return ((value + 2) / 5) * 5;
+ }
+ if (value < 100) {
+ return ((value + 5) / 10) * 10;
+ }
+ int m = 1;
+ double head = value;
+ while (head >= 100) {
+ head = head / 10.0;
+ m *= 10;
+ }
+ return getNicer((int) Math.round(head)) * m;
+ }
+
+ public static String format(final long v) {
+ final DecimalFormat df = new DecimalFormat();
+ df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
+ df.setGroupingSize(3);
+ df.setMaximumFractionDigits(0);
+ final String t = df.format(v).replace(',', ' ');
+ return t;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/NumberAnalyzed.java b/src/net/sourceforge/plantuml/api/NumberAnalyzed.java
new file mode 100644
index 000000000..bdbff7419
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/NumberAnalyzed.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * 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
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License aint with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+package net.sourceforge.plantuml.api;
+
+public class NumberAnalyzed implements INumberAnalyzed {
+
+ private int nb;
+ private int sum;
+ private int min;
+ private int max;
+
+ public NumberAnalyzed() {
+
+ }
+
+ private NumberAnalyzed(int nb, int sum, int min, int max) {
+ this.nb = nb;
+ this.sum = sum;
+ this.min = min;
+ this.max = max;
+ }
+
+ public synchronized INumberAnalyzed getCopyImmutable() {
+ final NumberAnalyzed copy = new NumberAnalyzed(nb, sum, min, max);
+ return copy;
+ }
+
+ public synchronized void addValue(int v) {
+ nb++;
+ if (nb == 1) {
+ sum = v;
+ min = v;
+ max = v;
+ return;
+ }
+ sum += v;
+ if (v > max) {
+ max = v;
+ }
+ if (v < min) {
+ min = v;
+ }
+ }
+
+ synchronized public final int getNb() {
+ return nb;
+ }
+
+ synchronized public final int getSum() {
+ return sum;
+ }
+
+ synchronized public final int getMin() {
+ return min;
+ }
+
+ synchronized public final int getMax() {
+ return max;
+ }
+
+ synchronized public final int getMean() {
+ if (nb == 0) {
+ return 0;
+ }
+ return sum / nb;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/TimeoutExecutor.java b/src/net/sourceforge/plantuml/api/TimeoutExecutor.java
new file mode 100644
index 000000000..7a347c4c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/TimeoutExecutor.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public final class TimeoutExecutor {
+
+ private final long ms;
+
+ public TimeoutExecutor(long ms) {
+ this.ms = ms;
+ }
+
+ public boolean executeNow(MyRunnable task) {
+ final MyThread mainThread = new MyThread(task);
+ boolean done = false;
+ try {
+ mainThread.start();
+ mainThread.join(ms);
+ } catch (InterruptedException e) {
+ System.err.println("TimeoutExecutorA " + e);
+ e.printStackTrace();
+ return false;
+ } finally {
+ done = mainThread.done.get();
+ if (done == false) {
+ task.cancelJob();
+ mainThread.interrupt();
+ }
+ }
+ return done;
+ }
+
+ class MyThread extends Thread {
+ private final MyRunnable task;
+ private final AtomicBoolean done = new AtomicBoolean(false);
+
+ private MyThread(MyRunnable task) {
+ this.task = task;
+ }
+
+ @Override
+ public void run() {
+ try {
+ task.runJob();
+ done.set(true);
+ } catch (InterruptedException e) {
+ System.err.println("TimeoutExecutorB " + e);
+ e.printStackTrace();
+ }
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java b/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
new file mode 100644
index 000000000..303206d7a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import java.util.Collection;
+
+public interface MDADiagram {
+ public Collection getPackages();
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
new file mode 100644
index 000000000..95fa61311
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+public interface MDAEntity {
+ public String getName();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
new file mode 100644
index 000000000..0b035763b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import java.util.Collection;
+
+public interface MDAPackage {
+
+ public String getName();
+
+ public Collection getEntities();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
new file mode 100644
index 000000000..76199dc13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import net.sourceforge.plantuml.mda.MDADiagramImpl;
+
+public class MDAUtils {
+
+ public static MDADiagram getMDADiagram(String plantumlDiagramSource) {
+ return MDADiagramImpl.create(plantumlDiagramSource);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java b/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
new file mode 100644
index 000000000..8b8878e6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
@@ -0,0 +1,37 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.api.mda.option3;
+
+public interface MDAVisitor {
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java
new file mode 100644
index 000000000..d44272b62
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4169 $
+ *
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+
+public abstract class AbstractComponentText implements Component {
+
+ public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
+ final double w = getPreferredWidth(stringBounder);
+ final double h = getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/FullLayout.java b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
new file mode 100644
index 000000000..36fa5f300
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 14203 $
+ *
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FullLayout implements UDrawable {
+
+ private final List all = new ArrayList();
+
+ public void addRowLayout(RowLayout rawLayout) {
+ this.all.add(rawLayout);
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ for (RowLayout rawLayout : all) {
+ rawLayout.drawU(ug.apply(new UTranslate(0, y)));
+ y += rawLayout.getHeight(ug.getStringBounder()) + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/RowLayout.java b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
new file mode 100644
index 000000000..f5fec1387
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 14203 $
+ *
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RowLayout implements UDrawable {
+
+ private final List all = new ArrayList();
+
+ public void addLeaf(TextBlock entityImageClass) {
+ this.all.add(entityImageClass);
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ double y = 0;
+ for (TextBlock leaf : all) {
+ y = Math.max(y, leaf.calculateDimension(stringBounder).getHeight());
+ }
+ return y;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ for (TextBlock leaf : all) {
+ leaf.drawU(ug.apply(new UTranslate(x, 0)));
+ x += leaf.calculateDimension(ug.getStringBounder()).getWidth() + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
new file mode 100644
index 000000000..9f514bd6a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7715 $
+ *
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandAllowMixing extends SingleLineCommand2 {
+
+ public CommandAllowMixing() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("allow_mixing"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.setAllowMixing(true);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
new file mode 100644
index 000000000..16e495175
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
@@ -0,0 +1,226 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7715 $
+ *
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateElementFull2 extends SingleLineCommand2 {
+
+ private final Mode mode;
+
+ public static enum Mode {
+ NORMAL_KEYWORD, WITH_MIX_PREFIX
+ }
+
+ public CommandCreateElementFull2(Mode mode) {
+ super(getRegexConcat(mode));
+ this.mode = mode;
+ }
+
+ private static RegexConcat getRegexConcat(Mode mode) {
+
+ String regex = "(?:(actor|usecase|component)[%s]+)";
+ if (mode == Mode.WITH_MIX_PREFIX) {
+ regex = "mix_" + regex;
+ }
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SYMBOL",
+ // "(?:(artifact|actor|folder|package|rectangle|node|frame|cloud|database|storage|agent|usecase|component|boundary|control|entity|interface|\\(\\))[%s]+)?"),
+ // //
+ regex), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("CODE1", CODE_WITH_QUOTE) //
+ ), //
+ new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String CODE = "(" + CODE_CORE + ")";
+ private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
+
+ private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
+ private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
+
+ @Override
+ final protected boolean isForbidden(String line) {
+ if (line.matches("^[\\p{L}0-9_.]+$")) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) {
+ return CommandExecutionResult
+ .error("Use 'allow_mixing' if you want to mix classes and other UML elements.");
+ }
+ String codeRaw = arg.getLazzy("CODE", 0);
+ final String displayRaw = arg.getLazzy("DISPLAY", 0);
+ final char codeChar = getCharEncoding(codeRaw);
+ final char codeDisplay = getCharEncoding(displayRaw);
+ final String symbol;
+ if (codeRaw.startsWith("()")) {
+ symbol = "interface";
+ codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
+ } else if (codeChar == '(' || codeDisplay == '(') {
+ symbol = "usecase";
+ } else if (codeChar == ':' || codeDisplay == ':') {
+ symbol = "actor";
+ } else if (codeChar == '[' || codeDisplay == '[') {
+ symbol = "component";
+ } else {
+ symbol = arg.get("SYMBOL", 0);
+ }
+
+ final LeafType type;
+ final USymbol usymbol;
+
+ if (symbol == null) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("artifact")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ARTIFACT;
+ } else if (symbol.equalsIgnoreCase("folder")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FOLDER;
+ } else if (symbol.equalsIgnoreCase("package")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.PACKAGE;
+ } else if (symbol.equalsIgnoreCase("rectangle")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.RECTANGLE;
+ } else if (symbol.equalsIgnoreCase("node")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.NODE;
+ } else if (symbol.equalsIgnoreCase("frame")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FRAME;
+ } else if (symbol.equalsIgnoreCase("cloud")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CLOUD;
+ } else if (symbol.equalsIgnoreCase("database")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.DATABASE;
+ } else if (symbol.equalsIgnoreCase("storage")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.STORAGE;
+ } else if (symbol.equalsIgnoreCase("agent")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.AGENT;
+ } else if (symbol.equalsIgnoreCase("actor")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("component")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
+ } else if (symbol.equalsIgnoreCase("boundary")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.BOUNDARY;
+ } else if (symbol.equalsIgnoreCase("control")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CONTROL;
+ } else if (symbol.equalsIgnoreCase("entity")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ENTITY_DOMAIN;
+ } else if (symbol.equalsIgnoreCase("interface")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("()")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("usecase")) {
+ type = LeafType.USECASE;
+ usymbol = null;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
+ String display = displayRaw;
+ if (display == null) {
+ display = code.getFullName();
+ }
+ display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
+ final String stereotype = arg.getLazzy("STEREOTYPE", 0);
+ final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
+ entity.setDisplay(Display.getWithNewlines(display));
+ entity.setUSymbol(usymbol);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+ private char getCharEncoding(final String codeRaw) {
+ return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
new file mode 100644
index 000000000..6887e7858
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7715 $
+ *
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandLayoutNewLine extends SingleLineCommand2 {
+
+ public CommandLayoutNewLine() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("layout_new_line"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.layoutNewLine();
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandAffineTransform.java b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java
new file mode 100644
index 000000000..689cbb0a8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandAffineTransform extends SingleLineCommand {
+
+ public CommandAffineTransform() {
+ super("(?i)^!transformation[%s]+([^{}]*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) {
+ final String value = arg.get(0);
+ diagram.setAnimation(Collections.singletonList(value));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java b/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java
new file mode 100644
index 000000000..fa896d768
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5957 $
+ *
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandAffineTransformMultiline extends CommandMultilines {
+
+ public CommandAffineTransformMultiline() {
+ super("(?i)^!transformation[%s]+\\{[%s]*$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*!\\}[%s]*$";
+ }
+
+ public CommandExecutionResult execute(final UmlDiagram diagram, List lines) {
+ final List data = lines.subList(1, lines.size() - 1);
+ diagram.setAnimation(data);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java b/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java
new file mode 100644
index 000000000..b41f03fe1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12235 $
+ *
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandFootboxIgnored extends SingleLineCommand {
+
+ public CommandFootboxIgnored() {
+ super("(?i)^(hide|show)?[%s]*footbox$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) {
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/MyPattern.java b/src/net/sourceforge/plantuml/command/regex/MyPattern.java
new file mode 100644
index 000000000..d9786bed0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/MyPattern.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.regex.Pattern;
+
+// Splitter.java to be finished
+public abstract class MyPattern {
+
+ public static Pattern cmpile(String p) {
+ p = transformAndCheck(p);
+ return Pattern.compile(p);
+ }
+
+ public static Pattern cmpileNockeck(String p) {
+ p = transform(p);
+ return Pattern.compile(p);
+ }
+
+ public static Pattern cmpile(String p, int type) {
+ p = transformAndCheck(p);
+ return Pattern.compile(p, type);
+ }
+
+ public static Pattern cmpileNockeck(String p, int type) {
+ p = transform(p);
+ return Pattern.compile(p, type);
+ }
+
+ private static String transformAndCheck(String p) {
+ // if (p.contains("\\s")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ // if (p.contains("'")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ // if (p.contains("\"")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ p = transform(p);
+ // if (p.contains(" ") || p.contains("%")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ return p;
+ }
+
+ private static String transform(String p) {
+ // Replace ReadLineReader.java
+ p = p.replaceAll("%s", "\\\\s\u00A0"); // space
+ p = p.replaceAll("%q", "'\u2018\u2019"); // quote
+ p = p.replaceAll("%g", "\"\u201c\u201d\u00ab\u00bb"); // double quote
+ return p;
+ }
+
+ public static boolean mtches(String input, String regex) {
+ return cmpile(regex).matcher(input).matches();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
new file mode 100644
index 000000000..2610b7338
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6009 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+class AtomEmbededSystem implements Atom {
+
+ final private List extends CharSequence> lines;
+
+ public AtomEmbededSystem(EmbededDiagram sys) {
+ this.lines = sys.getLines().as();
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ try {
+ final BufferedImage im = getImage();
+ return new Dimension2DDouble(im.getWidth(), im.getHeight());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return new Dimension2DDouble(42, 42);
+ }
+
+ public void drawU(UGraphic ug) {
+ try {
+ final BufferedImage im = getImage();
+ final UShape image = new UImage(im);
+ ug.draw(image);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private BufferedImage getImage() throws IOException, InterruptedException {
+ final Diagram system = getSystem();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG));
+ os.close();
+ final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ final BufferedImage im = ImageIO.read(is);
+ is.close();
+ return im;
+ }
+
+ // public HorizontalAlignment getHorizontalAlignment() {
+ // return HorizontalAlignment.LEFT;
+ // }
+ //
+ private Diagram getSystem() throws IOException, InterruptedException {
+ final BlockUml blockUml = new BlockUml(lines, 0);
+ return blockUml.getDiagram();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
new file mode 100644
index 000000000..d7872c9e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.openiconic.OpenIcon;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class AtomOpenIcon implements Atom {
+
+ private final OpenIcon openIcon;
+ private final FontConfiguration fontConfiguration;
+ private final double factor;
+
+ public AtomOpenIcon(OpenIcon openIcon, FontConfiguration fontConfiguration) {
+ this.openIcon = openIcon;
+ this.fontConfiguration = fontConfiguration;
+ this.factor = fontConfiguration.getSize2D() / 12;
+ }
+
+ private TextBlock asTextBlock() {
+ return TextBlockUtils.withMargin(openIcon.asTextBlock(fontConfiguration.getColor(), factor), 1, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return asTextBlock().calculateDimension(stringBounder);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return -3 * factor;
+ }
+
+ public void drawU(UGraphic ug) {
+ asTextBlock().drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomSpace.java b/src/net/sourceforge/plantuml/creole/AtomSpace.java
new file mode 100644
index 000000000..47ab34528
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomSpace.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class AtomSpace implements Atom {
+
+ private final double width;
+
+ public static Atom create(double width) {
+ return new AtomSpace(width);
+ }
+
+ private AtomSpace(double width) {
+ this.width = width;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, 1);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java b/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java
new file mode 100644
index 000000000..f55ba878f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleOpenIcon implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleOpenIcon(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleOpenIcon("^(?i)(" + Splitter.openiconPattern + ")");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String src = m.group(2);
+ stripe.addOpenIcon(src);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
new file mode 100644
index 000000000..2380cbfd2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class CommandCreoleSpace implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleSpace(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleSpace("^(?i)(\\)");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ // final int size = Integer.parseInt(m.group(2));
+ // final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ // final FontConfiguration fc2 = fc1.changeSize(size);
+ // stripe.setActualFontConfiguration(fc2);
+ // stripe.analyzeAndAdd(m.group(3));
+ final int size = Integer.parseInt(m.group(2));
+ stripe.addSpace(size);
+ // stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java
new file mode 100644
index 000000000..7b9b3daf4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.Splitter;
+import net.sourceforge.plantuml.graphic.SvgAttributes;
+
+public class CommandCreoleSvgAttributeChange implements Command {
+
+ private final Pattern pattern;
+
+ public static final String fontPattern = Splitter.svgAttributePattern;
+
+ public static Command create() {
+ return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*?)\\)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*))$");
+ }
+
+ private CommandCreoleSvgAttributeChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ FontConfiguration fc2 = fc1;
+ if (m.group(2) != null) {
+ fc2 = fc2.changeAttributes(new SvgAttributes(m.group(2)));
+ }
+
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(3));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/Fission.java b/src/net/sourceforge/plantuml/creole/Fission.java
new file mode 100644
index 000000000..58f314d9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Fission.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class Fission {
+
+ private final Stripe stripe;
+ private final double maxWidth;
+
+ public Fission(Stripe stripe, double maxWidth) {
+ this.stripe = stripe;
+ this.maxWidth = maxWidth;
+ }
+
+ public List getSplitted(StringBounder stringBounder) {
+ if (maxWidth == 0) {
+ return Arrays.asList(stripe);
+ }
+ final List result = new ArrayList();
+ StripeSimple current = new StripeSimple();
+ for (Atom a1 : stripe.getAtoms()) {
+ for (Atom atom : getSplitted(stringBounder, a1)) {
+ final double width = atom.calculateDimension(stringBounder).getWidth();
+ if (current.totalWidth + width > maxWidth) {
+ result.add(current);
+ current = new StripeSimple();
+ }
+ current.addAtom(atom, width);
+ }
+ }
+ if (current.totalWidth > 0) {
+ result.add(current);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Collection extends Atom> getSplitted(StringBounder stringBounder, Atom atom) {
+ if (atom instanceof AtomText) {
+ return ((AtomText) atom).getSplitted(stringBounder, maxWidth);
+ }
+ return Collections.singleton(atom);
+ }
+
+ private List getSplittedSimple() {
+ final StripeSimple result = new StripeSimple();
+ for (Atom atom : stripe.getAtoms()) {
+ result.addAtom(atom, 0);
+
+ }
+ return Arrays.asList((Stripe) result);
+ }
+
+ static class StripeSimple implements Stripe {
+
+ private final List atoms = new ArrayList();
+ private double totalWidth;
+
+ public List getAtoms() {
+ return Collections.unmodifiableList(atoms);
+ }
+
+ private void addAtom(Atom atom, double width) {
+ this.atoms.add(atom);
+ this.totalWidth += width;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java
new file mode 100644
index 000000000..a0295ccaf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java
@@ -0,0 +1,157 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SheetBlock1 implements TextBlock, Atom, Stencil {
+
+ private final Sheet sheet;
+ private List stripes;
+ private Map heights;
+ private Map widths;
+ private Map positions;
+ private MinMax minMax;
+ private final double maxWidth;
+ private final double padding;
+
+ public SheetBlock1(Sheet sheet, double maxWidth, double padding) {
+ this.sheet = sheet;
+ this.maxWidth = maxWidth;
+ this.padding = padding;
+ }
+
+ private void initMap(StringBounder stringBounder) {
+ if (positions != null) {
+ return;
+ }
+ stripes = new ArrayList();
+ for (Stripe stripe : sheet) {
+ stripes.addAll(new Fission(stripe, maxWidth).getSplitted(stringBounder));
+ }
+ positions = new LinkedHashMap();
+ widths = new LinkedHashMap();
+ heights = new LinkedHashMap();
+ minMax = MinMax.getEmpty(true);
+ double y = 0;
+ for (Stripe stripe : stripes) {
+ if (stripe.getAtoms().size() == 0) {
+ continue;
+ }
+ final Sea sea = new Sea(stringBounder);
+ for (Atom atom : stripe.getAtoms()) {
+ sea.add(atom);
+ }
+ sea.doAlign();
+ sea.translateMinYto(y);
+ sea.exportAllPositions(positions);
+ final double width = sea.getWidth();
+ widths.put(stripe, width);
+ minMax = sea.update(minMax);
+ final double height = sea.getHeight();
+ heights.put(stripe, height);
+ y += height;
+ }
+ final int coef;
+ if (sheet.getHorizontalAlignment() == HorizontalAlignment.CENTER) {
+ coef = 2;
+ } else if (sheet.getHorizontalAlignment() == HorizontalAlignment.RIGHT) {
+ coef = 1;
+ } else {
+ coef = 0;
+ }
+ if (coef != 0) {
+ double maxWidth = 0;
+ for (Double v : widths.values()) {
+ if (v > maxWidth) {
+ maxWidth = v;
+ }
+ }
+ for (Map.Entry ent : widths.entrySet()) {
+ final double diff = maxWidth - ent.getValue();
+ if (diff > 0) {
+ for (Atom atom : ent.getKey().getAtoms()) {
+ final Position pos = positions.get(atom);
+ positions.put(atom, pos.translateX(diff / coef));
+ }
+ }
+
+ }
+
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ initMap(stringBounder);
+ return Dimension2DDouble.delta(minMax.getDimension(), 2 * padding);
+ }
+
+ public void drawU(UGraphic ug) {
+ initMap(ug.getStringBounder());
+ if (padding > 0) {
+ ug = ug.apply(new UTranslate(padding, padding));
+ }
+ for (Stripe stripe : stripes) {
+ for (Atom atom : stripe.getAtoms()) {
+ final Position position = positions.get(atom);
+ atom.drawU(position.translate(ug));
+ // position.drawDebug(ug);
+ }
+ }
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return calculateDimension(stringBounder).getWidth();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock2.java b/src/net/sourceforge/plantuml/creole/SheetBlock2.java
new file mode 100644
index 000000000..e871554e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/SheetBlock2.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 11025 $
+ *
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SheetBlock2 implements TextBlock, Atom {
+
+ private final SheetBlock1 block;
+ private final UStroke defaultStroke;
+ private final Stencil stencil;
+
+ public SheetBlock2(SheetBlock1 block, Stencil stencil, UStroke defaultStroke) {
+ this.block = block;
+ this.stencil = stencil;
+ this.defaultStroke = defaultStroke;
+ if (stencil == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return block.calculateDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ if (stencil != null) {
+ ug = new UGraphicStencil(ug, stencil, defaultStroke);
+ }
+ block.drawU(ug);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display2.java b/src/net/sourceforge/plantuml/cucadiagram/Display2.java
new file mode 100644
index 000000000..11a608729
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Display2.java
@@ -0,0 +1,240 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8218 $
+ *
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+
+public class Display2 implements Iterable {
+
+ private final List display = new ArrayList();
+
+ public static Display2 empty() {
+ return new Display2();
+ }
+
+ public static Display2 create(CharSequence... s) {
+ if (s.length==1 && s[0]==null) {
+ return empty();
+ }
+ return new Display2(Arrays.asList(s));
+ }
+
+ public static Display2 create(List extends CharSequence> other) {
+ return new Display2(other);
+ }
+
+ public static Display2 getWithNewlines(Code s) {
+ return getWithNewlines(s.getFullName());
+ }
+
+ public static Display2 getWithNewlines(String s) {
+ if (s == null) {
+ return null;
+ }
+ final Display2 result = new Display2();
+ result.display.addAll(getWithNewlinesInternal(s));
+ return result;
+ }
+
+ private Display2(List extends CharSequence> other) {
+ for (CharSequence s : other) {
+ this.display.addAll(getWithNewlinesInternal(s));
+ }
+ }
+
+ private Display2(Display2 other) {
+ this.display.addAll(other.display);
+ }
+
+ private Display2() {
+ }
+
+ public Display2 underlined() {
+ final List result = new ArrayList();
+ for (CharSequence line : display) {
+ result.add("" + line);
+ }
+ return new Display2(result);
+ }
+
+ @Override
+ public String toString() {
+ return display.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return display.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return this.display.equals(((Display2) other).display);
+ }
+
+ public Display2 addAll(Display2 other) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(other.display);
+ return result;
+ }
+
+ public Display2 addFirst(CharSequence s) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(0, getWithNewlinesInternal(s));
+ return result;
+ }
+
+ public Display2 add(CharSequence s) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(getWithNewlinesInternal(s));
+ return result;
+ }
+
+ private boolean firstColumnRemovable() {
+ boolean allEmpty = true;
+ for (CharSequence s : this) {
+ if (s.length() == 0) {
+ continue;
+ }
+ allEmpty = false;
+ final char c = s.charAt(0);
+ if (c != ' ' && c != '\t') {
+ return false;
+ }
+ }
+ return allEmpty == false;
+ }
+
+ public Display2 removeEmptyColumns() {
+ if (firstColumnRemovable() == false) {
+ return this;
+ }
+ final Display2 result = new Display2(this);
+ do {
+ for (int i = 0; i < result.size(); i++) {
+ final CharSequence s = result.get(i);
+ if (s.length() > 0) {
+ result.display.set(i, s.toString().substring(1));
+ }
+ }
+ } while (result.firstColumnRemovable());
+ return result;
+ }
+
+ public int size() {
+ return display.size();
+ }
+
+ public CharSequence get(int i) {
+ return display.get(i);
+ }
+
+ public Iterator iterator() {
+ return Collections.unmodifiableList(display).iterator();
+ }
+
+ public Display2 subList(int i, int size) {
+ final Display2 result = new Display2();
+ result.display.addAll(display.subList(i, size));
+ return result;
+ }
+
+ public List extends CharSequence> as() {
+ return Collections.unmodifiableList(display);
+ }
+
+ private static List getWithNewlinesInternal(CharSequence s) {
+ final List result = new ArrayList();
+ final StringBuilder current = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '\\' && i < s.length() - 1) {
+ final char c2 = s.charAt(i + 1);
+ i++;
+ if (c2 == 'n') {
+ result.add(current.toString());
+ current.setLength(0);
+ } else if (c2 == 't') {
+ current.append('\t');
+ } else if (c2 == '\\') {
+ current.append(c2);
+ } else {
+ current.append(c);
+ current.append(c2);
+ }
+ } else {
+ current.append(c);
+ }
+ }
+ result.add(current.toString());
+ return result;
+ }
+
+ public Url initUrl() {
+ if (this.size() == 0) {
+ return null;
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
+ return urlBuilder.getUrl(this.get(0).toString().trim());
+ }
+
+ public Display2 removeUrl(Url url) {
+ if (url == null) {
+ return this;
+ }
+ final Display2 result = new Display2();
+ result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
+ result.display.addAll(this.subList(1, this.size()).display);
+ return result;
+ }
+
+ public boolean hasUrl() {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);
+ for (CharSequence s : this) {
+ if (urlBuilder.getUrl(s.toString()) != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Ident.java b/src/net/sourceforge/plantuml/cucadiagram/Ident.java
new file mode 100644
index 000000000..7b91f1926
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Ident.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8770 $
+ *
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class Ident implements Comparable {
+
+ private final String ident;
+
+ private Ident(String ident) {
+ if (ident == null) {
+ throw new IllegalArgumentException();
+ }
+ this.ident = ident;
+ }
+
+ public static Ident of(String code) {
+ return new Ident(code);
+ }
+
+ @Override
+ public String toString() {
+ return ident;
+ }
+
+ @Override
+ public int hashCode() {
+ return ident.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Ident other = (Ident) obj;
+ return this.ident.equals(other.ident);
+ }
+
+ public int compareTo(Ident other) {
+ return this.ident.compareTo(other.ident);
+ }
+
+ private Ident eventuallyRemoveStartingAndEndingDoubleQuote() {
+ return Ident.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ident));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LongCode.java b/src/net/sourceforge/plantuml/cucadiagram/LongCode.java
new file mode 100644
index 000000000..76c5eb8c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LongCode.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8770 $
+ *
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class LongCode implements Comparable {
+
+ private final String fullName;
+ private final String separator;
+
+ private LongCode(String fullName, String separator) {
+ if (fullName == null) {
+ throw new IllegalArgumentException();
+ }
+ this.fullName = fullName;
+ this.separator = separator;
+ }
+
+ public String getNamespaceSeparator() {
+ return separator;
+ }
+
+ public static LongCode of(String code, String separator) {
+ if (code == null) {
+ throw new IllegalStateException();
+ }
+ return new LongCode(code, separator);
+ }
+
+ public final String getFullName() {
+ return fullName;
+ }
+
+ @Override
+ public String toString() {
+ return fullName + "(" + separator + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ return fullName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final LongCode other = (LongCode) obj;
+ return this.fullName.equals(other.fullName);
+ }
+
+ public int compareTo(LongCode other) {
+ return this.fullName.compareTo(other.fullName);
+ }
+
+ private LongCode eventuallyRemoveStartingAndEndingDoubleQuote() {
+ return LongCode.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(fullName), separator);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
new file mode 100644
index 000000000..611f860e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 15529 $
+ *
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.svek.Bibliotekon;
+import net.sourceforge.plantuml.svek.Line;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Neighborhood {
+
+ private final ILeaf leaf;
+ private final List sametailLinks;
+ private final List allButSametails;
+
+ public Neighborhood(ILeaf leaf, List sametailLinks, List all) {
+ this.leaf = leaf;
+ this.sametailLinks = sametailLinks;
+ this.allButSametails = new ArrayList(all);
+ allButSametails.removeAll(sametailLinks);
+ }
+
+ public void drawU(UGraphic ug, double minX, double minY, Bibliotekon bibliotekon, Dimension2D shapeDim) {
+ final Set contactPoints = new HashSet();
+ for (Link link : sametailLinks) {
+ final Line line = bibliotekon.getLine(link);
+ final Point2D contact = line.getStartContactPoint();
+ contactPoints.add(contact);
+ }
+ final Rectangle2D rect = new Rectangle2D.Double(minX, minY, shapeDim.getWidth(), shapeDim.getHeight());
+ final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
+
+ for (Point2D pt : contactPoints) {
+ final Point2D inter = intersection(rect, center, pt);
+ if (inter == null) {
+ // System.err.println("rect=" + rect);
+ // System.err.println("center=" + center);
+ // System.err.println("pt=" + pt);
+ assert false;
+ continue;
+ }
+ final double theta = Math.atan2(center.getX() - pt.getX(), -(center.getY() - pt.getY()));
+ final Point2D middle = drawExtends(ug, inter, theta);
+ drawLine(ug, middle, pt);
+ }
+
+ for (Link link : allButSametails) {
+ final Line line = bibliotekon.getLine(link);
+ final Point2D contact = link.getEntity1() == leaf ? line.getStartContactPoint() : line.getEndContactPoint();
+ if (contact == null) {
+ assert false;
+ continue;
+ }
+ final Point2D inter = intersection(rect, center, contact);
+ if (inter == null) {
+ assert false;
+ continue;
+ }
+ drawLine(ug, inter, contact);
+ }
+ }
+
+ private Point2D drawExtends(UGraphic ug, Point2D contact, double theta) {
+ final UPolygon poly = new UPolygon();
+ poly.addPoint(0, 0);
+ poly.addPoint(7, 20);
+ poly.addPoint(-7, 20);
+ poly.rotate(theta);
+ final UTranslate translate = new UTranslate(contact);
+ ug.apply(translate).draw(poly);
+ final Point2D p1 = translate.getTranslated(poly.getPoints().get(1));
+ final Point2D p2 = translate.getTranslated(poly.getPoints().get(2));
+ return new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
+ }
+
+ static Point2D intersection(Rectangle2D rect, Point2D pt1, Point2D pt2) {
+ Point2D p;
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMinY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMaxY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
+ new Point2D.Double(rect.getMinX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMaxX(), rect.getMinY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ return null;
+ }
+
+ static private Point2D intersection(Point2D pt1, Point2D pt2, Point2D pt3, Point2D pt4) {
+ // System.err.println("Checking intersection of " + pt1 + "-" + pt2 + " and " + pt3 + "-" + pt4);
+ return intersection(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), pt3.getX(), pt3.getY(), pt4.getX(),
+ pt4.getY());
+ }
+
+ private static final double epsilon = .001;
+
+ static private Point2D intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
+ double y4) {
+ final double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
+ if (d == 0) {
+ return null;
+
+ }
+ final double xi = ((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d;
+ final double yi = ((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d;
+
+ final Point2D.Double p = new Point2D.Double(xi, yi);
+ if (xi + epsilon < Math.min(x1, x2) || xi - epsilon > Math.max(x1, x2)) {
+ return null;
+ }
+ if (xi + epsilon < Math.min(x3, x4) || xi - epsilon > Math.max(x3, x4)) {
+ return null;
+ }
+ if (yi + epsilon < Math.min(y1, y2) || yi - epsilon > Math.max(y1, y2)) {
+ return null;
+ }
+ if (yi + epsilon < Math.min(y3, y4) || yi - epsilon > Math.max(y3, y4)) {
+ return null;
+ }
+ return p;
+ }
+
+ private void drawLine(UGraphic ug, Point2D pt1, Point2D pt2) {
+ drawLine(ug, pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
+ }
+
+ private void drawLine(UGraphic ug, double x1, double y1, double x2, double y2) {
+ final ULine line = new ULine(x2 - x1, y2 - y1);
+ ug.apply(new UTranslate(x1, y1)).draw(line);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java b/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
new file mode 100644
index 000000000..dd30517f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
@@ -0,0 +1,97 @@
+package net.sourceforge.plantuml.cute;
+
+// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
+public class ApolloniusSolver {
+
+ static class Circle {
+ public double[] center;
+ public double radius;
+
+ public Circle(double[] center, double radius) {
+ this.center = center;
+ this.radius = radius;
+ }
+
+ public String toString() {
+ return String.format("Circle[x=%.2f,y=%.2f,r=%.2f]", center[0], center[1], radius);
+ }
+ }
+
+ /**
+ * Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
+ * approximately 68 heavy operations (multiplication, division, square-roots).
+ *
+ * @param c1
+ * One of the circles in the problem
+ * @param c2
+ * One of the circles in the problem
+ * @param c3
+ * One of the circles in the problem
+ * @param s1
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c1
+ * @param s2
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c2
+ * @param s3
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c3
+ * @return The circle that is tangent to c1, c2 and c3.
+ */
+ public static Circle solveApollonius(Circle c1, Circle c2, Circle c3, int s1, int s2, int s3) {
+ double x1 = c1.center[0];
+ double y1 = c1.center[1];
+ double r1 = c1.radius;
+ double x2 = c2.center[0];
+ double y2 = c2.center[1];
+ double r2 = c2.radius;
+ double x3 = c3.center[0];
+ double y3 = c3.center[1];
+ double r3 = c3.radius;
+
+ // Currently optimized for fewest multiplications. Should be optimized for
+ // readability
+ double v11 = 2 * x2 - 2 * x1;
+ double v12 = 2 * y2 - 2 * y1;
+ double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
+ double v14 = 2 * s2 * r2 - 2 * s1 * r1;
+
+ double v21 = 2 * x3 - 2 * x2;
+ double v22 = 2 * y3 - 2 * y2;
+ double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
+ double v24 = 2 * s3 * r3 - 2 * s2 * r2;
+
+ double w12 = v12 / v11;
+ double w13 = v13 / v11;
+ double w14 = v14 / v11;
+
+ double w22 = v22 / v21 - w12;
+ double w23 = v23 / v21 - w13;
+ double w24 = v24 / v21 - w14;
+
+ double P = -w23 / w22;
+ double Q = w24 / w22;
+ double M = -w12 * P - w13;
+ double N = w14 - w12 * Q;
+
+ double a = N * N + Q * Q - 1;
+ double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
+ double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
+
+ // Find a root of a quadratic equation. This requires the circle centers not
+ // to be e.g. colinear
+ double D = b * b - 4 * a * c;
+ double rs = (-b - Math.sqrt(D)) / (2 * a);
+ double xs = M + N * rs;
+ double ys = P + Q * rs;
+ return new Circle(new double[] { xs, ys }, rs);
+ }
+
+ public static void main(final String[] args) {
+ Circle c1 = new Circle(new double[] { 0, 0 }, 1);
+ Circle c2 = new Circle(new double[] { 4, 0 }, 1);
+ Circle c3 = new Circle(new double[] { 2, 4 }, 2);
+ // Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image)
+ System.out.println(solveApollonius(c1, c2, c3, 1, 1, 1));
+ // Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image)
+ System.out.println(solveApollonius(c1, c2, c3, -1, -1, -1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java b/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
new file mode 100644
index 000000000..2eca4cf14
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
@@ -0,0 +1,76 @@
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
+public class ApolloniusSolver2 {
+
+ /**
+ * Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
+ * approximately 68 heavy operations (multiplication, division, square-roots).
+ *
+ * @param c1
+ * One of the circles in the problem
+ * @param c2
+ * One of the circles in the problem
+ * @param c3
+ * One of the circles in the problem
+ * @param s1
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c1
+ * @param s2
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c2
+ * @param s3
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c3
+ * @return The circle that is tangent to c1, c2 and c3.
+ */
+ public static Balloon solveApollonius(Balloon c1, Balloon c2, Balloon c3, int s1, int s2, int s3) {
+ double x1 = c1.getCenter().getX();
+ double y1 = c1.getCenter().getY();
+ double r1 = c1.getRadius();
+ double x2 = c2.getCenter().getX();
+ double y2 = c2.getCenter().getY();
+ double r2 = c2.getRadius();
+ double x3 = c3.getCenter().getX();
+ double y3 = c3.getCenter().getY();
+ double r3 = c3.getRadius();
+
+ // Currently optimized for fewest multiplications. Should be optimized for
+ // readability
+ double v11 = 2 * x2 - 2 * x1;
+ double v12 = 2 * y2 - 2 * y1;
+ double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
+ double v14 = 2 * s2 * r2 - 2 * s1 * r1;
+
+ double v21 = 2 * x3 - 2 * x2;
+ double v22 = 2 * y3 - 2 * y2;
+ double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
+ double v24 = 2 * s3 * r3 - 2 * s2 * r2;
+
+ double w12 = v12 / v11;
+ double w13 = v13 / v11;
+ double w14 = v14 / v11;
+
+ double w22 = v22 / v21 - w12;
+ double w23 = v23 / v21 - w13;
+ double w24 = v24 / v21 - w14;
+
+ double P = -w23 / w22;
+ double Q = w24 / w22;
+ double M = -w12 * P - w13;
+ double N = w14 - w12 * Q;
+
+ double a = N * N + Q * Q - 1;
+ double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
+ double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
+
+ // Find a root of a quadratic equation. This requires the circle centers not
+ // to be e.g. colinear
+ double D = b * b - 4 * a * c;
+ double rs = (-b - Math.sqrt(D)) / (2 * a);
+ double xs = M + N * rs;
+ double ys = P + Q * rs;
+ return new Balloon(new Point2D.Double(xs, ys), rs);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Arc.java b/src/net/sourceforge/plantuml/cute/Arc.java
new file mode 100644
index 000000000..ae7342588
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Arc.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Arc {
+
+ private final Segment segment;
+ private final Tension tension;
+
+ public Tension getTension() {
+ return tension;
+ }
+
+ public Arc(final MyPoint2D a, final MyPoint2D b) {
+ this(a, b, Tension.none());
+ }
+
+ private Arc(final MyPoint2D a, final MyPoint2D b, Tension tension) {
+ this.segment = new Segment(a, b);
+ this.tension = tension;
+ }
+
+ public MyPoint2D getA() {
+ return (MyPoint2D) segment.getA();
+ }
+
+ public MyPoint2D getB() {
+ return (MyPoint2D) segment.getB();
+ }
+
+ public Arc withNoTension() {
+ return new Arc(getA(), getB(), Tension.none());
+ }
+
+ public Arc withTension(String tensionString) {
+ if (tensionString == null) {
+ return this;
+ }
+ final double newTension = Double.parseDouble(tensionString);
+ return new Arc(getA(), getB(), new Tension(newTension));
+ }
+
+ public Arc rotateZoom(RotationZoom rotationZoom) {
+ return new Arc(getA().rotateZoom(rotationZoom), getB().rotateZoom(rotationZoom),
+ tension.rotateZoom(rotationZoom));
+ }
+
+// public void appendTo(UPath path) {
+// if (tension.isNone()) {
+// path.lineTo(getB());
+// } else {
+// final double a = segment.getLength() / 2;
+// final double b = getTension().getValue();
+// final double radius = (a * a + b * b) / 2 / b;
+// final int sweep_flag = 1;
+// path.arcTo(getB(), radius, 0, sweep_flag);
+// }
+// }
+
+ public Point2D getTensionPoint() {
+ if (tension.isNone()) {
+ throw new IllegalArgumentException();
+ }
+ return segment.getOrthoPoint(-tension.getValue());
+ }
+
+ // public void appendTo(UPath path) {
+ // if (path.isEmpty()) {
+ // path.moveTo(getA());
+ // }
+ // path.lineTo(getB());
+ // }
+
+ public double getLength() {
+ return segment.getLength();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Balloon.java b/src/net/sourceforge/plantuml/cute/Balloon.java
new file mode 100644
index 000000000..e5ce91791
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Balloon.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Balloon implements UDrawable {
+
+ private final Point2D center;
+ private final double radius;
+
+ public Balloon(Point2D center, double radius) {
+ if (radius < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.center = center;
+ this.radius = radius;
+ }
+
+ public static Balloon fromRadiusSegment(Segment centerToContact) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Point2D getPointOnCircle(double a) {
+ return new Point2D.Double(center.getX() + radius * Math.cos(a), center.getY() + radius * Math.sin(a));
+ }
+
+ public Segment getSegmentCenterToPointOnCircle(double a) {
+ return new Segment(center, getPointOnCircle(a));
+ }
+
+ public Balloon translate(UTranslate translate) {
+ return new Balloon(translate.getTranslated(center), radius);
+ }
+
+ public Balloon rotate(RotationZoom rotationZoom) {
+ return new Balloon(rotationZoom.getPoint(center), rotationZoom.applyZoom(radius));
+ }
+
+ @Override
+ public String toString() {
+ return "Balloon(" + center + "," + radius + ")";
+ }
+
+ public Point2D getCenter() {
+ return center;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public void drawU(UGraphic ug) {
+ UEllipse circle = new UEllipse(2 * radius, 2 * radius);
+ ug.apply(new UTranslate(center.getX() - circle.getWidth() / 2, center.getY() - circle.getHeight() / 2)).draw(
+ circle);
+ }
+
+ public Balloon getInsideTangentBalloon1(double angle, double curvation) {
+ final double f = radius - curvation;
+ final double e = (radius * radius - f * f) / 2 / radius;
+ final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
+ final Point2D p1 = rotation.getPoint(f, e);
+ final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
+ return new Balloon(newCenter, e);
+ }
+
+ public Balloon getInsideTangentBalloon2(double angle, double curvation) {
+ final double f = radius - curvation;
+ final double e = (radius * radius - f * f) / 2 / radius;
+ final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
+ final Point2D p1 = rotation.getPoint(f, -e);
+ final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
+ return new Balloon(newCenter, e);
+ }
+
+ public Point2D getPointOnCirclePassingByThisPoint(Point2D passingBy) {
+ final Segment seg = new Segment(center, passingBy);
+ return seg.getFromAtoB(radius);
+ }
+
+ public Point2D getPointOnCircleOppositeToThisPoint(Point2D passingBy) {
+ final Segment seg = new Segment(center, passingBy);
+ return seg.getFromAtoB(-radius);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/BetweenCorners.java b/src/net/sourceforge/plantuml/cute/BetweenCorners.java
new file mode 100644
index 000000000..18a576e91
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/BetweenCorners.java
@@ -0,0 +1,193 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class BetweenCorners {
+
+ private final TriangleCorner corner1;
+ private final TriangleCorner corner2;
+ private final Tension tension;
+
+ private Balloon inside1;
+ private Balloon inside2;
+ private Balloon contact;
+ private Balloon apo;
+ private Point2D apopt1;
+ private Point2D apopt2;
+
+ public BetweenCorners(TriangleCorner corner1, TriangleCorner corner2, Tension tension) {
+ this.corner1 = corner1;
+ this.corner2 = corner2;
+ this.tension = tension;
+
+ if (corner1.hasCurvation()) {
+ inside1 = corner1.getBalloonInside();
+ }
+ if (corner2.hasCurvation()) {
+ inside2 = corner2.getBalloonInside();
+ }
+ if (tension.isNone() == false) {
+ contact = new Balloon(getTensionPoint(), getLength() / 1000.0);
+ }
+
+ if (inside1 != null && inside2 != null && contact != null) {
+ apo = ApolloniusSolver2.solveApollonius(inside1, inside2, contact, 1, 1, 1);
+ apopt1 = apo.getPointOnCirclePassingByThisPoint(inside1.getCenter());
+ apopt2 = apo.getPointOnCirclePassingByThisPoint(inside2.getCenter());
+ }
+
+ }
+
+ public Point2D getPointJ() {
+ if (getCorner1().hasCurvation() == false) {
+ return getCorner1().getO();
+ }
+ if (tension.isNone()) {
+ return getCorner1().getOnSegmentA(getCorner1().getCurvation());
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public Point2D getPointK() {
+ if (getCorner1().hasCurvation() == false) {
+ return getCorner1().getO();
+ }
+ if (tension.isNone()) {
+ return getCorner1().getOnSegmentB(getCorner1().getCurvation());
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private double getBalloonRadius() {
+ return getCorner1().getBalloonInside().getRadius();
+ }
+
+ public void initPath(UPath path) {
+ if (apo != null) {
+ path.moveTo(apopt2);
+ } else {
+ path.moveTo(getPointK());
+ }
+ }
+
+ public void addToPath(UPath path, int swepFlag) {
+ if (apo != null) {
+ path.arcTo(apopt1, getCorner1().getBalloonInside().getRadius(), 0, 1);
+ path.arcTo(apopt2, apo.getRadius(), 0, 1);
+ // } else if (getTension().isNone()) {
+ // path.lineTo(getPointJ());
+ // if (getCorner2().hasCurvation()) {
+ // path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ // }
+ // } else {
+ // // final int sweep_flag = 1;
+ // path.arcTo(getPointJ(), getRadiusFuzzy1(), 0, swepFlag);
+ // if (getCorner2().hasCurvation()) {
+ // path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ // }
+ // }
+ } else {
+ path.lineTo(getPointJ());
+ if (getCorner1().hasCurvation()) {
+ path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ }
+ }
+ }
+
+ public void debugMe(UGraphic ug) {
+ if (getCorner2().hasCurvation() == false) {
+ return;
+ }
+ if (tension.isNone()) {
+ return;
+ }
+ inside1.drawU(ug);
+ inside2.drawU(ug);
+ // getSegment().debugMe(ug);
+ contact.drawU(ug);
+
+ new Balloon(apopt1, 5).drawU(ug);
+ new Balloon(apopt2, 5).drawU(ug);
+
+ // getSegmentCross().debugMe(ug);
+
+ apo.drawU(ug);
+ //
+ // final Point2D newCenter = getSegmentCross().getOrthoPoint(-50);
+ // new Segment(newCenter, getCorner1().getBalloonInside().getCenter()).debugMe(ug);
+ // new Segment(newCenter, getCorner2().getBalloonInside().getCenter()).debugMe(ug);
+
+ }
+
+ private double getRadiusFuzzy1() {
+ final double a = getLength() / 2;
+ final double b = getTension().getValue();
+ final double radius = (a * a + b * b) / 2 / b;
+ return radius;
+ }
+
+ private Segment getSegment() {
+ return new Segment(getCorner1().getO(), getCorner2().getO());
+ }
+
+ private Point2D getTensionPoint() {
+ return getSegment().getOrthoPoint(getTension().getValue());
+ }
+
+ private Segment getSegmentCross() {
+ return new Segment(getCorner1().getCornerOrBalloonCenter(), getCorner2().getCornerOrBalloonCenter());
+ }
+
+ public Tension getTension() {
+ return tension;
+ }
+
+ public TriangleCorner getCorner1() {
+ return corner1;
+ }
+
+ public TriangleCorner getCorner2() {
+ return corner2;
+ }
+
+ public double getLength() {
+ return getSegment().getLength();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Cheese.java b/src/net/sourceforge/plantuml/cute/Cheese.java
new file mode 100644
index 000000000..a5e4f00fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Cheese.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Cheese implements CuteShape {
+
+ private final MyDouble radius;
+ private final MyDouble startAngle;
+ private final MyDouble endAngle;
+ private final RotationZoom rotationZoom;
+
+ public Cheese(VarArgs varArgs) {
+ this.radius = varArgs.getAsMyDouble("radius");
+ this.startAngle = varArgs.getAsMyDouble("start").toRadians();
+ this.endAngle = varArgs.getAsMyDouble("end").toRadians();
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ public Cheese(MyDouble radius, MyDouble startAngle, MyDouble endAngle, RotationZoom rotation) {
+ this.radius = radius;
+ this.startAngle = startAngle;
+ this.endAngle = endAngle;
+ this.rotationZoom = rotation;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Balloon balloon = new Balloon(new Point2D.Double(), radius.getValue())
+ .rotate(rotationZoom);
+
+ final double angle1 = rotationZoom.applyRotation(startAngle.getValue());
+ final double angle2 = rotationZoom.applyRotation(endAngle.getValue());
+
+ final Point2D ptA = balloon.getPointOnCircle(angle1);
+ final Point2D ptB = balloon.getPointOnCircle(angle2);
+
+ // balloon.drawU(ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
+ final UPath path = new UPath();
+ final Point2D ptA0;
+ if (radius.hasCurvation()) {
+ ptA0 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(radius.getCurvation(0));
+ path.moveTo(ptA0);
+ } else {
+ ptA0 = null;
+ path.moveTo(balloon.getCenter());
+ }
+ final Balloon insideA;
+ if (startAngle.hasCurvation()) {
+ insideA = balloon.getInsideTangentBalloon1(angle1, startAngle.getCurvation(0));
+ final Point2D ptA1 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(
+ radius.getValue() - startAngle.getCurvation(0));
+ final Point2D ptA2 = balloon.getPointOnCirclePassingByThisPoint(insideA.getCenter());
+ path.lineTo(ptA1);
+ path.arcTo(ptA2, insideA.getRadius(), 0, 1);
+ } else {
+ insideA = null;
+ path.lineTo(ptA);
+ }
+ final Balloon insideB;
+ if (endAngle.hasCurvation()) {
+ insideB = balloon.getInsideTangentBalloon2(angle2, endAngle.getCurvation(0));
+ final Point2D ptB1 = balloon.getPointOnCirclePassingByThisPoint(insideB.getCenter());
+ final Point2D ptB2 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(
+ radius.getValue() - endAngle.getCurvation(0));
+
+ path.arcTo(ptB1, balloon.getRadius(), 0, 1);
+ path.arcTo(ptB2, insideB.getRadius(), 0, 1);
+ } else {
+ insideB = null;
+ path.arcTo(ptB, balloon.getRadius(), 0, 1);
+ }
+ if (radius.hasCurvation()) {
+ final Point2D ptB0 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(radius.getCurvation(0));
+ path.lineTo(ptB0);
+ path.arcTo(ptA0, radius.getCurvation(0), 0, 1);
+ } else {
+ path.lineTo(balloon.getCenter());
+ }
+ path.closePath();
+ ug.draw(path);
+
+ // if (startAngle.hasCurvation()) {
+ // insideA.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ // }
+ // if (endAngle.hasCurvation()) {
+ // insideB.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ // }
+ }
+
+ public CuteShape rotateZoom(RotationZoom other) {
+ return new Cheese(radius, startAngle, endAngle, rotationZoom.compose(other));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Circle.java b/src/net/sourceforge/plantuml/cute/Circle.java
new file mode 100644
index 000000000..c77fc47cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Circle.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Circle implements CuteShape {
+
+ private final double radius;
+
+ public Circle(VarArgs varArgs) {
+ this.radius = varArgs.getAsDouble("radius");
+ }
+
+ private Circle(double radius) {
+ this.radius = radius;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(-radius, -radius));
+ ug.draw(new UEllipse(2 * radius, 2 * radius));
+ }
+
+ public Circle rotateZoom(RotationZoom rotationZoom) {
+ if (rotationZoom.isNone()) {
+ return this;
+ }
+ return new Circle(rotationZoom.applyZoom(radius));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Corner.java b/src/net/sourceforge/plantuml/cute/Corner.java
new file mode 100644
index 000000000..20b27d93a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Corner.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+public class Corner {
+
+ private final double curvation;
+
+ public Corner(double curvation) {
+ this.curvation = curvation;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Crossing.java b/src/net/sourceforge/plantuml/cute/Crossing.java
new file mode 100644
index 000000000..78930c953
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Crossing.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Crossing {
+
+ private final Balloon balloon;
+ private final InfiniteLine line;
+
+ public Crossing(Balloon balloon, InfiniteLine line) {
+ this.balloon = balloon;
+ this.line = line;
+ }
+
+ public List intersection() {
+ final List result = new ArrayList();
+
+ final UTranslate tr = new UTranslate(balloon.getCenter());
+ final UTranslate trInverse = tr.reverse();
+
+ final CrossingSimple simple = new CrossingSimple(balloon.getRadius(), line.translate(trInverse));
+ for (Point2D pt : simple.intersection()) {
+ result.add(tr.getTranslated(pt));
+ }
+
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CrossingSimple.java b/src/net/sourceforge/plantuml/cute/CrossingSimple.java
new file mode 100644
index 000000000..f5968d7e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CrossingSimple.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CrossingSimple {
+
+ // http://mathworld.wolfram.com/Circle-LineIntersection.html
+
+ private final double radius;
+ private final InfiniteLine line;
+
+ public CrossingSimple(double radius, InfiniteLine line) {
+ this.radius = radius;
+ this.line = line;
+ }
+
+ private double pow2(double x) {
+ return x * x;
+ }
+
+ private double sgn(double x) {
+ if (x < 0) {
+ return -1;
+ }
+ return 1;
+ }
+
+ public List intersection() {
+ final List result = new ArrayList();
+ final double delta = pow2(radius * line.getDr()) - pow2(line.getDiscriminant());
+
+ if (delta < 0) {
+ return result;
+ }
+
+ double x;
+ double y;
+
+ x = (line.getDiscriminant() * line.getDeltaY() + sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
+ / pow2(line.getDr());
+ y = (-line.getDiscriminant() * line.getDeltaX() + Math.abs(line.getDeltaY()) * Math.sqrt(delta))
+ / pow2(line.getDr());
+ result.add(new Point2D.Double(x, y));
+
+ x = (line.getDiscriminant() * line.getDeltaY() - sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
+ / pow2(line.getDr());
+ y = (-line.getDiscriminant() * line.getDeltaX() - Math.abs(line.getDeltaY()) * Math.sqrt(delta))
+ / pow2(line.getDr());
+ result.add(new Point2D.Double(x, y));
+
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CutePath.java b/src/net/sourceforge/plantuml/cute/CutePath.java
new file mode 100644
index 000000000..87261cd4f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CutePath.java
@@ -0,0 +1,178 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class CutePath {
+
+ private final List arcs = new ArrayList();
+
+ public CutePath(String value) {
+
+ MyPoint2D lastAdded = null;
+ String tension = null;
+
+ final StringTokenizer spl = new StringTokenizer(value, "~:", true);
+ while (spl.hasMoreTokens()) {
+ final String token = spl.nextToken();
+ if (token.equals(":")) {
+ continue;
+ } else if (token.equals("~")) {
+ tension = spl.nextToken();
+ final String next = spl.nextToken();
+ if (next.equals("~") == false) {
+ throw new IllegalArgumentException();
+ }
+ } else {
+ final StringTokenizer st = new StringTokenizer(token.replaceAll("[()]", ""), ",^");
+ final MyPoint2D current = new MyPoint2D(st);
+ if (lastAdded != null) {
+ add(new Arc(lastAdded, current).withTension(tension));
+ }
+ lastAdded = current;
+ tension = null;
+ }
+ }
+ add(new Arc(lastAdded, arcs.get(0).getA()).withTension(tension));
+
+ }
+
+ public CutePath() {
+ }
+
+ public void add(Arc arc) {
+ if (arcs.size() > 0) {
+ final Arc last = arcs.get(arcs.size() - 1);
+ if (last.getB().equals(arc.getA()) == false) {
+ throw new IllegalArgumentException("last=" + last.getB() + " arc=" + arc.getA());
+ }
+ }
+ this.arcs.add(arc);
+ }
+
+ private final MyPoint2D getMyPoint2D(int i) {
+ return getArc(i).getA();
+ }
+
+ private Arc getArc(int i) {
+ if (i == -1) {
+ return arcs.get(arcs.size() - 1);
+ }
+ if (i == arcs.size()) {
+ return arcs.get(0);
+ }
+ if (i == arcs.size() + 1) {
+ return arcs.get(1);
+ }
+ return arcs.get(i);
+ }
+
+ private UPath toUPath() {
+ final TriangleCorner corner0 = new TriangleCorner(getMyPoint2D(0), getMyPoint2D(1), getMyPoint2D(2));
+ final int swepFlag = corner0.determinant() < 0 ? 0 : 1;
+
+ final UPath path = new UPath();
+ final BetweenCorners betweenCornersLast = new BetweenCorners(getCorner(arcs.size() - 1),
+ getCorner(arcs.size()), arcs.get(arcs.size() - 1).getTension());
+ betweenCornersLast.initPath(path);
+ for (int i = 0; i < arcs.size(); i++) {
+
+ // if (i == 0) {
+ // if (getMyPoint2D(i).hasCurvation()) {
+ // path.moveTo(getPointK(i));
+ // } else {
+ // path.moveTo(arcs.get(i).getA());
+ // }
+ // }
+
+ final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
+ .getTension());
+ betweenCorners.addToPath(path, swepFlag);
+
+ }
+ path.closePath();
+ return path;
+ }
+
+ private void debugMe(UGraphic ug) {
+ for (int i = 0; i < arcs.size(); i++) {
+ final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
+ .getTension());
+ betweenCorners.debugMe(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ }
+ }
+
+ private Point2D getPointK(final int j) {
+ if (getMyPoint2D(j).hasCurvation()) {
+ return getCorner(j).getOnSegmentB(getMyPoint2D(j).getCurvation(0));
+ }
+ return arcs.get(j - 1).getB();
+ }
+
+ private TriangleCorner getCorner(int i) {
+ return new TriangleCorner(getMyPoint2D(i), getMyPoint2D(i - 1), getMyPoint2D(i + 1));
+ }
+
+ public void drawU(UGraphic ug) {
+ final UPath path = toUPath();
+ ug.draw(path);
+// debugMe(ug);
+ }
+
+ public CutePath rotateZoom(RotationZoom rotationZoom) {
+ final CutePath result = new CutePath();
+ for (Arc arc : arcs) {
+ result.arcs.add(arc.rotateZoom(rotationZoom));
+ }
+ return result;
+ }
+
+ public CutePath withNoTension() {
+ final CutePath result = new CutePath();
+ for (Arc arc : arcs) {
+ result.arcs.add(arc.withNoTension());
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/CuteShape.java b/src/net/sourceforge/plantuml/cute/CuteShape.java
new file mode 100644
index 000000000..c4577fa7b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CuteShape.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public interface CuteShape extends UDrawable {
+
+ public UDrawable rotateZoom(RotationZoom other);
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java b/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
new file mode 100644
index 000000000..a75d927ab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.Map;
+
+public class CuteShapeFactory {
+
+ private final Map groups;
+
+ public CuteShapeFactory(Map groups) {
+ this.groups = groups;
+
+ }
+
+ public Positionned createCuteShapePositionned(String data) {
+ final VarArgs varArgs = new VarArgs(data);
+ return new PositionnedImpl(createCuteShape(data), varArgs);
+ }
+
+ private CuteShape createCuteShape(String data) {
+ data = data.toLowerCase().trim();
+ final VarArgs varArgs = new VarArgs(data);
+ if (data.startsWith("circle ")) {
+ return new Circle(varArgs);
+ }
+ if (data.startsWith("cheese ")) {
+ return new Cheese(varArgs);
+ }
+ if (data.startsWith("stick ")) {
+ return new Stick(varArgs);
+ }
+ if (data.startsWith("rectangle ") || data.startsWith("rect ")) {
+ return new Rectangle(varArgs);
+ }
+ if (data.startsWith("triangle ")) {
+ return new Triangle(varArgs);
+ }
+ final String first = data.split(" ")[0];
+ System.err.println("Looking for group " + first + " in " + groups.keySet());
+ final Group group = groups.get(first);
+ if (group == null) {
+ throw new IllegalArgumentException("Cannot find group " + first + " in " + groups.keySet());
+ }
+ System.err.println("Found group " + first + " in " + groups.keySet());
+ return group;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Group.java b/src/net/sourceforge/plantuml/cute/Group.java
new file mode 100644
index 000000000..9ead8b0f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Group.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Group implements Positionned {
+
+ private final String groupName;
+ private final List shapes;
+ private final Group parent;
+ private final Map children;
+
+ // private final List children = new ArrayList();
+
+ @Override
+ public String toString() {
+ return "Group " + groupName + " (" + shapes.size() + ") ";
+ }
+
+ // public static Group fromList(List shapes) {
+ // return new Group("Automatic", shapes);
+ // }
+
+ public static Group createRoot() {
+ return new Group(null, "ROOT");
+ }
+
+ private Group(Group parent, String groupName) {
+ this.parent = parent;
+ this.groupName = groupName;
+ this.shapes = new ArrayList();
+ this.children = new HashMap();
+ }
+
+ private Group(Group parent, String groupName, List shapes) {
+ this.parent = parent;
+ this.groupName = groupName;
+ this.shapes = shapes;
+ this.children = null;
+ }
+
+ public Group createChild(String childName) {
+ final Group result = new Group(this, childName);
+ this.children.put(childName, result);
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ for (Positionned shape : shapes) {
+ shape.drawU(ug);
+ }
+ }
+
+ public void add(Positionned shape) {
+ shapes.add(shape);
+ }
+
+ public String getName() {
+ return groupName;
+ }
+
+ public Positionned rotateZoom(RotationZoom rotationZoom) {
+ if (rotationZoom.isNone()) {
+ return this;
+ }
+ final List result = new ArrayList();
+ for (Positionned shape : shapes) {
+ result.add(shape.rotateZoom(rotationZoom));
+ }
+ return new Group(parent, groupName + "->" + rotationZoom, result);
+ }
+
+ public Positionned translate(UTranslate translation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Group getParent() {
+ return parent;
+ }
+
+ public Map getChildren() {
+ return Collections.unmodifiableMap(children);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/InfiniteLine.java b/src/net/sourceforge/plantuml/cute/InfiniteLine.java
new file mode 100644
index 000000000..914ba86a7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/InfiniteLine.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class InfiniteLine {
+
+ private final Point2D a;
+ private final Point2D b;
+
+ public InfiniteLine(Point2D a, Point2D b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + a + ";" + b + "}";
+ }
+
+ public double getDeltaX() {
+ return b.getX() - a.getX();
+ }
+
+ public double getDeltaY() {
+ return b.getY() - a.getY();
+ }
+
+ public double getDr() {
+ return a.distance(b);
+ }
+
+ public double getDiscriminant() {
+ return a.getX() * b.getY() - b.getX() * a.getY();
+ }
+
+ public InfiniteLine translate(UTranslate translate) {
+ return new InfiniteLine(translate.getTranslated(a), translate.getTranslated(b));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/MyDouble.java b/src/net/sourceforge/plantuml/cute/MyDouble.java
new file mode 100644
index 000000000..4196ee3ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/MyDouble.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.StringTokenizer;
+
+public class MyDouble {
+
+ private static final double NO_CURVE = java.lang.Double.MIN_VALUE;
+ private final double value;
+ private final double curvation;
+
+ public MyDouble(String s) {
+ final StringTokenizer st = new StringTokenizer(s, ",");
+ this.value = java.lang.Double.parseDouble(st.nextToken());
+ if (st.hasMoreTokens()) {
+ this.curvation = java.lang.Double.parseDouble(st.nextToken());
+ } else {
+ this.curvation = NO_CURVE;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return value + "[" + curvation + "]";
+ }
+
+ private MyDouble(double value, double curvation) {
+ this.value = value;
+ this.curvation = curvation;
+ }
+
+ public double getCurvation(double def) {
+ if (curvation == NO_CURVE) {
+ return def;
+ }
+ return curvation;
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public boolean hasCurvation() {
+ return curvation != NO_CURVE;
+ }
+
+ public MyDouble rotateZoom(RotationZoom rotationZoom) {
+ final double newValue = rotationZoom.applyZoom(value);
+ final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
+ return new MyDouble(newValue, curvation);
+ }
+
+ public MyDouble toRadians() {
+ return new MyDouble(Math.toRadians(value), curvation);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/MyPoint2D.java b/src/net/sourceforge/plantuml/cute/MyPoint2D.java
new file mode 100644
index 000000000..dd98176f3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/MyPoint2D.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.StringTokenizer;
+
+public class MyPoint2D extends Point2D {
+
+ public static final double NO_CURVE = 0;
+ private final double x;
+ private final double y;
+ private final double curvation;
+
+ public MyPoint2D(StringTokenizer st) {
+ this.x = java.lang.Double.parseDouble(st.nextToken());
+ this.y = java.lang.Double.parseDouble(st.nextToken());
+ if (st.hasMoreTokens()) {
+ this.curvation = java.lang.Double.parseDouble(st.nextToken());
+ } else {
+ this.curvation = NO_CURVE;
+ }
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ final MyPoint2D other = (MyPoint2D) arg0;
+ return this.x == other.x && this.y == other.y && this.curvation == other.curvation;
+ }
+
+ public static MyPoint2D from(double x, double y) {
+ return new MyPoint2D(x, y, NO_CURVE);
+ }
+
+ public MyPoint2D withCurvation(double curvation) {
+ if (curvation == NO_CURVE) {
+ return this;
+ }
+ return new MyPoint2D(x, y, curvation);
+ }
+
+ private MyPoint2D(Point2D p, double curvation) {
+ this.x = p.getX();
+ this.y = p.getY();
+ this.curvation = curvation;
+ }
+
+ private MyPoint2D(double x, double y, double curvation) {
+ this.x = x;
+ this.y = y;
+ this.curvation = curvation;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + x + "," + y + ")";
+ }
+
+ public double getCurvation(double def) {
+ if (curvation == NO_CURVE) {
+ return def;
+ }
+ return curvation;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setLocation(double arg0, double arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public MyPoint2D rotateZoom(RotationZoom rotationZoom) {
+ final Point2D p = rotationZoom.getPoint(x, y);
+ final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
+ return new MyPoint2D(p, curvation);
+ }
+
+ public boolean hasCurvation() {
+ return curvation != NO_CURVE;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/PSystemCute.java b/src/net/sourceforge/plantuml/cute/PSystemCute.java
new file mode 100644
index 000000000..677d58080
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PSystemCute.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class PSystemCute extends AbstractPSystem {
+
+ // private final List shapes = new ArrayList();
+ // private final Map groups = new HashMap();
+ private final Group root = Group.createRoot();
+ private Group currentGroup = root;
+
+ public PSystemCute() {
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Cute)", getClass());
+ }
+
+ public void doCommandLine(String line) {
+ line = line.trim();
+ if (line.length()==0 || line.startsWith("'")) {
+ return;
+ }
+ if (line.startsWith("group ")) {
+ final StringTokenizer st = new StringTokenizer(line);
+ st.nextToken();
+ final String groupName = st.nextToken();
+ currentGroup = currentGroup.createChild(groupName);
+ } else if (line.startsWith("}")) {
+ currentGroup = currentGroup.getParent();
+ } else {
+ final Positionned shape = new CuteShapeFactory(currentGroup.getChildren()).createCuteShapePositionned(line);
+ // if (currentGroup == null) {
+ // shapes.add(shape);
+ // } else {
+ currentGroup.add(shape);
+ // }
+ }
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null, false);
+ builder.addUDrawable(root);
+ return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java b/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
new file mode 100644
index 000000000..10fcb7aab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 3830 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemCuteFactory extends PSystemBasicFactory {
+
+ public PSystemCuteFactory(DiagramType type) {
+ super(type);
+ }
+
+ public PSystemCute init(String startLine) {
+ if (getDiagramType() == DiagramType.CUTE) {
+ return new PSystemCute();
+ }
+
+ return null;
+ }
+
+ @Override
+ public PSystemCute executeLine(PSystemCute system, String line) {
+ system.doCommandLine(line);
+ return system;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Positionned.java b/src/net/sourceforge/plantuml/cute/Positionned.java
new file mode 100644
index 000000000..9803db1be
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Positionned.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public interface Positionned extends CuteShape {
+
+ public Positionned rotateZoom(RotationZoom rotation);
+
+ public Positionned translate(UTranslate translation);
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/PositionnedImpl.java b/src/net/sourceforge/plantuml/cute/PositionnedImpl.java
new file mode 100644
index 000000000..b2f9d1d87
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PositionnedImpl.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class PositionnedImpl implements Positionned {
+
+ private final CuteShape cuteShape;
+ private final HtmlColor color;
+ private final UTranslate position;
+ private final RotationZoom rotationZoom;
+
+ @Override
+ public String toString() {
+ return "Positionned " + position + " " + cuteShape;
+ }
+
+ public PositionnedImpl(CuteShape cuteShape, VarArgs args) {
+ this.cuteShape = cuteShape;
+ this.color = args.getAsColor("color");
+ this.position = args.getPosition();
+ this.rotationZoom = RotationZoom.fromVarArgs(args);
+ }
+
+ private PositionnedImpl(CuteShape cuteShape, HtmlColor color, UTranslate position, RotationZoom rotationZoom) {
+ this.cuteShape = cuteShape;
+ this.color = color;
+ this.position = position;
+ this.rotationZoom = rotationZoom;
+ }
+
+ public PositionnedImpl(Group group, RotationZoom rotation) {
+ this.cuteShape = group;
+ this.color = HtmlColorUtils.BLACK;
+ this.position = new UTranslate();
+ this.rotationZoom = rotation;
+ }
+
+ public PositionnedImpl(Group group, UTranslate translation) {
+ this.cuteShape = group;
+ this.color = HtmlColorUtils.BLACK;
+ this.position = translation;
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ private UGraphic applyColor(UGraphic ug) {
+ return ug.apply(new UChangeBackColor(color)).apply(new UChangeColor(color));
+
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = applyColor(ug);
+ ug = ug.apply(position);
+ final UDrawable tmp = rotationZoom.isNone() ? cuteShape : cuteShape.rotateZoom(rotationZoom);
+ // System.err.println("rotationZoom=" + rotationZoom + " tmp=" + tmp);
+ tmp.drawU(ug);
+ }
+
+ public Positionned rotateZoom(RotationZoom other) {
+ return new PositionnedImpl(cuteShape, color, other.getUTranslate(position), rotationZoom.compose(other));
+ }
+
+ public Positionned translate(UTranslate other) {
+ return new PositionnedImpl(cuteShape, color, position.compose(other), rotationZoom);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Rectangle.java b/src/net/sourceforge/plantuml/cute/Rectangle.java
new file mode 100644
index 000000000..7c3c289b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Rectangle.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Rectangle implements CuteShape {
+
+ private final double width;
+ private final double height;
+ private final RotationZoom rotationZoom;
+ private final double curvation;
+
+ public Rectangle(VarArgs varArgs) {
+ final Point2D dim = varArgs.getAsPoint("dimension");
+ this.width = dim.getX();
+ this.height = dim.getY();
+ this.rotationZoom = RotationZoom.none();
+ this.curvation = varArgs.getAsDouble("curve", MyPoint2D.NO_CURVE);
+ }
+
+ private Rectangle(double width, double height, RotationZoom rotationZoom, double curvation) {
+ this.width = width;
+ this.height = height;
+ this.rotationZoom = rotationZoom;
+ this.curvation = curvation;
+ }
+
+ public void drawU(UGraphic ug) {
+ CutePath cutePath = new CutePath();
+ cutePath.add(new Arc(MyPoint2D.from(0, 0).withCurvation(curvation), MyPoint2D.from(width, 0).withCurvation(
+ curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(width, 0).withCurvation(curvation), MyPoint2D.from(width, height)
+ .withCurvation(curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(width, height).withCurvation(curvation), MyPoint2D.from(0, height)
+ .withCurvation(curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(0, height).withCurvation(curvation), MyPoint2D.from(0, 0).withCurvation(
+ curvation)));
+ cutePath = cutePath.rotateZoom(rotationZoom);
+ cutePath.drawU(ug);
+ }
+
+ public void drawUOld(UGraphic ug) {
+ final UPath path = new UPath();
+ if (curvation == MyPoint2D.NO_CURVE) {
+ path.moveTo(rotationZoom.getPoint(0, 0));
+ path.lineTo(rotationZoom.getPoint(width, 0));
+ path.lineTo(rotationZoom.getPoint(width, height));
+ path.lineTo(rotationZoom.getPoint(0, height));
+ path.lineTo(rotationZoom.getPoint(0, 0));
+ } else {
+ path.moveTo(rotationZoom.getPoint(width, curvation));
+ path.lineTo(rotationZoom.getPoint(width, height - curvation));
+ path.arcTo(rotationZoom.getPoint(width - curvation, height), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(curvation, height));
+ path.arcTo(rotationZoom.getPoint(0, height - curvation), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(0, curvation));
+ path.arcTo(rotationZoom.getPoint(curvation, 0), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(width - curvation, 0));
+ path.arcTo(rotationZoom.getPoint(width, curvation), curvation, 0, 1);
+ }
+ path.closePath();
+ ug.draw(path);
+ }
+
+ public Rectangle rotateZoom(RotationZoom other) {
+ return new Rectangle(width, height, rotationZoom.compose(other), curvation);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/RotationZoom.java b/src/net/sourceforge/plantuml/cute/RotationZoom.java
new file mode 100644
index 000000000..250405ced
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/RotationZoom.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RotationZoom {
+
+ private final double angle;
+ private final double zoom;
+
+ private RotationZoom(double angle, double zoom) {
+ if (zoom < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.angle = angle;
+ this.zoom = zoom;
+ }
+
+ public RotationZoom compose(RotationZoom other) {
+ return new RotationZoom(this.angle + other.angle, this.zoom * other.zoom);
+ }
+
+ @Override
+ public String toString() {
+ return "Rotation=" + Math.toDegrees(angle) + " Zoom=" + zoom;
+ }
+
+ public static RotationZoom fromVarArgs(VarArgs varArgs) {
+ final double radians = Math.toRadians(varArgs.getAsDouble("rotation", 0));
+ final double scale = varArgs.getAsDouble("scale", 1);
+ return new RotationZoom(radians, scale);
+ }
+
+ public static RotationZoom rotationInDegrees(double angle) {
+ return new RotationZoom(Math.toRadians(angle), 1);
+ }
+
+ public static RotationZoom rotationInRadians(double angle) {
+ return new RotationZoom(angle, 1);
+ }
+
+ public static RotationZoom zoom(double zoom) {
+ return new RotationZoom(0, zoom);
+ }
+
+ public RotationZoom inverse() {
+ return new RotationZoom(-angle, 1 / zoom);
+ }
+
+ public double getAngleDegree() {
+ return Math.toDegrees(angle);
+ }
+
+ static public RotationZoom builtRotationOnYaxis(Point2D toRotate) {
+ final double a = Math.atan2(toRotate.getX(), toRotate.getY());
+ return new RotationZoom(a, 1);
+ }
+
+ public Point2D.Double getPoint(double x, double y) {
+ if (angle == 0) {
+ return new Point2D.Double(x * zoom, y * zoom);
+ }
+ final double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
+ final double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
+ return new Point2D.Double(x1 * zoom, y1 * zoom);
+ }
+
+ public Point2D getPoint(Point2D p) {
+ return getPoint(p.getX(), p.getY());
+ }
+
+ public UTranslate getUTranslate(UTranslate translate) {
+ return new UTranslate(getPoint(translate.getDx(), translate.getDy()));
+
+ }
+
+ public static RotationZoom none() {
+ return new RotationZoom(0, 1);
+ }
+
+ public boolean isNone() {
+ return angle == 0 && zoom == 1;
+ }
+
+ public double applyZoom(double value) {
+ return value * zoom;
+ }
+
+ public double applyRotation(double alpha) {
+ return angle + alpha;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Segment.java b/src/net/sourceforge/plantuml/cute/Segment.java
new file mode 100644
index 000000000..eaefc1334
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Segment.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Segment {
+
+ private final Point2D a;
+ private final Point2D b;
+ private final double length;
+
+ public Segment(Point2D a, Point2D b) {
+ this.a = a;
+ this.b = b;
+ this.length = a.distance(b);
+ if (length < 0.0001) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Point2D getFromAtoB(double dist) {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ final double coef = dist / length;
+ final double x = dx * coef;
+ final double y = dy * coef;
+ return new Point2D.Double(a.getX() + x, a.getY() + y);
+ }
+
+ public Point2D getA() {
+ return a;
+ }
+
+ public Point2D getB() {
+ return b;
+ }
+
+ public Point2D getMiddle() {
+ return new Point2D.Double((a.getX() + b.getX()) / 2, (a.getY() + b.getY()) / 2);
+ }
+
+ private Point2D orthoDirection() {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ return new Point2D.Double(-dy / length, dx / length);
+ }
+
+ public Point2D getOrthoPoint(double value) {
+ final Point2D ortho = orthoDirection();
+ final double dx = -ortho.getX() * value;
+ final double dy = -ortho.getY() * value;
+ return new Point2D.Double((a.getX() + b.getX()) / 2 + dx, (a.getY() + b.getY()) / 2 + dy);
+ }
+
+
+ private boolean isLeft(Point2D point) {
+ return ((b.getX() - a.getX()) * (point.getY() - a.getY()) - (b.getY() - a.getY()) * (point.getX() - a.getX())) > 0;
+ }
+
+ public double getLength() {
+ return length;
+ }
+
+ public void debugMe(UGraphic ug) {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ ug = ug.apply(new UTranslate(a));
+ ug.draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Stick.java b/src/net/sourceforge/plantuml/cute/Stick.java
new file mode 100644
index 000000000..8eba99524
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Stick.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Stick implements CuteShape {
+
+ private final double width;
+ private final double height;
+ private final RotationZoom rotationZoom;
+
+ public Stick(VarArgs varArgs) {
+ final Point2D dim = varArgs.getAsPoint("dimension");
+ this.width = dim.getX();
+ this.height = dim.getY();
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ private Stick(double width, double height, RotationZoom rotation) {
+ this.width = width;
+ this.height = height;
+ this.rotationZoom = rotation;
+ }
+
+ public void drawU(UGraphic ug) {
+ if (width > height) {
+ drawRotate1(ug);
+ } else {
+ drawRotate2(ug);
+ }
+ }
+
+ private void drawRotate1(UGraphic ug) {
+ assert width > height;
+ final UPath path = new UPath();
+ final double small = height / 2;
+ path.moveTo(rotationZoom.getPoint(small, 0));
+ path.lineTo(rotationZoom.getPoint(width - small, 0));
+ path.arcTo(rotationZoom.getPoint(width - small, height), small, 0, 1);
+ path.lineTo(rotationZoom.getPoint(small, height));
+ path.arcTo(rotationZoom.getPoint(small, 0), small, 0, 1);
+ path.closePath();
+ ug.draw(path);
+ }
+
+ private void drawRotate2(UGraphic ug) {
+ assert height > width;
+ final UPath path = new UPath();
+ final double small = width / 2;
+ path.moveTo(rotationZoom.getPoint(width, small));
+ path.lineTo(rotationZoom.getPoint(width, height - small));
+ path.arcTo(rotationZoom.getPoint(0, height - small), small, 0, 1);
+ path.lineTo(rotationZoom.getPoint(0, small));
+ path.arcTo(rotationZoom.getPoint(width, small), small, 0, 1);
+ path.closePath();
+ ug.draw(path);
+ }
+
+ public Stick rotateZoom(RotationZoom other) {
+ return new Stick(width, height, this.rotationZoom.compose(other));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Tension.java b/src/net/sourceforge/plantuml/cute/Tension.java
new file mode 100644
index 000000000..67434b9eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Tension.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+public class Tension {
+
+ private final double tension;
+
+ public Tension(double tension) {
+ this.tension = tension;
+ }
+
+ public static Tension none() {
+ return new Tension(0);
+ }
+
+ public Tension rotateZoom(RotationZoom rotationZoom) {
+ return new Tension(rotationZoom.applyZoom(tension));
+ }
+
+ public boolean isNone() {
+ return tension == 0;
+ }
+
+ public double getValue() {
+ return tension;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Triangle.java b/src/net/sourceforge/plantuml/cute/Triangle.java
new file mode 100644
index 000000000..fe795c723
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Triangle.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class Triangle implements CuteShape {
+
+ private final CutePath cutePath;
+
+ public Triangle(VarArgs varArgs) {
+ this(varArgs.getPointList("points"));
+ }
+
+ private Triangle(CutePath cutePath) {
+ this.cutePath = cutePath;
+ // if (points.size() != 3) {
+ // throw new IllegalArgumentException();
+ // }
+ }
+
+ public Triangle rotateZoom(final RotationZoom angle) {
+ if (angle.isNone()) {
+ return this;
+ }
+ return new Triangle(cutePath.rotateZoom(angle));
+ }
+
+ public void drawU(UGraphic ug) {
+ cutePath.drawU(ug);
+ // ug = ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK));
+ // cutePath.withNoTension().drawU(
+ // ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/TriangleCorner.java b/src/net/sourceforge/plantuml/cute/TriangleCorner.java
new file mode 100644
index 000000000..5ed980947
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/TriangleCorner.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TriangleCorner {
+
+ private final Point2D o;
+ private final Point2D a;
+ private final Point2D b;
+ private final TriangleCornerSimple simple;
+ private final UTranslate translateO;
+ private final UTranslate translateOreverse;
+
+ private final RotationZoom rotation;
+ private final RotationZoom rotationInverse;
+
+ @Override
+ public String toString() {
+ return "Corner " + o + " a=" + a + " b=" + b;
+ }
+
+ public boolean hasCurvation() {
+ return ((MyPoint2D) o).hasCurvation();
+ }
+
+ public double getCurvation() {
+ if (hasCurvation() == false) {
+ throw new IllegalStateException();
+ }
+ return ((MyPoint2D) o).getCurvation(0);
+ }
+
+ public TriangleCorner(Point2D o, Point2D a, Point2D b) {
+ this.o = o;
+ this.a = a;
+ this.b = b;
+ this.translateO = new UTranslate(o);
+ this.translateOreverse = translateO.reverse();
+ final Point2D a2 = translateOreverse.getTranslated(a);
+ final Point2D b2 = translateOreverse.getTranslated((b));
+
+ final Point2D a3, b3;
+ if (a2.getX() == 0) {
+ a3 = a2;
+ b3 = b2;
+ this.rotation = RotationZoom.none();
+ this.rotationInverse = RotationZoom.none();
+ } else {
+ this.rotation = RotationZoom.builtRotationOnYaxis(a2);
+ this.rotationInverse = rotation.inverse();
+ a3 = rotation.getPoint(a2);
+ b3 = rotation.getPoint(b2);
+ }
+
+ this.simple = new TriangleCornerSimple(a3, b3);
+ }
+
+ public Point2D getOnSegmentA(double dist) {
+ final Segment seg = new Segment(o, a);
+ return seg.getFromAtoB(dist);
+ }
+
+ public Point2D getOnSegmentB(double dist) {
+ final Segment seg = new Segment(o, b);
+ return seg.getFromAtoB(dist);
+ }
+
+ public Balloon getCenterWithFixedRadius(double radius) {
+ final Point2D centerSimple = simple.getCenterWithFixedRadius(radius);
+ return new Balloon(rotationInverse.getPoint(translateO.getTranslated(centerSimple)), radius);
+ }
+
+ private Balloon getBalloonWithFixedY(double y) {
+ Balloon result = simple.getBalloonWithFixedY(y);
+ result = result.rotate(rotationInverse);
+ result = result.translate(translateO);
+ return result;
+ }
+
+ public Point2D getCornerOrBalloonCenter() {
+ if (hasCurvation()) {
+ return getBalloonInside().getCenter();
+ }
+ return getO();
+ }
+
+ public double determinant() {
+ final double ux = a.getX() - o.getX();
+ final double uy = a.getY() - o.getY();
+ final double vx = b.getX() - o.getX();
+ final double vy = b.getY() - o.getY();
+ return ux * vy - uy * vx;
+ }
+
+ public Point2D getO() {
+ return o;
+ }
+
+ public Balloon getBalloonInside() {
+ if (hasCurvation() == false) {
+ throw new IllegalStateException();
+ }
+ return getBalloonWithFixedY(getCurvation());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java b/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
new file mode 100644
index 000000000..1b7319c5f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+public class TriangleCornerSimple {
+
+ private final Point2D a;
+ private final Point2D b;
+
+ @Override
+ public String toString() {
+ return "TriangleCornerSimple a=" + a + " " + Math.toDegrees(getAngleA()) + " b=" + b + " "
+ + Math.toDegrees(getAngleB());
+ }
+
+ public TriangleCornerSimple(Point2D a, Point2D b) {
+ if (isZero(a.getX()) == false) {
+ throw new IllegalArgumentException("a=" + a);
+ }
+ this.a = a;
+ this.b = b;
+ }
+
+ private static boolean isZero(double v) {
+ return Math.abs(v) < 0.0001;
+ }
+
+ double getAngleA() {
+ return getAngle(a);
+ }
+
+ double getAngleB() {
+ return getAngle(b);
+ }
+
+ double getAngle(Point2D pt) {
+ final double dx = pt.getX();
+ final double dy = pt.getY();
+ return Math.atan2(dy, dx);
+
+ }
+
+ static double solveY(double alpha, double x) {
+ if (alpha < 0 || alpha > Math.PI / 2) {
+ throw new IllegalArgumentException();
+ }
+ return x * Math.tan(alpha);
+ }
+
+ static double solveX(double alpha, double y) {
+ if (alpha < -Math.PI / 2 || alpha > Math.PI / 2) {
+ // throw new IllegalArgumentException("y=" + y + " alpha=" + Math.toDegrees(alpha));
+ }
+ final double beta = Math.PI / 2 - alpha;
+ // System.err.println("alpha1=" + Math.toDegrees(alpha));
+ // System.err.println("beta11=" + Math.toDegrees(beta));
+ // System.err.println("XX=" + y * Math.tan(beta));
+ return y * Math.tan(beta);
+
+ }
+
+ public Point2D getCenterWithFixedRadius(double radius) {
+ final double alpha = (getAngleA() + getAngleB()) / 2;
+ final double y = solveY(alpha, radius);
+ return new Point2D.Double(radius, y);
+ }
+
+ public Balloon getBalloonWithFixedY(double y) {
+ // System.err.println("TriangleCornerSimple::getCenterWithFixedY y=" + y);
+ // System.err.println("a=" + a + " " + Math.toDegrees(getAngleA()));
+ // System.err.println("b=" + b + " " + Math.toDegrees(getAngleB()));
+ final double alpha = (getAngleA() + getAngleB()) / 2;
+ // System.err.println("alpha=" + Math.toDegrees(alpha));
+ final double sign = Math.signum(a.getY());
+ // System.err.println("sgn=" + sign);
+ final double x = solveX(alpha, y);
+ final Balloon result = new Balloon(new Point2D.Double(x * sign, y * sign), Math.abs(x));
+ // System.err.println("result=" + result);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/VarArgs.java b/src/net/sourceforge/plantuml/cute/VarArgs.java
new file mode 100644
index 000000000..5fe98d5cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/VarArgs.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class VarArgs {
+
+ private final Map args = new HashMap();
+
+ public VarArgs(String data) {
+ for (String s : data.split("\\s")) {
+ if (s.contains("=")) {
+ final StringTokenizer st = new StringTokenizer(s, "=");
+ final String key = st.nextToken();
+ final String value = st.nextToken();
+ args.put(key, value);
+ }
+ }
+ // System.err.println("arg=" + args);
+ }
+
+ @Override
+ public String toString() {
+ return args.toString();
+ }
+
+ public double getAsDouble(String k, double def) {
+ if (args.containsKey(k)) {
+ return getAsDouble(k);
+ }
+ return def;
+ }
+
+ public double getAsDouble(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return Double.parseDouble(value);
+ }
+
+ public MyDouble getAsMyDouble(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return new MyDouble(value);
+ }
+
+ public HtmlColor getAsColor(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ return HtmlColorUtils.BLACK;
+ }
+ final HtmlColor result = HtmlColorSet.getInstance().getColorIfValid(value);
+ if (result == null) {
+ return HtmlColorUtils.BLACK;
+ }
+ return result;
+ }
+
+ public Point2D getAsPoint(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ final StringTokenizer st = new StringTokenizer(value.replaceAll("[()]", ""), ",");
+ return new Point2D.Double(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
+ }
+
+ public Point2D getAsPoint(String k, Point2D def) {
+ if (args.containsKey(k)) {
+ return getAsPoint(k);
+ }
+ return def;
+ }
+
+ public CutePath getPointList(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return new CutePath(value);
+ }
+
+ public UTranslate getPosition() {
+ return new UTranslate(getAsPoint("position", new Point2D.Double()));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java
new file mode 100644
index 000000000..58a244790
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9434 $
+ *
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+
+public class CommandNamespaceSeparator extends SingleLineCommand {
+
+ public CommandNamespaceSeparator() {
+ super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(DescriptionDiagram diagram, List arg) {
+ final String s = arg.get(0);
+ if ("none".equalsIgnoreCase(s)) {
+ diagram.setNamespaceSeparator(null);
+ } else {
+ diagram.setNamespaceSeparator(s);
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java
new file mode 100644
index 000000000..45c978154
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class PSystemCharlie extends AbstractPSystem {
+
+ private BufferedImage image;
+
+ PSystemCharlie() {
+ image = PSystemVersion.getCharlieImage();
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK,
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(new UDrawable() {
+
+ public void drawU(UGraphic ug) {
+ final UImage im = new UImage(image);
+ ug.draw(im);
+ }
+ });
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Version)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java
new file mode 100644
index 000000000..160bf1e80
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 3830 $
+ *
+ */
+package net.sourceforge.plantuml.eggs;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemCharlieFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.equalsIgnoreCase("charlie") || line.equalsIgnoreCase("jesuischarlie")) {
+ return new PSystemCharlie();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/fun/IconLoader.java b/src/net/sourceforge/plantuml/fun/IconLoader.java
new file mode 100644
index 000000000..b68b197a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/IconLoader.java
@@ -0,0 +1,102 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ */
+package net.sourceforge.plantuml.fun;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.imageio.ImageIO;
+
+public class IconLoader {
+
+ private static final int NUMBER_OF_ICONS = 20;
+
+ private final static Map all = new ConcurrentHashMap();
+
+ public static BufferedImage getRandom() {
+ // return addTransparent(getIcon("sprite013.png"));
+ return addTransparent(getIcon(getSomeQuote()));
+ }
+
+ private static String getSomeQuote() {
+ final int v = (int) (System.currentTimeMillis() / 1000L);
+ final int n = v % NUMBER_OF_ICONS;
+ return "sprite" + String.format("%03d", n) + ".png";
+ }
+
+ private static BufferedImage getIcon(String name) {
+ BufferedImage result = all.get(name);
+ if (result == null) {
+ result = getIconSlow(name);
+ if (result != null) {
+ all.put(name, result);
+ }
+ }
+ return result;
+ }
+
+ private static BufferedImage getIconSlow(String name) {
+ try {
+ final InputStream is = IconLoader.class.getResourceAsStream(name);
+ if (is == null) {
+ return null;
+ }
+ final BufferedImage image = ImageIO.read(is);
+ is.close();
+ return image;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static BufferedImage addTransparent(BufferedImage ico) {
+ if (ico == null) {
+ return null;
+ }
+ final BufferedImage transparentIcon = new BufferedImage(ico.getWidth(), ico.getHeight(),
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ for (int i = 0; i < ico.getWidth(); i++) {
+ for (int j = 0; j < ico.getHeight(); j++) {
+ final int col = ico.getRGB(i, j);
+ if (col != ico.getRGB(0, 0)) {
+ transparentIcon.setRGB(i, j, col);
+ }
+ }
+ }
+ return transparentIcon;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/fun/sprite000.png b/src/net/sourceforge/plantuml/fun/sprite000.png
new file mode 100644
index 000000000..48ab597ff
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite000.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite001.png b/src/net/sourceforge/plantuml/fun/sprite001.png
new file mode 100644
index 000000000..32f121dd4
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite001.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite002.png b/src/net/sourceforge/plantuml/fun/sprite002.png
new file mode 100644
index 000000000..dd18318b2
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite002.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite003.png b/src/net/sourceforge/plantuml/fun/sprite003.png
new file mode 100644
index 000000000..429dcedf0
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite003.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite004.png b/src/net/sourceforge/plantuml/fun/sprite004.png
new file mode 100644
index 000000000..6d925f7ef
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite004.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite005.png b/src/net/sourceforge/plantuml/fun/sprite005.png
new file mode 100644
index 000000000..fd5f6e77b
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite005.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite006.png b/src/net/sourceforge/plantuml/fun/sprite006.png
new file mode 100644
index 000000000..f9605ade5
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite006.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite007.png b/src/net/sourceforge/plantuml/fun/sprite007.png
new file mode 100644
index 000000000..817df6c45
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite007.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite008.png b/src/net/sourceforge/plantuml/fun/sprite008.png
new file mode 100644
index 000000000..5b3e95aab
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite008.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite009.png b/src/net/sourceforge/plantuml/fun/sprite009.png
new file mode 100644
index 000000000..0a647bad6
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite009.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite010.png b/src/net/sourceforge/plantuml/fun/sprite010.png
new file mode 100644
index 000000000..35a355af5
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite010.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite011.png b/src/net/sourceforge/plantuml/fun/sprite011.png
new file mode 100644
index 000000000..27e1b63e0
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite011.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite012.png b/src/net/sourceforge/plantuml/fun/sprite012.png
new file mode 100644
index 000000000..d83829226
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite012.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite013.png b/src/net/sourceforge/plantuml/fun/sprite013.png
new file mode 100644
index 000000000..0f65d9622
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite013.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite014.png b/src/net/sourceforge/plantuml/fun/sprite014.png
new file mode 100644
index 000000000..82cb17073
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite014.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite015.png b/src/net/sourceforge/plantuml/fun/sprite015.png
new file mode 100644
index 000000000..c30e60775
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite015.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite016.png b/src/net/sourceforge/plantuml/fun/sprite016.png
new file mode 100644
index 000000000..9f0ceba48
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite016.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite017.png b/src/net/sourceforge/plantuml/fun/sprite017.png
new file mode 100644
index 000000000..40e34ace2
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite017.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite018.png b/src/net/sourceforge/plantuml/fun/sprite018.png
new file mode 100644
index 000000000..21e9eaa07
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite018.png differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite019.png b/src/net/sourceforge/plantuml/fun/sprite019.png
new file mode 100644
index 000000000..a32ac403f
Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite019.png differ
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
new file mode 100644
index 000000000..95612dc02
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7946 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorSet {
+
+ private final static IHtmlColorSet singleton = new HtmlColorSetSimple();
+
+ public static IHtmlColorSet getInstance() {
+ return singleton;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
new file mode 100644
index 000000000..c2c99c603
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
@@ -0,0 +1,283 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7946 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class HtmlColorSetSimple implements IHtmlColorSet {
+
+ private final Map htmlNames;
+ private final Set names;
+
+ public Collection names() {
+ return Collections.unmodifiableSet(names);
+ }
+
+ public HtmlColor getColorIfValid(String s) {
+ return getColorIfValid(s, false);
+ }
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent) {
+ if (s == null) {
+ return null;
+ }
+ final Matcher m = MyPattern.cmpile("[-\\\\|/]").matcher(s);
+ if (m.find()) {
+ final char sep = m.group(0).charAt(0);
+ final int idx = s.indexOf(sep);
+ final String s1 = s.substring(0, idx);
+ final String s2 = s.substring(idx + 1);
+ if (isValid(s1, false) == false || isValid(s2, false) == false) {
+ return null;
+ }
+ return new HtmlColorGradient(build(s1), build(s2), sep);
+ // return getColorIfValid(s2);
+ }
+ if (isValid(s, acceptTransparent) == false) {
+ return new HtmlColorUserDef();
+ }
+ return build(s);
+ }
+
+ public HtmlColorSetSimple() {
+ // Taken from http://perl.wikipedia.com/wiki/Named_colors ?
+ // http://www.w3schools.com/HTML/html_colornames.asp
+ htmlNames = new HashMap();
+ names = new TreeSet();
+ register("AliceBlue", "#F0F8FF");
+ register("AntiqueWhite", "#FAEBD7");
+ register("Aqua", "#00FFFF");
+ register("Aquamarine", "#7FFFD4");
+ register("Azure", "#F0FFFF");
+ register("Beige", "#F5F5DC");
+ register("Bisque", "#FFE4C4");
+ register("Black", "#000000");
+ register("BlanchedAlmond", "#FFEBCD");
+ register("Blue", "#0000FF");
+ register("BlueViolet", "#8A2BE2");
+ register("Brown", "#A52A2A");
+ register("BurlyWood", "#DEB887");
+ register("CadetBlue", "#5F9EA0");
+ register("Chartreuse", "#7FFF00");
+ register("Chocolate", "#D2691E");
+ register("Coral", "#FF7F50");
+ register("CornflowerBlue", "#6495ED");
+ register("Cornsilk", "#FFF8DC");
+ register("Crimson", "#DC143C");
+ register("Cyan", "#00FFFF");
+ register("DarkBlue", "#00008B");
+ register("DarkCyan", "#008B8B");
+ register("DarkGoldenRod", "#B8860B");
+ register("DarkGray", "#A9A9A9");
+ register("DarkGrey", "#A9A9A9");
+ register("DarkGreen", "#006400");
+ register("DarkKhaki", "#BDB76B");
+ register("DarkMagenta", "#8B008B");
+ register("DarkOliveGreen", "#556B2F");
+ register("Darkorange", "#FF8C00");
+ register("DarkOrchid", "#9932CC");
+ register("DarkRed", "#8B0000");
+ register("DarkSalmon", "#E9967A");
+ register("DarkSeaGreen", "#8FBC8F");
+ register("DarkSlateBlue", "#483D8B");
+ register("DarkSlateGray", "#2F4F4F");
+ register("DarkSlateGrey", "#2F4F4F");
+ register("DarkTurquoise", "#00CED1");
+ register("DarkViolet", "#9400D3");
+ register("DeepPink", "#FF1493");
+ register("DeepSkyBlue", "#00BFFF");
+ register("DimGray", "#696969");
+ register("DimGrey", "#696969");
+ register("DodgerBlue", "#1E90FF");
+ register("FireBrick", "#B22222");
+ register("FloralWhite", "#FFFAF0");
+ register("ForestGreen", "#228B22");
+ register("Fuchsia", "#FF00FF");
+ register("Gainsboro", "#DCDCDC");
+ register("GhostWhite", "#F8F8FF");
+ register("Gold", "#FFD700");
+ register("GoldenRod", "#DAA520");
+ register("Gray", "#808080");
+ register("Grey", "#808080");
+ register("Green", "#008000");
+ register("GreenYellow", "#ADFF2F");
+ register("HoneyDew", "#F0FFF0");
+ register("HotPink", "#FF69B4");
+ register("IndianRed", "#CD5C5C");
+ register("Indigo", "#4B0082");
+ register("Ivory", "#FFFFF0");
+ register("Khaki", "#F0E68C");
+ register("Lavender", "#E6E6FA");
+ register("LavenderBlush", "#FFF0F5");
+ register("LawnGreen", "#7CFC00");
+ register("LemonChiffon", "#FFFACD");
+ register("LightBlue", "#ADD8E6");
+ register("LightCoral", "#F08080");
+ register("LightCyan", "#E0FFFF");
+ register("LightGoldenRodYellow", "#FAFAD2");
+ register("LightGray", "#D3D3D3");
+ register("LightGrey", "#D3D3D3");
+ register("LightGreen", "#90EE90");
+ register("LightPink", "#FFB6C1");
+ register("LightSalmon", "#FFA07A");
+ register("LightSeaGreen", "#20B2AA");
+ register("LightSkyBlue", "#87CEFA");
+ register("LightSlateGray", "#778899");
+ register("LightSlateGrey", "#778899");
+ register("LightSteelBlue", "#B0C4DE");
+ register("LightYellow", "#FFFFE0");
+ register("Lime", "#00FF00");
+ register("LimeGreen", "#32CD32");
+ register("Linen", "#FAF0E6");
+ register("Magenta", "#FF00FF");
+ register("Maroon", "#800000");
+ register("MediumAquaMarine", "#66CDAA");
+ register("MediumBlue", "#0000CD");
+ register("MediumOrchid", "#BA55D3");
+ register("MediumPurple", "#9370D8");
+ register("MediumSeaGreen", "#3CB371");
+ register("MediumSlateBlue", "#7B68EE");
+ register("MediumSpringGreen", "#00FA9A");
+ register("MediumTurquoise", "#48D1CC");
+ register("MediumVioletRed", "#C71585");
+ register("MidnightBlue", "#191970");
+ register("MintCream", "#F5FFFA");
+ register("MistyRose", "#FFE4E1");
+ register("Moccasin", "#FFE4B5");
+ register("NavajoWhite", "#FFDEAD");
+ register("Navy", "#000080");
+ register("OldLace", "#FDF5E6");
+ register("Olive", "#808000");
+ register("OliveDrab", "#6B8E23");
+ register("Orange", "#FFA500");
+ register("OrangeRed", "#FF4500");
+ register("Orchid", "#DA70D6");
+ register("PaleGoldenRod", "#EEE8AA");
+ register("PaleGreen", "#98FB98");
+ register("PaleTurquoise", "#AFEEEE");
+ register("PaleVioletRed", "#D87093");
+ register("PapayaWhip", "#FFEFD5");
+ register("PeachPuff", "#FFDAB9");
+ register("Peru", "#CD853F");
+ register("Pink", "#FFC0CB");
+ register("Plum", "#DDA0DD");
+ register("PowderBlue", "#B0E0E6");
+ register("Purple", "#800080");
+ register("Red", "#FF0000");
+ register("RosyBrown", "#BC8F8F");
+ register("RoyalBlue", "#4169E1");
+ register("SaddleBrown", "#8B4513");
+ register("Salmon", "#FA8072");
+ register("SandyBrown", "#F4A460");
+ register("SeaGreen", "#2E8B57");
+ register("SeaShell", "#FFF5EE");
+ register("Sienna", "#A0522D");
+ register("Silver", "#C0C0C0");
+ register("SkyBlue", "#87CEEB");
+ register("SlateBlue", "#6A5ACD");
+ register("SlateGray", "#708090");
+ register("SlateGrey", "#708090");
+ register("Snow", "#FFFAFA");
+ register("SpringGreen", "#00FF7F");
+ register("SteelBlue", "#4682B4");
+ register("Tan", "#D2B48C");
+ register("Teal", "#008080");
+ register("Thistle", "#D8BFD8");
+ register("Tomato", "#FF6347");
+ register("Turquoise", "#40E0D0");
+ register("Violet", "#EE82EE");
+ register("Wheat", "#F5DEB3");
+ register("White", "#FFFFFF");
+ register("WhiteSmoke", "#F5F5F5");
+ register("Yellow", "#FFFF00");
+ register("YellowGreen", "#9ACD32");
+ }
+
+ private void register(String s, String color) {
+ htmlNames.put(StringUtils.goLowerCase(s), color);
+ names.add(s);
+ }
+
+ private HtmlColor build(String s) {
+
+ s = removeFirstDieseAndgoLowerCase(s);
+ final Color color;
+ if (s.equalsIgnoreCase("transparent")) {
+ return new HtmlColorTransparent();
+ } else if (s.matches("[0-9A-Fa-f]{6}")) {
+ color = new Color(Integer.parseInt(s, 16));
+ } else {
+ final String value = htmlNames.get(s);
+ if (value == null) {
+ throw new IllegalArgumentException(s);
+ }
+ color = new Color(Integer.parseInt(value.substring(1), 16));
+ }
+ return new HtmlColorSimple(color, false);
+ }
+
+ private boolean isValid(String s, boolean acceptTransparent) {
+ s = removeFirstDieseAndgoLowerCase(s);
+ if (s.matches("[0-9A-Fa-f]{6}")) {
+ return true;
+ }
+ if (acceptTransparent && s.equalsIgnoreCase("transparent")) {
+ return true;
+ }
+ if (htmlNames.containsKey(s)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private String removeFirstDieseAndgoLowerCase(String s) {
+ s = StringUtils.goLowerCase(s);
+ if (s.startsWith("#")) {
+ s = s.substring(1);
+ }
+ return s;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
new file mode 100644
index 000000000..a3ac773b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7946 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorUserDef implements HtmlColor {
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
new file mode 100644
index 000000000..e010b3634
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 7946 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Collection;
+
+public interface IHtmlColorSet {
+
+ public Collection names();
+
+ public HtmlColor getColorIfValid(String s);
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
new file mode 100644
index 000000000..cfc8a2941
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 10266 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicCompress2;
+
+public class TextBlockCompressed2 implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final CompressionTransform compressionTransform;
+
+ public TextBlockCompressed2(TextBlock textBlock, CompressionTransform compressionTransform) {
+ this.textBlock = textBlock;
+ this.compressionTransform = compressionTransform;
+ }
+
+ public void drawU(final UGraphic ug) {
+ textBlock.drawU(new UGraphicCompress2(ug, compressionTransform));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(compressionTransform.transform(dim.getWidth()), dim.getHeight());
+ }
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
new file mode 100644
index 000000000..2e5800281
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6577 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UDrawableUtils {
+
+ public static UDrawable move(final UDrawable orig, final double dx, final double dy) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ orig.drawU(ug.apply(new UTranslate(dx, dy)));
+ }
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
new file mode 100644
index 000000000..6304a44a2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 10266 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorUDrawable extends UGraphicDelegator {
+
+ public UGraphicInterceptorUDrawable(UGraphic ug) {
+ super(ug);
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UDrawable) {
+ final UDrawable drawable = (UDrawable) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorUDrawable(getUg().apply(change));
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
new file mode 100644
index 000000000..31c06d6bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8066 $
+ *
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolCard extends USymbol {
+
+ public USymbolCard(ColorParam colorParamBack, ColorParam colorParamBorder, FontParam fontParam,
+ FontParam fontParamStereotype) {
+ super(colorParamBack, colorParamBorder, fontParam, fontParamStereotype);
+ }
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double top) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ if (top != 0) {
+ ug.apply(new UTranslate(0, top)).draw(new ULine(width, 0));
+ }
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 3, 3);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), 0);
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), dimTitle.getHeight()
+ + dimStereo.getHeight() + 4);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java b/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java
new file mode 100644
index 000000000..2b54ef1d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6711 $
+ *
+ */
+package net.sourceforge.plantuml.hector2;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.hector2.continuity.Skeleton;
+import net.sourceforge.plantuml.hector2.continuity.SkeletonBuilder;
+import net.sourceforge.plantuml.hector2.graphic.Foo2;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.hector2.layering.LayerFactory;
+import net.sourceforge.plantuml.hector2.mpos.Distribution;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayer;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+
+public class CucaDiagramFileMakerHectorC1 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramFileMakerHectorC1(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ public ImageData createFile(OutputStream os, List dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ for (Link link : diagram.getLinks()) {
+ skeletonBuilder.add(link);
+ }
+ final List skeletons = skeletonBuilder.getSkeletons();
+ if (skeletons.size() != 1) {
+ throw new UnsupportedOperationException("size=" + skeletons.size());
+ }
+ final List layers = new LayerFactory().getLayers(skeletons.get(0));
+ // System.err.println("layers=" + layers);
+
+ final Distribution distribution = new Distribution(layers);
+ final double cost1 = distribution.cost(diagram.getLinks());
+ System.err.println("cost1=" + cost1);
+
+ final List mutations = distribution.getPossibleMutations();
+ for (MutationLayer m : mutations) {
+ System.err.println(m.toString());
+ final Distribution muted = distribution.mute(m);
+ final double cost2 = muted.cost(diagram.getLinks());
+ System.err.println("cost2=" + cost2);
+ }
+
+ final Foo2 foo2 = new Foo2(distribution, diagram);
+
+ final Dimension2D dimTotal = foo2.calculateDimension(TextBlockUtils.getDummyStringBounder());
+
+ UGraphic2 ug = null; //fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ //dimTotal, null, false);
+ foo2.drawU(ug);
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/MinMax.java b/src/net/sourceforge/plantuml/hector2/MinMax.java
new file mode 100644
index 000000000..5459cecc2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/MinMax.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 6711 $
+ *
+ */
+package net.sourceforge.plantuml.hector2;
+
+import java.util.Collection;
+
+public class MinMax {
+
+ private final int min;
+ private final int max;
+
+ private MinMax(int min, int max) {
+ if (max < min) {
+ throw new IllegalArgumentException();
+ }
+ this.min = min;
+ this.max = max;
+ }
+
+ private MinMax(int value) {
+ this(value, value);
+ }
+
+ public MinMax add(int value) {
+ final int newMin = Math.min(min, value);
+ final int newMax = Math.max(max, value);
+ if (min == newMin && max == newMax) {
+ return this;
+ }
+ return new MinMax(newMin, newMax);
+ }
+
+ public MinMax add(MinMax other) {
+ final int newMin = Math.min(min, other.min);
+ final int newMax = Math.max(max, other.max);
+ if (min == newMin && max == newMax) {
+ return this;
+ }
+ return new MinMax(newMin, newMax);
+ }
+
+ public final int getMin() {
+ return min;
+ }
+
+ public final int getMax() {
+ return max;
+ }
+
+ public static MinMax from(Collection values) {
+ MinMax result = null;
+ for (Integer i : values) {
+ if (result == null) {
+ result = new MinMax(i);
+ } else {
+ result = result.add(i);
+ }
+ }
+ return result;
+ }
+
+ public int getDiff() {
+ return max - min;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java b/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java
new file mode 100644
index 000000000..3e773b77d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.continuity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class Skeleton {
+
+ private final Set entities = new HashSet();
+ private final List links = new ArrayList();
+
+ private Set getDirectChildren(IEntity parent) {
+ final Set result = new HashSet();
+ for (Link link : links) {
+ if (link.isAutolink()) {
+ continue;
+ }
+ if (link.getEntity1() == parent) {
+ result.add(link.getEntity2());
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ @Override
+ public String toString() {
+ return "skeleton " + links;
+ }
+
+ private Set getIndirectChildren(IEntity parent) {
+ final Set result = new HashSet(getDirectChildren(parent));
+ int currentSize = result.size();
+ while (true) {
+ for (IEntity ent : new HashSet(result)) {
+ result.addAll(getDirectChildren(ent));
+ }
+ if (result.contains(parent) || result.size() == currentSize) {
+ return Collections.unmodifiableSet(result);
+ }
+ currentSize = result.size();
+ }
+ }
+
+ private boolean hasCycle() {
+ for (IEntity ent : entities) {
+ if (getIndirectChildren(ent).contains(ent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Skeleton removeCycle() {
+ final Skeleton result = new Skeleton();
+ for (Link link : links) {
+ result.add(link);
+ if (result.hasCycle()) {
+ result.links.remove(link);
+ }
+ }
+ return result;
+ }
+
+ public void add(Link link) {
+ if (links.contains(link)) {
+ throw new IllegalArgumentException();
+ }
+ if (link.getEntity1().isGroup()) {
+ throw new IllegalArgumentException();
+ }
+ if (link.getEntity2().isGroup()) {
+ throw new IllegalArgumentException();
+ }
+ links.add(link);
+ entities.add(link.getEntity1());
+ entities.add(link.getEntity2());
+ }
+
+ public void addAll(Skeleton other) {
+ for (Link otherLink : other.links) {
+ this.add(otherLink);
+ }
+
+ }
+
+ public boolean doesTouch(Link other) {
+ for (Link link : links) {
+ if (link.doesTouch(other)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean doesTouch(Skeleton other) {
+ for (Link link : links) {
+ if (other.doesTouch(link)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void computeLayers() {
+ if (hasCycle()) {
+ throw new UnsupportedOperationException();
+ }
+ for (IEntity ent : entities) {
+ ent.setHectorLayer(0);
+ }
+ boolean changed;
+ do {
+ changed = false;
+ for (Link link : links) {
+ if (ensureLayer(link)) {
+ changed = true;
+ }
+ }
+ } while (changed);
+ }
+
+ private boolean ensureLayer(Link link) {
+ final int lenght = link.getLength();
+ final int l1 = link.getEntity1().getHectorLayer();
+ final int l2 = link.getEntity2().getHectorLayer();
+ if (lenght == 1) {
+ if (l1 < l2) {
+ link.getEntity1().setHectorLayer(l2);
+ return true;
+ } else if (l2 < l1) {
+ link.getEntity2().setHectorLayer(l1);
+ return true;
+ }
+ } else {
+ final int l2theoric = l1 + lenght - 1;
+ if (l2 < l2theoric) {
+ link.getEntity2().setHectorLayer(l2theoric);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Collection entities() {
+ return Collections.unmodifiableCollection(entities);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java b/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java
new file mode 100644
index 000000000..0f9387921
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.continuity;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class SkeletonBuilder {
+
+ private List all = new ArrayList();
+
+ public void add(Link link) {
+ addInternal(link);
+ do {
+ final boolean changed = merge();
+ if (changed == false) {
+ return;
+ }
+ } while (true);
+
+ }
+
+ private boolean merge() {
+ for (int i = 0; i < all.size() - 1; i++) {
+ for (int j = i + 1; j < all.size(); j++) {
+ if (all.get(i).doesTouch(all.get(j))) {
+ all.get(i).addAll(all.get(j));
+ all.remove(j);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void addInternal(Link link) {
+ for (Skeleton skeleton : all) {
+ if (skeleton.doesTouch(link)) {
+ skeleton.add(link);
+ return;
+ }
+ }
+ final Skeleton newSkeleton = new Skeleton();
+ newSkeleton.add(link);
+ all.add(newSkeleton);
+ }
+
+ public List getSkeletons() {
+ return Collections.unmodifiableList(all);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java
new file mode 100644
index 000000000..7573ba790
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+
+public class Foo1 {
+
+ public static Dimension2D getMaxCellDimension(StringBounder stringBounder, Layer layer, CucaDiagram diagram) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (IEntity ent : layer.entities()) {
+ final IEntityImage image = computeImage((ILeaf) ent, diagram);
+ final Dimension2D dim = image.calculateDimension(stringBounder);
+ result = Dimension2DDouble.max(result, dim);
+ }
+ return result;
+ }
+
+ private static IEntityImage computeImage(final ILeaf leaf, CucaDiagram diagram) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java
new file mode 100644
index 000000000..58dce0a57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.hector2.mpos.Distribution;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Foo2 implements TextBlock {
+
+ private final Distribution distribution;
+ private final CucaDiagram diagram;
+
+ public Foo2(Distribution distribution, CucaDiagram diagram) {
+ this.distribution = distribution;
+ this.diagram = diagram;
+ }
+
+ public Dimension2D getMaxCellDimension(StringBounder stringBounder) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (Layer layer : distribution.getLayers()) {
+ final Dimension2D dim = Foo1.getMaxCellDimension(stringBounder, layer, diagram);
+ result = Dimension2DDouble.max(result, dim);
+ }
+ return result;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D cell = getMaxCellDimension(stringBounder);
+ final MinMax longitudes = distribution.getMinMaxLongitudes();
+ final double width = (longitudes.getDiff() + 2) * cell.getWidth() / 2;
+ final double height = cell.getHeight() * distribution.getNbLayers();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D cell = getMaxCellDimension(stringBounder);
+ for (Layer layer : distribution.getLayers()) {
+ drawLayer(ug, layer, cell.getWidth(), cell.getHeight());
+ ug = ug.apply(new UTranslate(0, cell.getHeight()));
+ }
+ }
+
+ private void drawLayer(UGraphic ug, Layer layer, double w, double h) {
+ for (IEntity ent : layer.entities()) {
+ final IEntityImage image = computeImage((ILeaf) ent);
+ final int longitude = layer.getLongitude(ent);
+ final Dimension2D dimImage = image.calculateDimension(ug.getStringBounder());
+ final double diffx = w - dimImage.getWidth();
+ final double diffy = h - dimImage.getHeight();
+ image.drawU(ug.apply(new UTranslate(w * longitude / 2 + diffx / 2, diffy / 2)));
+ }
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/layering/Layer.java b/src/net/sourceforge/plantuml/hector2/layering/Layer.java
new file mode 100644
index 000000000..892fa1632
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/layering/Layer.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.layering;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayer;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayerMove;
+
+public class Layer {
+
+ private final int id;
+ private final Map entities = new HashMap();
+
+ public Layer(int id) {
+ this.id = id;
+ }
+
+ public Layer duplicate() {
+ final Layer result = new Layer(id);
+ result.entities.putAll(this.entities);
+ return result;
+ }
+
+ public List getPossibleMutations() {
+ final List result = new ArrayList();
+ for (Map.Entry ent : entities.entrySet()) {
+ final IEntity entity = ent.getKey();
+ final int longitude = ent.getValue();
+ if (isLongitudeFree(longitude + 2)) {
+ result.add(new MutationLayerMove(this, entity, longitude + 2));
+ }
+ if (isLongitudeFree(longitude - 2)) {
+ result.add(new MutationLayerMove(this, entity, longitude - 2));
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private boolean isLongitudeFree(int longitude) {
+ return entities.values().contains(longitude) == false;
+ }
+
+ public void put(IEntity ent, int longitude) {
+ if (entities.containsKey(ent) == false) {
+ throw new IllegalArgumentException();
+ }
+ this.entities.put(ent, longitude);
+ }
+
+ public void add(IEntity ent) {
+ final int pos = entities.size() * 2;
+ this.entities.put(ent, pos);
+ }
+
+ public Collection entities() {
+ return Collections.unmodifiableCollection(entities.keySet());
+ }
+
+ public int getLongitude(IEntity ent) {
+ return entities.get(ent);
+ }
+
+ public MinMax getMinMaxLongitudes() {
+ return MinMax.from(entities.values());
+ }
+
+ @Override
+ public String toString() {
+ return "layer " + id + " " + entities;
+ }
+
+ public final int getId() {
+ return id;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java b/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java
new file mode 100644
index 000000000..de70e6dbb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.layering;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.continuity.Skeleton;
+
+public class LayerFactory {
+
+ public List getLayers(Skeleton skeleton) {
+ skeleton = skeleton.removeCycle();
+ skeleton.computeLayers();
+ final List result = new ArrayList();
+ for (IEntity ent : skeleton.entities()) {
+ ensureLayer(result, ent.getHectorLayer());
+ }
+ for (IEntity ent : skeleton.entities()) {
+ final int layer = ent.getHectorLayer();
+ result.get(layer).add(ent);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private void ensureLayer(List result, int layerToAdd) {
+ while (result.size() <= layerToAdd) {
+ result.add(new Layer(result.size()));
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java b/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java
new file mode 100644
index 000000000..04180f341
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public class Distribution {
+
+ private final List layers;
+
+ public Distribution(List layers) {
+ this.layers = new ArrayList(layers);
+ }
+
+ public Distribution mute(MutationLayer mutation) {
+ final Distribution result = new Distribution(this.layers);
+ final int idx = result.layers.indexOf(mutation.getOriginal());
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ result.layers.set(idx, mutation.mute());
+ return result;
+ }
+
+ public double cost(Collection links) {
+ double result = 0;
+ for (Link link : links) {
+ result += getLength(link);
+ }
+ return result;
+ }
+
+ private double getLength(Link link) {
+ final IEntity ent1 = link.getEntity1();
+ final IEntity ent2 = link.getEntity2();
+ final int y1 = ent1.getHectorLayer();
+ final int x1 = layers.get(y1).getLongitude(ent1);
+ final int y2 = ent2.getHectorLayer();
+ final int x2 = layers.get(y2).getLongitude(ent2);
+ final int dx = x2 - x1;
+ final int dy = y2 - y1;
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+
+ public List getPossibleMutations() {
+ final List result = new ArrayList();
+ for (Layer layer : layers) {
+ result.addAll(layer.getPossibleMutations());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public final List getLayers() {
+ return Collections.unmodifiableList(layers);
+ }
+
+ public MinMax getMinMaxLongitudes() {
+ MinMax result = null;
+ for (Layer layer : layers) {
+ if (result == null) {
+ result = layer.getMinMaxLongitudes();
+ } else {
+ result = result.add(layer.getMinMaxLongitudes());
+ }
+ }
+ return result;
+ }
+
+ public double getNbLayers() {
+ return layers.size();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java
new file mode 100644
index 000000000..4fc03aa13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public interface MutationLayer {
+
+ public Layer getOriginal();
+
+ public Layer mute();
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java
new file mode 100644
index 000000000..5f1934c03
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5079 $
+ *
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public class MutationLayerMove implements MutationLayer {
+
+ private final Layer layer;
+ private final IEntity entity;
+ private final int newLongitude;
+
+ public MutationLayerMove(Layer layer, IEntity entity, int newLongitude) {
+ this.layer = layer;
+ this.entity = entity;
+ this.newLongitude = newLongitude;
+ }
+
+ public Layer mute() {
+ final Layer result = layer.duplicate();
+ result.put(entity, newLongitude);
+ return result;
+ }
+
+ public Layer getOriginal() {
+ return layer;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + layer.getId() + "} " + entity + " moveto " + newLongitude;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java b/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java
new file mode 100644
index 000000000..c0556098b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5424 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandAddLevel extends SingleLineCommand2 {
+
+ public CommandAddLevel() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("LEVEL", "(=+)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("LABEL", "(.+)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemTree diagram, RegexResult arg) {
+ final String level = arg.get("LEVEL", 0);
+ final String label = arg.get("LABEL", 0);
+ return diagram.addParagraph(level.length(), label);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/CommandEmpty.java b/src/net/sourceforge/plantuml/jungle/CommandEmpty.java
new file mode 100644
index 000000000..286d97c9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/CommandEmpty.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5424 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandEmpty extends SingleLineCommand2 {
+
+ public CommandEmpty() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemTree diagram, RegexResult arg) {
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GNode.java b/src/net/sourceforge/plantuml/jungle/GNode.java
new file mode 100644
index 000000000..798527669
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GNode.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class GNode {
+
+ private final Display display;
+ private final List children = new ArrayList();
+
+ public GNode(Display display) {
+ this.display = display;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public List getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public GNode addChild(Display display) {
+ final GNode child = new GNode(display);
+ children.add(child);
+ return child;
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/jungle/GNodeUtils.java b/src/net/sourceforge/plantuml/jungle/GNodeUtils.java
new file mode 100644
index 000000000..b2657ef74
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GNodeUtils.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+public class GNodeUtils {
+
+// public static GNode getIndirectChild(GNode root, String id) {
+// if (root.getId().equals(id)) {
+// return root;
+// }
+// for (GNode n : root.getChildren()) {
+// if (n.getId().equals(id)) {
+// return n;
+// }
+// final GNode result = getIndirectChild(n, id);
+// if (result != null) {
+// return result;
+// }
+// }
+// return null;
+// }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/jungle/GTile.java b/src/net/sourceforge/plantuml/jungle/GTile.java
new file mode 100644
index 000000000..1dcc91442
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTile.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface GTile extends TextBlock {
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder);
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileGeometry.java b/src/net/sourceforge/plantuml/jungle/GTileGeometry.java
new file mode 100644
index 000000000..18710494e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileGeometry.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.List;
+
+public class GTileGeometry extends Dimension2D {
+
+ private final double width;
+ private final double height;
+ private final List westPositions;
+
+ public GTileGeometry(Dimension2D dim, List westPositions) {
+ this(dim.getWidth(), dim.getHeight(), westPositions);
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public GTileGeometry(double width, double height, List westPositions) {
+ this.width = width;
+ this.height = height;
+ this.westPositions = westPositions;
+ }
+
+ @Override
+ public final double getWidth() {
+ return width;
+ }
+
+ @Override
+ public final double getHeight() {
+ return height;
+ }
+
+ public List getWestPositions() {
+ return Collections.unmodifiableList(westPositions);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java b/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java
new file mode 100644
index 000000000..3942d4013
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GTileLeftRight implements GTile {
+
+ private final GTile left;
+ private final GTile right;
+ private final double space;
+ private final double step = 5;
+
+ public GTileLeftRight(GTile left, GTile right, double space) {
+ this.left = left;
+ this.right = right;
+ this.space = space;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final GTileGeometry dimLeft = left.calculateDimension(stringBounder);
+ final GTileGeometry dimRight = right.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final double deltaH1 = dimTotal.getHeight() - dimLeft.getHeight();
+ final double deltaH2 = dimTotal.getHeight() - dimRight.getHeight();
+ left.drawU(ug.apply(new UTranslate(0, deltaH1 / 2)));
+ final double dx2 = dimLeft.getWidth() + space;
+ right.drawU(ug.apply(new UTranslate(dx2, deltaH2 / 2)));
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ final double step = dimLeft.getHeight() / (dimRight.getWestPositions().size() + 1);
+ double ystart = step + deltaH1 / 2;
+ for (Double w2 : dimRight.getWestPositions()) {
+ line(ug, dimLeft.getWidth(), ystart, dx2, w2 + deltaH2 / 2);
+ ystart += step;
+ }
+
+ }
+
+ private void line(UGraphic ug, double x1, double y1, double x2, double y2) {
+ // final ULine line = new ULine(x2 - x1, y2 - y1);
+ // ug.apply(new UTranslate(x1, y1)).draw(line);
+ final UPath path = new UPath();
+ path.moveTo(x1, y1);
+ path.lineTo(x1 + step, y1);
+ path.lineTo(x2 - step, y2);
+ path.lineTo(x2, y2);
+ ug.apply(new UTranslate(0, 0)).draw(path);
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ final GTileGeometry dimLeft = left.calculateDimension(stringBounder);
+ final Dimension2D dimRight = right.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = new Dimension2DDouble(dimLeft.getWidth() + space + dimRight.getHeight(), Math.max(
+ dimLeft.getHeight(), dimRight.getHeight()));
+ final double deltaH1 = dimTotal.getHeight() - dimLeft.getHeight();
+ final double west = dimLeft.getWestPositions().get(0) + deltaH1 / 2;
+ return new GTileGeometry(dimTotal, Arrays.asList(west));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileNode.java b/src/net/sourceforge/plantuml/jungle/GTileNode.java
new file mode 100644
index 000000000..9b1b8fb1b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileNode.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GTileNode implements GTile {
+
+ private final TextBlock tb;
+
+ public GTileNode(GNode node) {
+ final Display display = node.getDisplay();
+ final SheetBlock1 sheetBlock1 = getTextBlock(display);
+
+ final SymbolContext symbolContext = new SymbolContext(HtmlColorUtils.MY_YELLOW, HtmlColorUtils.BLACK);
+ tb = USymbol.RECTANGLE.asSmall(sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext);
+ }
+
+ public static SheetBlock1 getTextBlock(final Display display) {
+ final Rose rose = new Rose();
+ final SkinParam skinParam = new SkinParam();
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(display);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, 0, 0);
+ return sheetBlock1;
+ }
+
+ public void drawU(UGraphic ug) {
+ tb.drawU(ug);
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+ return new GTileGeometry(dim, Arrays.asList(dim.getHeight() / 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java b/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java
new file mode 100644
index 000000000..d14506e67
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GTileOneLevelFactory {
+
+ public GTile createGTile(GNode root) {
+ final GTileNode left = new GTileNode(root);
+ if (root.getChildren().size() == 0) {
+ return left;
+ }
+ final List all = new ArrayList();
+ for (GNode n : root.getChildren()) {
+ all.add(createGTile(n));
+ }
+ final GTileStack right = new GTileStack(all, 20);
+ return new GTileLeftRight(left, right, 30);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileStack.java b/src/net/sourceforge/plantuml/jungle/GTileStack.java
new file mode 100644
index 000000000..5738c343d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileStack.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GTileStack implements GTile {
+
+ private final List tiles;
+ private final double space;
+
+ public GTileStack(List tiles, double space) {
+ this.tiles = tiles;
+ this.space = space;
+ if (tiles.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ for (GTile tile : tiles) {
+ tile.drawU(ug);
+ final Dimension2D dim = tile.calculateDimension(ug.getStringBounder());
+ ug = ug.apply(new UTranslate(0, dim.getHeight() + space));
+ }
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ double delta = 0;
+ final List wests = new ArrayList();
+ for (GTile tile : tiles) {
+ final GTileGeometry dim = tile.calculateDimension(stringBounder);
+ wests.add(delta + dim.getWestPositions().get(0));
+ height += dim.getHeight();
+ delta += dim.getHeight() + space;
+ width = Math.max(width, dim.getWidth());
+ }
+ height += (tiles.size() - 1) * space;
+ return new GTileGeometry(width, height, wests);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/Needle.java b/src/net/sourceforge/plantuml/jungle/Needle.java
new file mode 100644
index 000000000..f529c7520
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/Needle.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Needle implements UDrawable {
+
+ private final double length;
+ private final Display display;
+ private final double degreePosition;
+ private final double degreeOperture;
+
+ private Needle(Display display, double length, double degreePosition, double degreeOperture) {
+ this.display = display;
+ this.degreePosition = degreePosition;
+ this.degreeOperture = degreeOperture;
+ this.length = length;
+ }
+
+ public void drawU(UGraphic ug) {
+ GTileNode.getTextBlock(display);
+ ug.draw(getLine());
+
+ ug = ug.apply(getTranslate(length));
+ GTileNode.getTextBlock(display).drawU(ug);
+ }
+
+ private ULine getLine() {
+ final UTranslate translate = getTranslate(length);
+ return new ULine(translate.getDx(), translate.getDy());
+ }
+
+ public UTranslate getTranslate(double dist) {
+ final double angle = degreePosition * Math.PI / 180.0;
+ final double dx = dist * Math.cos(angle);
+ final double dy = dist * Math.sin(angle);
+ return new UTranslate(dx, dy);
+ }
+
+ public UDrawable addChildren(final List children) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ Needle.this.drawU(ug);
+ if (children.size() == 0) {
+ return;
+ }
+ ug = ug.apply(getTranslate(length / 2));
+ final UDrawable child1 = getNeedle(children.get(0), length / 2, degreePosition + degreeOperture,
+ degreeOperture / 2);
+ child1.drawU(ug);
+ if (children.size() == 1) {
+ return;
+ }
+ final UDrawable child2 = getNeedle(children.get(1), length / 2, degreePosition - degreeOperture,
+ degreeOperture / 2);
+ child2.drawU(ug);
+
+ }
+ };
+ }
+
+ public static UDrawable getNeedle(GNode root, double length, double degree, double degreeOperture) {
+ final Needle needle0 = new Needle(root.getDisplay(), length, degree, degreeOperture);
+ final UDrawable n1 = needle0.addChildren(root.getChildren());
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ n1.drawU(ug);
+ }
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTree.java b/src/net/sourceforge/plantuml/jungle/PSystemTree.java
new file mode 100644
index 000000000..8f9bfe5a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/PSystemTree.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.UDrawableUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+
+public class PSystemTree extends AbstractPSystem {
+
+ private GNode root;
+ private List stack = new ArrayList();
+ private final Rendering rendering = Rendering.NEEDLE;
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Tree)", getClass());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null, null,
+ 5, 5, null, false);
+ if (rendering == Rendering.NEEDLE) {
+ final UDrawable tmp = Needle.getNeedle(root, 200, 0, 60);
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ tmp.drawU(limitFinder);
+ final double minY = limitFinder.getMinY();
+ builder.addUDrawable(UDrawableUtils.move(tmp, 0, -minY));
+ } else {
+ builder.addUDrawable(new GTileOneLevelFactory().createGTile(root));
+ }
+ return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public CommandExecutionResult addParagraph(int level, String label) {
+
+ if (level == 1 && root == null) {
+ root = new GNode(Display.create(label));
+ stack.add(root);
+ return CommandExecutionResult.ok();
+ } else if (level == 1 && root != null) {
+ return CommandExecutionResult.error("Not allowed 1");
+ }
+
+ final GNode parent = stack.get(level - 2);
+ final GNode newNode = parent.addChild(Display.create(label));
+
+ if (level > stack.size() + 1) {
+ return CommandExecutionResult.error("Not allowed 2");
+ } else if (level - 1 == stack.size()) {
+ stack.add(newNode);
+ } else {
+ stack.set(level - 1, newNode);
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java
new file mode 100644
index 000000000..c28e6db57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemTreeFactory extends UmlDiagramFactory {
+
+ public PSystemTreeFactory(DiagramType type) {
+ super(type);
+ }
+
+ @Override
+ protected List createCommands() {
+ final List cmds = new ArrayList();
+ cmds.add(new CommandEmpty());
+ cmds.add(new CommandAddLevel());
+ return cmds;
+ }
+
+ @Override
+ public PSystemTree createEmptyDiagram() {
+ return new PSystemTree();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/Rendering.java b/src/net/sourceforge/plantuml/jungle/Rendering.java
new file mode 100644
index 000000000..c13056847
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/Rendering.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 8475 $
+ *
+ */
+package net.sourceforge.plantuml.jungle;
+
+public enum Rendering {
+
+ BASIC, NEEDLE
+
+}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java
new file mode 100644
index 000000000..328fb8cde
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.mda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.SourceStringReader;
+import net.sourceforge.plantuml.api.mda.option2.MDADiagram;
+import net.sourceforge.plantuml.api.mda.option2.MDAPackage;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+
+public class MDADiagramImpl implements MDADiagram {
+
+ public static MDADiagram create(String uml) {
+ List blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ uml = "@startuml\n" + uml + "\n@enduml";
+ blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ return null;
+ }
+ }
+ final BlockUml block = blocks.get(0);
+ final Diagram diagram = block.getDiagram();
+ if (diagram instanceof ClassDiagram) {
+ return new MDADiagramImpl((ClassDiagram) diagram);
+ }
+ return null;
+ }
+
+ private final Collection packages = new ArrayList();
+
+ private MDADiagramImpl(ClassDiagram classDiagram) {
+ final EntityFactory entityFactory = classDiagram.getEntityFactory();
+ packages.add(new MDAPackageImpl(entityFactory.getRootGroup()));
+ for (IGroup group : entityFactory.getGroups().values()) {
+ packages.add(new MDAPackageImpl(group));
+ }
+ }
+
+ public Collection getPackages() {
+ return Collections.unmodifiableCollection(packages);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java
new file mode 100644
index 000000000..c81c87a9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.mda;
+
+import net.sourceforge.plantuml.api.mda.option2.MDAEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+
+public class MDAEntityImpl implements MDAEntity {
+
+ private final ILeaf leaf;
+
+ public MDAEntityImpl(ILeaf leaf) {
+ this.leaf = leaf;
+ }
+
+ public String getName() {
+ return leaf.getCode().getFullName();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java
new file mode 100644
index 000000000..5bda81ac2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 9786 $
+ *
+ */
+package net.sourceforge.plantuml.mda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.api.mda.option2.MDAEntity;
+import net.sourceforge.plantuml.api.mda.option2.MDAPackage;
+import net.sourceforge.plantuml.cucadiagram.GroupRoot;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+
+public class MDAPackageImpl implements MDAPackage {
+
+ private final Collection entities = new ArrayList();
+ private final IGroup group;
+
+ public MDAPackageImpl(IGroup group) {
+ this.group = group;
+ for (ILeaf leaf : group.getLeafsDirect()) {
+ entities.add(new MDAEntityImpl(leaf));
+ }
+ }
+
+ public Collection getEntities() {
+ return Collections.unmodifiableCollection(entities);
+ }
+
+ public String getName() {
+ if (group instanceof GroupRoot) {
+ return "";
+ }
+ return group.getCode().getFullName();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/Movement.java b/src/net/sourceforge/plantuml/openiconic/Movement.java
new file mode 100644
index 000000000..35be5c3c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/Movement.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class Movement {
+
+ private final SvgCommandLetter letter;
+ private final List arguments;
+
+ public Movement(Iterator it) {
+ this.letter = (SvgCommandLetter) it.next();
+ final int nb = letter.argumentNumber();
+ final SvgCommandNumber args[] = new SvgCommandNumber[nb];
+ for (int i = 0; i < nb; i++) {
+ args[i] = (SvgCommandNumber) it.next();
+ }
+ this.arguments = Arrays.asList(args);
+ }
+
+ private Movement(SvgCommandLetter letter, SvgCommandNumber... args) {
+ this.letter = letter;
+ this.arguments = Arrays.asList(args);
+ }
+
+ private Movement(SvgCommandLetter letter) {
+ this.letter = letter;
+ this.arguments = Collections.emptyList();
+ }
+
+ public char getLetter() {
+ return letter.getLetter();
+ }
+
+ private Movement(SvgCommandLetter letter, SvgPosition... pos) {
+ this.letter = letter;
+ final SvgCommandNumber args[] = new SvgCommandNumber[pos.length * 2];
+ for (int i = 0; i < pos.length; i++) {
+ args[2 * i] = pos[i].getX();
+ args[2 * i + 1] = pos[i].getY();
+ }
+ this.arguments = Arrays.asList(args);
+ }
+
+ public Movement mutoToC(SvgPosition mirrorControlPoint) {
+ if (is('S') == false) {
+ throw new UnsupportedOperationException();
+ }
+ if (mirrorControlPoint == null) {
+ // return this;
+ // throw new IllegalArgumentException();
+ return new Movement(new SvgCommandLetter("C"), this.getSvgPosition(0), this.getSvgPosition(0),
+ lastPosition());
+ }
+ return new Movement(new SvgCommandLetter("C"), mirrorControlPoint, this.getSvgPosition(0), lastPosition());
+ }
+
+ public String toSvg() {
+ final StringBuilder result = new StringBuilder();
+ result.append(letter.toSvg());
+ result.append(' ');
+ for (SvgCommandNumber arg : arguments) {
+ result.append(arg.toSvg());
+ result.append(' ');
+ }
+ return result.toString();
+ }
+
+ public SvgPosition getSvgPosition(int index) {
+ return new SvgPosition(arguments.get(index), arguments.get(index + 1));
+ }
+
+ public double getArgument(int index) {
+ return arguments.get(index).getDouble();
+ }
+
+ public SvgPosition lastPosition() {
+ if (letter.argumentNumber() == 0) {
+ return null;
+ }
+ return getSvgPosition(arguments.size() - 2);
+ // final SvgCommandNumber lastX = arguments.get(arguments.size() - 2);
+ // final SvgCommandNumber lastY = arguments.get(arguments.size() - 1);
+ // return new SvgPosition(lastX, lastY);
+ }
+
+ // public SvgPosition firstPosition() {
+ // return getSvgPosition(0);
+ // // final SvgCommandNumber firstX = arguments.get(0);
+ // // final SvgCommandNumber firstY = arguments.get(1);
+ // // return new SvgPosition(firstX, firstY);
+ // }
+
+ public Movement toAbsoluteUpperCase(SvgPosition delta) {
+ if (delta == null) {
+ throw new IllegalArgumentException();
+ }
+ if (letter.isUpperCase()) {
+ return this;
+ }
+ if (letter.is('m')) {
+ return new Movement(new SvgCommandLetter("M"), delta.add(getSvgPosition(0)));
+ }
+ if (letter.is('l')) {
+ return new Movement(new SvgCommandLetter("L"), delta.add(getSvgPosition(0)));
+ }
+ if (letter.is('z')) {
+ return new Movement(new SvgCommandLetter("Z"));
+ }
+ if (letter.is('c')) {
+ return new Movement(new SvgCommandLetter("C"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2)),
+ delta.add(getSvgPosition(4)));
+ }
+ if (letter.is('s')) {
+ return new Movement(new SvgCommandLetter("S"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2)));
+ }
+ if (letter.is('a')) {
+ final SvgPosition last = delta.add(lastPosition());
+ // System.err.println("LAST=" + last);
+ return new Movement(new SvgCommandLetter("A"), arguments.get(0), arguments.get(1), arguments.get(2),
+ arguments.get(3), arguments.get(4), last.getX(), last.getY());
+ }
+ // A still to be done
+ // System.err.println("Movement::goUpperCase " + letter);
+ throw new UnsupportedOperationException("Movement::goUpperCase " + letter);
+ }
+
+ public SvgPosition getMirrorControlPoint() {
+ if (letter.is('c')) {
+ throw new IllegalStateException();
+ }
+ if (letter.is('s')) {
+ throw new IllegalStateException();
+ }
+ if (letter.is('C')) {
+ final SvgPosition center = lastPosition();
+ final SvgPosition controlPoint = getSvgPosition(2);
+ return center.getMirror(controlPoint);
+ }
+ if (letter.is('S')) {
+ final SvgPosition center = lastPosition();
+ final SvgPosition controlPoint = getSvgPosition(0);
+ return center.getMirror(controlPoint);
+ }
+ return null;
+ }
+
+ public boolean is(char c) {
+ return letter.is(c);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/OpenIcon.java b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java
new file mode 100644
index 000000000..0484ec099
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java
@@ -0,0 +1,144 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.awt.geom.Dimension2D;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.openiconic.data.DummyIcon;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class OpenIcon {
+
+ private SvgPath svgPath;
+ private List rawData = new ArrayList();
+ private final String id;
+
+ public static OpenIcon retrieve(String name) {
+ final InputStream is = getRessource(name);
+ if (is == null) {
+ return null;
+ }
+ try {
+ return new OpenIcon(is, name);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ OpenIcon(String name) throws IOException {
+ this(getRessource(name), name);
+ }
+
+ private static InputStream getRessource(String name) {
+ // System.err.println("OPENING " + name);
+ return DummyIcon.class.getResourceAsStream(name + ".svg");
+ }
+
+ private OpenIcon(InputStream is, String id) throws IOException {
+ this.id = id;
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ rawData.add(s);
+ if (s.contains(" lines = new ArrayList();
+ lines.add("List Open Iconic");
+ lines.add("Credit to");
+ lines.add("https://useiconic.com/open");
+ lines.add(" ");
+ final BufferedReader br = new BufferedReader(new InputStreamReader(getRessourceAllTxt()));
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ // lines.add("<¥> " + s);
+ // System.err.println("s=" + s);
+ lines.add("<&" + s + "> " + s);
+ }
+ br.close();
+
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ final GraphicStrings graphicStrings = new GraphicStrings(lines, font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON);
+ graphicStrings.setMaxLine(35);
+ return graphicStrings;
+ }
+
+ private InputStream getRessourceAllTxt() {
+ return DummyIcon.class.getResourceAsStream("all.txt");
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Open iconic)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java
new file mode 100644
index 000000000..f21ff4381
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 3830 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemListOpenIconicFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final String lineLower = StringUtils.goLowerCase(line);
+ if (lineLower.startsWith("listopeniconic")) {
+ return new PSystemListOpenIconic();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java
new file mode 100644
index 000000000..fef4c1ee9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4041 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class PSystemOpenIconic extends AbstractPSystem {
+
+ private final String iconName;
+ private final double factor;
+
+ public PSystemOpenIconic(String iconName, double factor) {
+ this.iconName = iconName;
+ this.factor = factor;
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final OpenIcon icon = OpenIcon.retrieve(iconName);
+ // final Dimension2D dim = new Dimension2DDouble(100, 100);
+
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0,
+ null, null, null, 5, 5, null, false);
+ imageBuilder.addUDrawable(icon.asTextBlock(HtmlColorUtils.BLACK, factor));
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+
+// UGraphic2 ug = fileFormat.createUGraphic(dim);
+// ug = (UGraphic2) ug.apply(new UTranslate(10, 10));
+// // ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+// // ug.draw(new URectangle(7, 6));
+// icon.asTextBlock(HtmlColorUtils.BLACK, factor).drawU(ug);
+// ug.writeImageTOBEMOVED(os, null, 96);
+// return new ImageDataSimple(dim);
+ }
+
+ // 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,
+ // UAntiAliasing.ANTI_ALIASING_ON);
+ // return result;
+ // }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Open iconic)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java
new file mode 100644
index 000000000..340b19bb7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 3830 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemOpenIconicFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final String lineLower = StringUtils.goLowerCase(line);
+ if (lineLower.startsWith("openiconic ")) {
+ final int idx = line.indexOf(' ');
+ return new PSystemOpenIconic(lineLower.substring(idx + 1), 1.0);
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/StringDecipher.java b/src/net/sourceforge/plantuml/openiconic/StringDecipher.java
new file mode 100644
index 000000000..6de918819
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/StringDecipher.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+public class StringDecipher {
+
+ public static String decipher(String path) {
+ path = path.replaceAll("(\\S)-", "$1 -");
+ path = path.replaceAll("([a-zA-Z])(\\S)", "$1 $2");
+ path = path.replaceAll("(\\S)([a-zA-Z])", "$1 $2");
+ path = path.replaceAll("([a-zA-Z])(\\S)", "$1 $2");
+ while (path.matches(".*\\.\\d+\\..*")) {
+ path = path.replaceAll("(\\.\\d+)\\.", "$1 .");
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommand.java b/src/net/sourceforge/plantuml/openiconic/SvgCommand.java
new file mode 100644
index 000000000..062203430
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommand.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+public interface SvgCommand {
+
+ public String toSvg();
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java
new file mode 100644
index 000000000..7e3f3e5a4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SvgCommandLetter implements SvgCommand {
+
+ final private char letter;
+
+ public SvgCommandLetter(String letter) {
+ if (letter.matches("[a-zA-Z]") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.letter = letter.charAt(0);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + letter;
+ }
+
+ public String toSvg() {
+ return "" + letter;
+ }
+
+ public int argumentNumber() {
+ switch (StringUtils.goLowerCase(letter)) {
+ case 'm':
+ case 'M':
+ case 'l':
+ return 2;
+ case 'z':
+ return 0;
+ case 'c':
+ return 6;
+ case 's':
+ return 4;
+ case 'a':
+ return 7;
+ }
+ throw new UnsupportedOperationException("" + letter);
+ }
+
+// public UGraphic drawMe(UGraphic ug, Iterator it) {
+// System.err.println("drawMe " + letter);
+// final List numbers = new ArrayList();
+// for (int i = 0; i < argumentNumber(); i++) {
+// numbers.add((SvgCommandNumber) it.next());
+// }
+// return drawMe(ug, numbers);
+// }
+//
+// private UGraphic drawMe(UGraphic ug, List numbers) {
+// switch (letter) {
+// case 'M':
+// final double x = numbers.get(0).getDouble();
+// final double y = numbers.get(1).getDouble();
+// return ug.apply(new UTranslate(x, y));
+// }
+// return ug;
+//
+// }
+
+ public boolean isUpperCase() {
+ return Character.isUpperCase(letter);
+ }
+
+ public boolean is(char c) {
+ return this.letter == c;
+ }
+
+ public char getLetter() {
+ return letter;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java b/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java
new file mode 100644
index 000000000..5f9b2e877
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.Locale;
+
+public class SvgCommandNumber implements SvgCommand {
+
+ final private String number;
+
+ public SvgCommandNumber(String number) {
+ if (number.matches("[-.0-9]+") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.number = number;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + number;
+ }
+
+ public SvgCommandNumber(double number) {
+ this.number = String.format(Locale.US, "%1.4f", number);
+ }
+
+ public SvgCommandNumber add(SvgCommandNumber other) {
+ return new SvgCommandNumber(getDouble() + other.getDouble());
+ }
+
+ public String toSvg() {
+ return number;
+ }
+
+ public double getDouble() {
+ return Double.parseDouble(number);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgPath.java b/src/net/sourceforge/plantuml/openiconic/SvgPath.java
new file mode 100644
index 000000000..824c2a1b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgPath.java
@@ -0,0 +1,214 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * 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
+ * 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 12819 $
+ *
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class SvgPath {
+
+ // http://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands
+ // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
+ // http://tutorials.jenkov.com/svg/path-element.html
+
+ private List movements = new ArrayList();
+ private List commands = new ArrayList();
+
+ public SvgPath(String path) {
+ path = StringDecipher.decipher(path);
+ // List commands = new ArrayList();
+ for (final StringTokenizer st = new StringTokenizer(path); st.hasMoreTokens();) {
+ final String token = st.nextToken();
+ // System.err.println("token=" + token);
+ if (token.matches("[a-zA-Z]")) {
+ commands.add(new SvgCommandLetter(token));
+ } else {
+ commands.add(new SvgCommandNumber(token));
+ }
+ }
+ commands = manageHV(commands);
+ commands = insertMissingLetter(commands);
+ checkArguments(commands);
+ SvgPosition last = new SvgPosition();
+ SvgPosition mirrorControlPoint = null;
+ final Iterator iterator = commands.iterator();
+ while (iterator.hasNext()) {
+ Movement movement = new Movement(iterator);
+ // System.err.println("before=" + movement.toSvg());
+ movement = movement.toAbsoluteUpperCase(last);
+ // System.err.println("after=" + movement.toSvg());
+ if (movement.is('S')) {
+ // System.err.println(" before " + movement.toSvg());
+ movement = movement.mutoToC(mirrorControlPoint);
+ // System.err.println(" after " + movement.toSvg());
+ }
+ movements.add(movement);
+ if (movement.lastPosition() != null) {
+ last = movement.lastPosition();
+ }
+ mirrorControlPoint = movement.getMirrorControlPoint();
+ }
+ }
+
+ private List