net.sourceforge.plantuml.version.PSystemVersion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-lgpl Show documentation
Show all versions of plantuml-lgpl Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
/* +=======================================================================
* |
* | PlantUML : a free UML diagram generator
* |
* +=======================================================================
*
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/liberapay (only 1€ per month!)
* https://plantuml.com/paypal
*
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see .
*
* PlantUML can occasionally display sponsored or advertising messages. Those
* messages are usually generated on welcome or error images and never on
* functional diagrams.
* See https://plantuml.com/professional if you want to remove them
*
* Images (whatever their format : PNG, SVG, EPS...) generated by running PlantUML
* are owned by the author of their corresponding sources code (that is, their
* textual description in PlantUML language). Those images are not covered by
* this LGPL license.
*
* The generated images can then be used without any reference to the LGPL license.
* It is not even necessary to stipulate that they have been generated with PlantUML,
* although this will be appreciated by the PlantUML team.
*
* There is an exception : if the textual description in PlantUML language is also covered
* by any license, then the generated images are logically covered
* by the very same license.
*
* This is the IGY distribution (Install GraphViz by Yourself).
* You have to install GraphViz and to setup the GRAPHVIZ_DOT environment variable
* (see https://plantuml.com/graphviz-dot )
*
* Icons provided by OpenIconic : https://useiconic.com/open
* Archimate sprites provided by Archi : http://www.archimatetool.com
* Stdlib AWS provided by https://github.com/milo-minderbinder/AWS-PlantUML
* Stdlib Icons provided https://github.com/tupadr3/plantuml-icon-font-sprites
* ASCIIMathML (c) Peter Jipsen http://www.chapman.edu/~jipsen
* ASCIIMathML (c) David Lippman http://www.pierce.ctc.edu/dlippman
* CafeUndZopfli ported by Eugene Klyuchnikov https://github.com/eustas/CafeUndZopfli
* Brotli (c) by the Brotli Authors https://github.com/google/brotli
* Themes (c) by Brett Schwarz https://github.com/bschwarz/puml-themes
* Twemoji (c) by Twitter at https://twemoji.twitter.com/
*
*/
package net.sourceforge.plantuml.version;
import static net.sourceforge.plantuml.klimt.geom.GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.OptionPrint;
import net.sourceforge.plantuml.PlainStringsDiagram;
import net.sourceforge.plantuml.Run;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.dot.GraphvizUtils;
import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.preproc2.PreprocessorUtils;
import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SImageIO;
import net.sourceforge.plantuml.security.SecurityProfile;
import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.svek.GraphvizCrash;
public class PSystemVersion extends PlainStringsDiagram {
PSystemVersion(UmlSource source, boolean withImage, List args) {
super(source);
this.strings.addAll(args);
try {
if (withImage) {
this.image = getPlantumlImage();
this.imagePosition = BACKGROUND_CORNER_BOTTOM_RIGHT;
}
} catch (Exception e) {
e.printStackTrace();
}
}
private PSystemVersion(UmlSource source, List args, BufferedImage image) {
super(source);
this.strings.addAll(args);
this.image = image;
this.imagePosition = BACKGROUND_CORNER_BOTTOM_RIGHT;
}
public static BufferedImage getPlantumlImage() {
return getImage("logo.png");
}
public static BufferedImage getTime01() {
return getImage("time01.png");
}
public static BufferedImage getTime15() {
return getImage("time15.png");
}
public static BufferedImage getCharlieImage() {
return getImage("charlie.png");
}
public static BufferedImage getPlantumlSmallIcon() {
return getImage("favicon.png");
}
// ::comment when __CORE__
public static BufferedImage getArecibo() {
return getImage("arecibo.png");
}
public static BufferedImage getDotc() {
return getImage("dotc.png");
}
public static BufferedImage getDotd() {
return getImage("dotd.png");
}
public static BufferedImage getApple2Image() {
return getImageWebp("apple2.png");
}
private static BufferedImage getImage(final String name) {
try {
final InputStream is = PSystemVersion.class.getResourceAsStream(name);
final BufferedImage image = SImageIO.read(is);
is.close();
return image;
} catch (IOException e) {
Logme.error(e);
}
return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
}
// ::comment when __CORE__
private static BufferedImage getImageWebp(final String name) {
try (InputStream is = PSystemVersion.class.getResourceAsStream(name)) {
return SFile.getBufferedImageFromWebpButHeader(is);
} catch (IOException e) {
Logme.error(e);
}
return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
}
private static BufferedImage transparentIcon;
public static BufferedImage getPlantumlSmallIcon2() {
if (transparentIcon != null) {
return transparentIcon;
}
final BufferedImage ico = getPlantumlSmallIcon();
if (ico == null) {
return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
}
transparentIcon = new BufferedImage(ico.getWidth(), ico.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
for (int i = 0; i < ico.getWidth(); i++) {
for (int j = 0; j < ico.getHeight(); j++) {
final int col = ico.getRGB(i, j);
if (col != ico.getRGB(0, 0)) {
transparentIcon.setRGB(i, j, col);
}
}
}
return transparentIcon;
}
public static PSystemVersion createShowVersion2(UmlSource source) {
final List strings = new ArrayList<>();
strings.add("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
strings.add("(" + License.getCurrent() + " source distribution)");
// :: uncomment when __CORE__
// strings.add(" ");
// strings.add("Compiled with CheerpJ 2.3");
// strings.add("Powered by CheerpJ, a Leaning Technologies Java tool");
// :: comment when __CORE__
GraphvizCrash.checkOldVersionWarning(strings);
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) {
strings.add("Loaded from " + Version.getJarPath());
if (OptionFlags.getInstance().isWord()) {
strings.add("Word Mode");
strings.add("Command Line: " + Run.getCommandLine());
strings.add("Current Dir: " + new SFile(".").getAbsolutePath());
strings.add("plantuml.include.path: " + PreprocessorUtils.getenv(SecurityUtils.PATHS_INCLUDES));
}
}
strings.add(" ");
GraphvizUtils.addDotStatus(strings, true);
strings.add(" ");
for (String name : OptionPrint.interestingProperties())
strings.add(name);
for (String v : OptionPrint.interestingValues())
strings.add(v);
return new PSystemVersion(source, true, strings);
}
// :: comment when __CORE__
public static PSystemVersion createStdLib(UmlSource source) {
final List strings = new ArrayList<>();
Stdlib.addInfoVersion(strings, true);
strings.add(" ");
return new PSystemVersion(source, true, strings);
}
public static PSystemVersion createShowAuthors2(UmlSource source) {
// Duplicate in OptionPrint
final List strings = getAuthorsStrings(true);
return new PSystemVersion(source, true, strings);
}
public static List getAuthorsStrings(boolean withTag) {
final List strings = new ArrayList<>();
add(strings, "PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")",
withTag);
add(strings, "(" + License.getCurrent() + " source distribution)", withTag);
add(strings, " ", withTag);
add(strings, "Original idea: Arnaud Roques", withTag);
add(strings, "Word Macro: Alain Bertucat & Matthieu Sabatier", withTag);
add(strings, "Word Add-in: Adriaan van den Brand", withTag);
add(strings, "J2V8 & viz.js integration: Andreas Studer", withTag);
add(strings, "Official Eclipse Plugin: Hallvard Tr\u00E6tteberg", withTag);
add(strings, "Original Eclipse Plugin: Claude Durif & Anne Pecoil", withTag);
add(strings, "Servlet & XWiki: Maxime Sinclair", withTag);
add(strings, "Docker: David Ducatel", withTag);
add(strings, "AWS lib: Chris Passarello", withTag);
add(strings, "Stdlib Icons: tupadr3", withTag);
add(strings, "Site design: Raphael Cotisson", withTag);
add(strings, "Logo: Benjamin Croizet", withTag);
add(strings, "Web Assembly: Sakir Temel", withTag);
add(strings, " ", withTag);
add(strings, "https://plantuml.com", withTag);
add(strings, " ", withTag);
return strings;
}
private static void add(List result, String s, boolean withTag) {
if (withTag == false)
s = s.replaceAll("\\?\\w+\\>", "");
result.add(s);
}
// ::comment when __CORE__
public static PSystemVersion createTestDot(UmlSource source) throws IOException {
final List strings = new ArrayList<>();
strings.add(Version.fullDescription());
GraphvizUtils.addDotStatus(strings, true);
return new PSystemVersion(source, false, strings);
}
// public static PSystemVersion createDumpStackTrace() throws IOException {
// final List strings = new ArrayList<>();
// final Throwable creationPoint = new Throwable();
// creationPoint.fillInStackTrace();
// for (StackTraceElement ste : creationPoint.getStackTrace()) {
// strings.add(ste.toString());
// }
// return new PSystemVersion(false, strings);
// }
// ::comment when __CORE__
public static PSystemVersion createKeyDistributor(UmlSource source) throws IOException {
final LicenseInfo license = LicenseInfo.retrieveDistributor();
BufferedImage im = null;
final List strings = new ArrayList<>();
if (license == null) {
strings.add("No license found");
} else {
strings.add(license.getOwner());
strings.add(license.getContext());
strings.add(license.getGenerationDate().toString());
strings.add(license.getExpirationDate().toString());
im = LicenseInfo.retrieveDistributorImage(license);
}
return new PSystemVersion(source, strings, im);
}
// public static PSystemVersion createPath(UmlSource source) throws IOException {
// final List strings = new ArrayList<>();
// strings.add("Current Dir: " + new SFile(".").getPrintablePath());
// strings.add(" ");
// strings.add("Default path:");
// for (SFile f : ImportedFiles.createImportedFiles(null).getPath()) {
// strings.add(f.getPrintablePath());
// }
// return new PSystemVersion(source, true, strings);
// }
public DiagramDescription getDescription() {
return new DiagramDescription("(Version)");
}
public List getLines() {
return Collections.unmodifiableList(strings);
}
}