1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-03 09:00:48 +00:00
plantuml/src/net/sourceforge/plantuml/version/PSystemLicense.java

113 lines
3.8 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
2013-12-10 19:36:50 +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:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
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
*
*/
package net.sourceforge.plantuml.version;
2018-12-22 11:11:40 +00:00
import java.awt.image.BufferedImage;
2013-12-10 19:36:50 +00:00
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
2013-12-10 19:36:50 +00:00
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;
2018-12-22 11:11:40 +00:00
import net.sourceforge.plantuml.graphic.UDrawable;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.UImage;
import net.sourceforge.plantuml.klimt.UTranslate;
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;
2020-12-01 21:39:27 +00:00
import net.sourceforge.plantuml.ugraphic.PixelImage;
2018-12-22 11:11:40 +00:00
import net.sourceforge.plantuml.ugraphic.UGraphic;
2013-12-10 19:36:50 +00:00
public class PSystemLicense extends PlainDiagram implements UDrawable {
2013-12-10 19:36:50 +00:00
2016-12-01 20:29:25 +00:00
@Override
protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
return this;
2013-12-10 19:36:50 +00:00
}
2021-05-23 15:35:13 +00:00
public static PSystemLicense create(UmlSource source) throws IOException {
return new PSystemLicense(source);
}
public PSystemLicense(UmlSource source) {
super(source);
2013-12-10 19:36:50 +00:00
}
2018-12-22 11:11:40 +00:00
private TextBlockBackcolored getGraphicStrings(List<String> strings) {
2016-11-18 21:12:09 +00:00
return GraphicStrings.createBlackOnWhite(strings);
2013-12-10 19:36:50 +00:00
}
public DiagramDescription getDescription() {
2017-03-12 17:22:02 +00:00
return new DiagramDescription("(License)");
2013-12-10 19:36:50 +00:00
}
2018-12-22 11:11:40 +00:00
public void drawU(UGraphic ug) {
// ::comment when WASM
2018-12-22 11:11:40 +00:00
final LicenseInfo licenseInfo = LicenseInfo.retrieveQuick();
final BufferedImage logo = LicenseInfo.retrieveDistributorImage(licenseInfo);
if (logo == null) {
// ::done
2021-05-14 08:42:57 +00:00
final List<String> strings = new ArrayList<>();
// ::comment when WASM
2018-12-22 11:11:40 +00:00
strings.addAll(License.getCurrent().getText1(licenseInfo));
strings.addAll(License.getCurrent().getText2(licenseInfo));
// ::done
2018-12-22 11:11:40 +00:00
getGraphicStrings(strings).drawU(ug);
// ::comment when WASM
2018-12-22 11:11:40 +00:00
} else {
2021-05-14 08:42:57 +00:00
final List<String> strings1 = new ArrayList<>();
final List<String> strings2 = new ArrayList<>();
2018-12-22 11:11:40 +00:00
strings1.addAll(License.getCurrent().getText1(licenseInfo));
strings2.addAll(License.getCurrent().getText2(licenseInfo));
final TextBlockBackcolored result1 = getGraphicStrings(strings1);
result1.drawU(ug);
2020-03-18 10:50:02 +00:00
ug = ug.apply(UTranslate.dy(4 + result1.calculateDimension(ug.getStringBounder()).getHeight()));
2020-06-07 10:03:18 +00:00
UImage im = new UImage(new PixelImage(logo, AffineTransformType.TYPE_BILINEAR));
2020-03-18 10:50:02 +00:00
ug.apply(UTranslate.dx(20)).draw(im);
2018-12-22 11:11:40 +00:00
2020-03-18 10:50:02 +00:00
ug = ug.apply(UTranslate.dy(im.getHeight()));
2018-12-22 11:11:40 +00:00
final TextBlockBackcolored result2 = getGraphicStrings(strings2);
result2.drawU(ug);
}
// ::done
2018-12-22 11:11:40 +00:00
}
2013-12-10 19:36:50 +00:00
}