plantuml/src/net/sourceforge/plantuml/donors/PSystemDonors.java

170 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
2023-01-09 19:13:37 +00:00
public static final String DONORS = "6r8F0AoFktsyGOBPua5wjfPR-fZcX3WHBCyJYiF0HZpT1SGVuDxfSR-H_YAwqhrlcZ5glPofDGbvnfSS"
+ "iFHQuIQCt_d2eyvUFWIVD0A61iW0SLF_nZdioMcw8rM6bE3DT-Z-bidQawtZOb7pEH6u2g0IqPnYkvU9"
+ "URr2AgNu_9MFq4yWcuBESwPH96fUuEQexQVO-vhxdpexbp1BToim0gEY4QhylkPOUxarxw9Q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zCOEAsRxnZSL53W7_4bL6PNBlAgDP"
+ "OIJYA6HnxCVfRKFJ5pf8mHgeJU3OtUyj5XgQQxyYgJGSW7oo8QdKhD2YQarBOoEmKaxixwquAMVMPsUY"
+ "7zCwSrxLGzqaPzTJZ2Xy-oaqzmWJqqNSX8LmJyv934Rune9yKIsMnDAo3ZjDi8B_-tuCRoHiieCF5Ee9"
+ "fJpJWXnXa-nzgoZ-8DvTn40M5ijq9x5Ool58YgHmhcoPd25zfKyufMyGWw9m_7ylGRZCHFCLaYwzgvFC"
+ "vRTMamoYEDJF9Ab5obQB3EoRIovRl2AtRMtIOTl-1txYVFaZwkAR220GpONWDQUX3pVMgwbX2_ARETp7"
+ "PRPk9Z-FIz7EKGbirYSRDS1cgE991647e49u3VrL_GbRpcNus_DKAepKyDnH3JruhWQMaQqql4WQrBp8"
+ "OjhwVifDdXn8d00TKAawZPqUneneXKCjlscp98DAuauL_ti6qjqbLTwgc3JAaAXwWysIs3hlpD3fdDmg"
+ "N5xFyVJ632dr2-eBWZs6kbpF3NW20meXhW05oLNpljMACsHKbbNZmoeKHWws5JKqsWmMsHtZqr0shvYj"
+ "yUpO5i08L0pzWmjxZuP6JgXesUQ4CXiH1ObIQ0ieiySejc6VaYvkEJMTj_PENUY7pPDDDVeMbUB0EZoZ" + "yWe1";
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
}
}