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. + * + *
+ *  Example:
+ *     AnimatedGifEncoder e = new AnimatedGifEncoder();
+ *     e.start(outputFileName);
+ *     e.setDelay(1000);   // 1 frame per sec
+ *     e.addFrame(image1);
+ *     e.addFrame(image2);
+ *     e.finish();
+ * 
+ * + * 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 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 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 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 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 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 insertMissingLetter(List commands) { + final List result = new ArrayList(); + final Iterator it = commands.iterator(); + SvgCommandLetter lastLetter = null; + while (it.hasNext()) { + final SvgCommand cmd = it.next(); + // System.err.println("cmd=" + cmd); + final int nb; + if (cmd instanceof SvgCommandNumber) { + // System.err.println("INSERTING " + lastLetter); + result.add(lastLetter); + result.add(cmd); + nb = lastLetter.argumentNumber() - 1; + } else { + result.add(cmd); + lastLetter = (SvgCommandLetter) cmd; + nb = lastLetter.argumentNumber(); + } + for (int i = 0; i < nb; i++) { + final SvgCommandNumber number = (SvgCommandNumber) it.next(); + result.add(number); + } + } + return result; + } + + private void checkArguments(List commands) { + final Iterator it = commands.iterator(); + while (it.hasNext()) { + final SvgCommandLetter cmd = (SvgCommandLetter) it.next(); + final int nb = cmd.argumentNumber(); + for (int i = 0; i < nb; i++) { + final SvgCommandNumber number = (SvgCommandNumber) it.next(); + } + } + } + + private List manageHV(List commands) { + final List result = new ArrayList(); + SvgCommandNumber lastX = null; + SvgCommandNumber lastY = null; + final Iterator it = commands.iterator(); + while (it.hasNext()) { + final SvgCommand cmd = it.next(); + if (cmd instanceof SvgCommandNumber) { + lastX = lastY; + lastY = (SvgCommandNumber) cmd; + result.add(cmd); + continue; + } + final String letter = cmd.toSvg(); + if (letter.equals("h")) { + result.add(new SvgCommandLetter("l")); + result.add(it.next()); + result.add(new SvgCommandNumber("0")); + } else if (letter.equals("v")) { + result.add(new SvgCommandLetter("l")); + result.add(new SvgCommandNumber("0")); + result.add(it.next()); + } else { + result.add(cmd); + } + } + return result; + } + + public String toSvg() { + final StringBuilder result = new StringBuilder(""); + return result.toString(); + } + + private String toSvgNew() { + final StringBuilder result = new StringBuilder(""); + return result.toString(); + } + + private UPath toUPath(double factor) { + final UPath result = new UPath(); + for (Movement move : movements) { + final char letter = move.getLetter(); + final SvgPosition lastPosition = move.lastPosition(); + if (letter == 'M') { + result.moveTo(lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor); + } else if (letter == 'C') { + final SvgPosition ctl1 = move.getSvgPosition(0); + final SvgPosition ctl2 = move.getSvgPosition(2); + result.cubicTo(ctl1.getXDouble() * factor, ctl1.getYDouble() * factor, ctl2.getXDouble() * factor, + ctl2.getYDouble() * factor, lastPosition.getXDouble() * factor, lastPosition.getYDouble() + * factor); + } else if (letter == 'L') { + result.lineTo(lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor); + } else if (letter == 'A') { + + final double rx = move.getArgument(0); + final double ry = move.getArgument(1); + final double x_axis_rotation = move.getArgument(2); + final double large_arc_flag = move.getArgument(3); + final double sweep_flag = move.getArgument(4); + result.arcTo(rx * factor, ry * factor, x_axis_rotation, large_arc_flag, sweep_flag, + lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor); + } else if (letter == 'Z') { + result.closePath(); + } else { + throw new UnsupportedOperationException("letter " + letter); + } + + } + result.setOpenIconic(true); + return result; + } + + public void drawMe(UGraphic ug, double factor) { + final UPath path = toUPath(factor); + ug.draw(path); + } +} diff --git a/src/net/sourceforge/plantuml/openiconic/SvgPosition.java b/src/net/sourceforge/plantuml/openiconic/SvgPosition.java new file mode 100644 index 000000000..bc59dd4c2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/SvgPosition.java @@ -0,0 +1,88 @@ +/* ======================================================================== + * 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 SvgPosition { + + final private SvgCommandNumber x; + final private SvgCommandNumber y; + + public SvgPosition() { + this(new SvgCommandNumber("0"), new SvgCommandNumber("0")); + } + + public SvgPosition(SvgCommandNumber x, SvgCommandNumber y) { + this.x = x; + this.y = y; + } + + @Override + public String toString() { + return x.toSvg() + "," + y.toSvg(); + } + + public SvgPosition(double x, double y) { + this.x = new SvgCommandNumber(x); + this.y = new SvgCommandNumber(y); + } + + public SvgCommandNumber getX() { + return x; + } + + public SvgCommandNumber getY() { + return y; + } + + public double getXDouble() { + return x.getDouble(); + } + + public double getYDouble() { + return y.getDouble(); + } + + public SvgPosition add(SvgPosition other) { + return new SvgPosition(x.add(other.x), y.add(other.y)); + } + + public SvgPosition getMirror(SvgPosition tobeMirrored) { + final double centerX = getXDouble(); + final double centerY = getYDouble(); + // x1+x2 = 2*xc + final double x = 2 * centerX - tobeMirrored.getXDouble(); + final double y = 2 * centerY - tobeMirrored.getYDouble(); + return new SvgPosition(x, y); + } +} diff --git a/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java b/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java new file mode 100644 index 000000000..7c54f40d8 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.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: 12819 $ + * + */ +package net.sourceforge.plantuml.openiconic.data; + +public class DummyIcon { + +} diff --git a/src/net/sourceforge/plantuml/openiconic/data/account-login.svg b/src/net/sourceforge/plantuml/openiconic/data/account-login.svg new file mode 100644 index 000000000..225d912c7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/account-login.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg b/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg new file mode 100644 index 000000000..123ceceae --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg b/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg new file mode 100644 index 000000000..ce2da3c0b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg b/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg new file mode 100644 index 000000000..216bec1f0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-center.svg b/src/net/sourceforge/plantuml/openiconic/data/align-center.svg new file mode 100644 index 000000000..bbac8ec5b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/align-center.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-left.svg b/src/net/sourceforge/plantuml/openiconic/data/align-left.svg new file mode 100644 index 000000000..2e92e0dd9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/align-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-right.svg b/src/net/sourceforge/plantuml/openiconic/data/align-right.svg new file mode 100644 index 000000000..22d127ab3 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/align-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/all.txt b/src/net/sourceforge/plantuml/openiconic/data/all.txt new file mode 100644 index 000000000..feed1dec2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/all.txt @@ -0,0 +1,223 @@ +account-login +account-logout +action-redo +action-undo +align-center +align-left +align-right +aperture +arrow-bottom +arrow-circle-bottom +arrow-circle-left +arrow-circle-right +arrow-circle-top +arrow-left +arrow-right +arrow-thick-bottom +arrow-thick-left +arrow-thick-right +arrow-thick-top +arrow-top +audio-spectrum +audio +badge +ban +bar-chart +basket +battery-empty +battery-full +beaker +bell +bluetooth +bold +bolt +book +bookmark +box +briefcase +british-pound +browser +brush +bug +bullhorn +calculator +calendar +camera-slr +caret-bottom +caret-left +caret-right +caret-top +cart +chat +check +chevron-bottom +chevron-left +chevron-right +chevron-top +circle-check +circle-x +clipboard +clock +cloud-download +cloud-upload +cloud +cloudy +code +cog +collapse-down +collapse-left +collapse-right +collapse-up +command +comment-square +compass +contrast +copywriting +credit-card +crop +dashboard +data-transfer-download +data-transfer-upload +delete +dial +document +dollar +double-quote-sans-left +double-quote-sans-right +double-quote-serif-left +double-quote-serif-right +droplet +eject +elevator +ellipses +envelope-closed +envelope-open +euro +excerpt +expand-down +expand-left +expand-right +expand-up +external-link +eye +eyedropper +file +fire +flag +flash +folder +fork +fullscreen-enter +fullscreen-exit +globe +graph +grid-four-up +grid-three-up +grid-two-up +hard-drive +header +headphones +heart +home +image +inbox +infinity +info +italic +justify-center +justify-left +justify-right +key +laptop +layers +lightbulb +link-broken +link-intact +list-rich +list +location +lock-locked +lock-unlocked +loop-circular +loop-square +loop +magnifying-glass +map-marker +map +media-pause +media-play +media-record +media-skip-backward +media-skip-forward +media-step-backward +media-step-forward +media-stop +medical-cross +menu +microphone +minus +monitor +moon +move +musical-note +paperclip +pencil +people +person +phone +pie-chart +pin +play-circle +plus +power-standby +print +project +pulse +puzzle-piece +question-mark +rain +random +reload +resize-both +resize-height +resize-width +rss-alt +rss +script +share-boxed +share +shield +signal +signpost +sort-ascending +sort-descending +spreadsheet +star +sun +tablet +tag +tags +target +task +terminal +text +thumb-down +thumb-up +timer +transfer +trash +underline +vertical-align-bottom +vertical-align-center +vertical-align-top +video +volume-high +volume-low +volume-off +warning +wifi +wrench +x +yen +zoom-in +zoom-out diff --git a/src/net/sourceforge/plantuml/openiconic/data/aperture.svg b/src/net/sourceforge/plantuml/openiconic/data/aperture.svg new file mode 100644 index 000000000..84935dc4a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/aperture.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg new file mode 100644 index 000000000..b41aa3254 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg new file mode 100644 index 000000000..fffa96bc1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg new file mode 100644 index 000000000..b4d760096 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg new file mode 100644 index 000000000..a62bc1798 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg new file mode 100644 index 000000000..2ac6e7f15 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg new file mode 100644 index 000000000..7221cae48 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg new file mode 100644 index 000000000..fa49384ce --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg new file mode 100644 index 000000000..754e841f1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg new file mode 100644 index 000000000..94a93e1e3 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg new file mode 100644 index 000000000..5aa125ca5 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg new file mode 100644 index 000000000..92f6f9f09 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg new file mode 100644 index 000000000..305e05c6c --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg b/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg new file mode 100644 index 000000000..7077ec7f9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/audio.svg b/src/net/sourceforge/plantuml/openiconic/data/audio.svg new file mode 100644 index 000000000..5914b3aa9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/audio.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/badge.svg b/src/net/sourceforge/plantuml/openiconic/data/badge.svg new file mode 100644 index 000000000..34f43cf5f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/badge.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/ban.svg b/src/net/sourceforge/plantuml/openiconic/data/ban.svg new file mode 100644 index 000000000..3b701c31d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/ban.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg b/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg new file mode 100644 index 000000000..a1cde5a16 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/basket.svg b/src/net/sourceforge/plantuml/openiconic/data/basket.svg new file mode 100644 index 000000000..39f16f2c2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/basket.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg b/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg new file mode 100644 index 000000000..844a415b1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg b/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg new file mode 100644 index 000000000..ea757ee8d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/beaker.svg b/src/net/sourceforge/plantuml/openiconic/data/beaker.svg new file mode 100644 index 000000000..7083b1c65 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/beaker.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bell.svg b/src/net/sourceforge/plantuml/openiconic/data/bell.svg new file mode 100644 index 000000000..68b17ca08 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bell.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg b/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg new file mode 100644 index 000000000..6c802314f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bold.svg b/src/net/sourceforge/plantuml/openiconic/data/bold.svg new file mode 100644 index 000000000..60afa806b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bold.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bolt.svg b/src/net/sourceforge/plantuml/openiconic/data/bolt.svg new file mode 100644 index 000000000..1bfe8de6c --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bolt.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/book.svg b/src/net/sourceforge/plantuml/openiconic/data/book.svg new file mode 100644 index 000000000..d69afa440 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/book.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg b/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg new file mode 100644 index 000000000..586cf4d17 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/box.svg b/src/net/sourceforge/plantuml/openiconic/data/box.svg new file mode 100644 index 000000000..771adc4d7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/box.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg b/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg new file mode 100644 index 000000000..43a6d6413 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg b/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg new file mode 100644 index 000000000..af29a2edc --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/browser.svg b/src/net/sourceforge/plantuml/openiconic/data/browser.svg new file mode 100644 index 000000000..8a23116e5 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/browser.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/brush.svg b/src/net/sourceforge/plantuml/openiconic/data/brush.svg new file mode 100644 index 000000000..2fd9f8d55 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/brush.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bug.svg b/src/net/sourceforge/plantuml/openiconic/data/bug.svg new file mode 100644 index 000000000..e1f6ca494 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bug.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg b/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg new file mode 100644 index 000000000..288f25f72 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/calculator.svg b/src/net/sourceforge/plantuml/openiconic/data/calculator.svg new file mode 100644 index 000000000..8b7b3c49e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/calculator.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/calendar.svg b/src/net/sourceforge/plantuml/openiconic/data/calendar.svg new file mode 100644 index 000000000..48b394a3a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/calendar.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg b/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg new file mode 100644 index 000000000..704f920d7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg new file mode 100644 index 000000000..ac894c79f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg new file mode 100644 index 000000000..5912663cf --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg new file mode 100644 index 000000000..b69354efe --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg new file mode 100644 index 000000000..2a12b0b0f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cart.svg b/src/net/sourceforge/plantuml/openiconic/data/cart.svg new file mode 100644 index 000000000..a8dd9b5eb --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cart.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/chat.svg b/src/net/sourceforge/plantuml/openiconic/data/chat.svg new file mode 100644 index 000000000..e1a1da053 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/chat.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/check.svg b/src/net/sourceforge/plantuml/openiconic/data/check.svg new file mode 100644 index 000000000..61368e4d6 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/check.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg new file mode 100644 index 000000000..6b668691a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg new file mode 100644 index 000000000..0210e22f1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg new file mode 100644 index 000000000..1310503bf --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg new file mode 100644 index 000000000..e3f2f1436 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg b/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg new file mode 100644 index 000000000..a995328db --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg b/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg new file mode 100644 index 000000000..e5cf16ac0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg b/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg new file mode 100644 index 000000000..6b0be4d0d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/clock.svg b/src/net/sourceforge/plantuml/openiconic/data/clock.svg new file mode 100644 index 000000000..4d198bc25 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/clock.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg new file mode 100644 index 000000000..d6158cb0e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg new file mode 100644 index 000000000..6d3697f73 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud.svg new file mode 100644 index 000000000..01c3d549b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cloud.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg b/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg new file mode 100644 index 000000000..1595b2832 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/code.svg b/src/net/sourceforge/plantuml/openiconic/data/code.svg new file mode 100644 index 000000000..96d9bf454 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/code.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/cog.svg b/src/net/sourceforge/plantuml/openiconic/data/cog.svg new file mode 100644 index 000000000..6f4974183 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/cog.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg new file mode 100644 index 000000000..47a37c575 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg new file mode 100644 index 000000000..31ef1d68a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg new file mode 100644 index 000000000..6f104f665 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg new file mode 100644 index 000000000..6693e1ee4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/command.svg b/src/net/sourceforge/plantuml/openiconic/data/command.svg new file mode 100644 index 000000000..ae05df67f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/command.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg b/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg new file mode 100644 index 000000000..f04e55d6a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/compass.svg b/src/net/sourceforge/plantuml/openiconic/data/compass.svg new file mode 100644 index 000000000..488b37527 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/compass.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/contrast.svg b/src/net/sourceforge/plantuml/openiconic/data/contrast.svg new file mode 100644 index 000000000..126505dd7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/contrast.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg b/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg new file mode 100644 index 000000000..f1e7ddd1a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg b/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg new file mode 100644 index 000000000..aa9889bce --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/crop.svg b/src/net/sourceforge/plantuml/openiconic/data/crop.svg new file mode 100644 index 000000000..8a7f1eb71 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/crop.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg b/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg new file mode 100644 index 000000000..484c41afb --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg new file mode 100644 index 000000000..9f14f33d9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg new file mode 100644 index 000000000..5fb17fa58 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/delete.svg b/src/net/sourceforge/plantuml/openiconic/data/delete.svg new file mode 100644 index 000000000..f11bdcee3 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/delete.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/dial.svg b/src/net/sourceforge/plantuml/openiconic/data/dial.svg new file mode 100644 index 000000000..29930dae8 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/dial.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/document.svg b/src/net/sourceforge/plantuml/openiconic/data/document.svg new file mode 100644 index 000000000..8e2ba053d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/document.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/dollar.svg b/src/net/sourceforge/plantuml/openiconic/data/dollar.svg new file mode 100644 index 000000000..b0218adc4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/dollar.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg new file mode 100644 index 000000000..0a7a62689 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg new file mode 100644 index 000000000..49a8f3999 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg new file mode 100644 index 000000000..92181bf66 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg new file mode 100644 index 000000000..c7044318d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/droplet.svg b/src/net/sourceforge/plantuml/openiconic/data/droplet.svg new file mode 100644 index 000000000..80e7baf2e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/droplet.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/eject.svg b/src/net/sourceforge/plantuml/openiconic/data/eject.svg new file mode 100644 index 000000000..f7ff1021b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/eject.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/elevator.svg b/src/net/sourceforge/plantuml/openiconic/data/elevator.svg new file mode 100644 index 000000000..639e1ffb5 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/elevator.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg b/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg new file mode 100644 index 000000000..22f75f7e5 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg b/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg new file mode 100644 index 000000000..c0cf2658f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg b/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg new file mode 100644 index 000000000..659390e91 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/euro.svg b/src/net/sourceforge/plantuml/openiconic/data/euro.svg new file mode 100644 index 000000000..854aa4de9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/euro.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg b/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg new file mode 100644 index 000000000..e83a3ee32 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg new file mode 100644 index 000000000..b1d8ed054 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg new file mode 100644 index 000000000..380eae261 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg new file mode 100644 index 000000000..a75dadbf9 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg new file mode 100644 index 000000000..36c397319 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/external-link.svg b/src/net/sourceforge/plantuml/openiconic/data/external-link.svg new file mode 100644 index 000000000..6fdc00c61 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/external-link.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/eye.svg b/src/net/sourceforge/plantuml/openiconic/data/eye.svg new file mode 100644 index 000000000..c68604c24 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/eye.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg b/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg new file mode 100644 index 000000000..600fdbcca --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/file.svg b/src/net/sourceforge/plantuml/openiconic/data/file.svg new file mode 100644 index 000000000..145853d02 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/file.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/fire.svg b/src/net/sourceforge/plantuml/openiconic/data/fire.svg new file mode 100644 index 000000000..9d33359f4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/fire.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/flag.svg b/src/net/sourceforge/plantuml/openiconic/data/flag.svg new file mode 100644 index 000000000..f2fde233a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/flag.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/flash.svg b/src/net/sourceforge/plantuml/openiconic/data/flash.svg new file mode 100644 index 000000000..18f7fc3c8 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/flash.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/folder.svg b/src/net/sourceforge/plantuml/openiconic/data/folder.svg new file mode 100644 index 000000000..ef47dd612 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/folder.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/fork.svg b/src/net/sourceforge/plantuml/openiconic/data/fork.svg new file mode 100644 index 000000000..f494192de --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/fork.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg new file mode 100644 index 000000000..4efb89095 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg new file mode 100644 index 000000000..c57d8ad72 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/globe.svg b/src/net/sourceforge/plantuml/openiconic/data/globe.svg new file mode 100644 index 000000000..296c6498b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/globe.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/graph.svg b/src/net/sourceforge/plantuml/openiconic/data/graph.svg new file mode 100644 index 000000000..8db4da094 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/graph.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg new file mode 100644 index 000000000..bdcc178c4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg new file mode 100644 index 000000000..2a929a068 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg new file mode 100644 index 000000000..71503ba48 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg b/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg new file mode 100644 index 000000000..af63461f2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/header.svg b/src/net/sourceforge/plantuml/openiconic/data/header.svg new file mode 100644 index 000000000..e794cc453 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/header.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/headphones.svg b/src/net/sourceforge/plantuml/openiconic/data/headphones.svg new file mode 100644 index 000000000..fc44be966 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/headphones.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/heart.svg b/src/net/sourceforge/plantuml/openiconic/data/heart.svg new file mode 100644 index 000000000..7c060cf23 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/heart.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/home.svg b/src/net/sourceforge/plantuml/openiconic/data/home.svg new file mode 100644 index 000000000..e6cc83a2e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/home.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/image.svg b/src/net/sourceforge/plantuml/openiconic/data/image.svg new file mode 100644 index 000000000..fa9a105f3 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/image.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/inbox.svg b/src/net/sourceforge/plantuml/openiconic/data/inbox.svg new file mode 100644 index 000000000..72797fd77 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/inbox.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/infinity.svg b/src/net/sourceforge/plantuml/openiconic/data/infinity.svg new file mode 100644 index 000000000..5820ca531 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/infinity.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/info.svg b/src/net/sourceforge/plantuml/openiconic/data/info.svg new file mode 100644 index 000000000..6927b2452 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/info.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/italic.svg b/src/net/sourceforge/plantuml/openiconic/data/italic.svg new file mode 100644 index 000000000..381c08fc4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/italic.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg new file mode 100644 index 000000000..544162cd1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg new file mode 100644 index 000000000..e5787c325 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg new file mode 100644 index 000000000..2e8c6fdc6 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/key.svg b/src/net/sourceforge/plantuml/openiconic/data/key.svg new file mode 100644 index 000000000..d870d61f7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/key.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/laptop.svg b/src/net/sourceforge/plantuml/openiconic/data/laptop.svg new file mode 100644 index 000000000..1de7a54cc --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/laptop.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/layers.svg b/src/net/sourceforge/plantuml/openiconic/data/layers.svg new file mode 100644 index 000000000..564c4ae12 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/layers.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg b/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg new file mode 100644 index 000000000..9ae5b0b0f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg b/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg new file mode 100644 index 000000000..e1a933ac4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg b/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg new file mode 100644 index 000000000..1076eec06 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg b/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg new file mode 100644 index 000000000..cf816d13f --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/list.svg b/src/net/sourceforge/plantuml/openiconic/data/list.svg new file mode 100644 index 000000000..241e5e0ac --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/list.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/location.svg b/src/net/sourceforge/plantuml/openiconic/data/location.svg new file mode 100644 index 000000000..9fa01f239 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/location.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg b/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg new file mode 100644 index 000000000..5306dc97d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg b/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg new file mode 100644 index 000000000..5ee3b20a2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg b/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg new file mode 100644 index 000000000..fd720b981 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg b/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg new file mode 100644 index 000000000..e052f4037 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop.svg b/src/net/sourceforge/plantuml/openiconic/data/loop.svg new file mode 100644 index 000000000..48f897592 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/loop.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg b/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg new file mode 100644 index 000000000..387f47711 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg b/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg new file mode 100644 index 000000000..36841a391 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/map.svg b/src/net/sourceforge/plantuml/openiconic/data/map.svg new file mode 100644 index 000000000..8c868c1a7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/map.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg b/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg new file mode 100644 index 000000000..3b1bad800 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-play.svg b/src/net/sourceforge/plantuml/openiconic/data/media-play.svg new file mode 100644 index 000000000..7c4516d4e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-play.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-record.svg b/src/net/sourceforge/plantuml/openiconic/data/media-record.svg new file mode 100644 index 000000000..a52bee35b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-record.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg new file mode 100644 index 000000000..e4feb43ce --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg new file mode 100644 index 000000000..a7e7c10cd --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg new file mode 100644 index 000000000..2fc461b3d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg new file mode 100644 index 000000000..ade1440b0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg b/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg new file mode 100644 index 000000000..e9df2f0a4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg b/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg new file mode 100644 index 000000000..71028f9f6 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/menu.svg b/src/net/sourceforge/plantuml/openiconic/data/menu.svg new file mode 100644 index 000000000..a96555dc0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/menu.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/microphone.svg b/src/net/sourceforge/plantuml/openiconic/data/microphone.svg new file mode 100644 index 000000000..711e54674 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/microphone.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/minus.svg b/src/net/sourceforge/plantuml/openiconic/data/minus.svg new file mode 100644 index 000000000..83aa20868 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/minus.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/monitor.svg b/src/net/sourceforge/plantuml/openiconic/data/monitor.svg new file mode 100644 index 000000000..e4460cd0d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/monitor.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/moon.svg b/src/net/sourceforge/plantuml/openiconic/data/moon.svg new file mode 100644 index 000000000..37408d19d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/moon.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/move.svg b/src/net/sourceforge/plantuml/openiconic/data/move.svg new file mode 100644 index 000000000..4674db8d6 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/move.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg b/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg new file mode 100644 index 000000000..9bbd65a3b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg b/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg new file mode 100644 index 000000000..528f14f40 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/pencil.svg b/src/net/sourceforge/plantuml/openiconic/data/pencil.svg new file mode 100644 index 000000000..8109530e4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/pencil.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/people.svg b/src/net/sourceforge/plantuml/openiconic/data/people.svg new file mode 100644 index 000000000..2befc6bb3 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/people.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/person.svg b/src/net/sourceforge/plantuml/openiconic/data/person.svg new file mode 100644 index 000000000..0ce80f504 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/person.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/phone.svg b/src/net/sourceforge/plantuml/openiconic/data/phone.svg new file mode 100644 index 000000000..9c8cc0645 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/phone.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg b/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg new file mode 100644 index 000000000..7ac7577dd --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/pin.svg b/src/net/sourceforge/plantuml/openiconic/data/pin.svg new file mode 100644 index 000000000..2810c4632 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/pin.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg b/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg new file mode 100644 index 000000000..d668d5258 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/plus.svg b/src/net/sourceforge/plantuml/openiconic/data/plus.svg new file mode 100644 index 000000000..74aea49cf --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/plus.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg b/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg new file mode 100644 index 000000000..bbbd6c9b1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/print.svg b/src/net/sourceforge/plantuml/openiconic/data/print.svg new file mode 100644 index 000000000..f48d866b4 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/print.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/project.svg b/src/net/sourceforge/plantuml/openiconic/data/project.svg new file mode 100644 index 000000000..e8e91544d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/project.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/pulse.svg b/src/net/sourceforge/plantuml/openiconic/data/pulse.svg new file mode 100644 index 000000000..eb521c4de --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/pulse.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg b/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg new file mode 100644 index 000000000..f752fbbb5 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg b/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg new file mode 100644 index 000000000..7e1c76a0c --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/rain.svg b/src/net/sourceforge/plantuml/openiconic/data/rain.svg new file mode 100644 index 000000000..d9ff4ea70 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/rain.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/random.svg b/src/net/sourceforge/plantuml/openiconic/data/random.svg new file mode 100644 index 000000000..6cafaaee0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/random.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/reload.svg b/src/net/sourceforge/plantuml/openiconic/data/reload.svg new file mode 100644 index 000000000..8cb8492cc --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/reload.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg new file mode 100644 index 000000000..26f564a14 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg new file mode 100644 index 000000000..1b104fbab --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg new file mode 100644 index 000000000..cf7e7b13d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg b/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg new file mode 100644 index 000000000..67d4f85ae --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/rss.svg b/src/net/sourceforge/plantuml/openiconic/data/rss.svg new file mode 100644 index 000000000..a25f93903 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/rss.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/script.svg b/src/net/sourceforge/plantuml/openiconic/data/script.svg new file mode 100644 index 000000000..14b7ff859 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/script.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg b/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg new file mode 100644 index 000000000..dd8524fc0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/share.svg b/src/net/sourceforge/plantuml/openiconic/data/share.svg new file mode 100644 index 000000000..6dbf37c64 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/share.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/shield.svg b/src/net/sourceforge/plantuml/openiconic/data/shield.svg new file mode 100644 index 000000000..4adddf735 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/shield.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/signal.svg b/src/net/sourceforge/plantuml/openiconic/data/signal.svg new file mode 100644 index 000000000..14137f4a7 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/signal.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/signpost.svg b/src/net/sourceforge/plantuml/openiconic/data/signpost.svg new file mode 100644 index 000000000..965e95a0d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/signpost.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg b/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg new file mode 100644 index 000000000..bb8d497d2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg b/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg new file mode 100644 index 000000000..6af734901 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg b/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg new file mode 100644 index 000000000..bd52d5fa2 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/star.svg b/src/net/sourceforge/plantuml/openiconic/data/star.svg new file mode 100644 index 000000000..ab716a058 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/star.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/sun.svg b/src/net/sourceforge/plantuml/openiconic/data/sun.svg new file mode 100644 index 000000000..cc9082018 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/sun.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/tablet.svg b/src/net/sourceforge/plantuml/openiconic/data/tablet.svg new file mode 100644 index 000000000..14cca495c --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/tablet.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/tag.svg b/src/net/sourceforge/plantuml/openiconic/data/tag.svg new file mode 100644 index 000000000..b9efc2b14 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/tag.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/tags.svg b/src/net/sourceforge/plantuml/openiconic/data/tags.svg new file mode 100644 index 000000000..2f5792542 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/tags.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/target.svg b/src/net/sourceforge/plantuml/openiconic/data/target.svg new file mode 100644 index 000000000..180fee9bc --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/target.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/task.svg b/src/net/sourceforge/plantuml/openiconic/data/task.svg new file mode 100644 index 000000000..4dbb20eca --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/task.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/terminal.svg b/src/net/sourceforge/plantuml/openiconic/data/terminal.svg new file mode 100644 index 000000000..9d67ed370 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/terminal.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/text.svg b/src/net/sourceforge/plantuml/openiconic/data/text.svg new file mode 100644 index 000000000..7a4ffb4c0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/text.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg b/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg new file mode 100644 index 000000000..17d65260b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg b/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg new file mode 100644 index 000000000..a274e2196 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/timer.svg b/src/net/sourceforge/plantuml/openiconic/data/timer.svg new file mode 100644 index 000000000..0ced8ea11 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/timer.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/transfer.svg b/src/net/sourceforge/plantuml/openiconic/data/transfer.svg new file mode 100644 index 000000000..39ace350b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/transfer.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/trash.svg b/src/net/sourceforge/plantuml/openiconic/data/trash.svg new file mode 100644 index 000000000..f15725447 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/trash.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/underline.svg b/src/net/sourceforge/plantuml/openiconic/data/underline.svg new file mode 100644 index 000000000..a6f80735b --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/underline.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg new file mode 100644 index 000000000..9c21f6749 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg new file mode 100644 index 000000000..1827b909e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg new file mode 100644 index 000000000..4bac91343 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/video.svg b/src/net/sourceforge/plantuml/openiconic/data/video.svg new file mode 100644 index 000000000..8e516dd48 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/video.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg new file mode 100644 index 000000000..4786581d1 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg new file mode 100644 index 000000000..a08992b23 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg new file mode 100644 index 000000000..5b2d17243 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/warning.svg b/src/net/sourceforge/plantuml/openiconic/data/warning.svg new file mode 100644 index 000000000..9eca3d9e0 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/warning.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/wifi.svg b/src/net/sourceforge/plantuml/openiconic/data/wifi.svg new file mode 100644 index 000000000..cee1ea60c --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/wifi.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/wrench.svg b/src/net/sourceforge/plantuml/openiconic/data/wrench.svg new file mode 100644 index 000000000..3d91c7060 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/wrench.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/x.svg b/src/net/sourceforge/plantuml/openiconic/data/x.svg new file mode 100644 index 000000000..4c1b5058e --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/x.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/yen.svg b/src/net/sourceforge/plantuml/openiconic/data/yen.svg new file mode 100644 index 000000000..a79cd6c0d --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/yen.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg b/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg new file mode 100644 index 000000000..61b7648b6 --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg b/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg new file mode 100644 index 000000000..89d6c4c3a --- /dev/null +++ b/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java b/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java new file mode 100644 index 000000000..ebe0260b9 --- /dev/null +++ b/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java @@ -0,0 +1,68 @@ +/* ======================================================================== + * 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.preproc; + +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +class ReadLineInsertable implements ReadLine { + + private final ReadLine source; + private final List inserted = new LinkedList(); + + public ReadLineInsertable(ReadLine source) { + this.source = source; + } + + public void close() throws IOException { + source.close(); + } + + public String readLine() throws IOException { + if (inserted.size() > 0) { + final Iterator it = inserted.iterator(); + final String result = it.next(); + it.remove(); + return result; + } + return source.readLine(); + } + + public void insert(List data) { + inserted.addAll(data); + } + +} diff --git a/src/net/sourceforge/plantuml/real/PositiveForce.java b/src/net/sourceforge/plantuml/real/PositiveForce.java new file mode 100644 index 000000000..795115e38 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/PositiveForce.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +class PositiveForce { + + private final Real fixedPoint; + private final RealMoveable movingPoint; + private final double minimunDistance; + + public PositiveForce(Real fixedPoint, RealMoveable movingPoint, double minimunDistance) { + if (fixedPoint == movingPoint) { + throw new IllegalArgumentException(); + } + this.fixedPoint = fixedPoint; + this.movingPoint = movingPoint; + this.minimunDistance = minimunDistance; + } + + @Override + public String toString() { + return "PositiveForce fixed=" + fixedPoint + " moving=" + movingPoint + " min=" + minimunDistance; + } + + public boolean apply() { + final double distance = movingPoint.getCurrentValue() - fixedPoint.getCurrentValue(); + final double diff = distance - minimunDistance; + if (diff >= 0) { + return false; + } + // System.err.println("moving " + (-diff) + " " + movingPoint); + movingPoint.move(-diff); + return true; + } + +} diff --git a/src/net/sourceforge/plantuml/real/Real.java b/src/net/sourceforge/plantuml/real/Real.java new file mode 100644 index 000000000..e9db15aa8 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/Real.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +public interface Real { + + public String getName(); + + public double getCurrentValue(); + + public Real addFixed(double delta); + + public Real addAtLeast(double delta); + + public void ensureBiggerThan(Real other); + + public void compile(); + +} diff --git a/src/net/sourceforge/plantuml/real/RealDelta.java b/src/net/sourceforge/plantuml/real/RealDelta.java new file mode 100644 index 000000000..a675226a7 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealDelta.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +class RealDelta extends RealMoveable { + + private final Real delegated; + private final double diff; + + RealDelta(Real delegated, double diff) { + super("[Delegated {" + delegated.getName() + "} d=" + diff + "]"); + this.delegated = delegated; + this.diff = diff; + } + + public double getCurrentValue() { + return delegated.getCurrentValue() + diff; + } + + public Real addAtLeast(double delta) { + return new RealDelta(delegated.addAtLeast(delta), diff); + } + + public void ensureBiggerThan(Real other) { + delegated.ensureBiggerThan(new RealDelta(other, -diff)); + + } + + public void compile() { + delegated.compile(); + } + + void move(double delta) { + ((RealMoveable) delegated).move(delta); + } + + RealLine getLine() { + return ((RealMoveable) delegated).getLine(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealImpl.java b/src/net/sourceforge/plantuml/real/RealImpl.java new file mode 100644 index 000000000..a8acbebd7 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealImpl.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +class RealImpl extends RealMoveable { + + private final RealLine line; + private double currentValue; + + public RealImpl(String name, RealLine line, double currentValue) { + super(name); + this.line = line; + this.currentValue = currentValue; + } + + void move(double delta) { + this.currentValue += delta; + } + + public double getCurrentValue() { + return currentValue; + } + + public Real addAtLeast(double delta) { + final RealImpl result = new RealImpl(getName() + ".addAtLeast" + delta, line, this.currentValue + delta); + line.addForce(new PositiveForce(this, result, delta)); + return result; + } + + public void ensureBiggerThan(Real other) { + line.addForce(new PositiveForce(other, this, 0)); + } + + public void compile() { + line.compile(); + } + + RealLine getLine() { + return line; + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealLine.java b/src/net/sourceforge/plantuml/real/RealLine.java new file mode 100644 index 000000000..88c45a236 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealLine.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +import java.util.ArrayList; +import java.util.List; + +class RealLine { + + private final List forces = new ArrayList(); + + public void addForce(PositiveForce force) { + this.forces.add(force); + } + + static private int CPT; + + public void compile() { + int cpt = 0; + do { + boolean done = true; + for (PositiveForce f : forces) { + // System.err.println("force=" + f); + final boolean change = f.apply(); + if (change) { + // System.err.println("changed! " + f); + done = false; + } + } + if (done) { + // System.err.println("cpt=" + cpt + " size=" + forces.size()); + CPT += cpt; + // System.err.println("CPT=" + CPT); + return; + } + cpt++; + if (cpt > 99999) { + throw new IllegalStateException("Inifinite Loop?"); + } + } while (true); + + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMax.java b/src/net/sourceforge/plantuml/real/RealMax.java new file mode 100644 index 000000000..0a39bde43 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealMax.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +import java.util.ArrayList; +import java.util.List; + +public class RealMax implements Real { + + private final List all = new ArrayList(); + + public void put(Real real) { + if (real == null) { + throw new IllegalArgumentException(); + } + if (real == this) { + return; + } + all.add(real); + } + + public String getName() { + return "max " + all; + } + + public double getCurrentValue() { + double result = all.get(0).getCurrentValue(); + for (int i = 1; i < all.size(); i++) { + final double v = all.get(i).getCurrentValue(); + if (v > result) { + result = v; + } + } + return result; + } + + public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + all.add(other); + } + + public void compile() { + all.get(0).compile(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMiddle.java b/src/net/sourceforge/plantuml/real/RealMiddle.java new file mode 100644 index 000000000..5e5941d6b --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealMiddle.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +class RealMiddle implements Real { + + private final RealMoveable p1; + private final RealMoveable p2; + private final double delta; + + private RealMiddle(RealMoveable p1, RealMoveable p2, double delta) { + this.p1 = p1; + this.p2 = p2; + this.delta = delta; + } + + RealMiddle(RealMoveable p1, RealMoveable p2) { + this(p1, p2, 0); + } + + public double getCurrentValue() { + return (p1.getCurrentValue() + p2.getCurrentValue()) / 2 + delta; + } + + public Real addFixed(double diff) { + return new RealMiddle(p1, p2, delta + diff); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + throw new UnsupportedOperationException(); + } + + public void compile() { + p1.compile(); + } + + public String getName() { + return "[Middle " + p1.getName() + " and " + p2.getName() + "]"; + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMin.java b/src/net/sourceforge/plantuml/real/RealMin.java new file mode 100644 index 000000000..3e1b77f33 --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealMin.java @@ -0,0 +1,88 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +import java.util.ArrayList; +import java.util.List; + +public class RealMin implements Real { + + private final List all = new ArrayList(); + + public void put(Real real) { + if (real == null) { + throw new IllegalArgumentException(); + } + if (real == this) { + return; + } + all.add(real); + } + + public String getName() { + return "min " + all; + } + + public double getCurrentValue() { + double result = all.get(0).getCurrentValue(); + for (int i = 1; i < all.size(); i++) { + final double v = all.get(i).getCurrentValue(); + if (v < result) { + result = v; + } + } + return result; + } + + public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + throw new UnsupportedOperationException(); + } + + public void compile() { + all.get(0).compile(); + } + + public int size() { + return all.size(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMoveable.java b/src/net/sourceforge/plantuml/real/RealMoveable.java new file mode 100644 index 000000000..7c8a0613e --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealMoveable.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +abstract class RealMoveable implements Real { + + private final String name; + + RealMoveable(String name) { + this.name = name; + } + + abstract void move(double delta); + + abstract RealLine getLine(); + + final public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + @Override + public String toString() { + return name; + } + + final public String getName() { + return name; + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealUtils.java b/src/net/sourceforge/plantuml/real/RealUtils.java new file mode 100644 index 000000000..51753221d --- /dev/null +++ b/src/net/sourceforge/plantuml/real/RealUtils.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: 4636 $ + * + */ +package net.sourceforge.plantuml.real; + +import java.util.List; + +public class RealUtils { + + public static Real createOrigin() { + final RealLine line = new RealLine(); + final RealImpl result = new RealImpl("O", line, 0); + return result; + } + + public static Real middle(Real r1, Real r2) { + return new RealMiddle((RealMoveable) r1, (RealMoveable) r2); + } + + // public static Real max(List all) { + // return new RealMax(all); + // } + // + // public static Real min(List all) { + // return new RealMin(all); + // } + +} diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElement.java b/src/net/sourceforge/plantuml/salt/element/AbstractElement.java new file mode 100644 index 000000000..bd89cfc3e --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/element/AbstractElement.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: 3835 $ + * + */ +package net.sourceforge.plantuml.salt.element; + +public abstract class AbstractElement implements Element { + +} diff --git a/src/net/sourceforge/plantuml/salt/element/Grid2.java b/src/net/sourceforge/plantuml/salt/element/Grid2.java new file mode 100644 index 000000000..a8d64a560 --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/element/Grid2.java @@ -0,0 +1,91 @@ +/* ======================================================================== + * 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: 3835 $ + * + */ +package net.sourceforge.plantuml.salt.element; + +import java.util.List; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class Grid2 { + + private final List rowsStart; + private final List colsStart; + private final TableStrategy strategy; + + public Grid2(List rowsStart, List colsStart, TableStrategy strategy) { + this.rowsStart = rowsStart; + this.colsStart = colsStart; + this.strategy = strategy; + } + + public void drawU(UGraphic ug) { + final double xmin = colsStart.get(0); + final double xmax = colsStart.get(colsStart.size() - 1); + final double ymin = rowsStart.get(0); + final double ymax = rowsStart.get(rowsStart.size() - 1); + if (strategy == TableStrategy.DRAW_OUTSIDE) { + ug.apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, 0)); + ug.apply(new UTranslate(xmin, ymax)).draw(new ULine(xmax - xmin, 0)); + ug.apply(new UTranslate(xmin, ymin)).draw(new ULine(0, ymax - ymin)); + ug.apply(new UTranslate(xmax, ymin)).draw(new ULine(0, ymax - ymin)); + } + if (drawHorizontal()) { + for (Double y : rowsStart) { + ug.apply(new UTranslate(xmin, y)).draw(new ULine(xmax - xmin, 0)); + } + } + if (drawVertical()) { + for (Double x : colsStart) { + ug.apply(new UTranslate(x, ymin)).draw(new ULine(0, ymax - ymin)); + } + } + } + + private boolean drawHorizontal() { + if (strategy == TableStrategy.DRAW_HORIZONTAL || strategy == TableStrategy.DRAW_ALL) { + return true; + } + return false; + } + + private boolean drawVertical() { + if (strategy == TableStrategy.DRAW_VERTICAL || strategy == TableStrategy.DRAW_ALL) { + return true; + } + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/salt/element/ListWidth.java b/src/net/sourceforge/plantuml/salt/element/ListWidth.java new file mode 100644 index 000000000..94da61def --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/element/ListWidth.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: 3835 $ + * + */ +package net.sourceforge.plantuml.salt.element; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class ListWidth { + + private final List allWidth = new ArrayList(); + + public void add(double width) { + this.allWidth.add(width); + } + + public ListWidth mergeMax(ListWidth other) { + final ListWidth result = new ListWidth(); + for (int i = 0; i < this.allWidth.size() || i < other.allWidth.size(); i++) { + final double w1 = this.getWidthSafe(i); + final double w2 = other.getWidthSafe(i); + result.add(Math.max(w1, w2)); + } + return result; + } + + private double getWidthSafe(int i) { + if (i < allWidth.size()) { + return allWidth.get(i); + } + return 0; + } + + public double getTotalWidthWithMargin(final double margin) { + double result = 0; + for (Double w : allWidth) { + if (result > 0) { + result += margin; + } + result += w; + } + return result; + } + + public Iterator iterator() { + return allWidth.iterator(); + } + +} diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java new file mode 100644 index 000000000..3de264e4b --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java @@ -0,0 +1,95 @@ +/* ======================================================================== + * 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: 3835 $ + * + */ +package net.sourceforge.plantuml.salt.factory; + +import net.sourceforge.plantuml.salt.DataSource; +import net.sourceforge.plantuml.salt.Dictionary; +import net.sourceforge.plantuml.salt.Positionner2; +import net.sourceforge.plantuml.salt.Terminated; +import net.sourceforge.plantuml.salt.element.Element; +import net.sourceforge.plantuml.salt.element.ElementPyramid; +import net.sourceforge.plantuml.salt.element.ElementText; +import net.sourceforge.plantuml.salt.element.TableStrategy; + +public class ElementFactoryPyramid extends AbstractElementFactoryComplex { + + public ElementFactoryPyramid(DataSource dataSource, Dictionary dictionary) { + super(dataSource, dictionary); + } + + public Terminated create() { + if (ready() == false) { + throw new IllegalStateException(); + } + final String header = getDataSource().next().getElement(); + assert header.startsWith("{"); + + TableStrategy strategy = TableStrategy.DRAW_NONE; + if (header.length() == 2) { + strategy = TableStrategy.fromChar(header.charAt(1)); + } + + final Positionner2 positionner = new Positionner2(); + + while (getDataSource().peek(0).getElement().equals("}") == false) { + final Terminated next = getNextElement(); + if (isStar(next.getElement())) { + positionner.mergeLeft(next.getTerminator()); + } else { + positionner.add(next); + } + } + final Terminated next = getDataSource().next(); + return new Terminated(new ElementPyramid(positionner, strategy), next.getTerminator()); + } + + private boolean isStar(Element element) { + if (element instanceof ElementText == false) { + return false; + } + return "*".equals(((ElementText) element).getText()); + } + + public boolean ready() { + final String text = getDataSource().peek(0).getElement(); + if (text.equals("{") || text.equals("{+") || text.equals("{#") || text.equals("{!") || text.equals("{-")) { + final String text1 = getDataSource().peek(1).getElement(); + if (text1.matches("[NSEW]=|T")) { + return false; + } + return true; + } + return false; + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java new file mode 100644 index 000000000..fae8b23a1 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.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: 12235 $ + * + */ +package net.sourceforge.plantuml.sequencediagram; + +import net.sourceforge.plantuml.Url; + +public abstract class AbstractEvent implements Event { + + public boolean isParallel() { + return false; + } + + public Url getUrl() { + return null; + } + + public boolean hasUrl() { + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java new file mode 100644 index 000000000..9b9db34b5 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram; + +public interface EventWithDeactivate extends Event { + + public void setPosYendLevel(double posYendLevel); + + public double getPosYendLevel(); + + public boolean addLifeEvent(LifeEvent lifeEvent); + + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java new file mode 100644 index 000000000..9b29b1e6f --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.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: 12235 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.graphic; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class GraphicalElementLiveEvent extends GraphicalElement { + + public GraphicalElementLiveEvent(double startingY) { + super(startingY); + } + + protected void drawInternalU(UGraphic ug, double maxX, Context2D context) { + } + + public double getStartingX(StringBounder stringBounder) { + return 0; + } + + public double getPreferredWidth(StringBounder stringBounder) { + return 0; + } + + public double getPreferredHeight(StringBounder stringBounder) { + return 0; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java new file mode 100644 index 000000000..1858177d2 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -0,0 +1,313 @@ +/* ======================================================================== + * 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: 9591 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.graphic; + +import java.awt.geom.Dimension2D; +import java.io.IOException; +import java.io.OutputStream; +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.FileFormatOption; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.cucadiagram.Display; +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.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.VerticalAlignment; +import net.sourceforge.plantuml.png.PngTitler; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Newpage; +import net.sourceforge.plantuml.sequencediagram.Participant; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class SequenceDiagramFileMakerPuma2 implements FileMaker { + + private static final StringBounder dummyStringBounder = TextBlockUtils.getDummyStringBounder(); + + private final SequenceDiagram diagram; + private final DrawableSet drawableSet; + private final Dimension2D fullDimension; + private final List pages; + private final FileFormatOption fileFormatOption; + + private double scale; + + public SequenceDiagramFileMakerPuma2(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) { + this.diagram = sequenceDiagram; + this.fileFormatOption = fileFormatOption; + final DrawableSetInitializer initializer = new DrawableSetInitializer(skin, sequenceDiagram.getSkinParam(), + sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage()); + + for (Participant p : sequenceDiagram.participants().values()) { + initializer.addParticipant(p, sequenceDiagram.getEnglober(p)); + } + + for (Event ev : sequenceDiagram.events()) { + initializer.addEvent(ev); + // if (ev instanceof Message) { + // // TODO mieux faire + // final Message m = (Message) ev; + // for (LifeEvent lifeEvent : m.getLiveEvents()) { + // if (lifeEvent.getType() == LifeEventType.DESTROY + // /* + // * || lifeEvent.getType() == LifeEventType.CREATE + // */) { + // initializer.addEvent(lifeEvent); + // } + // } + // } + } + drawableSet = initializer.createDrawableSet(dummyStringBounder); + final List newpages = new ArrayList(); + for (Event ev : drawableSet.getAllEvents()) { + if (ev instanceof Newpage) { + newpages.add((Newpage) ev); + } + } + fullDimension = drawableSet.getDimension(); + final Map positions = new LinkedHashMap(); + for (Newpage n : newpages) { + positions.put(n, initializer.getYposition(dummyStringBounder, n)); + } + pages = create(drawableSet, positions, sequenceDiagram.isShowFootbox(), sequenceDiagram.getTitle()).getPages(); + } + + public int getNbPages() { + return pages.size(); + } + + private PageSplitter create(DrawableSet drawableSet, Map positions, boolean showFootbox, + Display title) { + + final double headerHeight = drawableSet.getHeadHeight(dummyStringBounder); + final double tailHeight = drawableSet.getTailHeight(dummyStringBounder, showFootbox); + final double signatureHeight = 0; + final double newpageHeight = drawableSet.getSkin() + .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), Display.create("")) + .getPreferredHeight(dummyStringBounder); + + return new PageSplitter(fullDimension.getHeight(), headerHeight, positions, tailHeight, signatureHeight, + newpageHeight, title); + } + + public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException { + + final Page page = pages.get(index); + final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), page.getHeight()); + + final Component compTitle; + if (page.getTitle() == null) { + compTitle = null; + } else { + compTitle = drawableSet.getSkin().createComponent(ComponentType.TITLE, null, drawableSet.getSkinParam(), + page.getTitle()); + area.setTitleArea(compTitle.getPreferredWidth(dummyStringBounder), + compTitle.getPreferredHeight(dummyStringBounder)); + } + addFooter2(area); + addHeader2(area); + + // final FileFormat fileFormat = fileFormatOption.getFileFormat(); + + final Display legend = diagram.getLegend(); + final TextBlock legendBlock; + if (legend == null) { + legendBlock = TextBlockUtils.empty(0, 0); + } else { + legendBlock = EntityImageLegend.create(legend, diagram.getSkinParam()); + } + final Dimension2D dimLegend = TextBlockUtils.getDimension(legendBlock); + + scale = getScale(area.getWidth(), area.getHeight()); + + final double dpiFactor = diagram.getDpiFactor(fileFormatOption); + // System.err.println("dpiFactor=" + dpiFactor); + // System.err.println("scale=" + scale); + + final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), oneOf(scale, + dpiFactor), diagram.getSkinParam().getBackgroundColor(), null, null, 3, 10, diagram.getAnimation(), diagram.getSkinParam().handwritten()); + + imageBuilder.addUDrawable(new UDrawable() { + public void drawU(UGraphic ug) { + + double delta = 0; + if (index > 0) { + delta = page.getNewpage1() - page.getHeaderHeight(); + } + if (delta < 0) { + delta = 0; + } + + double legendYdelta = 0; + if (compTitle != null) { + final StringBounder stringBounder = ug.getStringBounder(); + final double h = compTitle.getPreferredHeight(stringBounder); + legendYdelta += h; + final double w = compTitle.getPreferredWidth(stringBounder); + compTitle.drawU(ug.apply(new UTranslate(area.getTitleX(), area.getTitleY())), new Area( + new Dimension2DDouble(w, h)), new SimpleContext2D(false)); + } + + final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth()); + + final boolean legendTop = legend != null + && diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP; + + double sequenceAreaY = area.getSequenceAreaY(); + if (legendTop) { + sequenceAreaY += legendBlock.calculateDimension(ug.getStringBounder()).getHeight(); + } + drawableSet.drawU22(ug.apply(new UTranslate(area.getSequenceAreaX() + delta1 / 2, sequenceAreaY)), + delta, fullDimension.getWidth(), page, diagram.isShowFootbox()); + + addHeader3(area, ug); + addFooter3(area, ug); + + if (legend != null) { + final double delta2; + if (diagram.getLegendAlignment() == HorizontalAlignment.LEFT) { + delta2 = 0; + } else if (diagram.getLegendAlignment() == HorizontalAlignment.RIGHT) { + delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()); + } else { + delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()) / 2; + } + legendBlock.drawU(ug.apply(new UTranslate(delta2, legendTop ? legendYdelta : legendYdelta + + area.getHeight()))); + } + + } + }); + return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os); + } + + private double oneOf(double a, double b) { + if (a == 1) { + return b; + } + return a; + } + + private double getImageWidth(SequenceDiagramArea area, double dpiFactor, double legendWidth) { + final int minsize = diagram.getMinwidth(); + final double w = Math.max(area.getWidth() * getScale(area.getWidth(), area.getHeight()) * dpiFactor, + legendWidth); + if (minsize == Integer.MAX_VALUE) { + return w; + } + if (w >= minsize) { + return w; + } + return minsize; + } + + private double getScale(double width, double height) { + if (diagram.getScale() == null) { + return 1; + } + return diagram.getScale().getScale(width, height); + } + + private void addFooter2(SequenceDiagramArea area) { + final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); + final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null); + final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null); + final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize(); + final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily, + diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); + final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder); + if (dim != null) { + area.setFooterArea(dim.getWidth(), dim.getHeight(), 3); + } + } + + private void addHeader2(SequenceDiagramArea area) { + final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); + final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null); + final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null); + final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize(); + final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily, + diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); + final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder); + if (dim != null) { + area.setHeaderArea(dim.getWidth(), dim.getHeight(), 3); + } + } + + private void addFooter3(SequenceDiagramArea area, UGraphic ug) { + final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); + final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null); + final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null); + final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize(); + final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily, + diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); + final TextBlock text = pngTitler.getTextBlock(); + if (text == null) { + return; + } + text.drawU(ug.apply(new UTranslate(area.getFooterX(diagram.getFooterAlignment()), area.getFooterY()))); + } + + private void addHeader3(SequenceDiagramArea area, UGraphic ug) { + final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); + final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null); + final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null); + final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize(); + final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily, + diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); + final TextBlock text = pngTitler.getTextBlock(); + if (text == null) { + return; + } + text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeaderAlignment()), area.getHeaderY()))); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java new file mode 100644 index 000000000..141dea87a --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java @@ -0,0 +1,140 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.MessageExo; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationExoTile implements Tile { + + private final LivingSpace livingSpace; + private final MessageExo message; + private final Skin skin; + private final ISkinParam skinParam; + private final Real alpha; + private final Real omega; + + public Event getEvent() { + return message; + } + + + public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Skin skin, ISkinParam skinParam, + Real alpha, Real omega) { + this.livingSpace = livingSpace; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + this.alpha = alpha; + this.omega = omega; + } + + private Component getComponent(StringBounder stringBounder) { + ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); + if (message.getType().getDirection() == -1) { + arrowConfiguration = arrowConfiguration.reverse(); + } + final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam, + message.getLabel()); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double x1 = getPoint1(stringBounder).getCurrentValue(); + final double x2 = getPoint2(stringBounder).getCurrentValue(); + final Area area = new Area(x2 - x1, dim.getHeight()); + ug = ug.apply(new UTranslate(x1, 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double width = dim.getWidth(); + + final Real point1 = getPoint1(stringBounder); + final Real point2 = getPoint2(stringBounder); + if (point1.getCurrentValue() < point2.getCurrentValue()) { + point2.ensureBiggerThan(point1.addFixed(width)); + } else { + point1.ensureBiggerThan(point2.addFixed(width)); + } + } + + private Real getPoint1(final StringBounder stringBounder) { + if (message.getType().isRightBorder()) { + return livingSpace.getPosC(stringBounder); + } + return alpha; + } + + private Real getPoint2(final StringBounder stringBounder) { + if (message.getType().isRightBorder()) { + return omega; + } + return livingSpace.getPosC(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return getPoint1(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + return getPoint2(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java new file mode 100644 index 000000000..5603a01eb --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java @@ -0,0 +1,213 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.ArrowComponent; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationTile implements TileWithUpdateStairs { + + private final LivingSpace livingSpace1; + private final LivingSpace livingSpace2; + private final Message message; + private final Skin skin; + private final ISkinParam skinParam; + + public Event getEvent() { + return message; + } + + public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Skin skin, + ISkinParam skinParam) { + if (livingSpace1 == livingSpace2) { + throw new IllegalArgumentException(); + } + this.livingSpace1 = livingSpace1; + this.livingSpace2 = livingSpace2; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + // for (LifeEvent lifeEvent : message.getLiveEvents()) { + // System.err.println("lifeEvent = " + lifeEvent); + // // livingSpace1.addLifeEvent(this, lifeEvent); + // // livingSpace2.addLifeEvent(this, lifeEvent); + // } + } + + public boolean isReverse(StringBounder stringBounder) { + final Real point1 = livingSpace1.getPosC(stringBounder); + final Real point2 = livingSpace2.getPosC(stringBounder); + if (point1.getCurrentValue() > point2.getCurrentValue()) { + return true; + } + return false; + + } + + private Component getComponent(StringBounder stringBounder) { + ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); + /* + * if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else + */ + if (isReverse(stringBounder)) { + arrowConfiguration = arrowConfiguration.reverse(); + } + final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam, + message.getLabel()); + return comp; + } + + public static final double LIVE_DELTA_SIZE = 5; + + public void updateStairs(StringBounder stringBounder, double y) { + final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final Point2D p2 = comp.getEndPoint(stringBounder, dim); + // System.err.println("CommunicationTile::updateStairs y=" + y + " p1=" + p1 + " p2=" + p2 + " dim=" + dim); + final double arrowY = comp.getStartPoint(stringBounder, dim).getY(); + + livingSpace1.addStepForLivebox(getEvent(), y + arrowY); + livingSpace2.addStepForLivebox(getEvent(), y + arrowY); + + // System.err.println("CommunicationTile::updateStairs msg=" + message + " y=" + y + " arrowY=" + arrowY); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + double x1 = getPoint1(stringBounder).getCurrentValue(); + double x2 = getPoint2(stringBounder).getCurrentValue(); + + final int level1 = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE); + final int level2 = livingSpace2.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE); + // System.err.println("CommunicationTile::draw msg=" + message + " level1=" + level1 + " level2=" + level2); + + final Area area; + if (isReverse(stringBounder)) { + System.err.println("isreverse!"); + // x1 -= LIVE_DELTA_SIZE * level1; + x2 += LIVE_DELTA_SIZE * level2; + area = new Area(x1 - x2, dim.getHeight()); + ug = ug.apply(new UTranslate(x2, 0)); + } else { + x1 += LIVE_DELTA_SIZE * level1; + x2 -= LIVE_DELTA_SIZE * level2; + area = new Area(x2 - x1, dim.getHeight()); + ug = ug.apply(new UTranslate(x1, 0)); + } + comp.drawU(ug, area, (Context2D) ug); + // ug.draw(new ULine(x2 - x1, 0)); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double width = dim.getWidth(); + + // if (isSelf()) { + // final LivingSpace next = livingSpace1.getNext(); + // if (next != null) { + // next.getPosB().ensureBiggerThan(getMaxX(stringBounder)); + // } + // } else { + final Real point1 = getPoint1(stringBounder); + final Real point2 = getPoint2(stringBounder); + if (point1.getCurrentValue() < point2.getCurrentValue()) { + point2.ensureBiggerThan(point1.addFixed(width)); + } else { + point1.ensureBiggerThan(point2.addFixed(width)); + // } + } + } + + // private boolean isSelf() { + // return livingSpace1 == livingSpace2; + // } + + private Real getPoint1(final StringBounder stringBounder) { + return livingSpace1.getPosC(stringBounder); + } + + private Real getPoint2(final StringBounder stringBounder) { + if (message.isCreate()) { + if (isReverse(stringBounder)) { + return livingSpace2.getPosD(stringBounder); + } + return livingSpace2.getPosB(); + } + return livingSpace2.getPosC(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + if (isReverse(stringBounder)) { + return getPoint2(stringBounder); + } + return getPoint1(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + // if (isSelf()) { + // final Component comp = getComponent(stringBounder); + // final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final double width = dim.getWidth(); + // return livingSpace1.getPosC(stringBounder).addFixed(width); + // } + if (isReverse(stringBounder)) { + return getPoint1(stringBounder); + } + return getPoint2(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java new file mode 100644 index 000000000..454e22ac9 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java @@ -0,0 +1,125 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.ArrowComponent; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationTileNoteLeft implements TileWithUpdateStairs { + + private final TileWithUpdateStairs tile; + private final Message message; + private final Skin skin; + private final ISkinParam skinParam; + private final Display notes; + // private final NotePosition notePosition; + private final LivingSpace livingSpace; + + public Event getEvent() { + return message; + } + + + public CommunicationTileNoteLeft(TileWithUpdateStairs tile, Message message, Skin skin, ISkinParam skinParam, + LivingSpace livingSpace) { + this.tile = tile; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + this.notes = message.getNote(); + // this.notePosition = message.getNotePosition(); + this.livingSpace = livingSpace; + } + + public void updateStairs(StringBounder stringBounder, double y) { + tile.updateStairs(stringBounder, y); + } + + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.NOTE, null, skinParam, notes); + return comp; + } + + private Real getNotePosition(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return livingSpace.getPosC(stringBounder).addFixed(-dim.getWidth()); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(dim.getWidth(), dim.getHeight()); + tile.drawU(ug); + final Real p = getNotePosition(stringBounder); + + comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); + } + + public void addConstraints(StringBounder stringBounder) { + tile.addConstraints(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return getNotePosition(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + return tile.getMaxX(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java new file mode 100644 index 000000000..1aab8254a --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java @@ -0,0 +1,126 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationTileNoteRight implements TileWithUpdateStairs { + + private final TileWithUpdateStairs tile; + private final Message message; + private final Skin skin; + private final ISkinParam skinParam; + private final Display notes; + // private final NotePosition notePosition; + private final LivingSpace livingSpace; + + public Event getEvent() { + return message; + } + + + public CommunicationTileNoteRight(TileWithUpdateStairs tile, Message message, Skin skin, ISkinParam skinParam, + LivingSpace livingSpace) { + this.tile = tile; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + this.notes = message.getNote(); + // this.notePosition = message.getNotePosition(); + this.livingSpace = livingSpace; + } + + public void updateStairs(StringBounder stringBounder, double y) { + tile.updateStairs(stringBounder, y); + } + + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.NOTE, null, skinParam, notes); + return comp; + } + + private Real getNotePosition(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return livingSpace.getPosC(stringBounder); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(dim.getWidth(), dim.getHeight()); + tile.drawU(ug); + final Real p = getNotePosition(stringBounder); + + comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); + } + + public void addConstraints(StringBounder stringBounder) { + tile.addConstraints(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return tile.getMinX(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return getNotePosition(stringBounder).addFixed(dim.getWidth()); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java new file mode 100644 index 000000000..5492535d7 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.Iterator; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.ArrowComponent; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationTileSelf implements TileWithUpdateStairs { + + private final LivingSpace livingSpace1; + private final Message message; + private final Skin skin; + private final ISkinParam skinParam; + private final LivingSpaces livingSpaces; + + public Event getEvent() { + return message; + } + + public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Skin skin, ISkinParam skinParam, + LivingSpaces livingSpaces) { + this.livingSpace1 = livingSpace1; + this.livingSpaces = livingSpaces; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + } + + // private boolean isReverse(StringBounder stringBounder) { + // final Real point1 = livingSpace1.getPosC(stringBounder); + // final Real point2 = livingSpace2.getPosC(stringBounder); + // if (point1.getCurrentValue() > point2.getCurrentValue()) { + // return true; + // } + // return false; + // + // } + + private Component getComponent(StringBounder stringBounder) { + ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); + arrowConfiguration = arrowConfiguration.self(); + final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam, + message.getLabel()); + return comp; + } + + public void updateStairs(StringBounder stringBounder, double y) { + final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Point2D p1 = comp.getStartPoint(stringBounder, dim); + final Point2D p2 = comp.getEndPoint(stringBounder, dim); + + if (message.isActivate()) { + livingSpace1.addStepForLivebox(getEvent(), y + p2.getY()); + System.err.println("CommunicationTileSelf::updateStairs activate y=" + (y + p2.getY()) + " " + message); + } else if (message.isDeactivate()) { + livingSpace1.addStepForLivebox(getEvent(), y + p1.getY()); + System.err.println("CommunicationTileSelf::updateStairs deactivate y=" + (y + p1.getY()) + " " + message); + } + + // livingSpace1.addStep(y + arrowY, level1); + // livingSpace1.addStep(y + dim.getHeight(), level1); + // final int level2 = livingSpace2.getLevelAt(this); + // livingSpace2.addStep(y + arrowY, level2); + // livingSpace2.addStep(y + dim.getHeight(), level2); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + double x1 = getPoint1(stringBounder).getCurrentValue(); + final int levelIgnore = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_ACTIVATE); + final int levelConsidere = livingSpace1.getLevelAt(this, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE); + System.err.println("CommunicationTileSelf::drawU levelIgnore=" + levelIgnore + " levelConsidere=" + + levelConsidere); + x1 += CommunicationTile.LIVE_DELTA_SIZE * levelIgnore; + if (levelIgnore < levelConsidere) { + x1 += CommunicationTile.LIVE_DELTA_SIZE; + } + + final Area area = new Area(dim.getWidth(), dim.getHeight()); + // if (message.isActivate()) { + // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE); + // } else if (message.isDeactivate()) { + // // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE); + // // x1 += CommunicationTile.LIVE_DELTA_SIZE * levelConsidere; + // } + area.setDeltaX1((levelIgnore - levelConsidere) * CommunicationTile.LIVE_DELTA_SIZE); + ug = ug.apply(new UTranslate(x1, 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + // final Component comp = getComponent(stringBounder); + // final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final double width = dim.getWidth(); + + final LivingSpace next = getNext(); + if (next != null) { + next.getPosB().ensureBiggerThan(getMaxX(stringBounder)); + } + } + + // private boolean isSelf() { + // return livingSpace1 == livingSpace2; + // } + + private LivingSpace getNext() { + for (Iterator it = livingSpaces.values().iterator(); it.hasNext();) { + final LivingSpace current = it.next(); + if (current == livingSpace1 && it.hasNext()) { + return it.next(); + } + } + return null; + } + + private Real getPoint1(final StringBounder stringBounder) { + return livingSpace1.getPosC(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return getPoint1(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double width = dim.getWidth(); + return livingSpace1.getPosC(stringBounder).addFixed(width); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java new file mode 100644 index 000000000..020d4616e --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CommunicationTileSelfNoteRight implements TileWithUpdateStairs { + + private final CommunicationTileSelf tile; + private final Message message; + private final Skin skin; + private final ISkinParam skinParam; + private final Display notes; + + // private final NotePosition notePosition; + // private final LivingSpace livingSpace; + + public Event getEvent() { + return message; + } + + + public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Skin skin, ISkinParam skinParam) { + this.tile = tile; + this.message = message; + this.skin = skin; + this.skinParam = skinParam; + this.notes = message.getNote(); + // this.notePosition = message.getNotePosition(); + } + + public void updateStairs(StringBounder stringBounder, double y) { + tile.updateStairs(stringBounder, y); + } + + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.NOTE, null, skinParam, notes); + return comp; + } + + private Real getNotePosition(StringBounder stringBounder) { + return tile.getMaxX(stringBounder); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(dim.getWidth(), dim.getHeight()); + tile.drawU(ug); + final Real p = getNotePosition(stringBounder); + + comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); + } + + public void addConstraints(StringBounder stringBounder) { + tile.addConstraints(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return tile.getMinX(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return getNotePosition(stringBounder).addFixed(dim.getWidth()); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java new file mode 100644 index 000000000..539a025e1 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java @@ -0,0 +1,125 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Delay; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class DelayTile implements Tile { + + private final Delay delay; + private final TileArguments tileArguments; + private Real first; + private Real last; + + public Event getEvent() { + return delay; + } + + + public DelayTile(Delay delay, TileArguments tileArguments) { + this.delay = delay; + this.tileArguments = tileArguments; + } + + private void init(StringBounder stringBounder) { + if (first != null) { + return; + } + this.first = tileArguments.getFirstLivingSpace().getPosC(stringBounder); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + this.last = tileArguments.getLastLivingSpace().getPosC(stringBounder).addAtLeast(0); + this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth())); + + } + + private Component getComponent(StringBounder stringBounder) { + final Component comp = tileArguments.getSkin().createComponent(ComponentType.DELAY_TEXT, null, + tileArguments.getSkinParam(), delay.getText()); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + init(stringBounder); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight()); + + ug = ug.apply(new UTranslate(first.getCurrentValue(), 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + } + + public Real getMinX(StringBounder stringBounder) { + init(stringBounder); + return this.first; + } + + public Real getMaxX(StringBounder stringBounder) { + init(stringBounder); + return this.last; + } + +// private double startingY; +// +// public void setStartingY(double startingY) { +// this.startingY = startingY; +// } +// +// public double getStartingY() { +// return startingY; +// } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java new file mode 100644 index 000000000..b6abbf17d --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java @@ -0,0 +1,107 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Divider; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class DividerTile implements Tile { + + private final Skin skin; + private final ISkinParam skinParam; + private final Divider divider; + private final Real origin; + private final Real omega; + + public Event getEvent() { + return divider; + } + + + public DividerTile(Divider divider, Skin skin, ISkinParam skinParam, Real origin, Real omega) { + this.divider = divider; + this.skin = skin; + this.skinParam = skinParam; + this.origin = origin; + this.omega = omega; + } + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.DIVIDER, null, skinParam, divider.getText()); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(omega.getCurrentValue() - origin.getCurrentValue(), dim.getHeight()); + + // ug = ug.apply(new UTranslate(x, 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + // final Component comp = getComponent(stringBounder); + // final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final double width = dim.getWidth(); + } + + public Real getMinX(StringBounder stringBounder) { + return origin; + } + + public Real getMaxX(StringBounder stringBounder) { + return omega; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java new file mode 100644 index 000000000..27d0154c8 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java @@ -0,0 +1,110 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.GroupingLeaf; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ElseTile implements Tile { + + private final Skin skin; + private final ISkinParam skinParam; + private final GroupingLeaf anElse; + private final Tile parent; + + public Event getEvent() { + return anElse; + } + + + public ElseTile(GroupingLeaf anElse, Skin skin, ISkinParam skinParam, Tile parent) { + this.anElse = anElse; + this.skin = skin; + this.skinParam = skinParam; + this.parent = parent; + } + + private Component getComponent(StringBounder stringBounder) { + final Display display = Display.create(anElse.getTitle()); + final Component comp = skin.createComponent(ComponentType.GROUPING_ELSE, null, skinParam, display); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Real min = getMinX(stringBounder); + final Real max = getMaxX(stringBounder); + final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), dim.getHeight()); + ug = ug.apply(new UTranslate(min.getCurrentValue(), 0)); + // ug = ug.apply(new UTranslate(x, 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + // final Component comp = getComponent(stringBounder); + // final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final double width = dim.getWidth(); + } + + public Real getMinX(StringBounder stringBounder) { + return parent.getMinX(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + return parent.getMaxX(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java new file mode 100644 index 000000000..71b583b1c --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java @@ -0,0 +1,163 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.LifeEvent; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.sequencediagram.Note; +import net.sourceforge.plantuml.sequencediagram.Participant; + +public class EventsHistory { + + private final Participant p; + private final List events; + private final Map ys3 = new HashMap(); + + public EventsHistory(Participant p, List events) { + this.p = p; + this.events = events; + } + + public void addStepForLivebox(Event event, double y) { + ys3.put(event, y); + } + + public Participant getParticipant() { + return p; + } + + public int getLevelAt(Event event, EventsHistoryMode mode) { + final int result = getLevelAtInternal(event, mode); + // System.err.println("EventsHistory::getLevelAt " + mode + " " + result + " " + event); + return result; + } + + private int getLevelAtInternal(Event event, EventsHistoryMode mode) { + int level = 0; // p.getInitialLife(); + // System.err.println("--->EventsHistory for " + p + " " + event); + for (Iterator it = events.iterator(); it.hasNext();) { + final Event current = it.next(); + if (current instanceof LifeEvent) { + final LifeEvent le = (LifeEvent) current; + if (le.getParticipant() == p && le.isActivate()) { + level++; + } + if (le.getParticipant() == p && le.isDeactivateOrDestroy()) { + level--; + } + } + if (event == current) { + if (current instanceof Message) { + final Event next = nextButSkippingNotes(it); + if (next instanceof LifeEvent) { + final LifeEvent le = (LifeEvent) next; + final Message msg = (Message) current; + if (mode != EventsHistoryMode.IGNORE_FUTURE_ACTIVATE && le.isActivate() && msg.dealWith(p) + && le.getParticipant() == p) { + level++; + } + if (mode == EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE && le.isDeactivateOrDestroy() + && msg.dealWith(p) && le.getParticipant() == p) { + level--; + } + // System.err.println("Warning, this is message " + current + " next=" + next); + } + + } + // System.err.println("<-result1 is " + level); + return level; + } + } + throw new IllegalArgumentException(); + // return level; + } + + private boolean isNextEventADestroy(Event event) { + for (Iterator it = events.iterator(); it.hasNext();) { + final Event current = it.next(); + if (event != current) { + continue; + } + if (current instanceof Message) { + final Event next = nextButSkippingNotes(it); + if (next instanceof LifeEvent) { + final LifeEvent le = (LifeEvent) next; + return le.isDestroy(); + } + } + return false; + } + return false; + } + + private Event nextButSkippingNotes(Iterator it) { + while (true) { + if (it.hasNext() == false) { + return null; + } + final Event next = it.next(); + if (next instanceof Note) { + continue; + } + // System.err.println("nextButSkippingNotes=" + next); + return next; + } + } + + public Stairs2 getStairs(double totalHeight) { + System.err.println("EventsHistory::getStairs totalHeight=" + totalHeight); + final Stairs2 result = new Stairs2(); + int value = 0; + for (Event event : events) { + final Double position = ys3.get(event); + System.err.println("EventsHistory::getStairs event=" + event + " position=" + position); + if (position != null) { + assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight; + value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE); + result.addStep(new StairsPosition(position, isNextEventADestroy(event)), value); + } + } + System.err.println("EventsHistory::getStairs finishing totalHeight=" + totalHeight); + result.addStep(new StairsPosition(totalHeight, false), value); + // System.err.println("EventsHistory::getStairs " + p + " result=" + result); + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java new file mode 100644 index 000000000..f34f5bb81 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +public enum EventsHistoryMode { + IGNORE_FUTURE_DEACTIVATE, IGNORE_FUTURE_ACTIVATE, CONSIDERE_FUTURE_DEACTIVATE; + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java new file mode 100644 index 000000000..73e290aae --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java @@ -0,0 +1,166 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.real.RealMax; +import net.sourceforge.plantuml.real.RealMin; +import net.sourceforge.plantuml.real.RealUtils; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Grouping; +import net.sourceforge.plantuml.sequencediagram.GroupingLeaf; +import net.sourceforge.plantuml.sequencediagram.GroupingStart; +import net.sourceforge.plantuml.sequencediagram.GroupingType; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GroupingTile implements Tile { + + private static final int MARGINX = 16; + private static final int MARGINY = 10; + private final List tiles = new ArrayList(); + private final RealMin min = new RealMin(); + private final RealMax max = new RealMax(); + private final GroupingStart start; + + // private final double marginX = 20; + + private final Skin skin; + private final ISkinParam skinParam; + private final Display display; + + private double bodyHeight; + + public Event getEvent() { + return start; + } + + public GroupingTile(Iterator it, GroupingStart start, TileArguments tileArguments) { + final StringBounder stringBounder = tileArguments.getStringBounder(); + this.start = start; + this.display = start.getTitle().equals("group") ? Display.create(start.getComment()) : Display.create( + start.getTitle(), start.getComment()); + this.skin = tileArguments.getSkin(); + this.skinParam = tileArguments.getSkinParam(); + // this.max = min.addAtLeast(dim1.getWidth()); + + while (it.hasNext()) { + final Event ev = it.next(); + System.err.println("GroupingTile::ev=" + ev); + if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) { + break; + } + final Tile tile = TileBuilder.buildOne(it, tileArguments, ev, this); + if (tile != null) { + tiles.add(tile); + min.put(tile.getMinX(stringBounder).addFixed(-MARGINX)); + final Real m = tile.getMaxX(stringBounder); + max.put(m == tileArguments.getOmega() ? m : m.addFixed(MARGINX)); + bodyHeight += tile.getPreferredHeight(stringBounder); + } + } + final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder); + final double width = dim1.getWidth(); + System.err.println("width=" + width); + if (min.size() == 0) { + min.put(tileArguments.getOrigin()); + max.put(tileArguments.getOmega()); + } + // max.ensureBiggerThan(min.addFixed(width)); + this.max.ensureBiggerThan(getMinX(stringBounder).addFixed(width + 16)); + } + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.GROUPING_HEADER, null, skinParam, display); + return comp; + } + + public Dimension2D getPreferredDimensionIfEmpty(StringBounder stringBounder) { + return getComponent(stringBounder).getPreferredDimension(stringBounder); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final Component comp = getComponent(stringBounder); + final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder); + final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), bodyHeight + dim1.getHeight() + + MARGINY / 2); + + if (ug instanceof LiveBoxFinder == false) { + comp.drawU(ug.apply(new UTranslate(min.getCurrentValue(), 0)), area, (Context2D) ug); + } + // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).draw(new URectangle(area.getDimensionToUse())); + + double h = dim1.getHeight() + MARGINY / 2; + for (Tile tile : tiles) { + ug.apply(new UTranslate(0, h)).draw(tile); + h += tile.getPreferredHeight(stringBounder); + } + + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder); + return dim1.getHeight() + bodyHeight + MARGINY; + } + + public void addConstraints(StringBounder stringBounder) { + for (Tile tile : tiles) { + tile.addConstraints(stringBounder); + } + } + + public Real getMinX(StringBounder stringBounder) { + return min; + } + + public Real getMaxX(StringBounder stringBounder) { + return max; + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java new file mode 100644 index 000000000..038ca1711 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java @@ -0,0 +1,95 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.LifeEvent; +import net.sourceforge.plantuml.sequencediagram.LifeEventType; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class LifeEventTile implements TileWithUpdateStairs { + + private final LifeEvent lifeEvent; + private final TileArguments tileArguments; + private final LivingSpace livingSpace; + private final Skin skin; + private final ISkinParam skinParam; + + public void updateStairs(StringBounder stringBounder, double y) { + System.err.println("LifeEventTile::updateStairs " + lifeEvent + " " + livingSpace.getParticipant() + " y=" + y); + livingSpace.addStepForLivebox(getEvent(), y); + } + + public Event getEvent() { + return lifeEvent; + } + + public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Skin skin, + ISkinParam skinParam) { + this.lifeEvent = lifeEvent; + this.tileArguments = tileArguments; + this.livingSpace = livingSpace; + this.skin = skin; + this.skinParam = skinParam; + } + + public void drawU(UGraphic ug) { + } + + public double getPreferredHeight(StringBounder stringBounder) { + if (lifeEvent.isActivate()) { + return 20; + } + return 0; + } + + public void addConstraints(StringBounder stringBounder) { + } + + public Real getMinX(StringBounder stringBounder) { + return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosB(); + } + + public Real getMaxX(StringBounder stringBounder) { + return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosD(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java new file mode 100644 index 000000000..6c1fbd78d --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java @@ -0,0 +1,120 @@ +/* ======================================================================== + * 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.sequencediagram.teoz; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; +import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UParamNull; +import net.sourceforge.plantuml.ugraphic.UShape; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class LiveBoxFinder implements UGraphic { + + public boolean isSpecialTxt() { + return false; + } + + public UGraphic apply(UChange change) { + if (change instanceof UTranslate) { + return new LiveBoxFinder(stringBounder, translate.compose((UTranslate) change)); + } else if (change instanceof UStroke) { + return new LiveBoxFinder(this); + } else if (change instanceof UChangeBackColor) { + return new LiveBoxFinder(this); + } else if (change instanceof UChangeColor) { + return new LiveBoxFinder(this); + } + throw new UnsupportedOperationException(); + } + + private final StringBounder stringBounder; + private final UTranslate translate; + + public LiveBoxFinder(StringBounder stringBounder) { + this(stringBounder, new UTranslate()); + } + + private LiveBoxFinder(StringBounder stringBounder, UTranslate translate) { + this.stringBounder = stringBounder; + this.translate = translate; + } + + private LiveBoxFinder(LiveBoxFinder other) { + this(other.stringBounder, other.translate); + } + + public StringBounder getStringBounder() { + return stringBounder; + } + + public UParam getParam() { + return new UParamNull(); + } + + public void draw(UShape shape) { + final double x = translate.getDx(); + final double y = translate.getDy(); + if (shape instanceof GroupingTile) { + ((GroupingTile) shape).drawU(this); + } else if (shape instanceof TileWithUpdateStairs) { + ((TileWithUpdateStairs) shape).updateStairs(stringBounder, y); + } else if (shape instanceof Tile) { + System.err.println("OtherTile " + shape); + } else { + throw new UnsupportedOperationException(shape.getClass().getName()); + } + } + + public ColorMapper getColorMapper() { + return new ColorMapperIdentity(); + } + + public void startUrl(Url url) { + } + + public void closeAction() { + } + + public void flushUg() { + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java new file mode 100644 index 000000000..4910fc7be --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.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: 5183 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.util.Iterator; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class LiveBoxes implements UDrawable { + + private final EventsHistory eventsHistory; + private final Skin skin; + private final ISkinParam skinParam; + private final double totalHeight; + private final Context2D context; + + public LiveBoxes(EventsHistory eventsHistory, Skin skin, ISkinParam skinParam, double totalHeight, Context2D context) { + this.eventsHistory = eventsHistory; + this.skin = skin; + this.skinParam = skinParam; + this.totalHeight = totalHeight; + this.context = context; + } + + public void drawU(UGraphic ug) { + final Stairs2 stairs = eventsHistory.getStairs(totalHeight); + final int max = stairs.getMaxValue(); + for (int i = 1; i <= max; i++) { + drawOneLevel(ug, i, stairs, context); + } + } + + private void drawOneLevel(UGraphic ug, int levelToDraw, Stairs2 stairs, Context2D context) { + final Component comp = skin.createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null); + final Component cross = skin.createComponent(ComponentType.DESTROY, null, skinParam, null); + final Dimension2D dimCross = cross.getPreferredDimension(ug.getStringBounder()); + final double width = comp.getPreferredWidth(ug.getStringBounder()); + ug = ug.apply(new UTranslate((levelToDraw - 1) * width / 2.0, 0)); + + double y1 = Double.MAX_VALUE; + for (Iterator it = stairs.getYs().iterator(); it.hasNext();) { + final StairsPosition yposition = it.next(); + System.err.println("LiveBoxes::drawOneLevel " + levelToDraw + " " + yposition); + final int level = stairs.getValue(yposition.getValue()); + if (y1 == Double.MAX_VALUE && level == levelToDraw) { + y1 = yposition.getValue(); + } else if (y1 != Double.MAX_VALUE && (it.hasNext() == false || level < levelToDraw)) { + final double y2 = yposition.getValue(); + final Area area = new Area(width, y2 - y1); + comp.drawU(ug.apply(new UTranslate(-width / 2, y1)), area, context); + System.err.println("LiveBoxes::drawOneLevel one block " + y1 + " " + y2); + if (yposition.isDestroy()) { + System.err.println("LiveBoxes::drawOneLevel DESTROY " + yposition); + cross.drawU(ug.apply(new UTranslate(-dimCross.getWidth() / 2, y2 - dimCross.getHeight() / 2)), + null, context); + } else { + System.err.println("LiveBoxes::drawOneLevel NOTDESTROY " + yposition); + } + y1 = Double.MAX_VALUE; + } + } + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java new file mode 100644 index 000000000..57bdd5ea7 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java @@ -0,0 +1,199 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Delay; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Participant; +import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober; +import net.sourceforge.plantuml.sequencediagram.ParticipantType; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class LivingSpace { + + private final Participant p; + private final Skin skin; + private final ISkinParam skinParam; + private final ComponentType headType; + private final ComponentType tailType; + private final boolean useContinueLineBecauseOfDelay; + private final MutingLine mutingLine; + + // private final LivingSpaceImpl previous; + // private LivingSpace next; + + private final Real posB; + private Real posC; + private Real posD; + + private final EventsHistory eventsHistory; + + public int getLevelAt(Tile tile, EventsHistoryMode mode) { + // assert mode == EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE; + return eventsHistory.getLevelAt(tile.getEvent(), mode); + } + + public void addStepForLivebox(Event event, double y) { + eventsHistory.addStepForLivebox(event, y); + } + + @Override + public String toString() { + return p.getCode() + " B=" + posB.getCurrentValue() + "/C=" + currentValue(posC) + "/D=" + currentValue(posD); + } + + private static String currentValue(Real pos) { + if (pos == null) { + return null; + } + return "" + pos.getCurrentValue(); + } + + public LivingSpace(Participant p, ParticipantEnglober englober, Skin skin, ISkinParam skinParam, Real position, + List events) { + this.eventsHistory = new EventsHistory(p, events); + this.p = p; + this.skin = skin; + this.skinParam = skinParam; + this.posB = position; + if (p.getType() == ParticipantType.PARTICIPANT) { + headType = ComponentType.PARTICIPANT_HEAD; + tailType = ComponentType.PARTICIPANT_TAIL; + } else if (p.getType() == ParticipantType.ACTOR) { + headType = ComponentType.ACTOR_HEAD; + tailType = ComponentType.ACTOR_TAIL; + } else if (p.getType() == ParticipantType.BOUNDARY) { + headType = ComponentType.BOUNDARY_HEAD; + tailType = ComponentType.BOUNDARY_TAIL; + } else if (p.getType() == ParticipantType.CONTROL) { + headType = ComponentType.CONTROL_HEAD; + tailType = ComponentType.CONTROL_TAIL; + } else if (p.getType() == ParticipantType.ENTITY) { + headType = ComponentType.ENTITY_HEAD; + tailType = ComponentType.ENTITY_TAIL; + } else if (p.getType() == ParticipantType.DATABASE) { + headType = ComponentType.DATABASE_HEAD; + tailType = ComponentType.DATABASE_TAIL; + } else { + throw new IllegalArgumentException(); + } + // this.stairs2.addStep2(0, p.getInitialLife()); + // this.stairs2.addStep2(0, 0); + this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events); + this.mutingLine = new MutingLine(skin, skinParam, events); + + } + + private boolean useContinueLineBecauseOfDelay(List events) { + final String strategy = skinParam.getValue("lifelineStrategy"); + if ("nosolid".equalsIgnoreCase(strategy)) { + return false; + } + for (Event ev : events) { + if (ev instanceof Delay) { + return true; + } + } + return false; + } + + public void drawLineAndLiveBoxes(UGraphic ug, double height, Context2D context) { + + mutingLine.drawLine(ug, height, context); + // final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE + // : ComponentType.PARTICIPANT_LINE; + // final Component comp = skin.createComponent(defaultLineType, null, skinParam, p.getDisplay(false)); + // final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder()); + // final Area area = new Area(dim.getWidth(), height); + // comp.drawU(ug, area, new SimpleContext2D(false)); + + final LiveBoxes liveBoxes = new LiveBoxes(eventsHistory, skin, skinParam, height, context); + liveBoxes.drawU(ug); + } + + // public void addDelayTile(DelayTile tile) { + // System.err.println("addDelayTile " + this + " " + tile); + // } + + public void drawHead(UGraphic ug, Context2D context) { + final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false)); + final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder()); + final Area area = new Area(dim); + comp.drawU(ug, area, context); + } + + public Dimension2D getHeadPreferredDimension(StringBounder stringBounder) { + final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false)); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim; + } + + private double getPreferredWidth(StringBounder stringBounder) { + return getHeadPreferredDimension(stringBounder).getWidth(); + } + + public Real getPosC(StringBounder stringBounder) { + if (posC == null) { + this.posC = posB.addFixed(this.getPreferredWidth(stringBounder) / 2); + } + return posC; + } + + public Real getPosD(StringBounder stringBounder) { + if (posD == null) { + this.posD = posB.addFixed(this.getPreferredWidth(stringBounder)); + } + return posD; + } + + public Real getPosB() { + return posB; + } + + public Participant getParticipant() { + return p; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java new file mode 100644 index 000000000..b5cf9d2df --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import net.sourceforge.plantuml.sequencediagram.Participant; + +public class LivingSpaces { + + private final Map all = new LinkedHashMap(); + + public Collection values() { + return all.values(); + } + + public void put(Participant participant, LivingSpace livingSpace) { + all.put(participant, livingSpace); + } + + public LivingSpace get(Participant participant) { + return all.get(participant); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java new file mode 100644 index 000000000..ade1457bd --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.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: 9591 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.real.RealMax; +import net.sourceforge.plantuml.real.RealMin; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.LimitFinder; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class MainTile implements Tile { + + private final RealMin min = new RealMin(); + private final RealMax max = new RealMax(); + // private double height; + + private final List tiles = new ArrayList(); + + public MainTile(SequenceDiagram diagram, Skin skin, Real omega, LivingSpaces livingSpaces, Real origin) { + + min.put(origin); + max.put(omega); + + final ISkinParam skinParam = diagram.getSkinParam(); + final StringBounder stringBounder = TextBlockUtils.getDummyStringBounder(); + + final TileArguments tileArguments = new TileArguments(stringBounder, omega, livingSpaces, skin, skinParam, + origin); + + tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null)); + + for (Tile tile : tiles) { + // height += tile.getPreferredHeight(stringBounder); + min.put(tile.getMinX(stringBounder)); + max.put(tile.getMaxX(stringBounder)); + } + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final LiveBoxFinder liveBoxFinder = new LiveBoxFinder(stringBounder); + + drawUInternal(liveBoxFinder, false); + final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, true); + drawUInternal(interceptor, false); + } + + public void drawForeground(UGraphic ug) { + final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, false); + drawUInternal(interceptor, false); + } + + private double drawUInternal(UGraphic ug, boolean trace) { + final StringBounder stringBounder = ug.getStringBounder(); + double y = 0; + double lastY = 0; + final List positionedTiles = new ArrayList(); + for (Tile tile : tiles) { + if (tile.getEvent().isParallel()) { + y = lastY; + } + if (trace) { + System.err.println("MainTile::drawUInternal tile=" + tile + " y=" + y); + } + positionedTiles.add(new YPositionedTile(tile, y)); + lastY = y; + y += tile.getPreferredHeight(stringBounder); + } + for (YPositionedTile tile : positionedTiles) { + tile.drawU(ug); + } + System.err.println("MainTile::drawUInternal finalY=" + y); + return y; + } + + public double getPreferredHeight(StringBounder stringBounder) { + final LimitFinder limitFinder = new LimitFinder(stringBounder, true); + final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(limitFinder, false); + final double finalY = drawUInternal(interceptor, true); + final double result = Math.max(limitFinder.getMinMax().getDimension().getHeight(), finalY) + 10; + System.err.println("MainTile::getPreferredHeight=" + result); + return result; + } + + public void addConstraints(StringBounder stringBounder) { + for (Tile tile : tiles) { + tile.addConstraints(stringBounder); + } + } + + public Real getMinX(StringBounder stringBounder) { + return min; + } + + public Real getMaxX(StringBounder stringBounder) { + return max; + } + + public Event getEvent() { + return null; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java new file mode 100644 index 000000000..6773985af --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.sequencediagram.Delay; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class MutingLine { + + private final Skin skin; + private final ISkinParam skinParam; + private final boolean useContinueLineBecauseOfDelay; + + public MutingLine(Skin skin, ISkinParam skinParam, List events) { + this.skin = skin; + this.skinParam = skinParam; + this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events); + } + + private boolean useContinueLineBecauseOfDelay(List events) { + final String strategy = skinParam.getValue("lifelineStrategy"); + if ("nosolid".equalsIgnoreCase(strategy)) { + return false; + } + for (Event ev : events) { + if (ev instanceof Delay) { + return true; + } + } + return false; + } + + public void drawLine(UGraphic ug, double height, Context2D context) { + final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE + : ComponentType.PARTICIPANT_LINE; + final Component comp = skin.createComponent(defaultLineType, null, skinParam, null); + final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder()); + final Area area = new Area(dim.getWidth(), height); + comp.drawU(ug, area, context); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java new file mode 100644 index 000000000..0cdc27d16 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java @@ -0,0 +1,146 @@ +/* ======================================================================== + * 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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.real.RealUtils; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Note; +import net.sourceforge.plantuml.sequencediagram.NotePosition; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class NoteTile implements Tile { + + private final LivingSpace livingSpace1; + private final LivingSpace livingSpace2; + private final Skin skin; + private final ISkinParam skinParam; + private final Note note; + + public Event getEvent() { + return note; + } + + public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Skin skin, ISkinParam skinParam) { + this.livingSpace1 = livingSpace1; + this.livingSpace2 = livingSpace2; + this.note = note; + this.skin = skin; + this.skinParam = skinParam; + } + + private Component getComponent(StringBounder stringBounder) { + final Component comp = skin.createComponent(ComponentType.NOTE, null, skinParam, note.getStrings()); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double x = getX(stringBounder).getCurrentValue(); + final Area area = new Area(getUsedWidth(stringBounder), dim.getHeight()); + + ug = ug.apply(new UTranslate(x, 0)); + comp.drawU(ug, area, (Context2D) ug); + // ug.draw(new ULine(x2 - x1, 0)); + } + + private double getUsedWidth(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final double width = dim.getWidth(); + if (note.getPosition() == NotePosition.OVER_SEVERAL) { + final double x1 = livingSpace1.getPosB().getCurrentValue(); + final double x2 = livingSpace2.getPosD(stringBounder).getCurrentValue(); + final double w = x2 - x1; + if (width < w) { + return w; + } + } + return width; + } + + private Real getX(StringBounder stringBounder) { + final NotePosition position = note.getPosition(); + final double width = getUsedWidth(stringBounder); + if (position == NotePosition.LEFT) { + return livingSpace1.getPosC(stringBounder).addFixed(-width); + } else if (position == NotePosition.RIGHT) { + final int level = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE); + final double dx = level * CommunicationTile.LIVE_DELTA_SIZE; + return livingSpace1.getPosC(stringBounder).addFixed(dx); + } else if (position == NotePosition.OVER_SEVERAL) { + final Real x1 = livingSpace1.getPosC(stringBounder); + final Real x2 = livingSpace2.getPosC(stringBounder); + return RealUtils.middle(x1, x2).addFixed(-width / 2); + } else if (position == NotePosition.OVER) { + return livingSpace1.getPosC(stringBounder).addFixed(-width / 2); + } else { + throw new UnsupportedOperationException(position.toString()); + } + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + // final Component comp = getComponent(stringBounder); + // final Dimension2D dim = comp.getPreferredDimension(stringBounder); + // final double width = dim.getWidth(); + } + + public Real getMinX(StringBounder stringBounder) { + return getX(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + return getX(stringBounder).addFixed(getUsedWidth(stringBounder)); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java new file mode 100644 index 000000000..04a9f41dc --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.Participant; +import net.sourceforge.plantuml.sequencediagram.Reference; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ReferenceTile implements Tile { + + private final Reference reference; + private final TileArguments tileArguments; + private Real first; + private Real last; + + public Event getEvent() { + return reference; + } + + + public ReferenceTile(Reference reference, TileArguments tileArguments) { + this.reference = reference; + this.tileArguments = tileArguments; + } + + private void init(StringBounder stringBounder) { + if (first != null) { + return; + } + for (Participant p : reference.getParticipant()) { + final LivingSpace livingSpace = tileArguments.getLivingSpace(p); + final Real pos = livingSpace.getPosC(stringBounder); + if (first == null || pos.getCurrentValue() < first.getCurrentValue()) { + this.first = pos; + } + if (last == null || pos.getCurrentValue() > last.getCurrentValue()) { + this.last = pos; + } + } + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + this.last = this.last.addAtLeast(0); + this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth())); + + } + + private Component getComponent(StringBounder stringBounder) { + Display strings = Display.empty(); + strings = strings.add("ref"); + strings = strings.addAll(reference.getStrings()); + + final Component comp = tileArguments.getSkin().createComponent(ComponentType.REFERENCE, null, + tileArguments.getSkinParam(), strings); + return comp; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + init(stringBounder); + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight()); + + ug = ug.apply(new UTranslate(first.getCurrentValue(), 0)); + comp.drawU(ug, area, (Context2D) ug); + } + + public double getPreferredHeight(StringBounder stringBounder) { + final Component comp = getComponent(stringBounder); + final Dimension2D dim = comp.getPreferredDimension(stringBounder); + return dim.getHeight(); + } + + public void addConstraints(StringBounder stringBounder) { + } + + public Real getMinX(StringBounder stringBounder) { + init(stringBounder); + return this.first; + } + + public Real getMaxX(StringBounder stringBounder) { + init(stringBounder); + return this.last; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java new file mode 100644 index 000000000..9e4fd402e --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -0,0 +1,161 @@ +/* ======================================================================== + * 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: 9591 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.awt.geom.Dimension2D; +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.api.ImageDataSimple; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.real.RealUtils; +import net.sourceforge.plantuml.sequencediagram.Participant; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UGraphic2; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class SequenceDiagramFileMakerTeoz implements FileMaker { + + private final SequenceDiagram diagram; + private final FileFormatOption fileFormatOption; + private final Skin skin; + + public SequenceDiagramFileMakerTeoz(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) { + this.diagram = sequenceDiagram; + this.fileFormatOption = fileFormatOption; + this.skin = skin; + + } + + public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException { + StringBounder stringBounder = TextBlockUtils.getDummyStringBounder(); + + final ISkinParam skinParam = diagram.getSkinParam(); + + final Real origin = RealUtils.createOrigin(); + Real currentPos = origin.addAtLeast(0); + double headHeight = 0; + LivingSpace last = null; + LivingSpaces livingSpaces = new LivingSpaces(); + for (Participant p : diagram.participants().values()) { + final LivingSpace livingSpace = new LivingSpace(p, diagram.getEnglober(p), skin, skinParam, currentPos, + diagram.events()); + last = livingSpace; + ((LivingSpaces) livingSpaces).put(p, livingSpace); + final Dimension2D headDim = livingSpace.getHeadPreferredDimension(stringBounder); + currentPos = livingSpace.getPosD(stringBounder).addAtLeast(0); + headHeight = Math.max(headHeight, headDim.getHeight()); + } + // livingSpaces = new LivingSpacesDeltaSimple(livingSpaces); + + final MainTile mainTile = new MainTile(diagram, skin, last.getPosD(stringBounder).addAtLeast(0), livingSpaces, + origin); + mainTile.addConstraints(stringBounder); + origin.compile(); + + final double height = mainTile.getPreferredHeight(stringBounder) + 2 * headHeight; + + final Real min1 = mainTile.getMinX(stringBounder); + final Real max1 = mainTile.getMaxX(stringBounder); + // System.err.println("min1=" + min1.getCurrentValue()); + // System.err.println("max1=" + max1.getCurrentValue()); + + final Dimension2D dim = new Dimension2DDouble(max1.getCurrentValue() - min1.getCurrentValue(), height); + final UGraphic2 ug = (UGraphic2) fileFormatOption.createUGraphic(dim).apply( + new UTranslate(-min1.getCurrentValue(), 0)); + stringBounder = ug.getStringBounder(); + + final Context2D context = new SimpleContext2D(false); + drawHeads(ug, livingSpaces, context); + // mainTile.beforeDrawing(ug.getStringBounder(), livingSpaces.values()); + mainTile.drawU(ug.apply(new UTranslate(0, headHeight))); + drawLifeLines(ug.apply(new UTranslate(0, headHeight)), mainTile.getPreferredHeight(stringBounder), + livingSpaces, context); + drawHeads(ug.apply(new UTranslate(0, mainTile.getPreferredHeight(stringBounder) + headHeight)), livingSpaces, + context); + mainTile.drawForeground(ug.apply(new UTranslate(0, headHeight))); + + ug.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption)); + final Dimension2D info = new Dimension2DDouble(dim.getWidth(), dim.getHeight()); + + // if (fileFormatOption.getFileFormat() == FileFormat.PNG && ug instanceof UGraphicG2d) { + // final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); + // if (urls.size() > 0) { + // if (scale == 0) { + // throw new IllegalStateException(); + // } + // final CMapData cmap = CMapData.cmapString(urls, scale); + // return new ImageDataComplex(info, cmap, null); + // } + // } + return new ImageDataSimple(info); + } + + private void drawLifeLines(final UGraphic ug, double height, LivingSpaces livingSpaces, Context2D context) { + int i = 0; + for (LivingSpace livingSpace : livingSpaces.values()) { + // if (i++ == 0) { + // System.err.println("TEMPORARY SKIPPING OTHERS"); + // continue; + // } + // System.err.println("drawing lines " + livingSpace); + final double x = livingSpace.getPosC(ug.getStringBounder()).getCurrentValue(); + livingSpace.drawLineAndLiveBoxes(ug.apply(new UTranslate(x, 0)), height, context); + } + } + + private void drawHeads(final UGraphic ug, LivingSpaces livingSpaces, Context2D context) { + for (LivingSpace livingSpace : livingSpaces.values()) { + // System.err.println("drawing heads " + livingSpace); + final double x = livingSpace.getPosB().getCurrentValue(); + livingSpace.drawHead(ug.apply(new UTranslate(x, 0)), context); + } + } + + public int getNbPages() { + return 1; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java new file mode 100644 index 000000000..572577be1 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java @@ -0,0 +1,110 @@ +/* ======================================================================== + * 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: 6054 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Stairs2 { + + private final List ys = new ArrayList(); + private final List values = new ArrayList(); + private final Map cache = new HashMap(); + + public void addStep(StairsPosition position, int value) { + System.err.println("Stairs2::addStep " + position + " " + value); + assert ys.size() == values.size(); + if (ys.size() > 0) { + final double lastY = ys.get(ys.size() - 1).getValue(); + if (position.getValue() < lastY) { + throw new IllegalArgumentException(); + } + if (lastY == position.getValue()) { + values.set(ys.size() - 1, value); + cache.clear(); + return; + } + } + ys.add(position); + values.add(value); + cache.clear(); + } + + public int getMaxValue() { + int max = Integer.MIN_VALUE; + for (Integer v : values) { + if (v > max) { + max = v; + } + } + return max; + } + + public List getYs() { + return Collections.unmodifiableList(ys); + } + + public int getValue(double y) { + Integer result = cache.get(y); + if (result == null) { + result = getValueSlow(new StairsPosition(y, false)); + cache.put(y, result); + } + return result; + } + + private int getValueSlow(StairsPosition y) { + final int idx = Collections.binarySearch(ys, y); + if (idx >= 0) { + return values.get(idx); + } + final int insertPoint = -idx - 1; + if (insertPoint == 0) { + return 0; + } + return values.get(insertPoint - 1); + } + + public int getLastValue() { + final int size = values.size(); + if (size == 0) { + return 0; + } + return values.get(size - 1); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java new file mode 100644 index 000000000..b4f8cc7f8 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.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: 6054 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +public class StairsPosition implements Comparable { + + private final double value; + private final boolean destroy; + + public StairsPosition(double value, boolean destroy) { + this.value = value; + this.destroy = destroy; + } + + @Override + public String toString() { + return "" + value + "-(" + destroy + ")"; + } + + public double getValue() { + return value; + } + + public int compareTo(StairsPosition other) { + if (this.value > other.value) { + return 1; + } + if (this.value < other.value) { + return -1; + } + return 0; + } + + public boolean isDestroy() { + return destroy; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java new file mode 100644 index 000000000..1d002fb1d --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.ugraphic.UShape; + +public interface Tile extends UDrawable, UShape { + + public double getPreferredHeight(StringBounder stringBounder); + + public void addConstraints(StringBounder stringBounder); + + public Real getMinX(StringBounder stringBounder); + + public Real getMaxX(StringBounder stringBounder); + + public Event getEvent(); + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java new file mode 100644 index 000000000..0c45a6888 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.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: 9591 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.Collections; +import java.util.Map; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Participant; +import net.sourceforge.plantuml.skin.Skin; + +public class TileArguments { + private final StringBounder stringBounder; + private final Real omega; + private final Real origin; + private final LivingSpaces livingSpaces; + private final Skin skin; + private final ISkinParam skinParam; + + public TileArguments(StringBounder stringBounder, Real omega, LivingSpaces livingSpaces, Skin skin, + ISkinParam skinParam, Real origin) { + this.stringBounder = stringBounder; + this.origin = origin; + this.omega = omega; + this.livingSpaces = livingSpaces; + this.skin = skin; + this.skinParam = skinParam; + } + + public final StringBounder getStringBounder() { + return stringBounder; + } + + public final Real getOmega() { + return omega; + } + + public final Real getOrigin() { + return origin; + } + + public final LivingSpaces getLivingSpaces() { + return livingSpaces; + } + + public final Skin getSkin() { + return skin; + } + + public final ISkinParam getSkinParam() { + return skinParam; + } + + public LivingSpace getLivingSpace(Participant p) { + return livingSpaces.get(p); + } + + public LivingSpace getFirstLivingSpace() { + return livingSpaces.values().iterator().next(); + } + + public LivingSpace getLastLivingSpace() { + LivingSpace result = null; + for (LivingSpace v : livingSpaces.values()) { + result = v; + } + return result; + } + + // public void ensure(Tile tile) { + // getAlpha().ensureLowerThan(tile.getMinX(getStringBounder())); + // getOmega().ensureBiggerThan(tile.getMaxX(getStringBounder())); + // } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java new file mode 100644 index 000000000..85976738b --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java @@ -0,0 +1,142 @@ +/* ======================================================================== + * 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: 9591 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.sequencediagram.Delay; +import net.sourceforge.plantuml.sequencediagram.Divider; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.sequencediagram.GroupingLeaf; +import net.sourceforge.plantuml.sequencediagram.GroupingStart; +import net.sourceforge.plantuml.sequencediagram.GroupingType; +import net.sourceforge.plantuml.sequencediagram.LifeEvent; +import net.sourceforge.plantuml.sequencediagram.Message; +import net.sourceforge.plantuml.sequencediagram.MessageExo; +import net.sourceforge.plantuml.sequencediagram.Note; +import net.sourceforge.plantuml.sequencediagram.NotePosition; +import net.sourceforge.plantuml.sequencediagram.Reference; +import net.sourceforge.plantuml.skin.Skin; + +public class TileBuilder { + + public static List buildSeveral(Iterator it, TileArguments tileArguments, Tile parent) { + final List tiles = new ArrayList(); + while (it.hasNext()) { + final Event ev = it.next(); + final Tile tile = TileBuilder.buildOne(it, tileArguments, ev, parent); + if (tile != null) { + tiles.add(tile); + tileArguments.getOmega().ensureBiggerThan(tile.getMaxX(tileArguments.getStringBounder())); + } + } + return Collections.unmodifiableList(tiles); + } + + public static Tile buildOne(Iterator it, TileArguments tileArguments, final Event ev, Tile parent) { + + final StringBounder stringBounder = tileArguments.getStringBounder(); + final Skin skin = tileArguments.getSkin(); + final ISkinParam skinParam = tileArguments.getSkinParam(); + final LivingSpaces livingSpaces = tileArguments.getLivingSpaces(); + + Tile tile = null; + // System.err.println("TileBuilder::buildOne " + ev); + if (ev instanceof Message) { + final Message msg = (Message) ev; + final LivingSpace livingSpace1 = livingSpaces.get(msg.getParticipant1()); + final LivingSpace livingSpace2 = livingSpaces.get(msg.getParticipant2()); + boolean reverse = false; + if (msg.isSelfMessage()) { + tile = new CommunicationTileSelf(livingSpace1, msg, skin, skinParam, livingSpaces); + } else { + // System.err.println("msg=" + msg); + tile = new CommunicationTile(livingSpace1, livingSpace2, msg, skin, skinParam); + reverse = ((CommunicationTile) tile).isReverse(stringBounder); + } + if (msg.getNote() != null) { + final NotePosition notePosition = msg.getNotePosition(); + if (notePosition == NotePosition.LEFT) { + tile = new CommunicationTileNoteLeft((TileWithUpdateStairs) tile, msg, skin, skinParam, + reverse ? livingSpace2 : livingSpace1); + } else if (notePosition == NotePosition.RIGHT && msg.isSelfMessage()) { + tile = new CommunicationTileSelfNoteRight((CommunicationTileSelf) tile, msg, skin, skinParam); + } else if (notePosition == NotePosition.RIGHT) { + tile = new CommunicationTileNoteRight((TileWithUpdateStairs) tile, msg, skin, skinParam, + reverse ? livingSpace1 : livingSpace2); + } + } + } else if (ev instanceof Note) { + final Note note = (Note) ev; + final LivingSpace livingSpace1 = livingSpaces.get(note.getParticipant()); + final LivingSpace livingSpace2 = note.getParticipant2() == null ? null : livingSpaces.get(note + .getParticipant2()); + tile = new NoteTile(livingSpace1, livingSpace2, note, skin, skinParam); + } else if (ev instanceof Divider) { + final Divider divider = (Divider) ev; + tile = new DividerTile(divider, skin, skinParam, tileArguments.getOrigin(), tileArguments.getOmega()); + } else if (ev instanceof MessageExo) { + final MessageExo exo = (MessageExo) ev; + final LivingSpace livingSpace1 = livingSpaces.get(exo.getParticipant()); + tile = new CommunicationExoTile(livingSpace1, exo, skin, skinParam, tileArguments.getOrigin(), + tileArguments.getOmega()); + } else if (ev instanceof GroupingStart) { + final GroupingStart start = (GroupingStart) ev; + tile = new GroupingTile(it, start, tileArguments); + // tile = TileUtils.withMargin(tile, 10, 10, 10, 10); + } else if (ev instanceof GroupingLeaf && ((GroupingLeaf) ev).getType() == GroupingType.ELSE) { + final GroupingLeaf anElse = (GroupingLeaf) ev; + tile = new ElseTile(anElse, skin, skinParam, parent); + } else if (ev instanceof Reference) { + final Reference ref = (Reference) ev; + tile = new ReferenceTile(ref, tileArguments); + } else if (ev instanceof Delay) { + final Delay delay = (Delay) ev; + tile = new DelayTile(delay, tileArguments); + } else if (ev instanceof LifeEvent) { + final LifeEvent lifeEvent = (LifeEvent) ev; + final LivingSpace livingSpace = livingSpaces.get(lifeEvent.getParticipant()); + tile = new LifeEventTile(lifeEvent, tileArguments, livingSpace, skin, skinParam); + } else { + System.err.println("TileBuilder::Ignoring " + ev.getClass()); + } + return tile; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java new file mode 100644 index 000000000..e6ae5dbea --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.sequencediagram.Event; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class TileMarged implements Tile { + + private final Tile tile; + private final double x1; + private final double x2; + private final double y1; + private final double y2; + + public TileMarged(Tile tile, double x1, double x2, double y1, double y2) { + this.tile = tile; + this.x1 = x1; + this.x2 = x2; + this.y1 = y1; + this.y2 = y2; + } + + public void drawU(UGraphic ug) { + tile.drawU(ug.apply(new UTranslate(x1, y1))); + + } + + public double getPreferredHeight(StringBounder stringBounder) { + return tile.getPreferredHeight(stringBounder) + y1 + y2; + } + + public void addConstraints(StringBounder stringBounder) { + tile.addConstraints(stringBounder); + } + + public Real getMinX(StringBounder stringBounder) { + return tile.getMinX(stringBounder); + } + + public Real getMaxX(StringBounder stringBounder) { + return tile.getMaxX(stringBounder).addFixed(x1 + x2); + } + + public Event getEvent() { + return tile.getEvent(); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java new file mode 100644 index 000000000..249f81afd --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +public class TileUtils { + + private static Tile withMargin(Tile tile, double x1, double x2, double y1, double y2) { + return new TileMarged(tile, x1, x2, y1, y2); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java new file mode 100644 index 000000000..7b2c94afe --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.graphic.StringBounder; + +public interface TileWithUpdateStairs extends Tile { + + public void updateStairs(StringBounder stringBounder, double y); +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java new file mode 100644 index 000000000..f59d9d08b --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.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: 10266 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.graphic.UGraphicDelegator; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class UGraphicInterceptorTile extends UGraphicDelegator implements Context2D { + + private final boolean isBackground; + + public UGraphicInterceptorTile(UGraphic ug, boolean isBackground) { + super(ug); + this.isBackground = isBackground; + } + + public void draw(UShape shape) { + if (shape instanceof Tile) { + final Tile drawable = (Tile) shape; + drawable.drawU(this); + } else { + getUg().draw(shape); + } + + } + + public UGraphic apply(UChange change) { + return new UGraphicInterceptorTile(getUg().apply(change), isBackground); + } + + public boolean isBackground() { + return isBackground; + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java new file mode 100644 index 000000000..e5d503590 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.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: 4636 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.teoz; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class YPositionedTile implements UDrawable { + + private final Tile tile; + private final double y; + + public YPositionedTile(Tile tile, double y) { + this.tile = tile; + this.y = y; + } + + public void drawU(UGraphic ug) { + // System.err.println("YPositionedTile::drawU y=" + y + " " + tile); + ug.apply(new UTranslate(0, y)).draw(tile); + } + +} diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java new file mode 100644 index 000000000..c47875359 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -0,0 +1,295 @@ +/* ======================================================================== + * 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: 9696 $ + * + */ +package net.sourceforge.plantuml.skin.rose; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowDecoration; +import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.skin.ArrowDressing; +import net.sourceforge.plantuml.skin.ArrowHead; +import net.sourceforge.plantuml.skin.ArrowPart; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ComponentRoseArrow extends AbstractComponentRoseArrow { + + private final HorizontalAlignment messagePosition; + private final boolean niceArrow; + + public ComponentRoseArrow(HtmlColor foregroundColor, HtmlColor fontColor, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink, UFont font, Display stringsToDisplay, + ArrowConfiguration arrowConfiguration, HorizontalAlignment messagePosition, ISkinSimple spriteContainer, + HorizontalAlignment textHorizontalAlignment, double maxMessageSize, boolean niceArrow) { + super(foregroundColor, fontColor, hyperlinkColor, useUnderlineForHyperlink, font, stringsToDisplay, arrowConfiguration, spriteContainer, + textHorizontalAlignment, maxMessageSize); + this.messagePosition = messagePosition; + this.niceArrow = niceArrow; + } + + public static final double spaceCrossX = 6; + public static final double diamCircle = 8; + public static final double thinCircle = 1.5; + + @Override + public void drawInternalU(UGraphic ug, Area area) { + final Dimension2D dimensionToUse = area.getDimensionToUse(); + final StringBounder stringBounder = ug.getStringBounder(); + final int textHeight = (int) getTextHeight(stringBounder); + ug = ug.apply(new UChangeColor(getForegroundColor())); + + final ArrowDressing dressing1 = getArrowConfiguration().getDressing1(); + final ArrowDressing dressing2 = getArrowConfiguration().getDressing2(); + + double start = 0; + double len = dimensionToUse.getWidth() - 1; + + final double pos1 = start + 1; + final double pos2 = len - 1; + + if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE) { + len -= diamCircle / 2; + } + if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE) { + len -= diamCircle / 2 + thinCircle; + } + + if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE && dressing1.getHead() == ArrowHead.NONE) { + start += diamCircle / 2; + len -= diamCircle / 2; + } + if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE + && dressing1.getHead() == ArrowHead.NORMAL) { + start += diamCircle + thinCircle; + len -= diamCircle + thinCircle; + } + + drawDressing1(ug, pos1, dressing1, getArrowConfiguration().getDecoration1()); + drawDressing2(ug, pos2, dressing2, getArrowConfiguration().getDecoration2()); + + if (dressing2.getPart() == ArrowPart.FULL && dressing2.getHead() == ArrowHead.NORMAL) { + len -= getArrowDeltaX() / 2; + } + if (dressing1.getPart() == ArrowPart.FULL && dressing1.getHead() == ArrowHead.NORMAL) { + start += getArrowDeltaX() / 2; + len -= getArrowDeltaX() / 2; + } + + if (dressing2.getHead() == ArrowHead.CROSSX) { + len -= 2 * spaceCrossX; + } + if (dressing1.getHead() == ArrowHead.CROSSX) { + start += 2 * spaceCrossX; + len -= 2 * spaceCrossX; + } + + if (getArrowConfiguration().isDotted()) { + ug = stroke(ug, 2, 2); + } + ug.apply(new UTranslate(start, textHeight)).draw(new ULine(len, 0)); + if (getArrowConfiguration().isDotted()) { + ug = ug.apply(new UStroke()); + } + + final ArrowDirection direction2 = getDirection2(); + final double textPos; + if (messagePosition == HorizontalAlignment.CENTER) { + final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth(); + textPos = (dimensionToUse.getWidth() - textWidth) / 2; + } else if (messagePosition == HorizontalAlignment.RIGHT) { + final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth(); + textPos = dimensionToUse.getWidth() - textWidth - getMarginX2() + - (direction2 == ArrowDirection.LEFT_TO_RIGHT_NORMAL ? getArrowDeltaX() : 0); + } else { + textPos = getMarginX1() + + (direction2 == ArrowDirection.RIGHT_TO_LEFT_REVERSE + || direction2 == ArrowDirection.BOTH_DIRECTION ? getArrowDeltaX() : 0); + } + getTextBlock().drawU(ug.apply(new UTranslate(textPos, 0))); + } + + private void drawDressing1(UGraphic ug, double x, ArrowDressing dressing, ArrowDecoration decoration) { + final StringBounder stringBounder = ug.getStringBounder(); + final int textHeight = (int) getTextHeight(stringBounder); + + if (decoration == ArrowDecoration.CIRCLE) { + final UEllipse circle = new UEllipse(diamCircle, diamCircle); + ug.apply(new UStroke(thinCircle)) + .apply(new UChangeColor(getForegroundColor())) + .apply(new UTranslate(x - diamCircle / 2 - thinCircle, textHeight - diamCircle / 2 - thinCircle / 2)) + .draw(circle); + x += diamCircle / 2 + thinCircle; + } + + if (dressing.getHead() == ArrowHead.ASYNC) { + if (dressing.getPart() != ArrowPart.BOTTOM_PART) { + ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), -getArrowDeltaY())); + } + if (dressing.getPart() != ArrowPart.TOP_PART) { + ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), getArrowDeltaY())); + } + } else if (dressing.getHead() == ArrowHead.CROSSX) { + ug = ug.apply(new UStroke(2)); + ug.apply(new UTranslate(spaceCrossX, textHeight - getArrowDeltaX() / 2)).draw( + new ULine(getArrowDeltaX(), getArrowDeltaX())); + ug.apply(new UTranslate(spaceCrossX, textHeight + getArrowDeltaX() / 2)).draw( + new ULine(getArrowDeltaX(), -getArrowDeltaX())); + } else if (dressing.getHead() == ArrowHead.NORMAL) { + final UPolygon polygon = getPolygonReverse(dressing.getPart(), textHeight); + ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UTranslate(x, 0)).draw(polygon); + } + + } + + private void drawDressing2(UGraphic ug, double x, ArrowDressing dressing, ArrowDecoration decoration) { + final StringBounder stringBounder = ug.getStringBounder(); + final int textHeight = (int) getTextHeight(stringBounder); + + if (decoration == ArrowDecoration.CIRCLE) { + ug = ug.apply(new UStroke(thinCircle)).apply(new UChangeColor(getForegroundColor())); + final UEllipse circle = new UEllipse(diamCircle, diamCircle); + ug.apply(new UTranslate(x - diamCircle / 2 + thinCircle, textHeight - diamCircle / 2 - thinCircle / 2)) + .draw(circle); + ug = ug.apply(new UStroke()); + x -= diamCircle / 2 + thinCircle; + } + + if (dressing.getHead() == ArrowHead.ASYNC) { + if (dressing.getPart() != ArrowPart.BOTTOM_PART) { + ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), -getArrowDeltaY())); + } + if (dressing.getPart() != ArrowPart.TOP_PART) { + ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), getArrowDeltaY())); + } + } else if (dressing.getHead() == ArrowHead.CROSSX) { + ug = ug.apply(new UStroke(2)); + ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight - getArrowDeltaX() / 2)).draw( + new ULine(getArrowDeltaX(), getArrowDeltaX())); + ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight + getArrowDeltaX() / 2)).draw( + new ULine(getArrowDeltaX(), -getArrowDeltaX())); + ug = ug.apply(new UStroke()); + } else if (dressing.getHead() == ArrowHead.NORMAL) { + final UPolygon polygon = getPolygonNormal(dressing.getPart(), textHeight, x); + ug.apply(new UChangeBackColor(getForegroundColor())).draw(polygon); + } + + } + + private UPolygon getPolygonNormal(ArrowPart part, final int textHeight, final double x2) { + final UPolygon polygon = new UPolygon(); + if (part == ArrowPart.TOP_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight); + } else if (part == ArrowPart.BOTTOM_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + 1); + polygon.addPoint(x2, textHeight + 1); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY() + 1); + } else { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + if (niceArrow) { + polygon.addPoint(x2 - getArrowDeltaX() + 4, textHeight); + } + } + return polygon; + } + + private UPolygon getPolygonReverse(ArrowPart part, final int textHeight) { + final UPolygon polygon = new UPolygon(); + if (part == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight); + } else if (part == ArrowPart.BOTTOM_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight + 1); + polygon.addPoint(0, textHeight + 1); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + 1); + } else { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + if (niceArrow) { + polygon.addPoint(getArrowDeltaX() - 4, textHeight); + } + } + return polygon; + } + + public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { + final int textHeight = (int) getTextHeight(stringBounder); + if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { + return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); + } + return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); + } + + public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { + final int textHeight = (int) getTextHeight(stringBounder); + if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { + return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); + } + return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); + } + + final private ArrowDirection getDirection2() { + return getArrowConfiguration().getArrowDirection(); + } + + @Override + public double getPreferredHeight(StringBounder stringBounder) { + return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY(); + } + + @Override + public double getPreferredWidth(StringBounder stringBounder) { + return getTextWidth(stringBounder) + getArrowDeltaX(); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java new file mode 100644 index 000000000..e0f54c352 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java @@ -0,0 +1,159 @@ +/* ======================================================================== + * 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.svek; + +import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public final class CucaDiagramFileMakerSvek2InternalImage implements IEntityImage { + + private final List inners = new ArrayList(); + private final Separator separator; + private final ISkinParam skinParam; + private final HtmlColor backColor; + + static enum Separator { + VERTICAL, HORIZONTAL; + + static Separator fromChar(char sep) { + if (sep == '|') { + return VERTICAL; + } + if (sep == '-') { + return HORIZONTAL; + } + throw new IllegalArgumentException(); + } + + UTranslate move(Dimension2D dim) { + if (this == VERTICAL) { + return new UTranslate(dim.getWidth(), 0); + } + return new UTranslate(0, dim.getHeight()); + } + + Dimension2D add(Dimension2D orig, Dimension2D other) { + if (this == VERTICAL) { + return new Dimension2DDouble(orig.getWidth() + other.getWidth(), Math.max(orig.getHeight(), + other.getHeight())); + } + return new Dimension2DDouble(Math.max(orig.getWidth(), other.getWidth()), orig.getHeight() + + other.getHeight()); + } + + void drawSeparator(UGraphic ug, Dimension2D dimTotal) { + final double THICKNESS_BORDER = 1.5; + final int DASH = 8; + ug = ug.apply(new UStroke(DASH, 10, THICKNESS_BORDER)); + if (this == VERTICAL) { + ug.draw(new ULine(0, dimTotal.getHeight() + DASH)); + } else { + ug.draw(new ULine(dimTotal.getWidth() + DASH, 0)); + } + + } + } + + private HtmlColor getColor(ColorParam colorParam) { + return new Rose().getHtmlColor(skinParam, colorParam); + } + + public CucaDiagramFileMakerSvek2InternalImage(Collection leafs, char concurrentSeparator, + ISkinParam skinParam, HtmlColor backColor) { + this.separator = Separator.fromChar(concurrentSeparator); + this.skinParam = skinParam; + this.backColor = backColor; + for (ILeaf inner : leafs) { + inners.add(inner.getSvekImage()); + } + } + + public void drawU(UGraphic ug) { + final HtmlColor dotColor = getColor(ColorParam.stateBorder); + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D dimTotal = calculateDimension(stringBounder); + + for (int i = 0; i < inners.size(); i++) { + final IEntityImage inner = inners.get(i); + inner.drawU(ug); + final Dimension2D dim = inner.calculateDimension(stringBounder); + ug = ug.apply(separator.move(dim)); + if (i < inners.size() - 1) { + separator.drawSeparator(ug.apply(new UChangeColor(dotColor)), dimTotal); + } + } + + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + Dimension2D result = new Dimension2DDouble(0, 0); + for (IEntityImage inner : inners) { + final Dimension2D dim = inner.calculateDimension(stringBounder); + result = separator.add(result, dim); + } + return result; + } + + public HtmlColor getBackcolor() { + return backColor; + } + + public boolean isHidden() { + return false; + } + + public int getShield() { + return 0; + } + + public ShapeType getShapeType() { + return ShapeType.RECTANGLE; + } +} diff --git a/src/net/sourceforge/plantuml/svek/EntityImageProtected.java b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java new file mode 100644 index 000000000..735f3b306 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java @@ -0,0 +1,88 @@ +/* ======================================================================== + * 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.svek; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class EntityImageProtected implements IEntityImage, Untranslated { + + private final IEntityImage orig; + private final double border; + private final Bibliotekon bibliotekon; + private final Neighborhood neighborhood; + + public EntityImageProtected(IEntityImage orig, double border, Neighborhood neighborhood, Bibliotekon bibliotekon) { + this.orig = orig; + this.border = border; + this.bibliotekon = bibliotekon; + this.neighborhood = neighborhood; + } + + public boolean isHidden() { + return orig.isHidden(); + } + + public HtmlColor getBackcolor() { + return orig.getBackcolor(); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return Dimension2DDouble.delta(orig.calculateDimension(stringBounder), 2 * border); + } + + public void drawU(UGraphic ug) { + orig.drawU(ug.apply(new UTranslate(border, border))); + } + + public void drawUntranslated(UGraphic ug, double minX, double minY) { + final Dimension2D dim = orig.calculateDimension(ug.getStringBounder()); + neighborhood.drawU(ug, minX + border, minY + border, bibliotekon, dim); + } + + public ShapeType getShapeType() { + return orig.getShapeType(); + } + + public int getShield() { + return orig.getShield(); + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/Untranslated.java b/src/net/sourceforge/plantuml/svek/Untranslated.java new file mode 100644 index 000000000..62090fbf5 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/Untranslated.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: 4236 $ + * + */ +package net.sourceforge.plantuml.svek; + +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public interface Untranslated extends IEntityImage { + + public void drawUntranslated(UGraphic ug, double minX, double minY); + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java new file mode 100644 index 000000000..461fe6073 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.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: 4236 $ + * + */ +package net.sourceforge.plantuml.svek.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterfaceEye2; +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.UTranslate; + +class ExtremityParenthesis2 extends Extremity { + + private final Point2D contact; + private final Point2D center; + + private final double ortho; + private final double ang = 30; + + public ExtremityParenthesis2(Point2D contact, double ortho, Point2D p1) { + this.contact = new Point2D.Double(contact.getX(), contact.getY()); + this.ortho = ortho; + final double dx = p1.getX() - contact.getX(); + final double dy = p1.getY() - contact.getY(); + final double distance1 = Math.round(contact.distance(p1)); + // System.err.println("distance=" + distance1); + final double len = Math.round(distance1 + EntityImageLollipopInterfaceEye2.SIZE / 2); + this.center = new Point2D.Double(contact.getX() + dx / distance1 * len, contact.getY() + dy / distance1 * len); + } + + public void drawU(UGraphic ug) { + final double deg = -ortho * 180 / Math.PI + 90 - ang; + // final Point2D other = new Point2D.Double(contact.getX() + 10 * Math.cos(deg), contact.getY() + 10 + // * Math.sin(deg)); + // final ULine line = new ULine(1, 1); + // ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(new UTranslate(contact.getX(), contact.getY())) + // .draw(line); + // ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UTranslate(center.getX(), + // center.getY())).draw(line); + // // final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, deg, 2 * ang); + // // ug.apply(new UStroke(1.5)).apply(new UTranslate(dest.getX() - radius2, dest.getY() - radius2)).draw(arc1); + // + final double size = Math.round(contact.distance(center)); + // System.err.println("size=" + size); + final UEllipse circle = new UEllipse(size * 2, size * 2, deg, 2 * ang); + ug.apply(new UTranslate(center.getX() - size, center.getY() - size)).draw(circle); + + } +} diff --git a/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java b/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java new file mode 100644 index 000000000..07a9a50f9 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.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: 5183 $ + * + */ +package net.sourceforge.plantuml.svek.image; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +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.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ConnectedCircle implements UDrawable { + + private final double radius; + private final List angles = new ArrayList(); + private final List points = new ArrayList(); + + public ConnectedCircle(double radius) { + this.radius = radius; + } + + public void drawU(UGraphic ug) { + final UEllipse circle = new UEllipse(2 * radius, 2 * radius); + // ug.draw(circle); + for (Double angle : angles) { + final double delta = 30; + final UEllipse part = new UEllipse(2 * radius, 2 * radius, angle - delta, 2 * delta); + ug.draw(part); + } + ug = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(new UChangeBackColor(HtmlColorUtils.GREEN)); + for (Point2D pt : points) { + final UTranslate tr = new UTranslate(pt); + // ug.apply(tr).draw(new UEllipse(2, 2)); + } + + } + + public void addSecondaryConnection(Point2D pt) { + points.add(pt); + // double angle = Math.atan2(pt.getY() - radius, pt.getX() - radius); + // double angle = Math.atan2(pt.getX() - radius, pt.getY() - radius); + double angle = Math.atan2(radius - pt.getY(), pt.getX() - radius); + angle = angle * 180.0 / Math.PI; + System.err.println("pt1=" + pt + " " + angle); + angles.add(angle); + + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java new file mode 100644 index 000000000..e6de6b6ce --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java @@ -0,0 +1,139 @@ +/* ======================================================================== + * 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.svek.image; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.List; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.svek.AbstractEntityImage; +import net.sourceforge.plantuml.svek.Bibliotekon; +import net.sourceforge.plantuml.svek.Line; +import net.sourceforge.plantuml.svek.ShapeType; +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.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class EntityImageLollipopInterfaceEye1 extends AbstractEntityImage { + + private static final int SIZE = 24; + private final TextBlock desc; + private final Bibliotekon bibliotekon; + final private Url url; + + public EntityImageLollipopInterfaceEye1(ILeaf entity, ISkinParam skinParam, Bibliotekon bibliotekon) { + super(entity, skinParam); + this.bibliotekon = bibliotekon; + final Stereotype stereotype = entity.getStereotype(); + this.desc = TextBlockUtils.create( + entity.getDisplay(), + new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.url = entity.getUrl99(); + + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(SIZE, SIZE); + } + + final public void drawU(UGraphic ug) { + ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo()))); + ug = ug.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground, + getStereo()))); + if (url != null) { + ug.startUrl(url); + } + final double sizeSmall = 14; + final double diff = (SIZE - sizeSmall) / 2; + final UEllipse circle1 = new UEllipse(sizeSmall, sizeSmall); + if (getSkinParam().shadowing()) { + // circle.setDeltaShadow(4); + } + ug.apply(new UStroke(1.5)).apply(new UTranslate(diff, diff)).draw(circle1); + ug = ug.apply(new UChangeBackColor(null)); + + Point2D pos = bibliotekon.getShape(getEntity()).getPosition(); + + final List lines = bibliotekon.getAllLineConnectedTo(getEntity()); + final UTranslate reverse = new UTranslate(pos).reverse(); + final ConnectedCircle connectedCircle = new ConnectedCircle(SIZE / 2); + for (Line line : lines) { + Point2D pt = line.getMyPoint(getEntity()); + pt = reverse.getTranslated(pt); + connectedCircle.addSecondaryConnection(pt); + + } + // connectedCircle.drawU(ug.apply(new UStroke(1.5))); + connectedCircle.drawU(ug); + + // + // final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); + // final double widthDesc = dimDesc.getWidth(); + // // final double totalWidth = Math.max(widthDesc, SIZE); + // + // final double x = SIZE / 2 - widthDesc / 2; + // final double y = SIZE; + // desc.drawU(ug.apply(new UTranslate(x, y))); + if (url != null) { + ug.closeAction(); + } + } + + public ShapeType getShapeType() { + return ShapeType.CIRCLE; + } + + public int getShield() { + return 0; + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java new file mode 100644 index 000000000..36ac1cfa7 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java @@ -0,0 +1,145 @@ +/* ======================================================================== + * 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.svek.image; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityPortion; +import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.PortionShower; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +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.SymbolContext; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.svek.AbstractEntityImage; +import net.sourceforge.plantuml.svek.ShapeType; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage { + + public static final double SIZE = 14; + private final TextBlock desc; + private final TextBlock stereo; + private final SymbolContext ctx; + final private Url url; + + public EntityImageLollipopInterfaceEye2(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) { + super(entity, skinParam); + final Stereotype stereotype = entity.getStereotype(); + + final USymbol symbol = entity.getUSymbol() == null ? (skinParam.useUml2ForComponent() ? USymbol.COMPONENT2 + : USymbol.COMPONENT1) : entity.getUSymbol(); + if (symbol == null) { + throw new IllegalArgumentException(); + } + + this.desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, + stereotype, symbol.manageHorizontalLine(), false); + + this.url = entity.getUrl99(); + + HtmlColor backcolor = getEntity().getSpecificBackColor(); + if (backcolor == null) { + backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo()); + } + // backcolor = HtmlColorUtils.BLUE; + final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), getStereo()); + this.ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow( + getSkinParam().shadowing()); + + if (stereotype != null && stereotype.getLabel(false) != null + && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) { + stereo = TextBlockUtils.create( + Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), + new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + symbol.getFontParamStereotype(), stereotype), SkinParamUtils.getFontColor(getSkinParam(), + symbol.getFontParamStereotype(), null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + } else { + stereo = TextBlockUtils.empty(0, 0); + } + + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(SIZE, SIZE); + } + + final public void drawU(UGraphic ug) { + if (url != null) { + ug.startUrl(url); + } + final UEllipse circle = new UEllipse(SIZE, SIZE); + if (getSkinParam().shadowing()) { + circle.setDeltaShadow(4); + } + ctx.apply(ug).draw(circle); + + final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); + final double x1 = SIZE / 2 - dimDesc.getWidth() / 2; + final double y1 = SIZE * 1.4; + desc.drawU(ug.apply(new UTranslate(x1, y1))); + + final Dimension2D dimStereo = stereo.calculateDimension(ug.getStringBounder()); + final double x2 = SIZE / 2 - dimStereo.getWidth() / 2; + final double y2 = -dimStereo.getHeight(); + stereo.drawU(ug.apply(new UTranslate(x2, y2))); + + if (url != null) { + ug.closeAction(); + } + } + + public ShapeType getShapeType() { + return ShapeType.CIRCLE; + } + + public int getShield() { + return 0; + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java new file mode 100644 index 000000000..4797d5c64 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java @@ -0,0 +1,122 @@ +/* ======================================================================== + * 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.svek.image; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineConfigurable; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.cucadiagram.Member; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +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.svek.AbstractEntityImage; +import net.sourceforge.plantuml.svek.ShapeType; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; + +public class EntityImageState2 extends AbstractEntityImage { + + final private Url url; + + final private LineConfigurable lineConfig; + + private final TextBlock asSmall; + + public EntityImageState2(IEntity entity, ISkinParam skinParam) { + super(entity, skinParam); + this.lineConfig = entity; + final Stereotype stereotype = entity.getStereotype(); + + Display list = Display.empty(); + for (Member att : entity.getFieldsToDisplay()) { + list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); + } + + final USymbol symbol = USymbol.FRAME; + + HtmlColor backcolor = getEntity().getSpecificBackColor(); + if (backcolor == null) { + backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo()); + } + // backcolor = HtmlColorUtils.BLUE; + final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), getStereo()); + + final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow( + getSkinParam().shadowing()); + + this.url = entity.getUrl99(); + TextBlock stereo = TextBlockUtils.empty(0, 0); + + final TextBlock desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, + HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false); + + asSmall = symbol.asSmall(desc, stereo, ctx); + + } + + public ShapeType getShapeType() { + return ShapeType.RECTANGLE; + } + + public int getShield() { + return 0; + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return asSmall.calculateDimension(stringBounder); + } + + final public void drawU(UGraphic ug) { + if (url != null) { + ug.startUrl(url); + } + asSmall.drawU(ug); + + if (url != null) { + ug.closeAction(); + } + } + +} diff --git a/src/net/sourceforge/plantuml/swing/ImageHelper.java b/src/net/sourceforge/plantuml/swing/ImageHelper.java new file mode 100644 index 000000000..697992401 --- /dev/null +++ b/src/net/sourceforge/plantuml/swing/ImageHelper.java @@ -0,0 +1,172 @@ +/* ======================================================================== + * 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: Zane D. Purvis + * + * Revision $Revision: 5885 $ + * + */ +package net.sourceforge.plantuml.swing; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.RenderingHints; +import java.awt.Transparency; +import java.awt.image.BufferedImage; + +/** + * A collection of methods to help with processing images. A majority of this code was originally found online. + */ +public class ImageHelper { + /** + * Returns a scaled instance of a {@code BufferedImage}. + * + * Modified from: https://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html + * + * @param img + * the original image to be scaled + * @param targetDim + * the desired dimensions of the scaled instance, in pixels + * @param hint + * RenderingHints used when scaling the image + * @param higherQuality + * if true, this method will use a multi-step scaling technique that provides higher quality than the + * usual one-step technique (only useful in downscaling cases, targetDim is smaller than the original + * dimensions, and generally only when the {@code BILINEAR} hint is specified) + * @return a scaled version of the original {@code BufferedImage} + */ + public static BufferedImage getScaledInstance(BufferedImage img, Dimension targetDim, RenderingHints hints, + boolean higherQuality) { + final int targetWidth = targetDim.width; + final int targetHeight = targetDim.height; + final int type = (img.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB + : BufferedImage.TYPE_INT_ARGB; + BufferedImage ret = (BufferedImage) img; + int w; + int h; + if (higherQuality) { + // Use multi-step technique: start with original size, then + // scale down in multiple passes with drawImage() + // until the target size is reached + w = img.getWidth(); + h = img.getHeight(); + } else { + // Use one-step technique: scale directly from original + // size to target size with a single drawImage() call + w = targetWidth; + h = targetHeight; + } + + do { + if (higherQuality && w > targetWidth) { + w /= 2; + if (w < targetWidth) { + w = targetWidth; + } + } + + if (higherQuality && h > targetHeight) { + h /= 2; + if (h < targetHeight) { + h = targetHeight; + } + } + + final BufferedImage tmp = new BufferedImage(w, h, type); + final Graphics2D g2 = tmp.createGraphics(); + g2.setRenderingHints(hints); + g2.drawImage(ret, 0, 0, w, h, null); + g2.dispose(); + + ret = tmp; + } while (w != targetWidth || h != targetHeight); + + return ret; + } + + /** + * Converts an Image to a BufferedImage. + * + * From: http://stackoverflow.com/questions/13605248/java-converting-image-to-bufferedimage + */ + public static BufferedImage toBufferedImage(Image img) { + if (img instanceof BufferedImage) { + return (BufferedImage) img; + } + // Create a buffered image with transparency + final BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), + BufferedImage.TYPE_INT_ARGB); + + // Draw the image on to the buffered image + final Graphics2D bGr = bimage.createGraphics(); + bGr.drawImage(img, 0, 0, null); + bGr.dispose(); + + return bimage; + } + + /** + * Calculates the dimensions of a scaled image given the dimensions of an image and the area it is to be drawn in + * while preserving aspect ratio. + * + * From: http://stackoverflow.com/questions/10245220/java-image-resize-maintain-aspect-ratio + * + * @param imgSize + * dimensions of the original image. + * @param boundary + * dimensions of the area the image is to be drawn in. + */ + public static Dimension getScaledDimension(Dimension imgSize, Dimension boundary) { + + final int originalWidth = imgSize.width; + final int originaHeight = imgSize.height; + final int boundWidth = boundary.width; + final int boundHeight = boundary.height; + int newWidth = originalWidth; + int newHeight = originaHeight; + + // first check if we need to scale width + if (originalWidth > boundWidth) { + // scale width to fit + newWidth = boundWidth; + // scale height to maintain aspect ratio + newHeight = (newWidth * originaHeight) / originalWidth; + } + + // then check if we need to scale even with the new height + if (newHeight > boundHeight) { + // scale height to fit instead + newHeight = boundHeight; + // scale width to maintain aspect ratio + newWidth = (newHeight * originalWidth) / originaHeight; + } + + return new Dimension(newWidth, newHeight); + } +} diff --git a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java new file mode 100644 index 000000000..0c1f9e147 --- /dev/null +++ b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java @@ -0,0 +1,301 @@ +/* ======================================================================== + * 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: 12561 $ + * + */ +package net.sourceforge.plantuml.tikz; + +import java.awt.Color; +import java.awt.geom.PathIterator; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.eps.EpsGraphics; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.USegment; +import net.sourceforge.plantuml.ugraphic.USegmentType; +import net.sourceforge.plantuml.version.Version; + +public class TikzGraphics { + + // https://www.sharelatex.com/blog/2013/08/27/tikz-series-pt1.html + // http://cremeronline.com/LaTeX/minimaltikz.pdf + + private final List cmd = new ArrayList(); + + private Color color = Color.BLACK; + private Color fillcolor = Color.BLACK; + private double thickness = 1.0; + private String dash = null; + + private final Map colornames = new LinkedHashMap(); + + private String getColorName(Color c) { + if (c.equals(Color.WHITE)) { + return "white"; + } + if (c.equals(Color.BLACK)) { + return "black"; + } + final String result = colornames.get(c); + if (result == null) { + throw new IllegalArgumentException(); + } + return result; + } + + public void createData(OutputStream os) throws IOException { + out(os, "\\documentclass{article}"); + out(os, "\\usepackage{tikz}"); + out(os, "\\usepackage{aeguill}"); + // out(os, "\\usetikzlibrary{trees}"); + out(os, "\\begin{document}"); + out(os, "% generated by Plantuml " + Version.versionString()); + for (Map.Entry ent : colornames.entrySet()) { + out(os, definecolor(ent.getValue(), ent.getKey())); + + } + out(os, "\\begin{tikzpicture}[yscale=-1]"); + for (String s : cmd) { + out(os, s); + } + out(os, "\\end{tikzpicture}"); + out(os, "\\end{document}"); + } + + private String definecolor(String name, Color color) { + return "\\definecolor{" + name + "}{RGB}{" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + + "}"; + } + + public void rectangle(double x, double y, double width, double height) { + final StringBuilder sb = new StringBuilder(); + sb.append("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + if (color == null) { + sb.append("color=" + getColorName(fillcolor) + ","); + } + } + sb.append("line width=" + thickness + "pt] "); + sb.append(couple(x, y) + " rectangle " + couple(x + width, y + height)); + sb.append(";"); + cmd.add(sb.toString()); + } + + private String couple(double x, double y) { + return "(" + format(x) + "pt," + format(y) + "pt)"; + } + + private String format(double x) { + return EpsGraphics.format(x); + } + + private void out(OutputStream os, String s) throws IOException { + os.write(s.getBytes()); + os.write("\n".getBytes()); + } + + public void text(double x, double y, String text) { + final String s = "\\node at " + couple(x, y) + "[below right]{" + protectText(text) + "};"; + cmd.add(s); + } + + private String protectText(String text) { + text = text.replaceAll("_", "\\\\_"); + text = text.replaceAll("\u00AB", "\\\\guillemotleft "); + text = text.replaceAll("\u00BB", "\\\\guillemotright "); + text = text.replaceAll("<", "\\\\textless "); + text = text.replaceAll(">", "\\\\textgreater "); + return text; + } + + public void line(double x1, double y1, double x2, double y2) { + final StringBuilder sb = new StringBuilder(); + sb.append("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + sb.append("line width=" + thickness + "pt"); + if (dash != null) { + sb.append(",dash pattern=" + dash); + } + sb.append("] "); + sb.append(couple(x1, y1)); + sb.append(" -- "); + sb.append(couple(x2, y2)); + sb.append(";"); + cmd.add(sb.toString()); + } + + public void polygon(double[] points) { + final StringBuilder sb = new StringBuilder("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + } + sb.append("line width=" + thickness + "pt]"); + sb.append(" "); + for (int i = 0; i < points.length; i += 2) { + sb.append(couple(points[i], points[i + 1])); + sb.append(" -- "); + } + sb.append("cycle;"); + cmd.add(sb.toString()); + } + + public void upath(double x, double y, UPath path) { + final StringBuilder sb = new StringBuilder("\\draw[color=" + getColorName(color) + ",line width=" + thickness + + "pt] "); + for (USegment seg : path) { + final USegmentType type = seg.getSegmentType(); + final double coord[] = seg.getCoord(); + if (type == USegmentType.SEG_MOVETO) { + sb.append(couple(coord[0] + x, coord[1] + y)); + } else if (type == USegmentType.SEG_LINETO) { + sb.append(" -- "); + sb.append(couple(coord[0] + x, coord[1] + y)); + } else if (type == USegmentType.SEG_QUADTO) { + throw new UnsupportedOperationException(); + } else if (type == USegmentType.SEG_CUBICTO) { + // curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y); + sb.append(" ..controls "); + sb.append(couple(coord[0] + x, coord[1] + y)); + sb.append(" and "); + sb.append(couple(coord[2] + x, coord[3] + y)); + sb.append(" .. "); + sb.append(couple(coord[4] + x, coord[5] + y)); + } else if (type == USegmentType.SEG_CLOSE) { + // Nothing + } else { + Log.println("unknown " + seg); + } + } + sb.append(";"); + cmd.add(sb.toString()); + } + + public void ellipse(double x, double y, double width, double height) { + final StringBuilder sb = new StringBuilder(); + sb.append("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + } + sb.append("line width=" + thickness + "pt] " + couple(x, y) + " ellipse (" + format(width) + "pt and " + + format(height) + "pt);"); + cmd.add(sb.toString()); + } + + public void drawPathIterator(double x, double y, PathIterator path) { + final StringBuilder sb = new StringBuilder("\\draw[color=" + getColorName(color) + ",fill=" + + getColorName(color) + "] "); + final double coord[] = new double[6]; + while (path.isDone() == false) { + final int code = path.currentSegment(coord); + if (code == PathIterator.SEG_MOVETO) { + sb.append(couple(coord[0] + x, coord[1] + y)); + } else if (code == PathIterator.SEG_LINETO) { + sb.append(" -- "); + sb.append(couple(coord[0] + x, coord[1] + y)); + } else if (code == PathIterator.SEG_CLOSE) { + sb.append(";"); + cmd.add(sb.toString()); + sb.setLength(0); + sb.append("\\draw "); + } else if (code == PathIterator.SEG_CUBICTO) { + sb.append(" ..controls "); + sb.append(couple(coord[0] + x, coord[1] + y)); + sb.append(" and "); + sb.append(couple(coord[2] + x, coord[3] + y)); + sb.append(" .. "); + sb.append(couple(coord[4] + x, coord[5] + y)); + } else if (code == PathIterator.SEG_QUADTO) { + sb.append(" ..controls "); + sb.append(couple(coord[0] + x, coord[1] + y)); + sb.append(" .. "); + sb.append(couple(coord[2] + x, coord[3] + y)); + } else { + throw new UnsupportedOperationException("code=" + code); + } + + path.next(); + } + + // eps.fill(path.getWindingRule()); + + } + + public void setFillColor(Color c) { + // if (c == null) { + // c = Color.WHITE; + // } + this.fillcolor = c; + addColor(c); + } + + public void setStrokeColor(Color c) { + // if (c == null) { + // throw new IllegalArgumentException(); + // } + this.color = c; + addColor(c); + } + + private void addColor(Color c) { + if (c == null) { + return; + } + if (colornames.containsKey(c)) { + return; + } + final String name = "plantucolor" + String.format("%04d", colornames.size()); + colornames.put(c, name); + } + + public void setStrokeWidth(double thickness, String dash) { + this.thickness = thickness; + this.dash = dash; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java new file mode 100644 index 000000000..797be035f --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -0,0 +1,303 @@ +/* ======================================================================== + * 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.ugraphic; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.AffineTransform; +import java.awt.geom.Dimension2D; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Set; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; + +import net.sourceforge.plantuml.AnimatedGifEncoder; +import net.sourceforge.plantuml.CMapData; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.EmptyImageBuilder; +import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.anim.AffineTransformation; +import net.sourceforge.plantuml.anim.Animation; +import net.sourceforge.plantuml.api.ImageDataComplex; +import net.sourceforge.plantuml.api.ImageDataSimple; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.eps.EpsStrategy; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorGradient; +import net.sourceforge.plantuml.graphic.HtmlColorSimple; +import net.sourceforge.plantuml.graphic.HtmlColorTransparent; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; +import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps; +import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; +import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten; +import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5; +import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg; +import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz; +import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx; +import net.sourceforge.plantuml.StringUtils; + +public class ImageBuilder { + + private final ColorMapper colorMapper; + private final double dpiFactor; + private final HtmlColor mybackcolor; + private final String metadata; + private final String warningOrError; + private final double margin1; + private final double margin2; + private final Animation affineTransformations; + private final boolean useHandwritten; + + // private final AffineTransform affineTransform; + // private final boolean withMetadata; + // private final boolean useRedForError; + + private UDrawable udrawable; + + public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata, + String warningOrError, double margin1, double margin2, Animation affineTransformations, + boolean useHandwritten) { + this.colorMapper = colorMapper; + this.dpiFactor = dpiFactor; + this.mybackcolor = mybackcolor; + this.metadata = metadata; + this.warningOrError = warningOrError; + this.margin1 = margin1; + this.margin2 = margin2; + this.affineTransformations = affineTransformations; + this.useHandwritten = useHandwritten; + } + + public void addUDrawable(UDrawable udrawable) { + this.udrawable = udrawable; + } + + public ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os) throws IOException { + if (fileFormat == FileFormat.MJPEG) { + return writeImageMjpeg(os); + } else if (fileFormat == FileFormat.ANIMATED_GIF) { + return writeImageAnimatedGif(os); + } + return writeImageTOBEMOVED(fileFormat, os, affineTransformations); + } + + private ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os, Animation affineTransforms) + throws IOException { + final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true); + udrawable.drawU(limitFinder); + Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2, limitFinder.getMaxY() + + 1 + margin1 + margin2); + double dx = 0; + double dy = 0; + if (affineTransforms != null) { + final MinMax minmax = affineTransformations.getMinMax(dim); + affineTransforms.setDimension(dim); + dim = minmax.getDimension(); + dx = -minmax.getMinX(); + dy = -minmax.getMinY(); + } + + final UGraphic2 ug = createUGraphic(fileFormat, dim, affineTransforms, dx, dy); + udrawable.drawU(handwritten(ug.apply(new UTranslate(margin1, margin1)))); + ug.writeImageTOBEMOVED(os, metadata, 96); + os.flush(); + + if (ug instanceof UGraphicG2d) { + final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); + if (urls.size() > 0) { + final CMapData cmap = CMapData.cmapString(urls, dpiFactor); + return new ImageDataComplex(dim, cmap, warningOrError); + } + } + + return new ImageDataSimple(dim); + } + + private UGraphic handwritten(UGraphic ug) { + if (useHandwritten) { + return new UGraphicHandwritten(ug); + } + return ug; + } + + private ImageData writeImageMjpeg(OutputStream os) throws IOException { + + final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true); + udrawable.drawU(limitFinder); + final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2, + limitFinder.getMaxY() + 1 + margin1 + margin2); + + final File f = new File("c:/tmp.avi"); + + final int nbframe = 100; + + final MJPEGGenerator m = new MJPEGGenerator(f, getAviImage(null).getWidth(null), getAviImage(null).getHeight( + null), 12.0, nbframe); + for (int i = 0; i < nbframe; i++) { + // AffineTransform at = AffineTransform.getRotateInstance(1.0); + AffineTransform at = AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2); + at.rotate(90.0 * Math.PI / 180.0 * i / 100); + at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2); + // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0); + // final ImageIcon ii = new ImageIcon(getAviImage(at)); + // m.addImage(ii.getImage()); + throw new UnsupportedOperationException(); + } + m.finishAVI(); + + FileUtils.copyToStream(f, os); + + return new ImageDataSimple(dim); + + } + + private ImageData writeImageAnimatedGif(OutputStream os) throws IOException { + + final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true); + udrawable.drawU(limitFinder); + final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2, + limitFinder.getMaxY() + 1 + margin1 + margin2); + + final MinMax minmax = affineTransformations.getMinMax(dim); + + final AnimatedGifEncoder e = new AnimatedGifEncoder(); + // e.setQuality(1); + e.setRepeat(0); + e.start(os); + // e.setDelay(1000); // 1 frame per sec + // e.setDelay(100); // 10 frame per sec + e.setDelay(60); // 16 frame per sec + // e.setDelay(50); // 20 frame per sec + + for (AffineTransformation at : affineTransformations.getAll()) { + final ImageIcon ii = new ImageIcon(getAviImage(at)); + e.addFrame((BufferedImage) ii.getImage()); + } + e.finish(); + return new ImageDataSimple(dim); + + } + + private Image getAviImage(AffineTransformation affineTransform) throws IOException { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + writeImageTOBEMOVED(FileFormat.PNG, baos, Animation.singleton(affineTransform)); + baos.close(); + + final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final Image im = ImageIO.read(bais); + bais.close(); + return im; + } + + private UGraphic2 createUGraphic(FileFormat fileFormat, final Dimension2D dim, Animation affineTransforms, + double dx, double dy) { + switch (fileFormat) { + case PNG: + return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, affineTransforms, dx, dy); + case SVG: + return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor); + case EPS: + return new UGraphicEps(colorMapper, EpsStrategy.getDefault2()); + case EPS_TEXT: + return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT); + case HTML5: + return new UGraphicHtml5(colorMapper); + case VDX: + return new UGraphicVdx(colorMapper); + case LATEX: + return new UGraphicTikz(colorMapper); + default: + throw new UnsupportedOperationException(fileFormat.toString()); + } + } + + private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor) { + Color backColor = Color.WHITE; + if (mybackcolor instanceof HtmlColorSimple) { + backColor = colorMapper.getMappedColor(mybackcolor); + } + final UGraphicSvg ug; + if (mybackcolor instanceof HtmlColorGradient) { + ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale); + } else if (backColor == null || backColor.equals(Color.WHITE)) { + ug = new UGraphicSvg(colorMapper, false, scale); + } else { + ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale); + } + return ug; + + } + + private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim, + HtmlColor mybackcolor, Animation affineTransforms, double dx, double dy) { + Color backColor = Color.WHITE; + if (mybackcolor instanceof HtmlColorSimple) { + backColor = colorMapper.getMappedColor(mybackcolor); + } else if (mybackcolor instanceof HtmlColorTransparent) { + backColor = null; + } + + /* + * if (rotation) { builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() * + * dpiFactor), backColor); graphics2D = builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2); + * graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else { + */ + final EmptyImageBuilder builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), + (int) (dim.getHeight() * dpiFactor), backColor); + final Graphics2D graphics2D = builder.getGraphics2D(); + + // } + final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor, affineTransforms == null ? null + : affineTransforms.getFirst(), dx, dy); + ug.setBufferedImage(builder.getBufferedImage()); + final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage(); + if (mybackcolor instanceof HtmlColorGradient) { + ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight())); + } + + return ug; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/Scalable.java b/src/net/sourceforge/plantuml/ugraphic/Scalable.java new file mode 100644 index 000000000..ac0578f33 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/Scalable.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: 12235 $ + * + */ +package net.sourceforge.plantuml.ugraphic; + +public interface Scalable { + + public UShape getScaled(double scale); +} diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java new file mode 100644 index 000000000..50e760be3 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java @@ -0,0 +1,150 @@ +/* ======================================================================== + * 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.ugraphic; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.graphic.StringBounder; + +public class SlotFinderX implements UGraphic { + + public boolean isSpecialTxt() { + return false; + } + + public UGraphic apply(UChange change) { + if (change instanceof UTranslate) { + return new SlotFinderX(stringBounder, xslot, yslot, translate.compose((UTranslate) change)); + } else if (change instanceof UStroke) { + return new SlotFinderX(this); + } else if (change instanceof UChangeBackColor) { + return new SlotFinderX(this); + } else if (change instanceof UChangeColor) { + return new SlotFinderX(this); + } + throw new UnsupportedOperationException(); + } + + private final SlotSet xslot; + private final SlotSet yslot; + private final StringBounder stringBounder; + private final UTranslate translate; + + public SlotFinderX(StringBounder stringBounder) { + this(stringBounder, new SlotSet(), new SlotSet(), new UTranslate()); + } + + private SlotFinderX(StringBounder stringBounder, SlotSet xslot, SlotSet yslot, UTranslate translate) { + this.stringBounder = stringBounder; + this.xslot = xslot; + this.yslot = yslot; + this.translate = translate; + } + + private SlotFinderX(SlotFinderX other) { + this(other.stringBounder, other.xslot, other.yslot, other.translate); + } + + public StringBounder getStringBounder() { + return stringBounder; + } + + public UParam getParam() { + return new UParamNull(); + } + + public void draw(UShape shape) { + final double x = translate.getDx(); + final double y = translate.getDy(); + if (shape instanceof URectangle) { + drawRectangle(x, y, (URectangle) shape); + } else if (shape instanceof UPolygon) { + drawPolygon(x, y, (UPolygon) shape); + } else if (shape instanceof UEllipse) { + drawEllipse(x, y, (UEllipse) shape); + } else if (shape instanceof UText) { + drawText(x, y, (UText) shape); + } else if (shape instanceof UEmpty) { + drawEmpty(x, y, (UEmpty) shape); + } + } + + private void drawEmpty(double x, double y, UEmpty shape) { + xslot.addSlot(x, x + shape.getWidth()); + yslot.addSlot(y, y + shape.getHeight()); + } + + private void drawText(double x, double y, UText shape) { + final TextLimitFinder finder = new TextLimitFinder(stringBounder, false); + finder.apply(new UTranslate(x, y)).draw(shape); + xslot.addSlot(finder.getMinX(), finder.getMaxX()); + yslot.addSlot(finder.getMinY(), finder.getMaxY()); + } + + private void drawEllipse(double x, double y, UEllipse shape) { + xslot.addSlot(x, x + shape.getWidth()); + yslot.addSlot(y, y + shape.getHeight()); + } + + private void drawPolygon(double x, double y, UPolygon shape) { + xslot.addSlot(x + shape.getMinX(), x + shape.getMaxX()); + yslot.addSlot(y + shape.getMinY(), y + shape.getMaxY()); + } + + private void drawRectangle(double x, double y, URectangle shape) { + xslot.addSlot(x, x + shape.getWidth()); + yslot.addSlot(y, y + shape.getHeight()); + } + + public ColorMapper getColorMapper() { + return new ColorMapperIdentity(); + } + + public void startUrl(Url url) { + } + + public void closeAction() { + } + + public SlotSet getXSlotSet() { + return xslot; + } + + public SlotSet getYSlotSet() { + return yslot; + } + + public void flushUg() { + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java new file mode 100644 index 000000000..9df8ead5a --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.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: 13805 $ + * + */ +package net.sourceforge.plantuml.ugraphic; + +import java.io.IOException; +import java.io.OutputStream; + +public interface UGraphic2 extends UGraphic { + + public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException; +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java new file mode 100644 index 000000000..326097f5f --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.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: 5183 $ + * + */ +package net.sourceforge.plantuml.ugraphic; + +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.graphic.UGraphicDelegator; + +public class UGraphicCompress2 extends UGraphicDelegator { + + public UGraphic apply(UChange change) { + if (change instanceof UTranslate) { + return new UGraphicCompress2(getUg(), compressionTransform, translate.compose((UTranslate) change)); + } else if (change instanceof UStroke || change instanceof UChangeBackColor || change instanceof UChangeColor) { + return new UGraphicCompress2(getUg().apply(change), compressionTransform, translate); + } + throw new UnsupportedOperationException(); + } + + private final CompressionTransform compressionTransform; + private final UTranslate translate; + + public UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform) { + this(ug, compressionTransform, new UTranslate()); + } + + private UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform, UTranslate translate) { + super(ug); + this.compressionTransform = compressionTransform; + this.translate = translate; + } + + public void draw(UShape shape) { + final double x = translate.getDx(); + final double y = translate.getDy(); + if (shape instanceof ULine) { + drawLine(x, y, (ULine) shape); + } else if (shape instanceof Snake) { + drawSnake(x, y, (Snake) shape); + } else { + getUg().apply(new UTranslate(ct(x), y)).draw(shape); + } + } + + private void drawSnake(double x, double y, Snake shape) { + final Snake transformed = shape.translate(new UTranslate(x, y)).transformX(compressionTransform); + getUg().draw(transformed); + } + + private void drawLine(double x, double y, ULine shape) { + drawLine(ct(x), y, ct(x + shape.getDX()), y + shape.getDY()); + } + + private double ct(double v) { + return compressionTransform.transform(v); + } + + private void drawLine(double x1, double y1, double x2, double y2) { + final double xmin = Math.min(x1, x2); + final double xmax = Math.max(x1, x2); + final double ymin = Math.min(y1, y2); + final double ymax = Math.max(y1, y2); + getUg().apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, ymax - ymin)); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java new file mode 100644 index 000000000..133854f6d --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.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: 13989 $ + * + */ +package net.sourceforge.plantuml.ugraphic; + +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.EnsureVisible; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlockUtils; + +public class UGraphicNull extends AbstractUGraphic implements EnsureVisible, UGraphic2 { + + @Override + protected AbstractCommonUGraphic copyUGraphic() { + return new UGraphicNull(this); + } + + private UGraphicNull(UGraphicNull other) { + super(other); + } + + public UGraphicNull() { + super(new ColorMapperIdentity(), "foo"); + } + + public StringBounder getStringBounder() { + return TextBlockUtils.getDummyStringBounder(); + } + + public void startUrl(Url url) { + } + + public void closeAction() { + } + + public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException { + } + + public void ensureVisible(double x, double y) { + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UScale.java b/src/net/sourceforge/plantuml/ugraphic/UScale.java new file mode 100644 index 000000000..2f4f9bb58 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/UScale.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: 9786 $ + * + */ +package net.sourceforge.plantuml.ugraphic; + + +public class UScale implements UChange { + + private final double scale; + + @Override + public String toString() { + return "scale scale=" + scale; + } + + public UScale(double scale) { + this.scale = scale; + } + + public double getScale() { + return scale; + } + +// public Point2D getTranslated(Point2D p) { +// if (p == null) { +// return null; +// } +// return new Point2D.Double(p.getX() + dx, p.getY() + dy); +// } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java new file mode 100644 index 000000000..eb0dd8fa2 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java @@ -0,0 +1,765 @@ +/* ======================================================================== + * 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: Thierry Kormann + * + * Revision $Revision: 3837 $ + * + */ +package net.sourceforge.plantuml.ugraphic.arc; + +/* + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + */ + +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Arc2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +/** + * The ExtendedGeneralPath class represents a geometric path constructed from straight lines, quadratic and + * cubic (Bezier) curves and elliptical arc. This class delegates lines and curves to an enclosed + * GeneralPath. Elliptical arc is implemented using an Arc2D in double precision. + * + *

+ * Warning : An elliptical arc may be composed of several path segments. For futher details, see the SVG + * Appendix F.6 + * + * @author Thierry Kormann + * @version $Id: ExtendedGeneralPath.java 594018 2007-11-12 04:17:41Z cam $ + */ +public class ExtendedGeneralPath implements Shape, Cloneable { + + /** The enclosed general path. */ + private GeneralPath path; + + private int numVals = 0; + private int numSeg = 0; + private double[] values = null; + private int[] types = null; + + private double mx; + private double my; + private double cx; + private double cy; + + /** + * Constructs a new ExtendedGeneralPath. + */ + public ExtendedGeneralPath() { + path = new GeneralPath(); + } + + /** + * Constructs a new ExtendedGeneralPath with the specified winding rule to control operations that + * require the interior of the path to be defined. + */ + public ExtendedGeneralPath(int rule) { + path = new GeneralPath(rule); + } + + /** + * Constructs a new ExtendedGeneralPath object with the specified winding rule and the specified + * initial capacity to store path coordinates. + */ + public ExtendedGeneralPath(int rule, int initialCapacity) { + path = new GeneralPath(rule, initialCapacity); + } + + /** + * Constructs a new ExtendedGeneralPath object from an arbitrary Shape object. + */ + public ExtendedGeneralPath(Shape s) { + this(); + append(s, false); + } + + /** + * Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a + * flag to indicate if we increase or decrease the angles and the final point of the arc. + * + * @param rx + * the x radius of the ellipse + * @param ry + * the y radius of the ellipse + * + * @param angle + * the angle from the x-axis of the current coordinate system to the x-axis of the ellipse in degrees. + * + * @param largeArcFlag + * the large arc flag. If true the arc spanning less than or equal to 180 degrees is chosen, otherwise + * the arc spanning greater than 180 degrees is chosen + * + * @param sweepFlag + * the sweep flag. If true the line joining center to arc sweeps through decreasing angles otherwise it + * sweeps through increasing angles + * + * @param x + * the absolute x coordinate of the final point of the arc. + * @param y + * the absolute y coordinate of the final point of the arc. + */ + public void arcTo(double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag, + double x, double y) { + + // Ensure radii are valid + if (rx == 0 || ry == 0) { + lineTo(x, y); + return; + } + + checkMoveTo(); // check if prev command was moveto + + // Get the current (x, y) coordinates of the path + final double x0 = cx; + final double y0 = cy; + if (x0 == x && y0 == y) { + // If the endpoints (x, y) and (x0, y0) are identical, then this + // is equivalent to omitting the elliptical arc segment entirely. + return; + } + + final Arc2D arc = computeArc(x0, y0, rx, ry, angle, largeArcFlag, sweepFlag, x, y); + if (arc == null) { + return; + } + + final AffineTransform t = AffineTransform.getRotateInstance(Math.toRadians(angle), arc.getCenterX(), + arc.getCenterY()); + final Shape s = t.createTransformedShape(arc); + path.append(s, true); + + makeRoom(7); + types[numSeg++] = ExtendedPathIterator.SEG_ARCTO; + values[numVals++] = rx; + values[numVals++] = ry; + values[numVals++] = angle; + values[numVals++] = largeArcFlag ? 1 : 0; + values[numVals++] = sweepFlag ? 1 : 0; + cx = values[numVals++] = x; + cy = values[numVals++] = y; + } + + /** + * This constructs an unrotated Arc2D from the SVG specification of an Elliptical arc. To get the final arc you need + * to apply a rotation transform such as: + * + * AffineTransform.getRotateInstance (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2); + */ + public static Arc2D computeArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag, + boolean sweepFlag, double x, double y) { + // + // Elliptical arc implementation based on the SVG specification notes + // + + // Compute the half distance between the current and the final point + final double dx2 = (x0 - x) / 2.0; + final double dy2 = (y0 - y) / 2.0; + // Convert angle from degrees to radians + angle = Math.toRadians(angle % 360.0); + final double cosAngle = Math.cos(angle); + final double sinAngle = Math.sin(angle); + + // + // Step 1 : Compute (x1, y1) + // + final double x1 = cosAngle * dx2 + sinAngle * dy2; + final double y1 = -sinAngle * dx2 + cosAngle * dy2; + // Ensure radii are large enough + rx = Math.abs(rx); + ry = Math.abs(ry); + double prx = rx * rx; + double pry = ry * ry; + final double px1 = x1 * x1; + final double py1 = y1 * y1; + // check that radii are large enough + final double radiiCheck = px1 / prx + py1 / pry; + if (radiiCheck > 1) { + rx = Math.sqrt(radiiCheck) * rx; + ry = Math.sqrt(radiiCheck) * ry; + prx = rx * rx; + pry = ry * ry; + } + + // + // Step 2 : Compute (cx1, cy1) + // + double sign = (largeArcFlag == sweepFlag) ? -1 : 1; + double sq = ((prx * pry) - (prx * py1) - (pry * px1)) / ((prx * py1) + (pry * px1)); + sq = (sq < 0) ? 0 : sq; + final double coef = sign * Math.sqrt(sq); + final double cx1 = coef * ((rx * y1) / ry); + final double cy1 = coef * -((ry * x1) / rx); + + // + // Step 3 : Compute (cx, cy) from (cx1, cy1) + // + final double sx2 = (x0 + x) / 2.0; + final double sy2 = (y0 + y) / 2.0; + final double cx = sx2 + (cosAngle * cx1 - sinAngle * cy1); + final double cy = sy2 + (sinAngle * cx1 + cosAngle * cy1); + + // + // Step 4 : Compute the angleStart (angle1) and the angleExtent (dangle) + // + final double ux = (x1 - cx1) / rx; + final double uy = (y1 - cy1) / ry; + final double vx = (-x1 - cx1) / rx; + final double vy = (-y1 - cy1) / ry; + // Compute the angle start + double n = Math.sqrt((ux * ux) + (uy * uy)); + double p = ux; // (1 * ux) + (0 * uy) + sign = (uy < 0) ? -1.0 : 1.0; + double angleStart = Math.toDegrees(sign * Math.acos(p / n)); + + // Compute the angle extent + n = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy)); + p = ux * vx + uy * vy; + sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0; + double angleExtent = Math.toDegrees(sign * Math.acos(p / n)); + if (!sweepFlag && angleExtent > 0) { + angleExtent -= 360f; + } else if (sweepFlag && angleExtent < 0) { + angleExtent += 360f; + } + angleExtent %= 360f; + angleStart %= 360f; + + // + // We can now build the resulting Arc2D in double precision + // + final Arc2D.Double arc = new Arc2D.Double(); + arc.x = cx - rx; + arc.y = cy - ry; + arc.width = rx * 2.0; + arc.height = ry * 2.0; + arc.start = -angleStart; + arc.extent = -angleExtent; + + return arc; + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void moveTo(double x, double y) { + // Don't add moveto to general path unless there is a reason. + makeRoom(2); + types[numSeg++] = PathIterator.SEG_MOVETO; + cx = mx = values[numVals++] = x; + cy = my = values[numVals++] = y; + + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void lineTo(double x, double y) { + checkMoveTo(); // check if prev command was moveto + path.lineTo(x, y); + + makeRoom(2); + types[numSeg++] = PathIterator.SEG_LINETO; + cx = values[numVals++] = x; + cy = values[numVals++] = y; + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void quadTo(double x1, double y1, double x2, double y2) { + checkMoveTo(); // check if prev command was moveto + path.quadTo(x1, y1, x2, y2); + + makeRoom(4); + types[numSeg++] = PathIterator.SEG_QUADTO; + values[numVals++] = x1; + values[numVals++] = y1; + cx = values[numVals++] = x2; + cy = values[numVals++] = y2; + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { + checkMoveTo(); // check if prev command was moveto + path.curveTo(x1, y1, x2, y2, x3, y3); + + makeRoom(6); + types[numSeg++] = PathIterator.SEG_CUBICTO; + values[numVals++] = x1; + values[numVals++] = y1; + values[numVals++] = x2; + values[numVals++] = y2; + cx = values[numVals++] = x3; + cy = values[numVals++] = y3; + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void closePath() { + // Don't double close path. + if (numSeg != 0 && types[numSeg - 1] == PathIterator.SEG_CLOSE) { + return; + } + + // Only close path if the previous command wasn't a moveto + if (numSeg != 0 && types[numSeg - 1] != PathIterator.SEG_MOVETO) { + path.closePath(); + } + + makeRoom(0); + types[numSeg++] = PathIterator.SEG_CLOSE; + cx = mx; + cy = my; + } + + /** + * Checks if previous command was a moveto command, skipping a close command (if present). + */ + protected void checkMoveTo() { + if (numSeg == 0) { + return; + } + + switch (types[numSeg - 1]) { + + case PathIterator.SEG_MOVETO: + path.moveTo(values[numVals - 2], values[numVals - 1]); + break; + + case PathIterator.SEG_CLOSE: + if (numSeg == 1) { + return; + } + if (types[numSeg - 2] == PathIterator.SEG_MOVETO) { + path.moveTo(values[numVals - 2], values[numVals - 1]); + } + break; + + default: + break; + } + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void append(Shape s, boolean connect) { + append(s.getPathIterator(new AffineTransform()), connect); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void append(PathIterator pi, boolean connect) { + final double[] vals = new double[6]; + + while (!pi.isDone()) { + Arrays.fill(vals, 0); + int type = pi.currentSegment(vals); + pi.next(); + if (connect && numVals != 0) { + if (type == PathIterator.SEG_MOVETO) { + final double x = vals[0]; + final double y = vals[1]; + if (x != cx || y != cy) { + // Change MOVETO to LINETO. + type = PathIterator.SEG_LINETO; + } else { + // Redundent segment (move to current loc) drop it... + if (pi.isDone()) { + break; // Nothing interesting + } + type = pi.currentSegment(vals); + pi.next(); + } + } + connect = false; + } + + switch (type) { + case PathIterator.SEG_CLOSE: + closePath(); + break; + case PathIterator.SEG_MOVETO: + moveTo(vals[0], vals[1]); + break; + case PathIterator.SEG_LINETO: + lineTo(vals[0], vals[1]); + break; + case PathIterator.SEG_QUADTO: + quadTo(vals[0], vals[1], vals[2], vals[3]); + break; + case PathIterator.SEG_CUBICTO: + curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]); + break; + } + } + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void append(ExtendedPathIterator epi, boolean connect) { + final double[] vals = new double[7]; + while (!epi.isDone()) { + Arrays.fill(vals, 0); + int type = epi.currentSegment(vals); + epi.next(); + if (connect && numVals != 0) { + if (type == PathIterator.SEG_MOVETO) { + final double x = vals[0]; + final double y = vals[1]; + if ((x != cx) || (y != cy)) { + // Change MOVETO to LINETO. + type = PathIterator.SEG_LINETO; + } else { + // Redundant segment (move to current loc) drop it... + if (epi.isDone()) { + break; // Nothing interesting + } + type = epi.currentSegment(vals); + epi.next(); + } + } + connect = false; + } + + switch (type) { + case PathIterator.SEG_CLOSE: + closePath(); + break; + case PathIterator.SEG_MOVETO: + moveTo(vals[0], vals[1]); + break; + case PathIterator.SEG_LINETO: + lineTo(vals[0], vals[1]); + break; + case PathIterator.SEG_QUADTO: + quadTo(vals[0], vals[1], vals[2], vals[3]); + break; + case PathIterator.SEG_CUBICTO: + curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]); + break; + case ExtendedPathIterator.SEG_ARCTO: + arcTo(vals[0], vals[1], vals[2], vals[3] != 0, vals[4] != 0, vals[5], vals[6]); + break; + } + } + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public int getWindingRule() { + return path.getWindingRule(); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void setWindingRule(int rule) { + path.setWindingRule(rule); + } + + /** + * get the current position or null. + */ + public Point2D getCurrentPoint() { + if (numVals == 0) { + return null; + } + return new Point2D.Double(cx, cy); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void reset() { + path.reset(); + + numSeg = 0; + numVals = 0; + values = null; + types = null; + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public void transform(AffineTransform at) { + if (at.getType() != AffineTransform.TYPE_IDENTITY) { + throw new IllegalArgumentException("ExtendedGeneralPaths can not be transformed"); + } + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public Shape createTransformedShape(AffineTransform at) { + return path.createTransformedShape(at); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public Rectangle getBounds() { + return path.getBounds(); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public Rectangle2D getBounds2D() { + return path.getBounds2D(); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean contains(double x, double y) { + return path.contains(x, y); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean contains(Point2D p) { + return path.contains(p); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean contains(double x, double y, double w, double h) { + return path.contains(x, y, w, h); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean contains(Rectangle2D r) { + return path.contains(r); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean intersects(double x, double y, double w, double h) { + return path.intersects(x, y, w, h); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public boolean intersects(Rectangle2D r) { + return path.intersects(r); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public PathIterator getPathIterator(AffineTransform at) { + return path.getPathIterator(at); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public PathIterator getPathIterator(AffineTransform at, double flatness) { + return path.getPathIterator(at, flatness); + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public ExtendedPathIterator getExtendedPathIterator() { + return new EPI(); + } + + class EPI implements ExtendedPathIterator { + private int segNum = 0; + private int valsIdx = 0; + + public int currentSegment() { + return types[segNum]; + } + + public int currentSegment(double[] coords) { + final int ret = types[segNum]; + switch (ret) { + case SEG_CLOSE: + break; + case SEG_MOVETO: + case SEG_LINETO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx + 1]; + break; + case SEG_QUADTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx + 1]; + coords[2] = values[valsIdx + 2]; + coords[3] = values[valsIdx + 3]; + break; + case SEG_CUBICTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx + 1]; + coords[2] = values[valsIdx + 2]; + coords[3] = values[valsIdx + 3]; + coords[4] = values[valsIdx + 4]; + coords[5] = values[valsIdx + 5]; + break; + case SEG_ARCTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx + 1]; + coords[2] = values[valsIdx + 2]; + coords[3] = values[valsIdx + 3]; + coords[4] = values[valsIdx + 4]; + coords[5] = values[valsIdx + 5]; + coords[6] = values[valsIdx + 6]; + break; + } + return ret; + } + + public int getWindingRule() { + return path.getWindingRule(); + } + + public boolean isDone() { + return segNum == numSeg; + } + + public void next() { + final int type = types[segNum++]; + switch (type) { + case SEG_CLOSE: + break; + case SEG_MOVETO: // fallthrough is intended + case SEG_LINETO: + valsIdx += 2; + break; + case SEG_QUADTO: + valsIdx += 4; + break; + case SEG_CUBICTO: + valsIdx += 6; + break; + case SEG_ARCTO: + valsIdx += 7; + break; + } + } + } + + /** + * Delegates to the enclosed GeneralPath. + */ + public Object clone() { + try { + final ExtendedGeneralPath result = (ExtendedGeneralPath) super.clone(); + result.path = (GeneralPath) path.clone(); + + if (values != null) { + result.values = new double[values.length]; + System.arraycopy(values, 0, result.values, 0, values.length); + } + result.numVals = numVals; + + if (types != null) { + result.types = new int[types.length]; + System.arraycopy(types, 0, result.types, 0, types.length); + } + result.numSeg = numSeg; + + return result; + } catch (CloneNotSupportedException ex) { + ex.printStackTrace(); + } + return null; + } + + /** + * Make sure, that the requested number of slots in vales[] are available. Must be called even for numValues = 0, + * because it is also used for initialization of those arrays. + * + * @param numValues + * number of requested coordinates + */ + private void makeRoom(int numValues) { + if (values == null) { + values = new double[2 * numValues]; + types = new int[2]; + numVals = 0; + numSeg = 0; + return; + } + + final int newSize = numVals + numValues; + if (newSize > values.length) { + int nlen = values.length * 2; + if (nlen < newSize) { + nlen = newSize; + } + + final double[] nvals = new double[nlen]; + System.arraycopy(values, 0, nvals, 0, numVals); + values = nvals; + } + + if (numSeg == types.length) { + final int[] ntypes = new int[types.length * 2]; + System.arraycopy(types, 0, ntypes, 0, types.length); + types = ntypes; + } + } +} diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java new file mode 100644 index 000000000..609561213 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java @@ -0,0 +1,132 @@ +/* ======================================================================== + * 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: Thomas DeWeese + * + * Revision $Revision: 3837 $ + * + */ +package net.sourceforge.plantuml.ugraphic.arc; + +import java.awt.geom.PathIterator; + + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE + * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/** + * The ExtendedPathIterator class represents a geometric path constructed from straight lines, quadratic + * and cubic (Bezier) curves and elliptical arcs. This interface is identical to that of PathIterator except it can + * return SEG_ARCTO from currentSegment, also the array of values passed to currentSegment must be of length 7 or an + * error will be thrown. + * + * This does not extend PathIterator as it would break the interface contract for that class. + * + * @author Thomas DeWeese + * @version $Id: ExtendedPathIterator.java 475477 2006-11-15 22:44:28Z cam $ + */ +public interface ExtendedPathIterator { + + /** + * The segment type constant that specifies that the preceding subpath should be closed by appending a line segment + * back to the point corresponding to the most recent SEG_MOVETO. + */ + int SEG_CLOSE = PathIterator.SEG_CLOSE; + + /** + * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently + * specified point. + */ + int SEG_MOVETO = PathIterator.SEG_MOVETO; + + /** + * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently + * specified point. + */ + int SEG_LINETO = PathIterator.SEG_LINETO; + + /** + * The segment type constant for the pair of points that specify a quadratic parametric curve to be drawn from the + * most recently specified point. The curve is interpolated by solving the parametric control equation in the range + * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), and the final + * interpolated control point (P2). + */ + int SEG_QUADTO = PathIterator.SEG_QUADTO; + + /** + * The segment type constant for the set of 3 points that specify a cubic parametric curve to be drawn from the most + * recently specified point. The curve is interpolated by solving the parametric control equation in the range + * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), the second + * control point (P2), and the final interpolated control point (P3). + */ + int SEG_CUBICTO = PathIterator.SEG_CUBICTO; + + /** + * The segment type constant for an elliptical arc. This consists of Seven values [rx, ry, angle, largeArcFlag, + * sweepFlag, x, y]. rx, ry are the radious of the ellipse. angle is angle of the x axis of the ellipse. + * largeArcFlag is zero if the smaller of the two arcs are to be used. sweepFlag is zero if the 'left' branch is + * taken one otherwise. x and y are the destination for the ellipse. + */ + int SEG_ARCTO = 4321; + + /** + * The winding rule constant for specifying an even-odd rule for determining the interior of a path. The even-odd + * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is + * crossed by path segments an odd number of times. + */ + int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD; + + /** + * The winding rule constant for specifying a non-zero rule for determining the interior of a path. The non-zero + * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is + * crossed by path segments a different number of times in the counter-clockwise direction than the clockwise + * direction. + */ + int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO; + + int currentSegment(); + + int currentSegment(double[] coords); + + int getWindingRule(); + + boolean isDone(); + + void next(); +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java new file mode 100644 index 000000000..0cd93cd91 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java @@ -0,0 +1,156 @@ +/* ======================================================================== + * 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: 3837 $ + * + */ +package net.sourceforge.plantuml.ugraphic.g2d; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Path2D; + +import net.sourceforge.plantuml.golem.MinMaxDouble; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorGradient; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.USegment; +import net.sourceforge.plantuml.ugraphic.USegmentType; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver { + + private final double dpiFactor; + + public DriverPathG2dLegacy(double dpiFactor) { + this.dpiFactor = dpiFactor; + } + + public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) { + final UPath shape = (UPath) ushape; + DriverLineG2d.manageStroke(param, g2d); + + final Path2D.Double p = new Path2D.Double(); + boolean hasBezier = false; + final MinMaxDouble minMax = new MinMaxDouble(); + minMax.manage(x, y); + for (USegment seg : shape) { + final USegmentType type = seg.getSegmentType(); + final double coord[] = seg.getCoord(); + if (type == USegmentType.SEG_MOVETO) { + p.moveTo(x + coord[0], y + coord[1]); + minMax.manage(x + coord[0], y + coord[1]); + } else if (type == USegmentType.SEG_LINETO) { + p.lineTo(x + coord[0], y + coord[1]); + minMax.manage(x + coord[0], y + coord[1]); + } else if (type == USegmentType.SEG_CUBICTO) { + p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]); + minMax.manage(x + coord[4], y + coord[5]); + hasBezier = true; + } else { + throw new UnsupportedOperationException(); + } + } + + if (shape.isOpenIconic()) { + p.closePath(); + g2d.setColor(mapper.getMappedColor(param.getColor())); + g2d.fill(p); + return; + } + + // Shadow + if (shape.getDeltaShadow() != 0) { + if (hasBezier) { + drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor); + } else { + double lastX = 0; + double lastY = 0; + for (USegment seg : shape) { + final USegmentType type = seg.getSegmentType(); + final double coord[] = seg.getCoord(); + // Cast float for Java 1.5 + if (type == USegmentType.SEG_MOVETO) { + lastX = x + coord[0]; + lastY = y + coord[1]; + } else if (type == USegmentType.SEG_LINETO) { + final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]); + drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor); + lastX = x + coord[0]; + lastY = y + coord[1]; + } else { + throw new UnsupportedOperationException(); + } + } + } + } + + final HtmlColor back = param.getBackcolor(); + if (back instanceof HtmlColorGradient) { + final HtmlColorGradient gr = (HtmlColorGradient) back; + final char policy = gr.getPolicy(); + final GradientPaint paint; + if (policy == '|') { + paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2, + mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2, + mapper.getMappedColor(gr.getColor2())); + } else if (policy == '\\') { + paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr + .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr + .getColor2())); + } else if (policy == '-') { + paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(), + mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(), + mapper.getMappedColor(gr.getColor2())); + } else { + // for / + paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), + (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); + } + g2d.setPaint(paint); + g2d.fill(p); + } else if (back != null) { + g2d.setColor(mapper.getMappedColor(back)); + g2d.fill(p); + } + + if (param.getColor() != null) { + g2d.setColor(mapper.getMappedColor(param.getColor())); + g2d.draw(p); + } + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java new file mode 100644 index 000000000..dda13664f --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java @@ -0,0 +1,155 @@ +/* ======================================================================== + * 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: 3837 $ + * + */ +package net.sourceforge.plantuml.ugraphic.g2d; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; + +import net.sourceforge.plantuml.golem.MinMaxDouble; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorGradient; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.USegment; +import net.sourceforge.plantuml.ugraphic.USegmentType; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverPathOldG2d extends DriverShadowedG2d implements UDriver { + + private final double dpiFactor; + + public DriverPathOldG2d(double dpiFactor) { + this.dpiFactor = dpiFactor; + } + + public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) { + final UPath shape = (UPath) ushape; + DriverLineG2d.manageStroke(param, g2d); + + final GeneralPath p = new GeneralPath(); + boolean hasBezier = false; + final MinMaxDouble minMax = new MinMaxDouble(); + minMax.manage(x, y); + for (USegment seg : shape) { + final USegmentType type = seg.getSegmentType(); + final double coord[] = seg.getCoord(); + // Cast float for Java 1.5 + if (type == USegmentType.SEG_MOVETO) { + p.moveTo((float) (x + coord[0]), (float) (y + coord[1])); + minMax.manage(x + coord[0], y + coord[1]); + } else if (type == USegmentType.SEG_LINETO) { + p.lineTo((float) (x + coord[0]), (float) (y + coord[1])); + minMax.manage(x + coord[0], y + coord[1]); + } else if (type == USegmentType.SEG_CUBICTO) { + p.curveTo((float) (x + coord[0]), (float) (y + coord[1]), (float) (x + coord[2]), + (float) (y + coord[3]), (float) (x + coord[4]), (float) (y + coord[5])); + minMax.manage(x + coord[4], y + coord[5]); + hasBezier = true; + } else { + throw new UnsupportedOperationException(); + } + // bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + + // bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y + // + bez.ctrly2, x + bez.x2, y + bez.y2); + // p.append(bez, true); + } + // p.closePath(); + + // Shadow + if (shape.getDeltaShadow() != 0) { + if (hasBezier) { + drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor); + } else { + double lastX = 0; + double lastY = 0; + for (USegment seg : shape) { + final USegmentType type = seg.getSegmentType(); + final double coord[] = seg.getCoord(); + // Cast float for Java 1.5 + if (type == USegmentType.SEG_MOVETO) { + lastX = x + coord[0]; + lastY = y + coord[1]; + } else if (type == USegmentType.SEG_LINETO) { + final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]); + drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor); + lastX = x + coord[0]; + lastY = y + coord[1]; + } else { + throw new UnsupportedOperationException(); + } + } + } + } + + final HtmlColor back = param.getBackcolor(); + if (back instanceof HtmlColorGradient) { + final HtmlColorGradient gr = (HtmlColorGradient) back; + final char policy = gr.getPolicy(); + final GradientPaint paint; + if (policy == '|') { + paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2, + mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2, + mapper.getMappedColor(gr.getColor2())); + } else if (policy == '\\') { + paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr + .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr + .getColor2())); + } else if (policy == '-') { + paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(), + mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(), + mapper.getMappedColor(gr.getColor2())); + } else { + // for / + paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), + (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); + } + g2d.setPaint(paint); + g2d.fill(p); + } else if (back != null) { + g2d.setColor(mapper.getMappedColor(back)); + g2d.fill(p); + } + + if (param.getColor() != null) { + g2d.setColor(mapper.getMappedColor(param.getColor())); + g2d.draw(p); + } + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java new file mode 100644 index 000000000..63ffa34ae --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java @@ -0,0 +1,151 @@ +/* ======================================================================== + * 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: 13912 $ + * + */ +package net.sourceforge.plantuml.ugraphic.g2d; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.font.FontRenderContext; +import java.awt.font.TextLayout; +import java.awt.geom.Dimension2D; +import java.awt.geom.Rectangle2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.EnsureVisible; +import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.FontStyle; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.StringBounderUtils; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; +import net.sourceforge.plantuml.ugraphic.UText; + +public class DriverTextAsPathG2d implements UDriver { + + private final EnsureVisible visible; + private final FontRenderContext fontRenderContext; + + public DriverTextAsPathG2d(EnsureVisible visible, FontRenderContext fontRenderContext) { + this.visible = visible; + this.fontRenderContext = fontRenderContext; + } + + private static void printFont() { + final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + final String fontNames[] = ge.getAvailableFontFamilyNames(); + final int j = fontNames.length; + for (int i = 0; i < j; i++) { + Log.info("Available fonts: " + fontNames[i]); + } + } + + public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { + final UText shape = (UText) ushape; + final FontConfiguration fontConfiguration = shape.getFontConfiguration(); + + final UFont font = fontConfiguration.getFont().scaled(param.getScale()); + final Dimension2D dimBack = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText()); + if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { + final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor()); + if (extended != null) { + g2d.setColor(extended); + g2d.setBackground(extended); + g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack + .getHeight())); + } + } + visible.ensureVisible(x, y - dimBack.getHeight() + 1.5); + visible.ensureVisible(x + dimBack.getWidth(), y + 1.5); + + g2d.setFont(font.getFont()); + g2d.setColor(mapper.getMappedColor(fontConfiguration.getColor())); + final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext); + g2d.translate(x, y); + g2d.fill(t.getOutline(null)); + g2d.translate(-x, -y); + + if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { + final HtmlColor extended = fontConfiguration.getExtendedColor(); + if (extended != null) { + g2d.setColor(mapper.getMappedColor(extended)); + } + final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText()); + final int ypos = (int) (y + 2.5); + g2d.setStroke(new BasicStroke((float) 1)); + g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); + g2d.setStroke(new BasicStroke()); + } + if (fontConfiguration.containsStyle(FontStyle.WAVE)) { + final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText()); + final int ypos = (int) (y + 2.5) - 1; + final HtmlColor extended = fontConfiguration.getExtendedColor(); + if (extended != null) { + g2d.setColor(mapper.getMappedColor(extended)); + } + for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) { + g2d.drawLine(i, ypos - 0, i + 3, ypos + 1); + g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0); + } + } + if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { + final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText()); + final FontMetrics fm = g2d.getFontMetrics(font.getFont()); + final int ypos = (int) (y - fm.getDescent() - 0.5); + final HtmlColor extended = fontConfiguration.getExtendedColor(); + if (extended != null) { + g2d.setColor(mapper.getMappedColor(extended)); + } + g2d.setStroke(new BasicStroke((float) 1.5)); + g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); + g2d.setStroke(new BasicStroke()); + } + } + + static public Dimension2D calculateDimension(StringBounder stringBounder, UFont font, String text) { + final Dimension2D rect = stringBounder.calculateDimension(font, text); + double h = rect.getHeight(); + if (h < 10) { + h = 10; + } + return new Dimension2DDouble(rect.getWidth(), h); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java new file mode 100644 index 000000000..3f8862b5e --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java @@ -0,0 +1,136 @@ +/* ======================================================================== + * 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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import java.awt.geom.CubicCurve2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.Collection; + +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UPolygon; + +public class HandJiggle { + private final Collection points = new ArrayList(); + + private double startX; + private double startY; + private final double defaultVariation; + + public HandJiggle(double startX, double startY, double defaultVariation) { + this.startX = startX; + this.startY = startY; + this.defaultVariation = defaultVariation; + points.add(new Point2D.Double(startX, startY)); + } + + public HandJiggle(Point2D start, double defaultVariation) { + this(start.getX(), start.getY(), defaultVariation); + } + + public void addPoints(Point2D end) { + addPoints(end.getX(), end.getY()); + } + + public void addPoints(final double endX, final double endY) { + + final double diffX = Math.abs(endX - startX); + final double diffY = Math.abs(endY - startY); + final double distance = Math.sqrt(diffX * diffX + diffY * diffY); + if (distance < 0.001) { + return; + } + + int segments = (int) Math.round(distance / 10); + double variation = defaultVariation; + if (segments < 5) { + segments = 5; + variation /= 3; + } + + final double stepX = Math.signum(endX - startX) * diffX / segments; + final double stepY = Math.signum(endY - startY) * diffY / segments; + + final double fx = diffX / distance; + final double fy = diffY / distance; + + for (int s = 0; s < segments; s++) { + double x = stepX * s + startX; + double y = stepY * s + startY; + + final double offset = (Math.random() - 0.5) * variation; + points.add(new Point2D.Double(x - offset * fy, y - offset * fx)); + } + points.add(new Point2D.Double(endX, endY)); + + this.startX = endX; + this.startY = endY; + } + + public UPolygon toUPolygon() { + final UPolygon result = new UPolygon(); + for (Point2D p : points) { + result.addPoint(p.getX(), p.getY()); + } + return result; + } + + public UPath toUPath() { + UPath path = null; + for (Point2D p : points) { + if (path == null) { + path = new UPath(); + path.moveTo(p); + } else { + path.lineTo(p); + } + } + if (path == null) { + throw new IllegalStateException(); + } + return path; + } + + public void addCurve(CubicCurve2D curve) { + final double flatness = curve.getFlatness(); + final double dist = curve.getP1().distance(curve.getP2()); + if (flatness > 0.1 && dist > 20) { + final CubicCurve2D left = new CubicCurve2D.Double(); + final CubicCurve2D right = new CubicCurve2D.Double(); + curve.subdivide(left, right); + addCurve(left); + addCurve(right); + return; + } + addPoints(curve.getP2()); + } +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/PathJiggle.java b/src/net/sourceforge/plantuml/ugraphic/hand/PathJiggle.java new file mode 100644 index 000000000..8ad069fe6 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/PathJiggle.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.ugraphic.UPath; + +public class PathJiggle { + private final UPath path; + + private final double defaultVariation; + + public PathJiggle(UPath source, double defaultVariation) { + this.defaultVariation = defaultVariation; + this.path = null; + } + + public UPath toUPath() { + return path; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java new file mode 100644 index 000000000..223cb7089 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import java.awt.geom.CubicCurve2D; + +import net.sourceforge.plantuml.posimo.DotPath; +import net.sourceforge.plantuml.ugraphic.UPath; + +public class UDotPathHand { + + private final UPath path; + + public UDotPathHand(DotPath source) { + + final HandJiggle jiggle = new HandJiggle(source.getStartPoint(), 3.0); + for (CubicCurve2D curve : source.getBeziers()) { + jiggle.addCurve(curve); + } + + this.path = jiggle.toUPath(); + } + + public UPath getHanddrawn() { + return this.path; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java new file mode 100644 index 000000000..d630eb5e1 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.ugraphic.Shadowable; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UPolygon; + +public class UEllipseHand { + + private final Shadowable poly; + + public UEllipseHand(UEllipse source) { + + if (source.getStart() != 0 || source.getExtend() != 0) { + this.poly = source; + return; + } + final UPolygon result = new UPolygon(); + final double width = source.getWidth(); + final double height = source.getHeight(); + double angle = 0; + while (angle < Math.PI * 2) { + angle += (10 + Math.random() * 10) * Math.PI / 180; + final double variation = 1 + (Math.random() - 0.5) / 8; + final double x = width / 2 + Math.cos(angle) * width * variation / 2; + final double y = height / 2 + Math.sin(angle) * height * variation / 2; + // final Point2D.Double p = new Point2D.Double(x, y); + result.addPoint(x, y); + } + + this.poly = result; + this.poly.setDeltaShadow(source.getDeltaShadow()); + } + + public Shadowable getHanddrawn() { + return this.poly; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java new file mode 100644 index 000000000..3105e288f --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.posimo.DotPath; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class UGraphicHandwritten implements UGraphic { + + private final UGraphic ug; + + public UGraphicHandwritten(UGraphic ug) { + this.ug = ug; + } + + public StringBounder getStringBounder() { + return ug.getStringBounder(); + } + + public UParam getParam() { + return ug.getParam(); + } + + public void draw(UShape shape) { + // http://www.ufonts.com/fonts/felt-tip-roman.html + // http://webdesignledger.com/freebies/20-amazing-free-handwritten-fonts-for-your-designs + if (shape instanceof ULine) { + drawHand((ULine) shape); + } else if (shape instanceof URectangle) { + drawHand((URectangle) shape); + } else if (shape instanceof UPolygon) { + drawHand((UPolygon) shape); + } else if (shape instanceof UEllipse) { + drawHand((UEllipse) shape); + } else if (shape instanceof DotPath) { + drawHand((DotPath) shape); + } else { + ug.draw(shape); + } + } + + private void drawHand(DotPath shape) { + final UDotPathHand uline = new UDotPathHand(shape); + ug.draw(uline.getHanddrawn()); + } + + private void drawHand(UPolygon shape) { + final UPolygonHand hand = new UPolygonHand(shape); + ug.draw(hand.getHanddrawn()); + } + + private void drawHand(URectangle shape) { + final URectangleHand hand = new URectangleHand(shape); + ug.draw(hand.getHanddrawn()); + } + + private void drawHand(ULine line) { + final ULineHand uline = new ULineHand(line); + ug.draw(uline.getHanddrawn()); + } + + private void drawHand(UEllipse shape) { + final UEllipseHand uline = new UEllipseHand(shape); + ug.draw(uline.getHanddrawn()); + } + + public UGraphic apply(UChange change) { + return new UGraphicHandwritten(ug.apply(change)); + } + + public ColorMapper getColorMapper() { + return ug.getColorMapper(); + } + + public void startUrl(Url url) { + ug.startUrl(url); + } + + public void closeAction() { + ug.closeAction(); + } + + public void flushUg() { + ug.flushUg(); + } + + public boolean isSpecialTxt() { + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java new file mode 100644 index 000000000..6217fffe6 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UPath; + +public class ULineHand { + + private UPath path; + + public ULineHand(ULine line) { + final double endX = line.getDX(); + final double endY = line.getDY(); + final HandJiggle jiggle = new HandJiggle(0, 0, 2.0); + jiggle.addPoints(endX, endY); + + this.path = jiggle.toUPath(); + + } + + public UPath getHanddrawn() { + return this.path; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java new file mode 100644 index 000000000..fb036bdcd --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.ugraphic.UPath; + +public class UPathHand { + + private final UPath path; + + public UPathHand(UPath source) { + + final PathJiggle jiggle = new PathJiggle(source, 3.0); + this.path = jiggle.toUPath(); + } + + public UPath getHanddrawn() { + return this.path; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java new file mode 100644 index 000000000..9fe9617df --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import java.awt.geom.Point2D; +import java.util.List; + +import net.sourceforge.plantuml.ugraphic.Shadowable; +import net.sourceforge.plantuml.ugraphic.UPolygon; + +public class UPolygonHand { + + private final UPolygon poly; + + public UPolygonHand(UPolygon source) { + + final List pt = source.getPoints(); + final HandJiggle jiggle = new HandJiggle(pt.get(0), 1.5); + for (int i = 1; i < pt.size(); i++) { + jiggle.addPoints(pt.get(i)); + } + jiggle.addPoints(pt.get(0)); + + this.poly = jiggle.toUPolygon(); + this.poly.setDeltaShadow(source.getDeltaShadow()); + } + + public Shadowable getHanddrawn() { + return this.poly; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java new file mode 100644 index 000000000..8d771fef5 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.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: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.hand; + +import net.sourceforge.plantuml.ugraphic.Shadowable; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.URectangle; + +public class URectangleHand { + + final private UPolygon poly; + + public URectangleHand(URectangle rectangle) { + final double width = rectangle.getWidth(); + final double height = rectangle.getHeight(); + final HandJiggle jiggle = new HandJiggle(0, 0, 1.5); + jiggle.addPoints(width, 0); + jiggle.addPoints(width, height); + jiggle.addPoints(0, height); + jiggle.addPoints(0, 0); + + this.poly = jiggle.toUPolygon(); + this.poly.setDeltaShadow(rectangle.getDeltaShadow()); + } + + public Shadowable getHanddrawn() { + return this.poly; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java new file mode 100644 index 000000000..bb10bd979 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.creole.AtomText; +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverAtomTextTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final AtomText text = (AtomText) shape; + + tikz.text(x, y, text.getText()); + + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java new file mode 100644 index 000000000..213dbe2ce --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import java.awt.font.TextLayout; + +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UnusedSpace; +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UCenteredCharacter; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverCenteredCharacterTikz implements UDriver { + + public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape; + final char c = centeredCharacter.getChar(); + final UFont font = centeredCharacter.getFont(); + final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c); + + final double xpos = x - unusedSpace.getCenterX() - 0.5; + final double ypos = y - unusedSpace.getCenterY() - 0.5; + + final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null)); + + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java new file mode 100644 index 000000000..025ee438f --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.posimo.DotPath; +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverDotPathTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final DotPath path = (DotPath) shape; + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + tikz.upath(x, y, path.toUPath()); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java new file mode 100644 index 000000000..dd5addabb --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverEllipseTikz implements UDriver { + + public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final UEllipse shape = (UEllipse) ushape; + final double width = shape.getWidth(); + final double height = shape.getHeight(); + + double start = shape.getStart(); + final double extend = shape.getExtend(); + final double cx = x + width / 2; + final double cy = y + height / 2; + tikz.setFillColor(mapper.getMappedColor(param.getBackcolor())); + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + if (start == 0 && extend == 0) { + tikz.ellipse(cx, cy, width / 2, height / 2); + } else { + throw new UnsupportedOperationException(); + // // http://www.itk.ilstu.edu/faculty/javila/SVG/SVG_drawing1/elliptical_curve.htm + // start = start + 90; + // final double x1 = cx + Math.sin(start * Math.PI / 180.) * width / 2; + // final double y1 = cy + Math.cos(start * Math.PI / 180.) * height / 2; + // final double x2 = cx + Math.sin((start + extend) * Math.PI / 180.) * width / 2; + // final double y2 = cy + Math.cos((start + extend) * Math.PI / 180.) * height / 2; + // // svg.svgEllipse(x1, y1, 1, 1, 0); + // // svg.svgEllipse(x2, y2, 1, 1, 0); + // svg.svgArcEllipse(width / 2, height / 2, x1, y1, x2, y2); + } + } +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java new file mode 100644 index 000000000..7fd182d58 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java @@ -0,0 +1,53 @@ +/* ======================================================================== + * 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.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverLineTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final ULine line = (ULine) shape; + + double x2 = x + line.getDX(); + double y2 = y + line.getDY(); + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + tikz.line(x, y, x2, y2); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java new file mode 100644 index 000000000..1f3e98fed --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * 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.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverNoneTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics object) { + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java new file mode 100644 index 000000000..b016a3f9c --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverPolygonTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final UPolygon poly = (UPolygon) shape; + final double points[] = poly.getPointArray(x, y); + + tikz.setFillColor(mapper.getMappedColor(param.getBackcolor())); + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + + tikz.polygon(points); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java new file mode 100644 index 000000000..d0b8aa402 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverRectangleTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final URectangle rect = (URectangle) shape; + + final double width = rect.getWidth(); + final double height = rect.getHeight(); + tikz.setFillColor(mapper.getMappedColor(param.getBackcolor())); + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + tikz.rectangle(x, y, width, height); + + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java new file mode 100644 index 000000000..6f120fb76 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class DriverUPathTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final UPath path = (UPath) shape; + tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); + tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); + tikz.upath(x, y, path); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java new file mode 100644 index 000000000..b6a5d098d --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.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 + * + */ +package net.sourceforge.plantuml.ugraphic.tikz; + +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UDriver; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; +import net.sourceforge.plantuml.ugraphic.UText; + +public class DriverUTextTikz implements UDriver { + + public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { + final UText text = (UText) shape; + + tikz.text(x, y, text.getText()); + + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java new file mode 100644 index 000000000..909636a43 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java @@ -0,0 +1,121 @@ +/* ======================================================================== + * 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.ugraphic.tikz; + +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.creole.AtomText; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.posimo.DotPath; +import net.sourceforge.plantuml.tikz.TikzGraphics; +import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; +import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; +import net.sourceforge.plantuml.ugraphic.ClipContainer; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UCenteredCharacter; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic2; +import net.sourceforge.plantuml.ugraphic.UImage; +import net.sourceforge.plantuml.ugraphic.UImageSvg; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UText; + +public class UGraphicTikz extends AbstractUGraphic implements ClipContainer, UGraphic2 { + + private final StringBounder stringBounder; + + private UGraphicTikz(ColorMapper colorMapper, TikzGraphics tikz) { + super(colorMapper, tikz); + this.stringBounder = TextBlockUtils.getDummyStringBounder(); + register(); + + } + + public UGraphicTikz(ColorMapper colorMapper) { + this(colorMapper, new TikzGraphics()); + + } + + @Override + protected AbstractCommonUGraphic copyUGraphic() { + return new UGraphicTikz(this); + } + + private UGraphicTikz(UGraphicTikz other) { + super(other); + this.stringBounder = other.stringBounder; + register(); + } + + private void register() { + registerDriver(URectangle.class, new DriverRectangleTikz()); + registerDriver(UText.class, new DriverUTextTikz()); + registerDriver(AtomText.class, new DriverAtomTextTikz()); + registerDriver(ULine.class, new DriverLineTikz()); + registerDriver(UPolygon.class, new DriverPolygonTikz()); + registerDriver(UEllipse.class, new DriverEllipseTikz()); + registerDriver(UImage.class, new DriverNoneTikz()); + registerDriver(UImageSvg.class, new DriverNoneTikz()); + registerDriver(UPath.class, new DriverUPathTikz()); + registerDriver(DotPath.class, new DriverDotPathTikz()); + registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz()); + } + + public StringBounder getStringBounder() { + return stringBounder; + } + + public void startUrl(Url url) { + } + + public void closeAction() { + } + + public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException { + createTikz(os); + } + + public void createTikz(OutputStream os) throws IOException { + getGraphicObject().createData(os); + } + + public boolean isSpecialTxt() { + return true; + } + +} diff --git a/src/net/sourceforge/plantuml/utils/CharHidder.java b/src/net/sourceforge/plantuml/utils/CharHidder.java new file mode 100644 index 000000000..1cc815802 --- /dev/null +++ b/src/net/sourceforge/plantuml/utils/CharHidder.java @@ -0,0 +1,95 @@ +/* ======================================================================== + * 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: 5749 $ + * + */ +package net.sourceforge.plantuml.utils; + +public class CharHidder { + + public static String addTileAtBegin(String s) { + return "~" + s; + } + + public static String hide(String s) { + // System.err.println("hide " + s); + final StringBuilder result = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (c == '~' && i + 1 < s.length()) { + i++; + final char c2 = s.charAt(i); + if (isToBeHidden(c2)) { + result.append(hideChar(c2)); + } else { + result.append(c); + result.append(c2); + } + + } else { + result.append(c); + } + } + return result.toString(); + } + + private static boolean isToBeHidden(final char c) { + if (c == '_' || c == '\"' || c == '#' || c == ']' || c == '[' || c == '*' || c == '.' || c == '/') { + return true; + } + return false; + } + + private static char hideChar(char c) { + if (c > 255) { + throw new IllegalArgumentException(); + } + return (char) ('\uE000' + c); + } + + private static char unhideChar(char c) { + if (c >= '\uE000' && c <= '\uE0FF') { + return (char) (c - '\uE000'); + } + return c; + } + + public static String unhide(String s) { + final StringBuilder result = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + result.append(unhideChar(c)); + } + // System.err.println("unhide " + result); + return result.toString(); + } + +} diff --git a/src/net/sourceforge/plantuml/utils/MathUtils.java b/src/net/sourceforge/plantuml/utils/MathUtils.java new file mode 100644 index 000000000..799f07b9b --- /dev/null +++ b/src/net/sourceforge/plantuml/utils/MathUtils.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: 6719 $ + * + */ +package net.sourceforge.plantuml.utils; + +public class MathUtils { + + public static double max(double a, double b) { + return Math.max(a, b); + } + + public static double max(double a, double b, double c) { + return Math.max(Math.max(a, b), c); + } + + public static double limitation(double v, double min, double max) { + if (min >= max) { + assert false : "min="+min+" max="+max+" v="+v; + return v; + // throw new IllegalArgumentException("min="+min+" max="+max+" v="+v); + } + if (v < min) { + return min; + } + if (v > max) { + return max; + } + return v; + } + +} diff --git a/src/net/sourceforge/plantuml/utils/StartUtils.java b/src/net/sourceforge/plantuml/utils/StartUtils.java new file mode 100644 index 000000000..2eeb311fb --- /dev/null +++ b/src/net/sourceforge/plantuml/utils/StartUtils.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: 6110 $ + * + */ +package net.sourceforge.plantuml.utils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.sourceforge.plantuml.command.regex.MyPattern; + +public class StartUtils { + + public static boolean isArobaseStartDiagram(String s) { + s = s.trim(); + return s.startsWith("@start"); + } + + public static boolean isArobaseEndDiagram(String s) { + s = s.trim(); + return s.startsWith("@end"); + } + + public static boolean isArobasePauseDiagram(String s) { + s = s.trim(); + return s.startsWith("@pause"); + } + + public static boolean isArobaseUnpauseDiagram(String s) { + s = s.trim(); + return s.startsWith("@unpause"); + } + + private static final Pattern append = MyPattern.cmpile("^\\W*@append"); + + public static String getPossibleAppend(String s) { + final Matcher m = append.matcher(s); + if (m.find()) { + return s.substring(m.group(0).length()).trim(); + } + return null; + } + +} diff --git a/src/net/sourceforge/plantuml/utils/UniqueSequence.java b/src/net/sourceforge/plantuml/utils/UniqueSequence.java new file mode 100644 index 000000000..34922ad27 --- /dev/null +++ b/src/net/sourceforge/plantuml/utils/UniqueSequence.java @@ -0,0 +1,56 @@ +/* ======================================================================== + * 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: 13946 $ + * + */ +package net.sourceforge.plantuml.utils; + +import java.util.concurrent.atomic.AtomicInteger; + +import net.sourceforge.plantuml.cucadiagram.Code; + +public class UniqueSequence { + + private static final AtomicInteger cpt = new AtomicInteger(1); + + public static void reset() { + cpt.set(0); + } + + public static int getValue() { + return cpt.addAndGet(1); + } + + public static Code getCode(String prefix) { + return Code.of(prefix + getValue()); + } + +} diff --git a/src/net/sourceforge/plantuml/version/charlie.png b/src/net/sourceforge/plantuml/version/charlie.png new file mode 100644 index 000000000..1d4281d12 Binary files /dev/null and b/src/net/sourceforge/plantuml/version/charlie.png differ