summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/donors/PSystemDonors.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/donors/PSystemDonors.java')
-rw-r--r--src/net/sourceforge/plantuml/donors/PSystemDonors.java121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java
new file mode 100644
index 0000000..fdcc790
--- /dev/null
+++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.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.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.donors;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.code.Transcoder;
+import net.sourceforge.plantuml.code.TranscoderImpl;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class PSystemDonors extends AbstractPSystem {
+
+ public static final String DONORS = "UDfTaikosZ0CXlTw2gypquT8IOTEu5pcqEcYEv7e41sCH6s7DddwYhR11gsiqUtx9TU--cyKu9KI1LTBKc7iu1jLsVG4MyrkY50lfRY7TSWXcc17Uuo9KTop3WArz1hSMYdDT7s-lrl6aeu2Mom6IOA65uSzrBcrNc0tPeG9rbpTcoYq2-KOOPVeF92ubUhPz3NB78gmEJsKQe2LUXRtfcCaQCU7UFMX9cHnpWnF1JMUIjT6rPv-e_IspjN0rlM0OJAbRpVPSe3daZxDyEBvOWKDTqSZlqLOu4kyjPO2eg8BDFE9KvZS5WVj4ThhqdyCQEsBl8fyFfVPSR8r2IRBCpxZQl_1q_5EbVHtxjzAjaRUobv2uXc-vd2lyCJTGDvzHlPJgS3F9KoCZsWjeNngiVivKdJDk0zef_LP_dVzIDGDRXCmOaOwaFtOue2_hX_DKjn6Bmn_0C5QlDy0";
+
+ // public ImageData exportDiagram(OutputStream os, int num, FileFormatOption
+ // fileFormat) throws IOException {
+ // return getGraphicStrings().exportDiagram(os, fileFormat);
+ // }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final List<String> lines = new ArrayList<String>();
+ lines.add("<b>Special thanks to our sponsors and donors !");
+ lines.add(" ");
+ int i = 0;
+ final List<String> donors = getDonors();
+ final int maxLine = (donors.size() + 1) / 2;
+ for (String d : donors) {
+ lines.add(d);
+ i++;
+ if (i == maxLine) {
+ lines.add(" ");
+ lines.add(" ");
+ i = 0;
+ }
+ }
+ lines.add(" ");
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ final GraphicStrings graphicStrings = new GraphicStrings(lines, font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, PSystemVersion.getPlantumlImage(),
+ GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
+ graphicStrings.setMaxLine(maxLine + 2);
+ return graphicStrings;
+ }
+
+ private List<String> getDonors() throws IOException {
+ final List<String> lines = new ArrayList<String>();
+ final Transcoder t = new TranscoderImpl();
+ final String s = t.decode(DONORS).replace('*', '.');
+ final StringTokenizer st = new StringTokenizer(s, "\n");
+ while (st.hasMoreTokens()) {
+ lines.add(st.nextToken());
+ }
+ return lines;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Donors)", getClass());
+ }
+
+ public static PSystemDonors create() {
+ return new PSystemDonors();
+ }
+
+}