2013-12-10 19:36:50 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2019-01-16 18:34:41 +00:00
|
|
|
* (C) Copyright 2009-2020, 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.io.OutputStream;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.sourceforge.plantuml.AbstractPSystem;
|
|
|
|
import net.sourceforge.plantuml.FileFormatOption;
|
|
|
|
import net.sourceforge.plantuml.core.DiagramDescription;
|
|
|
|
import net.sourceforge.plantuml.core.ImageData;
|
|
|
|
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
2018-12-22 11:11:40 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
2016-11-18 21:12:09 +00:00
|
|
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
2018-12-22 11:11:40 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.UImage;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
2020-03-18 10:50:02 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2018-12-22 11:11:40 +00:00
|
|
|
public class PSystemLicense extends AbstractPSystem implements UDrawable {
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2016-12-01 20:29:25 +00:00
|
|
|
@Override
|
2017-04-19 18:30:16 +00:00
|
|
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
2016-12-01 20:29:25 +00:00
|
|
|
throws IOException {
|
2020-05-07 14:12:08 +00:00
|
|
|
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null,
|
|
|
|
getMetadata(), null, 1.0, null);
|
2018-12-22 11:11:40 +00:00
|
|
|
imageBuilder.setUDrawable(this);
|
2017-04-19 18:30:16 +00:00
|
|
|
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static PSystemLicense create() throws IOException {
|
|
|
|
return new PSystemLicense();
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
final LicenseInfo licenseInfo = LicenseInfo.retrieveQuick();
|
|
|
|
final BufferedImage logo = LicenseInfo.retrieveDistributorImage(licenseInfo);
|
|
|
|
|
|
|
|
if (logo == null) {
|
|
|
|
final List<String> strings = new ArrayList<String>();
|
|
|
|
strings.addAll(License.getCurrent().getText1(licenseInfo));
|
|
|
|
strings.addAll(License.getCurrent().getText2(licenseInfo));
|
|
|
|
getGraphicStrings(strings).drawU(ug);
|
|
|
|
} else {
|
|
|
|
final List<String> strings1 = new ArrayList<String>();
|
|
|
|
final List<String> strings2 = new ArrayList<String>();
|
|
|
|
|
|
|
|
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()));
|
2018-12-22 11:11:40 +00:00
|
|
|
UImage im = new UImage(logo);
|
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);
|
|
|
|
}
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|