1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-06 10:20:54 +00:00
plantuml/src/net/sourceforge/plantuml/donors/PSystemDonors.java

171 lines
7.2 KiB
Java
Raw Normal View History

2013-12-10 19:36:50 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2022-03-07 19:33:46 +00:00
* (C) Copyright 2009-2023, Arnaud Roques
2013-12-10 19:36:50 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2022-08-17 17:34:24 +00:00
*
2017-03-15 19:13:31 +00:00
* If you like this project or if you find it useful, you can support us at:
2022-08-17 17:34:24 +00:00
*
2017-03-15 19:13:31 +00:00
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
2022-08-17 17:34:24 +00:00
*
2013-12-10 19:36:50 +00:00
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
2022-08-17 17:34:24 +00:00
*
2013-12-10 19:36:50 +00:00
*
*/
package net.sourceforge.plantuml.donors;
import java.io.IOException;
import java.util.ArrayList;
2016-12-01 20:29:25 +00:00
import java.util.Arrays;
2013-12-10 19:36:50 +00:00
import java.util.List;
import java.util.StringTokenizer;
2017-06-05 11:27:21 +00:00
import net.sourceforge.plantuml.BackSlash;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
2022-09-12 20:08:34 +00:00
import net.sourceforge.plantuml.awt.geom.XDimension2D;
2018-05-01 17:26:04 +00:00
import net.sourceforge.plantuml.code.AsciiEncoder;
2017-12-11 21:02:10 +00:00
import net.sourceforge.plantuml.code.CompressionBrotli;
import net.sourceforge.plantuml.code.NoPlantumlCompressionException;
2018-05-06 19:59:19 +00:00
import net.sourceforge.plantuml.code.StringCompressorNone;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl;
import net.sourceforge.plantuml.core.DiagramDescription;
2021-05-23 15:35:13 +00:00
import net.sourceforge.plantuml.core.UmlSource;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.graphic.GraphicStrings;
2016-12-01 20:29:25 +00:00
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
2022-08-17 17:34:24 +00:00
import net.sourceforge.plantuml.log.Logme;
2016-11-18 21:12:09 +00:00
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
2020-06-07 10:03:18 +00:00
import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.PixelImage;
2016-12-01 20:29:25 +00:00
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends PlainDiagram {
2019-02-09 21:56:24 +00:00
private static final int COLS = 6;
private static final int FREE_LINES = 6;
2019-05-24 19:59:31 +00:00
2022-05-27 14:18:47 +00:00
public static final String DONORS = "6miF03mSRygAr4-2sU91UhPs3uiVqvmG9uBbUK9nOX6dku3u0zmxFUutqbz4LtRlcsP4hTScvGoY-Y3e"
+ "0Uzk2-r3wNzz4EOiUH7ScH9SG0g8ukWI-P5kP3jzKcL82TvyX-vlcQmzsJek5ZMV4u6h02gHaD6SOhkN"
+ "YNczGYgb-FoLZz1Fu6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
+ "xPL0b8ADzC4kwlPbHld6JvORaPlMNZzKuKzJZ0h7_K2s2r_HtkUIAjCNqwW6-yEx3XSv6FubgWo8vB8t"
+ "CoiZKIR1nN4VfxKDpLWwG0tcG9q4djtzsMAXeR7sAvGgmmcGhpSabHfbMbWTqzBO2AoK4_jxQqxA6VNP"
+ "6SJF7klCULKFTPCKrrECA7o7ISXJmiJC8d4YWjtYEIb13z_i8rzK2oMnjAdDpX2iaF--7yCR2GVia0SQ"
+ "zOHIdcb13jkaUziiy4U2zn0ba8N5Cjr5B9JAU215KZ2NMyOpfA-q6QVs1j0f2iR_zmQKoqmqFwBPfNTr"
+ "ahd2rdRY82h3_PubjYZPQf61VLVDPUkNvRRDJMROaV-17plV_AYwVX41DKHN9NZDQUJ3ZSrgQjYY_cOE"
+ "zt6PhPl9p-DIj7DK0vlqPAE6iXaev2I4I0T2XVHL-5Nz2LlEEVBfVQeK1cfu7hiDFNYk1kR8LXfU9Gse"
+ "NcHnR7s_uIPF3XHEJBR-LQUnqyEO7gqmrAQRDcl8e1AvIyLNZc1sSqcLjoecbJAyy-FUKBCajFQTxUZq"
+ "JcuXbzTpFBqnWqlzakWpmJa6ch9U7CY41cGHMK4ZYAwI_Q8LPyYeBAl4HwfWc3ZQ4kxGQ3DOk3lMfw5i"
+ "NZ5RuziaFZ126vR-nWNSUuP4pmKD8zkS06nO52cKX6OetMCGEs57p2vkUISVW_BMtW00";
2015-04-07 18:18:37 +00:00
2019-08-26 17:07:21 +00:00
/*
* Special thanks to our sponsors and donors:
2022-08-17 17:34:24 +00:00
*
2019-09-14 18:12:04 +00:00
* - Noam Tamim
2019-08-26 17:07:21 +00:00
*/
2021-05-23 15:35:13 +00:00
public PSystemDonors(UmlSource source) {
super(source);
}
2016-12-01 20:29:25 +00:00
@Override
protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
2019-02-09 21:56:24 +00:00
final List<TextBlock> cols = getCols(getDonors(), COLS, FREE_LINES);
2016-12-01 20:29:25 +00:00
return new UDrawable() {
public void drawU(UGraphic ug) {
2020-02-18 21:24:31 +00:00
final TextBlockBackcolored header = GraphicStrings
.createBlackOnWhite(Arrays.asList("<b>Special thanks to our sponsors and donors !"));
2016-12-01 20:29:25 +00:00
header.drawU(ug);
final StringBounder stringBounder = ug.getStringBounder();
2020-03-18 10:50:02 +00:00
ug = ug.apply(UTranslate.dy(header.calculateDimension(stringBounder).getHeight()));
2016-12-01 20:29:25 +00:00
double x = 0;
double lastX = 0;
double y = 0;
for (TextBlock tb : cols) {
2022-09-12 20:08:34 +00:00
final XDimension2D dim = tb.calculateDimension(stringBounder);
2020-03-18 10:50:02 +00:00
tb.drawU(ug.apply(UTranslate.dx(x)));
2016-12-01 20:29:25 +00:00
lastX = x;
x += dim.getWidth() + 10;
y = Math.max(y, dim.getHeight());
}
2020-06-07 10:03:18 +00:00
final UImage logo = new UImage(
new PixelImage(PSystemVersion.getPlantumlImage(), AffineTransformType.TYPE_BILINEAR));
2016-12-01 20:29:25 +00:00
ug.apply(new UTranslate(lastX, y - logo.getHeight())).draw(logo);
2015-04-07 18:18:37 +00:00
}
2016-12-01 20:29:25 +00:00
};
}
public static List<TextBlock> getCols(List<String> lines, final int nbCol, final int reserved) throws IOException {
2021-05-14 08:42:57 +00:00
final List<TextBlock> result = new ArrayList<>();
2016-12-01 20:29:25 +00:00
final int maxLine = (lines.size() + (nbCol - 1) + reserved) / nbCol;
for (int i = 0; i < lines.size(); i += maxLine) {
final List<String> current = lines.subList(i, Math.min(lines.size(), i + maxLine));
result.add(GraphicStrings.createBlackOnWhite(current));
2015-04-07 18:18:37 +00:00
}
2016-12-01 20:29:25 +00:00
return result;
2015-04-07 18:18:37 +00:00
}
private List<String> getDonors() throws IOException {
2021-05-14 08:42:57 +00:00
final List<String> lines = new ArrayList<>();
final Transcoder t = TranscoderImpl.utf8(new AsciiEncoder(), new StringCompressorNone(),
2020-02-18 21:24:31 +00:00
new CompressionBrotli());
try {
final String s = t.decode(DONORS).replace('*', '.');
final StringTokenizer st = new StringTokenizer(s, BackSlash.NEWLINE);
while (st.hasMoreTokens()) {
lines.add(st.nextToken());
}
} catch (NoPlantumlCompressionException e) {
2022-08-17 17:34:24 +00:00
Logme.error(e);
2013-12-10 19:36:50 +00:00
}
2015-04-07 18:18:37 +00:00
return lines;
2013-12-10 19:36:50 +00:00
}
public DiagramDescription getDescription() {
2017-03-12 17:22:02 +00:00
return new DiagramDescription("(Donors)");
2013-12-10 19:36:50 +00:00
}
2021-05-23 15:35:13 +00:00
public static PSystemDonors create(UmlSource source) {
return new PSystemDonors(source);
2013-12-10 19:36:50 +00:00
}
}