src/ 0040755 0000000 0000000 00000000000 12521434546 010405 5 ustar 00 0000000 0000000 src/net/ 0040755 0000000 0000000 00000000000 12521434546 011173 5 ustar 00 0000000 0000000 src/net/sourceforge/ 0040755 0000000 0000000 00000000000 12521434546 013516 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ 0040755 0000000 0000000 00000000000 12521434562 015350 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram/ 0040755 0000000 0000000 00000000000 12521434546 020533 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram3/ 0040755 0000000 0000000 00000000000 12521434546 020616 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram3/command/ 0040755 0000000 0000000 00000000000 12521434546 022234 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram3/ftile/ 0040755 0000000 0000000 00000000000 12521434546 021721 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ 0040755 0000000 0000000 00000000000 12521434546 023535 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/ 0040755 0000000 0000000 00000000000 12521434546 023532 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/activitydiagram/command/ 0040755 0000000 0000000 00000000000 12521434546 022151 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/anim/ 0040755 0000000 0000000 00000000000 12521434546 016276 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ant/ 0040755 0000000 0000000 00000000000 12521434546 016134 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/api/ 0040755 0000000 0000000 00000000000 12521434546 016123 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/api/mda/ 0040755 0000000 0000000 00000000000 12521434546 016664 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/api/mda/option2/ 0040755 0000000 0000000 00000000000 12521434546 020256 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/api/mda/option3/ 0040755 0000000 0000000 00000000000 12521434546 020257 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/applet/ 0040755 0000000 0000000 00000000000 12521434546 016637 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/asciiart/ 0040755 0000000 0000000 00000000000 12521434547 017152 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/braille/ 0040755 0000000 0000000 00000000000 12521434547 016765 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/classdiagram/ 0040755 0000000 0000000 00000000000 12521434547 020005 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/classdiagram/command/ 0040755 0000000 0000000 00000000000 12521434547 021423 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/code/ 0040755 0000000 0000000 00000000000 12521434547 016265 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/command/ 0040755 0000000 0000000 00000000000 12521434547 016771 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/command/note/ 0040755 0000000 0000000 00000000000 12521434547 017736 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/command/note/sequence/ 0040755 0000000 0000000 00000000000 12521434547 021546 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/command/regex/ 0040755 0000000 0000000 00000000000 12521434547 020103 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/compositediagram/ 0040755 0000000 0000000 00000000000 12521434547 020702 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/compositediagram/command/ 0040755 0000000 0000000 00000000000 12521434547 022320 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/core/ 0040755 0000000 0000000 00000000000 12521434547 016303 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/creole/ 0040755 0000000 0000000 00000000000 12521434547 016624 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/cucadiagram/ 0040755 0000000 0000000 00000000000 12521434550 017605 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/cucadiagram/dot/ 0040755 0000000 0000000 00000000000 12521434547 020401 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/cucadiagram/entity/ 0040755 0000000 0000000 00000000000 12521434547 021127 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/cute/ 0040755 0000000 0000000 00000000000 12521434550 016305 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/descdiagram/ 0040755 0000000 0000000 00000000000 12521434550 017610 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/descdiagram/command/ 0040755 0000000 0000000 00000000000 12521434550 021226 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/directdot/ 0040755 0000000 0000000 00000000000 12521434550 017326 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/donors/ 0040755 0000000 0000000 00000000000 12521434550 016651 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/eggs/ 0040755 0000000 0000000 00000000000 12521434550 016272 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/eps/ 0040755 0000000 0000000 00000000000 12521434550 016134 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/flashcode/ 0040755 0000000 0000000 00000000000 12521434550 017275 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/flowdiagram/ 0040755 0000000 0000000 00000000000 12521434550 017641 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/font/ 0040755 0000000 0000000 00000000000 12521434550 016313 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ftp/ 0040755 0000000 0000000 00000000000 12521434550 016136 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/fun/ 0040755 0000000 0000000 00000000000 12521434550 016135 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/geom/ 0040755 0000000 0000000 00000000000 12521434550 016274 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/geom/kinetic/ 0040755 0000000 0000000 00000000000 12521434550 017722 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/golem/ 0040755 0000000 0000000 00000000000 12521434550 016450 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/graph/ 0040755 0000000 0000000 00000000000 12521434551 016447 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/graph2/ 0040755 0000000 0000000 00000000000 12521434551 016531 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/graphic/ 0040755 0000000 0000000 00000000000 12521434551 016763 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector/ 0040755 0000000 0000000 00000000000 12521434552 016633 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector2/ 0040755 0000000 0000000 00000000000 12521434552 016715 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector2/continuity/ 0040755 0000000 0000000 00000000000 12521434552 021122 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector2/graphic/ 0040755 0000000 0000000 00000000000 12521434552 020332 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector2/layering/ 0040755 0000000 0000000 00000000000 12521434552 020527 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/hector2/mpos/ 0040755 0000000 0000000 00000000000 12521434552 017673 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/html/ 0040755 0000000 0000000 00000000000 12521434552 016313 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/jungle/ 0040755 0000000 0000000 00000000000 12521434552 016633 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/mda/ 0040755 0000000 0000000 00000000000 12521434552 016110 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/mjpeg/ 0040755 0000000 0000000 00000000000 12521434552 016451 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/objectdiagram/ 0040755 0000000 0000000 00000000000 12521434552 020142 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/objectdiagram/command/ 0040755 0000000 0000000 00000000000 12521434552 021560 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/openiconic/ 0040755 0000000 0000000 00000000000 12521434553 017476 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/openiconic/data/ 0040755 0000000 0000000 00000000000 12521434553 020407 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/oregon/ 0040755 0000000 0000000 00000000000 12521434554 016642 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/pdf/ 0040755 0000000 0000000 00000000000 12521434555 016123 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/png/ 0040755 0000000 0000000 00000000000 12521434555 016136 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/posimo/ 0040755 0000000 0000000 00000000000 12521434555 016660 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/postit/ 0040755 0000000 0000000 00000000000 12521434556 016675 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/preproc/ 0040755 0000000 0000000 00000000000 12521434556 017025 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/printskin/ 0040755 0000000 0000000 00000000000 12521434556 017374 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/project/ 0040755 0000000 0000000 00000000000 12521434556 017021 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/project2/ 0040755 0000000 0000000 00000000000 12521434556 017103 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/project2/command/ 0040755 0000000 0000000 00000000000 12521434556 020521 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/project/command/ 0040755 0000000 0000000 00000000000 12521434556 020437 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/project/graphic/ 0040755 0000000 0000000 00000000000 12521434556 020436 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/real/ 0040755 0000000 0000000 00000000000 12521434556 016276 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/salt/ 0040755 0000000 0000000 00000000000 12521434557 016317 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/salt/element/ 0040755 0000000 0000000 00000000000 12521434556 017747 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/salt/factory/ 0040755 0000000 0000000 00000000000 12521434557 017766 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/sequencediagram/ 0040755 0000000 0000000 00000000000 12521434557 020511 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/sequencediagram/command/ 0040755 0000000 0000000 00000000000 12521434557 022127 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/sequencediagram/graphic/ 0040755 0000000 0000000 00000000000 12521434557 022126 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/sequencediagram/puma/ 0040755 0000000 0000000 00000000000 12521434557 021453 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/sequencediagram/teoz/ 0040755 0000000 0000000 00000000000 12521434557 021472 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/skin/ 0040755 0000000 0000000 00000000000 12521434560 016312 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/skin/bluemodern/ 0040755 0000000 0000000 00000000000 12521434560 020446 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/skin/rose/ 0040755 0000000 0000000 00000000000 12521434560 017262 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/statediagram/ 0040755 0000000 0000000 00000000000 12521434560 020013 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/statediagram/command/ 0040755 0000000 0000000 00000000000 12521434560 021431 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/suggest/ 0040755 0000000 0000000 00000000000 12521434560 017027 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/svek/ 0040755 0000000 0000000 00000000000 12521434561 016317 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/svek/extremity/ 0040755 0000000 0000000 00000000000 12521434560 020350 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/svek/image/ 0040755 0000000 0000000 00000000000 12521434561 017401 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/svg/ 0040755 0000000 0000000 00000000000 12521434561 016146 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/swing/ 0040755 0000000 0000000 00000000000 12521434561 016476 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/syntax/ 0040755 0000000 0000000 00000000000 12521434561 016675 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/telnet/ 0040755 0000000 0000000 00000000000 12521434561 016642 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/tikz/ 0040755 0000000 0000000 00000000000 12521434561 016330 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/ 0040755 0000000 0000000 00000000000 12521434562 017152 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/arc/ 0040755 0000000 0000000 00000000000 12521434561 017716 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/eps/ 0040755 0000000 0000000 00000000000 12521434561 017740 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/g2d/ 0040755 0000000 0000000 00000000000 12521434561 017625 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/hand/ 0040755 0000000 0000000 00000000000 12521434562 020064 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/html5/ 0040755 0000000 0000000 00000000000 12521434562 020203 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/svg/ 0040755 0000000 0000000 00000000000 12521434562 017751 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/tikz/ 0040755 0000000 0000000 00000000000 12521434562 020133 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/txt/ 0040755 0000000 0000000 00000000000 12521434562 017771 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/ugraphic/visio/ 0040755 0000000 0000000 00000000000 12521434562 020303 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/utils/ 0040755 0000000 0000000 00000000000 12521434562 016510 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/version/ 0040755 0000000 0000000 00000000000 12521434562 017035 5 ustar 00 0000000 0000000 src/net/sourceforge/plantuml/xmi/ 0040755 0000000 0000000 00000000000 12521434562 016145 5 ustar 00 0000000 0000000 COPYING 0100644 0000000 0000000 00000002616 12521434562 010651 0 ustar 00 0000000 0000000 ========================================================================
PlantUML : a free UML diagram generator
========================================================================
(C) Copyright 2009-2014, Arnaud Roques
PlantUML is free software; you can redistribute it and/or modify it under the
terms of the MIT License.
See http://opensource.org/licenses/MIT
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README 0100644 0000000 0000000 00000000070 12521434562 010466 0 ustar 00 0000000 0000000 Goto http://plantuml.sourceforge.net/ for product info
build.xml 0100644 0000000 0000000 00000003312 12521434562 011431 0 ustar 00 0000000 0000000
PlantUML Build File
src/net/sourceforge/plantuml/AbstractPSystem.java 0100644 0000000 0000000 00000007300 12521434546 021302 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.ProtectedCommand;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.Version;
public abstract class AbstractPSystem implements Diagram {
private UmlSource source;
private String getVersion() {
final StringBuilder toAppend = new StringBuilder();
toAppend.append("PlantUML version ");
toAppend.append(Version.versionString());
toAppend.append("(" + Version.compileTimeString() + ")\n");
toAppend.append("(" + License.getCurrent() + " source distribution)\n");
final Properties p = System.getProperties();
toAppend.append(p.getProperty("java.runtime.name"));
toAppend.append('\n');
toAppend.append(p.getProperty("java.vm.name"));
toAppend.append('\n');
toAppend.append(p.getProperty("java.runtime.version"));
toAppend.append('\n');
toAppend.append(p.getProperty("os.name"));
return toAppend.toString();
}
final public String getMetadata() {
if (source == null) {
return getVersion();
}
return source.getPlainString() + "\n" + getVersion();
}
final public UmlSource getSource() {
return source;
}
final public void setSource(UmlSource source) {
this.source = source;
}
public int getNbImages() {
return 1;
}
public Display getTitle() {
if (source == null) {
return Display.empty();
}
return source.getTitle();
}
public String getWarningOrError() {
return null;
}
public void makeDiagramReady() {
}
public boolean isOk() {
return true;
}
public CommandExecutionResult executeCommand(Command cmd, List lines) {
cmd = new ProtectedCommand(cmd);
return cmd.execute(this, lines);
}
public boolean hasUrl() {
return false;
}
}
src/net/sourceforge/plantuml/AlignParam.java 0100644 0000000 0000000 00000004153 12521434546 020230 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public enum AlignParam {
SEQUENCE_MESSAGE_ALIGN(HorizontalAlignment.LEFT),
SEQUENCE_MESSAGETEXT_ALIGN(HorizontalAlignment.LEFT),
SEQUENCE_REFERENCE_ALIGN(HorizontalAlignment.CENTER);
private final HorizontalAlignment defaultValue;
private AlignParam(HorizontalAlignment defaultValue) {
this.defaultValue = defaultValue;
}
public final HorizontalAlignment getDefaultValue() {
return defaultValue;
}
}
src/net/sourceforge/plantuml/AnimatedGifEncoder.java 0100644 0000000 0000000 00000106155 12521434546 021672 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Class AnimatedGifEncoder - Encodes a GIF file consisting of one or more
* frames.
*
*
* Example:
* AnimatedGifEncoder e = new AnimatedGifEncoder();
* e.start(outputFileName);
* e.setDelay(1000); // 1 frame per sec
* e.addFrame(image1);
* e.addFrame(image2);
* e.finish();
*
*
* No copyright asserted on the source code of this class. May be used for any
* purpose, however, refer to the Unisys LZW patent for restrictions on use of
* the associated LZWEncoder class. Please forward any corrections to
* kweiner@fmsware.com.
*
* @author Kevin Weiner, FM Software
* @version 1.03 November 2003
*
*/
public class AnimatedGifEncoder {
protected int width; // image size
protected int height;
protected Color transparent = null; // transparent color if given
protected int transIndex; // transparent index in color table
protected int repeat = -1; // no repeat
protected int delay = 0; // frame delay (hundredths)
protected boolean started = false; // ready to output frames
protected OutputStream out;
protected BufferedImage image; // current frame
protected byte[] pixels; // BGR byte array from frame
protected byte[] indexedPixels; // converted frame indexed to palette
protected int colorDepth; // number of bit planes
protected byte[] colorTab; // RGB palette
protected boolean[] usedEntry = new boolean[256]; // active palette
// entries
protected int palSize = 7; // color table size (bits-1)
protected int dispose = -1; // disposal code (-1 = use default)
protected boolean closeStream = false; // close stream when finished
protected boolean firstFrame = true;
protected boolean sizeSet = false; // if false, get size from first frame
protected int sample = 10; // default sample interval for quantizer
/**
* Sets the delay time between each frame, or changes it for subsequent
* frames (applies to last frame added).
*
* @param ms
* int delay time in milliseconds
*/
public void setDelay(int ms) {
delay = Math.round(ms / 10.0f);
}
/**
* Sets the GIF frame disposal code for the last added frame and any
* subsequent frames. Default is 0 if no transparent color has been set,
* otherwise 2.
*
* @param code
* int disposal code.
*/
public void setDispose(int code) {
if (code >= 0) {
dispose = code;
}
}
/**
* Sets the number of times the set of GIF frames should be played. Default
* is 1; 0 means play indefinitely. Must be invoked before the first image
* is added.
*
* @param iter
* int number of iterations.
* @return
*/
public void setRepeat(int iter) {
if (iter >= 0) {
repeat = iter;
}
}
/**
* Sets the transparent color for the last added frame and any subsequent
* frames. Since all colors are subject to modification in the quantization
* process, the color in the final palette for each frame closest to the
* given color becomes the transparent color for that frame. May be set to
* null to indicate no transparent color.
*
* @param c
* Color to be treated as transparent on display.
*/
public void setTransparent(Color c) {
transparent = c;
}
/**
* Adds next GIF frame. The frame is not written immediately, but is
* actually deferred until the next frame is received so that timing data
* can be inserted. Invoking finish() flushes all frames. If
* setSize was not invoked, the size of the first image is
* used for all subsequent frames.
*
* @param im
* BufferedImage containing frame to write.
* @return true if successful.
*/
public boolean addFrame(BufferedImage im) {
if ((im == null) || !started) {
return false;
}
boolean ok = true;
try {
if (!sizeSet) {
// use first frame's size
setSize(im.getWidth(), im.getHeight());
}
image = im;
getImagePixels(); // convert to correct format if necessary
analyzePixels(); // build color table & map pixels
if (firstFrame) {
writeLSD(); // logical screen descriptior
writePalette(); // global color table
if (repeat >= 0) {
// use NS app extension to indicate reps
writeNetscapeExt();
}
}
writeGraphicCtrlExt(); // write graphic control extension
writeImageDesc(); // image descriptor
if (!firstFrame) {
writePalette(); // local color table
}
writePixels(); // encode and write pixel data
firstFrame = false;
} catch (IOException e) {
ok = false;
}
return ok;
}
/**
* Flushes any pending data and closes output file. If writing to an
* OutputStream, the stream is not closed.
*/
public boolean finish() {
if (!started)
return false;
boolean ok = true;
started = false;
try {
out.write(0x3b); // gif trailer
out.flush();
if (closeStream) {
out.close();
}
} catch (IOException e) {
ok = false;
}
// reset for subsequent use
transIndex = 0;
out = null;
image = null;
pixels = null;
indexedPixels = null;
colorTab = null;
closeStream = false;
firstFrame = true;
return ok;
}
/**
* Sets frame rate in frames per second. Equivalent to
* setDelay(1000/fps).
*
* @param fps
* float frame rate (frames per second)
*/
public void setFrameRate(float fps) {
if (fps != 0f) {
delay = Math.round(100f / fps);
}
}
/**
* Sets quality of color quantization (conversion of images to the maximum
* 256 colors allowed by the GIF specification). Lower values (minimum = 1)
* produce better colors, but slow processing significantly. 10 is the
* default, and produces good color mapping at reasonable speeds. Values
* greater than 20 do not yield significant improvements in speed.
*
* @param quality
* int greater than 0.
* @return
*/
public void setQuality(int quality) {
if (quality < 1)
quality = 1;
sample = quality;
}
/**
* Sets the GIF frame size. The default size is the size of the first frame
* added if this method is not invoked.
*
* @param w
* int frame width.
* @param h
* int frame width.
*/
public void setSize(int w, int h) {
if (started && !firstFrame)
return;
width = w;
height = h;
if (width < 1)
width = 320;
if (height < 1)
height = 240;
sizeSet = true;
}
/**
* Initiates GIF file creation on the given stream. The stream is not closed
* automatically.
*
* @param os
* OutputStream on which GIF images are written.
* @return false if initial write failed.
*/
public boolean start(OutputStream os) {
if (os == null)
return false;
boolean ok = true;
closeStream = false;
out = os;
try {
writeString("GIF89a"); // header
} catch (IOException e) {
ok = false;
}
return started = ok;
}
/**
* Initiates writing of a GIF file with the specified name.
*
* @param file
* String containing output file name.
* @return false if open or initial write failed.
*/
public boolean start(String file) {
boolean ok = true;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
ok = start(out);
closeStream = true;
} catch (IOException e) {
ok = false;
}
return started = ok;
}
/**
* Analyzes image colors and creates color map.
*/
protected void analyzePixels() {
int len = pixels.length;
int nPix = len / 3;
indexedPixels = new byte[nPix];
NeuQuant nq = new NeuQuant(pixels, len, sample);
// initialize quantizer
colorTab = nq.process(); // create reduced palette
// convert map from BGR to RGB
for (int i = 0; i < colorTab.length; i += 3) {
byte temp = colorTab[i];
colorTab[i] = colorTab[i + 2];
colorTab[i + 2] = temp;
usedEntry[i / 3] = false;
}
// map image pixels to new palette
int k = 0;
for (int i = 0; i < nPix; i++) {
int index = nq.map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff);
usedEntry[index] = true;
indexedPixels[i] = (byte) index;
}
pixels = null;
colorDepth = 8;
palSize = 7;
// get closest match to transparent color if specified
if (transparent != null) {
transIndex = findClosest(transparent);
}
}
/**
* Returns index of palette color closest to c
*
*/
protected int findClosest(Color c) {
if (colorTab == null)
return -1;
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
int minpos = 0;
int dmin = 256 * 256 * 256;
int len = colorTab.length;
for (int i = 0; i < len;) {
int dr = r - (colorTab[i++] & 0xff);
int dg = g - (colorTab[i++] & 0xff);
int db = b - (colorTab[i] & 0xff);
int d = dr * dr + dg * dg + db * db;
int index = i / 3;
if (usedEntry[index] && (d < dmin)) {
dmin = d;
minpos = index;
}
i++;
}
return minpos;
}
/**
* Extracts image pixels into byte array "pixels"
*/
protected void getImagePixels() {
int w = image.getWidth();
int h = image.getHeight();
int type = image.getType();
if ((w != width) || (h != height) || (type != BufferedImage.TYPE_3BYTE_BGR)) {
// create new image with right size/format
BufferedImage temp = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = temp.createGraphics();
g.drawImage(image, 0, 0, null);
image = temp;
}
pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
}
/**
* Writes Graphic Control Extension
*/
protected void writeGraphicCtrlExt() throws IOException {
out.write(0x21); // extension introducer
out.write(0xf9); // GCE label
out.write(4); // data block size
int transp, disp;
if (transparent == null) {
transp = 0;
disp = 0; // dispose = no action
} else {
transp = 1;
disp = 2; // force clear if using transparent color
}
if (dispose >= 0) {
disp = dispose & 7; // user override
}
disp <<= 2;
// packed fields
out.write(0 | // 1:3 reserved
disp | // 4:6 disposal
0 | // 7 user input - 0 = none
transp); // 8 transparency flag
writeShort(delay); // delay x 1/100 sec
out.write(transIndex); // transparent color index
out.write(0); // block terminator
}
/**
* Writes Image Descriptor
*/
protected void writeImageDesc() throws IOException {
out.write(0x2c); // image separator
writeShort(0); // image position x,y = 0,0
writeShort(0);
writeShort(width); // image size
writeShort(height);
// packed fields
if (firstFrame) {
// no LCT - GCT is used for first (or only) frame
out.write(0);
} else {
// specify normal LCT
out.write(0x80 | // 1 local color table 1=yes
0 | // 2 interlace - 0=no
0 | // 3 sorted - 0=no
0 | // 4-5 reserved
palSize); // 6-8 size of color table
}
}
/**
* Writes Logical Screen Descriptor
*/
protected void writeLSD() throws IOException {
// logical screen size
writeShort(width);
writeShort(height);
// packed fields
out.write((0x80 | // 1 : global color table flag = 1 (gct used)
0x70 | // 2-4 : color resolution = 7
0x00 | // 5 : gct sort flag = 0
palSize)); // 6-8 : gct size
out.write(0); // background color index
out.write(0); // pixel aspect ratio - assume 1:1
}
/**
* Writes Netscape application extension to define repeat count.
*/
protected void writeNetscapeExt() throws IOException {
out.write(0x21); // extension introducer
out.write(0xff); // app extension label
out.write(11); // block size
writeString("NETSCAPE" + "2.0"); // app id + auth code
out.write(3); // sub-block size
out.write(1); // loop sub-block id
writeShort(repeat); // loop count (extra iterations, 0=repeat forever)
out.write(0); // block terminator
}
/**
* Writes color table
*/
protected void writePalette() throws IOException {
out.write(colorTab, 0, colorTab.length);
int n = (3 * 256) - colorTab.length;
for (int i = 0; i < n; i++) {
out.write(0);
}
}
/**
* Encodes and writes pixel data
*/
protected void writePixels() throws IOException {
LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth);
encoder.encode(out);
}
/**
* Write 16-bit value to output stream, LSB first
*/
protected void writeShort(int value) throws IOException {
out.write(value & 0xff);
out.write((value >> 8) & 0xff);
}
/**
* Writes string to output stream
*/
protected void writeString(String s) throws IOException {
for (int i = 0; i < s.length(); i++) {
out.write((byte) s.charAt(i));
}
}
}
/*
* NeuQuant Neural-Net Quantization Algorithm
* ------------------------------------------
*
* Copyright (c) 1994 Anthony Dekker
*
* NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
* "Kohonen neural networks for optimal colour quantization" in "Network:
* Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
* the algorithm.
*
* Any party obtaining a copy of these files from the author, directly or
* indirectly, is granted, free of charge, a full and unrestricted irrevocable,
* world-wide, paid up, royalty-free, nonexclusive right and license to deal in
* this software and documentation files (the "Software"), including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons who
* receive copies from any such party to do so, with the only requirement being
* that this copyright notice remain intact.
*/
// Ported to Java 12/00 K Weiner
class NeuQuant {
protected static final int netsize = 256; /* number of colours used */
/* four primes near 500 - assume no image has a length so large */
/* that it is divisible by all four primes */
protected static final int prime1 = 499;
protected static final int prime2 = 491;
protected static final int prime3 = 487;
protected static final int prime4 = 503;
protected static final int minpicturebytes = (3 * prime4);
/* minimum size for input image */
/*
* Program Skeleton ---------------- [select samplefac in range 1..30] [read
* image from input file] pic = (unsigned char*) malloc(3*width*height);
* initnet(pic,3*width*height,samplefac); learn(); unbiasnet(); [write
* output image header, using writecolourmap(f)] inxbuild(); write output
* image using inxsearch(b,g,r)
*/
/*
* Network Definitions -------------------
*/
protected static final int maxnetpos = (netsize - 1);
protected static final int netbiasshift = 4; /* bias for colour values */
protected static final int ncycles = 100; /* no. of learning cycles */
/* defs for freq and bias */
protected static final int intbiasshift = 16; /* bias for fractions */
protected static final int intbias = (((int) 1) << intbiasshift);
protected static final int gammashift = 10; /* gamma = 1024 */
protected static final int gamma = (((int) 1) << gammashift);
protected static final int betashift = 10;
protected static final int beta = (intbias >> betashift); /* beta = 1/1024 */
protected static final int betagamma = (intbias << (gammashift - betashift));
/* defs for decreasing radius factor */
protected static final int initrad = (netsize >> 3); /*
* for 256 cols,
* radius starts
*/
protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */
protected static final int radiusbias = (((int) 1) << radiusbiasshift);
protected static final int initradius = (initrad * radiusbias); /*
* and
* decreases
* by a
*/
protected static final int radiusdec = 30; /* factor of 1/30 each cycle */
/* defs for decreasing alpha factor */
protected static final int alphabiasshift = 10; /* alpha starts at 1.0 */
protected static final int initalpha = (((int) 1) << alphabiasshift);
protected int alphadec; /* biased by 10 bits */
/* radbias and alpharadbias used for radpower calculation */
protected static final int radbiasshift = 8;
protected static final int radbias = (((int) 1) << radbiasshift);
protected static final int alpharadbshift = (alphabiasshift + radbiasshift);
protected static final int alpharadbias = (((int) 1) << alpharadbshift);
/*
* Types and Global Variables --------------------------
*/
protected byte[] thepicture; /* the input image itself */
protected int lengthcount; /* lengthcount = H*W*3 */
protected int samplefac; /* sampling factor 1..30 */
// typedef int pixel[4]; /* BGRc */
protected int[][] network; /* the network itself - [netsize][4] */
protected int[] netindex = new int[256];
/* for network lookup - really 256 */
protected int[] bias = new int[netsize];
/* bias and freq arrays for learning */
protected int[] freq = new int[netsize];
protected int[] radpower = new int[initrad];
/* radpower for precomputation */
/*
* Initialise network in range (0,0,0) to (255,255,255) and set parameters
* -----------------------------------------------------------------------
*/
public NeuQuant(byte[] thepic, int len, int sample) {
int i;
int[] p;
thepicture = thepic;
lengthcount = len;
samplefac = sample;
network = new int[netsize][];
for (i = 0; i < netsize; i++) {
network[i] = new int[4];
p = network[i];
p[0] = p[1] = p[2] = (i << (netbiasshift + 8)) / netsize;
freq[i] = intbias / netsize; /* 1/netsize */
bias[i] = 0;
}
}
public byte[] colorMap() {
byte[] map = new byte[3 * netsize];
int[] index = new int[netsize];
for (int i = 0; i < netsize; i++)
index[network[i][3]] = i;
int k = 0;
for (int i = 0; i < netsize; i++) {
int j = index[i];
map[k++] = (byte) (network[j][0]);
map[k++] = (byte) (network[j][1]);
map[k++] = (byte) (network[j][2]);
}
return map;
}
/*
* Insertion sort of network and building of netindex[0..255] (to do after
* unbias)
* -------------------------------------------------------------------------------
*/
public void inxbuild() {
int i, j, smallpos, smallval;
int[] p;
int[] q;
int previouscol, startpos;
previouscol = 0;
startpos = 0;
for (i = 0; i < netsize; i++) {
p = network[i];
smallpos = i;
smallval = p[1]; /* index on g */
/* find smallest in i..netsize-1 */
for (j = i + 1; j < netsize; j++) {
q = network[j];
if (q[1] < smallval) { /* index on g */
smallpos = j;
smallval = q[1]; /* index on g */
}
}
q = network[smallpos];
/* swap p (i) and q (smallpos) entries */
if (i != smallpos) {
j = q[0];
q[0] = p[0];
p[0] = j;
j = q[1];
q[1] = p[1];
p[1] = j;
j = q[2];
q[2] = p[2];
p[2] = j;
j = q[3];
q[3] = p[3];
p[3] = j;
}
/* smallval entry is now in position i */
if (smallval != previouscol) {
netindex[previouscol] = (startpos + i) >> 1;
for (j = previouscol + 1; j < smallval; j++)
netindex[j] = i;
previouscol = smallval;
startpos = i;
}
}
netindex[previouscol] = (startpos + maxnetpos) >> 1;
for (j = previouscol + 1; j < 256; j++)
netindex[j] = maxnetpos; /* really 256 */
}
/*
* Main Learning Loop ------------------
*/
public void learn() {
int i, j, b, g, r;
int radius, rad, alpha, step, delta, samplepixels;
byte[] p;
int pix, lim;
if (lengthcount < minpicturebytes)
samplefac = 1;
alphadec = 30 + ((samplefac - 1) / 3);
p = thepicture;
pix = 0;
lim = lengthcount;
samplepixels = lengthcount / (3 * samplefac);
delta = samplepixels / ncycles;
alpha = initalpha;
radius = initradius;
rad = radius >> radiusbiasshift;
if (rad <= 1)
rad = 0;
for (i = 0; i < rad; i++)
radpower[i] = alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
// fprintf(stderr,"beginning 1D learning: initial radius=%d\n", rad);
if (lengthcount < minpicturebytes)
step = 3;
else if ((lengthcount % prime1) != 0)
step = 3 * prime1;
else {
if ((lengthcount % prime2) != 0)
step = 3 * prime2;
else {
if ((lengthcount % prime3) != 0)
step = 3 * prime3;
else
step = 3 * prime4;
}
}
i = 0;
while (i < samplepixels) {
b = (p[pix + 0] & 0xff) << netbiasshift;
g = (p[pix + 1] & 0xff) << netbiasshift;
r = (p[pix + 2] & 0xff) << netbiasshift;
j = contest(b, g, r);
altersingle(alpha, j, b, g, r);
if (rad != 0)
alterneigh(rad, j, b, g, r); /* alter neighbours */
pix += step;
if (pix >= lim)
pix -= lengthcount;
i++;
if (delta == 0)
delta = 1;
if (i % delta == 0) {
alpha -= alpha / alphadec;
radius -= radius / radiusdec;
rad = radius >> radiusbiasshift;
if (rad <= 1)
rad = 0;
for (j = 0; j < rad; j++)
radpower[j] = alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
}
}
// fprintf(stderr,"finished 1D learning: final alpha=%f
// !\n",((float)alpha)/initalpha);
}
/*
* Search for BGR values 0..255 (after net is unbiased) and return colour
* index
* ----------------------------------------------------------------------------
*/
public int map(int b, int g, int r) {
int i, j, dist, a, bestd;
int[] p;
int best;
bestd = 1000; /* biggest possible dist is 256*3 */
best = -1;
i = netindex[g]; /* index on g */
j = i - 1; /* start at netindex[g] and work outwards */
while ((i < netsize) || (j >= 0)) {
if (i < netsize) {
p = network[i];
dist = p[1] - g; /* inx key */
if (dist >= bestd)
i = netsize; /* stop iter */
else {
i++;
if (dist < 0)
dist = -dist;
a = p[0] - b;
if (a < 0)
a = -a;
dist += a;
if (dist < bestd) {
a = p[2] - r;
if (a < 0)
a = -a;
dist += a;
if (dist < bestd) {
bestd = dist;
best = p[3];
}
}
}
}
if (j >= 0) {
p = network[j];
dist = g - p[1]; /* inx key - reverse dif */
if (dist >= bestd)
j = -1; /* stop iter */
else {
j--;
if (dist < 0)
dist = -dist;
a = p[0] - b;
if (a < 0)
a = -a;
dist += a;
if (dist < bestd) {
a = p[2] - r;
if (a < 0)
a = -a;
dist += a;
if (dist < bestd) {
bestd = dist;
best = p[3];
}
}
}
}
}
return (best);
}
public byte[] process() {
learn();
unbiasnet();
inxbuild();
return colorMap();
}
/*
* Unbias network to give byte values 0..255 and record position i to
* prepare for sort
* -----------------------------------------------------------------------------------
*/
public void unbiasnet() {
int i, j;
for (i = 0; i < netsize; i++) {
network[i][0] >>= netbiasshift;
network[i][1] >>= netbiasshift;
network[i][2] >>= netbiasshift;
network[i][3] = i; /* record colour no */
}
}
/*
* Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in
* radpower[|i-j|]
* ---------------------------------------------------------------------------------
*/
protected void alterneigh(int rad, int i, int b, int g, int r) {
int j, k, lo, hi, a, m;
int[] p;
lo = i - rad;
if (lo < -1)
lo = -1;
hi = i + rad;
if (hi > netsize)
hi = netsize;
j = i + 1;
k = i - 1;
m = 1;
while ((j < hi) || (k > lo)) {
a = radpower[m++];
if (j < hi) {
p = network[j++];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
} catch (Exception e) {
} // prevents 1.3 miscompilation
}
if (k > lo) {
p = network[k--];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
} catch (Exception e) {
}
}
}
}
/*
* Move neuron i towards biased (b,g,r) by factor alpha
* ----------------------------------------------------
*/
protected void altersingle(int alpha, int i, int b, int g, int r) {
/* alter hit neuron */
int[] n = network[i];
n[0] -= (alpha * (n[0] - b)) / initalpha;
n[1] -= (alpha * (n[1] - g)) / initalpha;
n[2] -= (alpha * (n[2] - r)) / initalpha;
}
/*
* Search for biased BGR values ----------------------------
*/
protected int contest(int b, int g, int r) {
/* finds closest neuron (min dist) and updates freq */
/* finds best neuron (min dist-bias) and returns position */
/*
* for frequently chosen neurons, freq[i] is high and bias[i] is
* negative
*/
/* bias[i] = gamma*((1/netsize)-freq[i]) */
int i, dist, a, biasdist, betafreq;
int bestpos, bestbiaspos, bestd, bestbiasd;
int[] n;
bestd = ~(((int) 1) << 31);
bestbiasd = bestd;
bestpos = -1;
bestbiaspos = bestpos;
for (i = 0; i < netsize; i++) {
n = network[i];
dist = n[0] - b;
if (dist < 0)
dist = -dist;
a = n[1] - g;
if (a < 0)
a = -a;
dist += a;
a = n[2] - r;
if (a < 0)
a = -a;
dist += a;
if (dist < bestd) {
bestd = dist;
bestpos = i;
}
biasdist = dist - ((bias[i]) >> (intbiasshift - netbiasshift));
if (biasdist < bestbiasd) {
bestbiasd = biasdist;
bestbiaspos = i;
}
betafreq = (freq[i] >> betashift);
freq[i] -= betafreq;
bias[i] += (betafreq << gammashift);
}
freq[bestpos] += beta;
bias[bestpos] -= betagamma;
return (bestbiaspos);
}
}
// ==============================================================================
// Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott.
// K Weiner 12/00
class LZWEncoder {
private static final int EOF = -1;
private int imgW, imgH;
private byte[] pixAry;
private int initCodeSize;
private int remaining;
private int curPixel;
// GIFCOMPR.C - GIF Image compression routines
//
// Lempel-Ziv compression based on 'compress'. GIF modifications by
// David Rowley (mgardi@watdcsu.waterloo.edu)
// General DEFINEs
static final int BITS = 12;
static final int HSIZE = 5003; // 80% occupancy
// GIF Image compression - modified 'compress'
//
// Based on: compress.c - File compression ala IEEE Computer, June 1984.
//
// By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
// Jim McKie (decvax!mcvax!jim)
// Steve Davies (decvax!vax135!petsd!peora!srd)
// Ken Turkowski (decvax!decwrl!turtlevax!ken)
// James A. Woods (decvax!ihnp4!ames!jaw)
// Joe Orost (decvax!vax135!petsd!joe)
int n_bits; // number of bits/code
int maxbits = BITS; // user settable max # bits/code
int maxcode; // maximum code, given n_bits
int maxmaxcode = 1 << BITS; // should NEVER generate this code
int[] htab = new int[HSIZE];
int[] codetab = new int[HSIZE];
int hsize = HSIZE; // for dynamic table sizing
int free_ent = 0; // first unused entry
// block compression parameters -- after all codes are used up,
// and compression rate changes, start over.
boolean clear_flg = false;
// Algorithm: use open addressing double hashing (no chaining) on the
// prefix code / next character combination. We do a variant of Knuth's
// algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
// secondary probe. Here, the modular division first probe is gives way
// to a faster exclusive-or manipulation. Also do block compression with
// an adaptive reset, whereby the code table is cleared when the compression
// ratio decreases, but after the table fills. The variable-length output
// codes are re-sized at this point, and a special CLEAR code is generated
// for the decompressor. Late addition: construct the table according to
// file size for noticeable speed improvement on small files. Please direct
// questions about this implementation to ames!jaw.
int g_init_bits;
int ClearCode;
int EOFCode;
// output
//
// Output the given code.
// Inputs:
// code: A n_bits-bit integer. If == -1, then EOF. This assumes
// that n_bits =< wordsize - 1.
// Outputs:
// Outputs code to the file.
// Assumptions:
// Chars are 8 bits long.
// Algorithm:
// Maintain a BITS character long buffer (so that 8 codes will
// fit in it exactly). Use the VAX insv instruction to insert each
// code in turn. When the buffer fills up empty it and start over.
int cur_accum = 0;
int cur_bits = 0;
int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,
0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
// Number of characters so far in this 'packet'
int a_count;
// Define the storage for the packet accumulator
byte[] accum = new byte[256];
// ----------------------------------------------------------------------------
LZWEncoder(int width, int height, byte[] pixels, int color_depth) {
imgW = width;
imgH = height;
pixAry = pixels;
initCodeSize = Math.max(2, color_depth);
}
// Add a character to the end of the current packet, and if it is 254
// characters, flush the packet to disk.
void char_out(byte c, OutputStream outs) throws IOException {
accum[a_count++] = c;
if (a_count >= 254)
flush_char(outs);
}
// Clear out the hash table
// table clear for block compress
void cl_block(OutputStream outs) throws IOException {
cl_hash(hsize);
free_ent = ClearCode + 2;
clear_flg = true;
output(ClearCode, outs);
}
// reset code table
void cl_hash(int hsize) {
for (int i = 0; i < hsize; ++i)
htab[i] = -1;
}
void compress(int init_bits, OutputStream outs) throws IOException {
int fcode;
int i /* = 0 */;
int c;
int ent;
int disp;
int hsize_reg;
int hshift;
// Set up the globals: g_init_bits - initial number of bits
g_init_bits = init_bits;
// Set up the necessary values
clear_flg = false;
n_bits = g_init_bits;
maxcode = MAXCODE(n_bits);
ClearCode = 1 << (init_bits - 1);
EOFCode = ClearCode + 1;
free_ent = ClearCode + 2;
a_count = 0; // clear packet
ent = nextPixel();
hshift = 0;
for (fcode = hsize; fcode < 65536; fcode *= 2)
++hshift;
hshift = 8 - hshift; // set hash code range bound
hsize_reg = hsize;
cl_hash(hsize_reg); // clear hash table
output(ClearCode, outs);
outer_loop: while ((c = nextPixel()) != EOF) {
fcode = (c << maxbits) + ent;
i = (c << hshift) ^ ent; // xor hashing
if (htab[i] == fcode) {
ent = codetab[i];
continue;
} else if (htab[i] >= 0) // non-empty slot
{
disp = hsize_reg - i; // secondary hash (after G. Knott)
if (i == 0)
disp = 1;
do {
if ((i -= disp) < 0)
i += hsize_reg;
if (htab[i] == fcode) {
ent = codetab[i];
continue outer_loop;
}
} while (htab[i] >= 0);
}
output(ent, outs);
ent = c;
if (free_ent < maxmaxcode) {
codetab[i] = free_ent++; // code -> hashtable
htab[i] = fcode;
} else
cl_block(outs);
}
// Put out the final code.
output(ent, outs);
output(EOFCode, outs);
}
// ----------------------------------------------------------------------------
void encode(OutputStream os) throws IOException {
os.write(initCodeSize); // write "initial code size" byte
remaining = imgW * imgH; // reset navigation variables
curPixel = 0;
compress(initCodeSize + 1, os); // compress and write the pixel data
os.write(0); // write block terminator
}
// Flush the packet to disk, and reset the accumulator
void flush_char(OutputStream outs) throws IOException {
if (a_count > 0) {
outs.write(a_count);
outs.write(accum, 0, a_count);
a_count = 0;
}
}
final int MAXCODE(int n_bits) {
return (1 << n_bits) - 1;
}
// ----------------------------------------------------------------------------
// Return the next pixel from the image
// ----------------------------------------------------------------------------
private int nextPixel() {
if (remaining == 0)
return EOF;
--remaining;
byte pix = pixAry[curPixel++];
return pix & 0xff;
}
void output(int code, OutputStream outs) throws IOException {
cur_accum &= masks[cur_bits];
if (cur_bits > 0)
cur_accum |= (code << cur_bits);
else
cur_accum = code;
cur_bits += n_bits;
while (cur_bits >= 8) {
char_out((byte) (cur_accum & 0xff), outs);
cur_accum >>= 8;
cur_bits -= 8;
}
// If the next entry is going to be too big for the code size,
// then increase it, if possible.
if (free_ent > maxcode || clear_flg) {
if (clear_flg) {
maxcode = MAXCODE(n_bits = g_init_bits);
clear_flg = false;
} else {
++n_bits;
if (n_bits == maxbits)
maxcode = maxmaxcode;
else
maxcode = MAXCODE(n_bits);
}
}
if (code == EOFCode) {
// At EOF, write the rest of the buffer.
while (cur_bits > 0) {
char_out((byte) (cur_accum & 0xff), outs);
cur_accum >>= 8;
cur_bits -= 8;
}
flush_char(outs);
}
}
}
src/net/sourceforge/plantuml/BasicEnsureVisible.java 0100644 0000000 0000000 00000004771 12521434547 021745 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class BasicEnsureVisible implements EnsureVisible {
private double minX = Double.MAX_VALUE;
private double maxX = -Double.MAX_VALUE;
private double minY = Double.MAX_VALUE;
private double maxY = -Double.MAX_VALUE;
public void ensureVisible(double x, double y) {
if (x > maxX) {
maxX = x;
}
if (x < minX) {
minX = x;
}
if (y > maxY) {
maxY = y;
}
if (y < minY) {
minY = y;
}
}
public String getCoords(double scale) {
if (minX == Double.MAX_VALUE) {
return "0,0,0,0";
}
final int x1 = (int) (minX * scale);
final int y1 = (int) (minY * scale);
final int x2 = (int) (maxX * scale);
final int y2 = (int) (maxY * scale);
return "" + x1 + "," + y1 + "," + x2 + "," + y2;
}
public double getSurface() {
if (minX == Double.MAX_VALUE) {
return 0;
}
return (maxX - minX) * (maxY - minY);
}
}
src/net/sourceforge/plantuml/BlockUml.java 0100644 0000000 0000000 00000006352 12521434547 017731 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.core.Diagram;
public class BlockUml {
private final List extends CharSequence> data;
private final int startLine;
private Diagram system;
private static final Pattern patternFilename = MyPattern.cmpile("^@start[^%s{}%g]+[%s{][%s%g]*([^%g]*?)[%s}%g]*$");
BlockUml(String... strings) {
this(Arrays.asList(strings), 0);
}
public BlockUml(List extends CharSequence> strings, int startLine) {
this.startLine = startLine;
final String s0 = strings.get(0).toString().trim();
if (s0.startsWith("@start") == false) {
throw new IllegalArgumentException();
}
this.data = new ArrayList(strings);
}
public String getFilename() {
if (OptionFlags.getInstance().isWord()) {
return null;
}
final Matcher m = patternFilename.matcher(data.get(0).toString().trim());
final boolean ok = m.find();
if (ok == false) {
return null;
}
String result = m.group(1);
final int x = result.indexOf(',');
if (x != -1) {
result = result.substring(0, x);
}
for (int i = 0; i < result.length(); i++) {
final char c = result.charAt(i);
if ("<>|".indexOf(c) != -1) {
return null;
}
}
return result;
}
public Diagram getDiagram() {
if (system == null) {
system = new PSystemBuilder().createPSystem(data);
}
return system;
}
public final int getStartLine() {
return startLine;
}
}
src/net/sourceforge/plantuml/BlockUmlBuilder.java 0100644 0000000 0000000 00000010540 12521434547 021232 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.Preprocessor;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.UncommentReadLine;
import net.sourceforge.plantuml.utils.StartUtils;
final public class BlockUmlBuilder {
private final List blocks = new ArrayList();
private final Set usedFiles = new HashSet();
private final UncommentReadLine reader2;
public BlockUmlBuilder(List config, String charset, Defines defines, Reader reader, File newCurrentDir)
throws IOException {
Preprocessor includer = null;
try {
reader2 = new UncommentReadLine(new ReadLineReader(reader));
includer = new Preprocessor(reader2, charset, defines, usedFiles, newCurrentDir);
init(includer, config);
} finally {
if (includer != null) {
includer.close();
}
}
}
private void init(Preprocessor includer, List config) throws IOException {
String s = null;
List current = null;
boolean paused = false;
int startLine = 0;
while ((s = includer.readLine()) != null) {
if (StartUtils.isArobaseStartDiagram(s)) {
current = new ArrayList();
paused = false;
startLine = includer.getLineNumber();
}
if (StartUtils.isArobasePauseDiagram(s)) {
paused = true;
reader2.setPaused(true);
}
if (current != null && paused == false) {
current.add(s);
} else if (paused) {
final String append = StartUtils.getPossibleAppend(s);
if (append != null) {
current.add(append);
}
}
if (StartUtils.isArobaseUnpauseDiagram(s)) {
paused = false;
reader2.setPaused(false);
}
if (StartUtils.isArobaseEndDiagram(s) && current != null) {
current.addAll(1, config);
blocks.add(new BlockUml(current, startLine));
current = null;
reader2.setPaused(false);
}
}
}
public List getBlockUmls() {
return Collections.unmodifiableList(blocks);
}
public final Set getIncludedFiles() {
return Collections.unmodifiableSet(usedFiles);
}
/*
* private List getStrings(Reader reader) throws IOException { final List result = new
* ArrayList(); Preprocessor includer = null; try { includer = new Preprocessor(reader, defines); String s =
* null; while ((s = includer.readLine()) != null) { result.add(s); } } finally { if (includer != null) {
* includer.close(); } } return Collections.unmodifiableList(result); }
*/
}
src/net/sourceforge/plantuml/CMapData.java 0100644 0000000 0000000 00000005734 12521434547 017636 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class CMapData {
private final StringBuilder stringBuilder = new StringBuilder();
public String asString(String nameId) {
return "\n";
}
public boolean containsData() {
return stringBuilder.length() > 0;
}
public void appendString(String s) {
stringBuilder.append(s);
}
public void appendLong(long s) {
stringBuilder.append(s);
}
public void appendUrl(int seq, Url url, double scale) {
appendString("");
appendString("\n");
}
// private CMapData() {
// }
public static CMapData cmapString(Set allUrlEncountered, double scale) {
final CMapData cmapdata = new CMapData();
final List all = new ArrayList(allUrlEncountered);
Collections.sort(all, Url.SURFACE_COMPARATOR);
int seq = 1;
for (Url u : all) {
cmapdata.appendUrl(seq, u, scale);
seq++;
}
return cmapdata;
}
}
src/net/sourceforge/plantuml/ColorParam.java 0100644 0000000 0000000 00000014342 12521434547 020256 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
public enum ColorParam {
background(HtmlColorUtils.WHITE),
hyperlink(HtmlColorUtils.BLUE),
activityBackground(HtmlColorUtils.MY_YELLOW),
activityBorder(HtmlColorUtils.MY_RED),
activityStart(HtmlColorUtils.BLACK),
activityEnd(HtmlColorUtils.BLACK),
activityBar(HtmlColorUtils.BLACK),
activityArrow(HtmlColorUtils.MY_RED),
usecaseBorder(HtmlColorUtils.MY_RED),
usecaseBackground(HtmlColorUtils.MY_YELLOW),
usecaseArrow(HtmlColorUtils.MY_RED),
objectBackground(HtmlColorUtils.MY_YELLOW),
objectBorder(HtmlColorUtils.MY_RED),
objectArrow(HtmlColorUtils.MY_RED),
classHeaderBackground(null),
classBackground(HtmlColorUtils.MY_YELLOW),
classBorder(HtmlColorUtils.MY_RED),
stereotypeCBackground(HtmlColorUtils.COL_ADD1B2),
stereotypeABackground(HtmlColorUtils.COL_A9DCDF),
stereotypeIBackground(HtmlColorUtils.COL_B4A7E5),
stereotypeEBackground(HtmlColorUtils.COL_EB937F),
classArrow(HtmlColorUtils.MY_RED),
packageBackground(HtmlColorUtils.MY_YELLOW),
packageBorder(HtmlColorUtils.BLACK),
partitionBackground(HtmlColorUtils.MY_YELLOW),
partitionBorder(HtmlColorUtils.BLACK),
componentBackground(HtmlColorUtils.MY_YELLOW),
componentBorder(HtmlColorUtils.MY_RED),
interfaceBackground(HtmlColorUtils.MY_YELLOW),
interfaceBorder(HtmlColorUtils.MY_RED),
// componentArrow,
stateBackground(HtmlColorUtils.MY_YELLOW),
stateBorder(HtmlColorUtils.MY_RED),
stateArrow(HtmlColorUtils.MY_RED),
stateStart(HtmlColorUtils.BLACK),
stateEnd(HtmlColorUtils.BLACK),
noteBackground(HtmlColorUtils.COL_FBFB77, true),
noteBorder(HtmlColorUtils.MY_RED),
legendBackground(HtmlColorUtils.COL_DDDDDD, true),
legendBorder(HtmlColorUtils.BLACK),
actorBackground(HtmlColorUtils.MY_YELLOW, true),
actorBorder(HtmlColorUtils.MY_RED),
participantBackground(HtmlColorUtils.MY_YELLOW, true),
participantBorder(HtmlColorUtils.MY_RED),
sequenceGroupBorder(HtmlColorUtils.BLACK),
sequenceGroupBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceReferenceBorder(HtmlColorUtils.BLACK),
sequenceReferenceHeaderBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceReferenceBackground(HtmlColorUtils.WHITE, true),
sequenceDividerBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceLifeLineBackground(HtmlColorUtils.WHITE, true),
sequenceLifeLineBorder(HtmlColorUtils.MY_RED),
sequenceArrow(HtmlColorUtils.MY_RED),
sequenceBoxBorder(HtmlColorUtils.MY_RED),
sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true),
artifactBackground(HtmlColorUtils.MY_YELLOW),
artifactBorder(HtmlColorUtils.MY_RED),
cloudBackground(HtmlColorUtils.MY_YELLOW),
cloudBorder(HtmlColorUtils.MY_RED),
queueBackground(HtmlColorUtils.MY_YELLOW),
queueBorder(HtmlColorUtils.MY_RED),
databaseBackground(HtmlColorUtils.MY_YELLOW),
databaseBorder(HtmlColorUtils.MY_RED),
folderBackground(HtmlColorUtils.MY_YELLOW),
folderBorder(HtmlColorUtils.MY_RED),
frameBackground(HtmlColorUtils.MY_YELLOW),
frameBorder(HtmlColorUtils.MY_RED),
nodeBackground(HtmlColorUtils.MY_YELLOW),
nodeBorder(HtmlColorUtils.MY_RED),
rectangleBackground(HtmlColorUtils.MY_YELLOW),
rectangleBorder(HtmlColorUtils.MY_RED),
agentBackground(HtmlColorUtils.MY_YELLOW),
agentBorder(HtmlColorUtils.MY_RED),
storageBackground(HtmlColorUtils.MY_YELLOW),
storageBorder(HtmlColorUtils.MY_RED),
boundaryBackground(HtmlColorUtils.MY_YELLOW),
boundaryBorder(HtmlColorUtils.MY_RED),
controlBackground(HtmlColorUtils.MY_YELLOW),
controlBorder(HtmlColorUtils.MY_RED),
entityBackground(HtmlColorUtils.MY_YELLOW),
entityBorder(HtmlColorUtils.MY_RED),
iconPrivate(HtmlColorUtils.COL_C82930),
iconPrivateBackground(HtmlColorUtils.COL_F24D5C),
iconPackage(HtmlColorUtils.COL_1963A0),
iconPackageBackground(HtmlColorUtils.COL_4177AF),
iconProtected(HtmlColorUtils.COL_B38D22),
iconProtectedBackground(HtmlColorUtils.COL_FFFF44),
iconPublic(HtmlColorUtils.COL_038048),
iconPublicBackground(HtmlColorUtils.COL_84BE84);
private final boolean isBackground;
private final HtmlColor defaultValue;
private ColorParam(HtmlColor defaultValue) {
this(defaultValue, false);
}
private ColorParam() {
this(null, false);
}
private ColorParam(boolean isBackground) {
this(null, isBackground);
}
private ColorParam(HtmlColor defaultValue, boolean isBackground) {
this.isBackground = isBackground;
this.defaultValue = defaultValue;
}
protected boolean isBackground() {
return isBackground;
}
public final HtmlColor getDefaultValue() {
return defaultValue;
}
}
src/net/sourceforge/plantuml/CounterOutputStream.java 0100644 0000000 0000000 00000005030 12521434547 022225 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.io.OutputStream;
public class CounterOutputStream extends OutputStream {
private int length;
private final OutputStream os;
public CounterOutputStream(OutputStream os) {
this.os = os;
}
/**
* Writes to nowhere
*/
@Override
public void write(int b) throws IOException {
os.write(b);
length++;
}
/**
* Overridden for performance reason
*/
@Override
public void write(byte b[]) throws IOException {
os.write(b);
length += b.length;
}
/**
* Overridden for performance reason
*/
@Override
public void write(byte b[], int off, int len) throws IOException {
os.write(b, off, len);
length += len;
}
public int getLength() {
return length;
}
@Override
public void flush() throws IOException {
os.flush();
}
@Override
public void close() throws IOException {
os.close();
}
}
src/net/sourceforge/plantuml/Dimension2DDouble.java 0100644 0000000 0000000 00000010331 12521434550 021451 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.utils.MathUtils;
public class Dimension2DDouble extends Dimension2D {
final private double width;
final private double height;
public Dimension2DDouble(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public String toString() {
return "[" + width + "," + height + "]";
}
@Override
public double getHeight() {
return height;
}
@Override
public double getWidth() {
return width;
}
@Override
public void setSize(double width, double height) {
throw new UnsupportedOperationException();
}
public static Dimension2D delta(Dimension2D dim, double delta) {
return delta(dim, delta, delta);
}
public static Dimension2D delta(Dimension2D dim, double deltaWidth, double deltaHeight) {
if (deltaHeight == 0 && deltaWidth == 0) {
return dim;
}
return new Dimension2DDouble(dim.getWidth() + deltaWidth, dim.getHeight() + deltaHeight);
}
public static Dimension2D mergeTB(Dimension2D top, Dimension2D bottom) {
final double width = Math.max(top.getWidth(), bottom.getWidth());
final double height = top.getHeight() + bottom.getHeight();
return new Dimension2DDouble(width, height);
}
public static Dimension2D mergeTB(Dimension2D a, Dimension2D b, Dimension2D c) {
final double width = MathUtils.max(a.getWidth(), b.getWidth(), c.getWidth());
final double height = a.getHeight() + b.getHeight() + c.getHeight();
return new Dimension2DDouble(width, height);
}
public static Dimension2D mergeLR(Dimension2D left, Dimension2D right) {
final double height = Math.max(left.getHeight(), right.getHeight());
final double width = left.getWidth() + right.getWidth();
return new Dimension2DDouble(width, height);
}
public static Dimension2D mergeLayoutT12B3(Dimension2D top1, Dimension2D top2, Dimension2D bottom) {
final double width = MathUtils.max(top1.getWidth(), top2.getWidth(), bottom.getWidth());
final double height = top1.getHeight() + top2.getHeight() + bottom.getHeight();
return new Dimension2DDouble(width, height);
}
public static Dimension2D max(Dimension2D dim1, Dimension2D dim2) {
return atLeast(dim1, dim2.getWidth(), dim2.getHeight());
}
public static Dimension2D atLeast(Dimension2D dim, double minWidth, double minHeight) {
double h = dim.getHeight();
double w = dim.getWidth();
if (w > minWidth && h > minHeight) {
return dim;
}
if (h < minHeight) {
h = minHeight;
}
if (w < minWidth) {
w = minWidth;
}
return new Dimension2DDouble(w, h);
}
}
src/net/sourceforge/plantuml/DirWatcher.java 0100644 0000000 0000000 00000010243 12521434550 020241 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.preproc.Defines;
@Deprecated
public class DirWatcher {
final private File dir;
final private Option option;
final private String pattern;
final private Map modifieds = new HashMap();
public DirWatcher(File dir, Option option, String pattern) {
this.dir = dir;
this.option = option;
this.pattern = pattern;
}
public List buildCreatedFiles() throws IOException, InterruptedException {
boolean error = false;
final List result = new ArrayList();
for (File f : dir.listFiles()) {
if (error) {
continue;
}
if (f.isFile() == false) {
continue;
}
if (fileToProcess(f.getName()) == false) {
continue;
}
final FileWatcher watcher = modifieds.get(f);
if (watcher == null || watcher.hasChanged()) {
final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
option.getConfig(), option.getCharset(), option.getFileFormatOption());
final Set files = new HashSet(sourceFileReader.getIncludedFiles());
files.add(f);
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
result.add(g);
if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) {
error = true;
}
}
modifieds.put(f, new FileWatcher(files));
}
}
Collections.sort(result);
return Collections.unmodifiableList(result);
}
public File getErrorFile() throws IOException, InterruptedException {
for (File f : dir.listFiles()) {
if (f.isFile() == false) {
continue;
}
if (fileToProcess(f.getName()) == false) {
continue;
}
final FileWatcher watcher = modifieds.get(f);
if (watcher == null || watcher.hasChanged()) {
final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
option.getConfig(), option.getCharset(), option.getFileFormatOption());
if (sourceFileReader.hasError()) {
return f;
}
}
}
return null;
}
private boolean fileToProcess(String name) {
return name.matches(pattern);
}
public final File getDir() {
return dir;
}
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
}
src/net/sourceforge/plantuml/DirWatcher2.java 0100644 0000000 0000000 00000011024 12521434550 020321 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import net.sourceforge.plantuml.preproc.Defines;
public class DirWatcher2 {
final private File dir;
final private Option option;
final private String pattern;
final private Map modifieds = new ConcurrentHashMap();
final private ExecutorService executorService;
public DirWatcher2(File dir, Option option, String pattern) {
this.dir = dir;
this.option = option;
this.pattern = pattern;
final int nb = Option.defaultNbThreads();
this.executorService = Executors.newFixedThreadPool(nb);
}
public Map>> buildCreatedFiles() throws IOException, InterruptedException {
final Map>> result = new TreeMap>>();
if (dir.listFiles() != null) {
for (final File f : dir.listFiles()) {
if (f.isFile() == false) {
continue;
}
if (fileToProcess(f.getName()) == false) {
continue;
}
final FileWatcher watcher = modifieds.get(f);
if (watcher == null || watcher.hasChanged()) {
final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f,
option.getOutputDir(), option.getConfig(), option.getCharset(),
option.getFileFormatOption());
modifieds.put(f, new FileWatcher(Collections.singleton(f)));
final Future> value = executorService
.submit(new Callable>() {
public List call() throws Exception {
try {
final List generatedImages = sourceFileReader
.getGeneratedImages();
final Set files = new HashSet(sourceFileReader.getIncludedFiles());
files.add(f);
modifieds.put(f, new FileWatcher(files));
return Collections.unmodifiableList(generatedImages);
} catch (Exception e) {
e.printStackTrace();
return Collections.emptyList();
}
}
});
result.put(f, value);
}
}
}
return Collections.unmodifiableMap(result);
}
private boolean fileToProcess(String name) {
return name.matches(pattern);
}
public final File getDir() {
return dir;
}
public void cancel() {
executorService.shutdownNow();
}
public void waitEnd() throws InterruptedException {
executorService.shutdown();
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
}
src/net/sourceforge/plantuml/Direction.java 0100644 0000000 0000000 00000006244 12521434550 020133 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.geom.Point2D;
public enum Direction {
RIGHT, LEFT, DOWN, UP;
public Direction getInv() {
if (this == RIGHT) {
return LEFT;
}
if (this == LEFT) {
return RIGHT;
}
if (this == DOWN) {
return UP;
}
if (this == UP) {
return DOWN;
}
throw new IllegalStateException();
}
public static Direction fromChar(char c) {
if (c == '<') {
return Direction.LEFT;
}
if (c == '>') {
return Direction.RIGHT;
}
if (c == '^') {
return Direction.UP;
}
return Direction.DOWN;
}
public Direction clockwise() {
if (this == RIGHT) {
return DOWN;
}
if (this == LEFT) {
return UP;
}
if (this == DOWN) {
return LEFT;
}
if (this == UP) {
return RIGHT;
}
throw new IllegalStateException();
}
public static Direction leftOrRight(Point2D p1, Point2D p2) {
if (p1.getX() < p2.getX()) {
return Direction.LEFT;
}
if (p1.getX() > p2.getX()) {
return Direction.RIGHT;
}
throw new IllegalArgumentException();
}
public static Direction fromVector(Point2D p1, Point2D p2) {
final double x1 = p1.getX();
final double y1 = p1.getY();
final double x2 = p2.getX();
final double y2 = p2.getY();
if (x1 == x2 && y1 == y2) {
return null;
}
if (x1 == x2) {
if (y2 > y1) {
return Direction.DOWN;
}
return Direction.UP;
}
if (y1 == y2) {
if (x2 > x1) {
return Direction.RIGHT;
}
return Direction.LEFT;
}
throw new IllegalArgumentException("Not a H or V line!");
}
}
src/net/sourceforge/plantuml/EmbededDiagram.java 0100644 0000000 0000000 00000004204 12521434550 021017 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Display;
public class EmbededDiagram implements CharSequence {
private final Display system;
public EmbededDiagram(Display system) {
this.system = system;
}
public int length() {
return toString().length();
}
public char charAt(int index) {
return toString().charAt(index);
}
public CharSequence subSequence(int start, int end) {
return toString().subSequence(start, end);
}
public final Display getLines() {
return system;
}
}
src/net/sourceforge/plantuml/EmptyImageBuilder.java 0100644 0000000 0000000 00000006207 12521434550 021562 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
public class EmptyImageBuilder {
private final BufferedImage im;
private final Graphics2D g2d;
public EmptyImageBuilder(double width, double height, Color background) {
this((int) width, (int) height, background);
}
public EmptyImageBuilder(int width, int height, Color background) {
Log.info("Creating image " + width + "x" + height);
im = new BufferedImage(width, height, background == null ? BufferedImage.TYPE_INT_ARGB
: BufferedImage.TYPE_INT_RGB);
g2d = im.createGraphics();
UAntiAliasing.ANTI_ALIASING_ON.apply(g2d);
if (background != null) {
g2d.setColor(background);
g2d.fillRect(0, 0, width, height);
}
}
public EmptyImageBuilder(int width, int height, Color background, double dpiFactor) {
this(width * dpiFactor, height * dpiFactor, background);
if (dpiFactor != 1.0) {
g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor));
}
}
public BufferedImage getBufferedImage() {
return im;
}
public Graphics2D getGraphics2D() {
return g2d;
}
public UGraphicG2d getUGraphicG2d() {
final UGraphicG2d result = new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0);
result.setBufferedImage(im);
return result;
}
}
src/net/sourceforge/plantuml/EnsureVisible.java 0100644 0000000 0000000 00000003320 12521434550 020762 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public interface EnsureVisible {
public void ensureVisible(double x, double y);
}
src/net/sourceforge/plantuml/ErrorUml.java 0100644 0000000 0000000 00000006115 12521434550 017757 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.suggest.SuggestEngineResult;
import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
public class ErrorUml {
private final String error;
private final int position;
private final ErrorUmlType type;
private SuggestEngineResult suggest;
public ErrorUml(ErrorUmlType type, String error, int position) {
if (error == null || type == null || StringUtils.isEmpty(error)) {
throw new IllegalArgumentException();
}
this.error = error;
this.type = type;
this.position = position;
}
@Override
public boolean equals(Object obj) {
final ErrorUml this2 = (ErrorUml) obj;
return this.type == this2.type && this.position == this2.position && this.error.equals(this2.error);
}
@Override
public int hashCode() {
return error.hashCode() + type.hashCode() + position + (suggest == null ? 0 : suggest.hashCode());
}
@Override
public String toString() {
return type.toString() + " " + position + " " + error + " " + suggest;
}
public final String getError() {
return error;
}
public final ErrorUmlType getType() {
return type;
}
public int getPosition() {
return position;
}
public final SuggestEngineResult getSuggest() {
return suggest;
}
public final boolean hasSuggest() {
return suggest != null && suggest.getStatus() == SuggestEngineStatus.ONE_SUGGESTION;
}
public void setSuggest(SuggestEngineResult suggest) {
this.suggest = suggest;
}
}
src/net/sourceforge/plantuml/ErrorUmlType.java 0100644 0000000 0000000 00000003267 12521434550 020626 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public enum ErrorUmlType {
SYNTAX_ERROR, EXECUTION_ERROR
}
src/net/sourceforge/plantuml/FileFormat.java 0100644 0000000 0000000 00000007143 12521434550 020242 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
/**
* Format for output files generated by PlantUML.
*
* @author Arnaud Roques
*
*/
public enum FileFormat {
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, BASE64;
/**
* Returns the file format to be used for that format.
*
* @return a string starting by a point.
*/
public String getFileSuffix() {
if (name().startsWith("XMI")) {
return ".xmi";
}
if (this == MJPEG) {
return ".avi";
}
if (this == ANIMATED_GIF) {
return ".gif";
}
if (this == EPS_TEXT) {
return EPS.getFileSuffix();
}
return "." + StringUtils.goLowerCase(name());
}
/**
* Check if this file format is Encapsulated PostScript.
*
* @return true for EPS.
*/
public boolean isEps() {
if (this == EPS) {
return true;
}
if (this == EPS_TEXT) {
return true;
}
return false;
}
public String changeName(String fileName, int cpt) {
if (cpt == 0) {
return changeName(fileName, getFileSuffix());
}
return changeName(fileName, "_" + String.format("%03d", cpt) + getFileSuffix());
}
private String changeName(String fileName, String replacement) {
String result = fileName.replaceAll("\\.\\w+$", replacement);
if (result.equals(fileName)) {
result = fileName + replacement;
}
return result;
}
public File computeFilename(File pngFile, int i) {
if (i == 0) {
return pngFile;
}
final File dir = pngFile.getParentFile();
return new File(dir, computeFilename(pngFile.getName(), i));
// String name = pngFile.getName();
// name = name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
// return new File(dir, name);
}
public String computeFilename(String name, int i) {
if (i == 0) {
return name;
}
return name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
}
}
src/net/sourceforge/plantuml/FileFormatOption.java 0100644 0000000 0000000 00000016212 12521434550 021430 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
import net.sourceforge.plantuml.StringUtils;
/**
* A FileFormat with some parameters.
*
*
* @author Arnaud Roques
*
*/
public class FileFormatOption {
private final FileFormat fileFormat;
private final AffineTransform affineTransform;
private final boolean withMetadata;
private final boolean useRedForError;
public FileFormatOption(FileFormat fileFormat) {
this(fileFormat, null, true, false);
}
public final boolean isWithMetadata() {
return withMetadata;
}
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, false, false);
}
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError) {
this.fileFormat = fileFormat;
this.affineTransform = at;
this.withMetadata = withMetadata;
this.useRedForError = useRedForError;
}
public FileFormatOption withUseRedForError() {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true);
}
@Override
public String toString() {
return fileFormat.toString() + " " + affineTransform;
}
public final FileFormat getFileFormat() {
return fileFormat;
}
public AffineTransform getAffineTransform() {
return affineTransform;
}
/**
* Create a UGraphic corresponding to this FileFormatOption
*
* @param colorMapper
* @param dpiFactor
* 1.0 for a standard dot per inch
* @param dim
* @param mybackcolor
* @param rotation
* @return
*/
public UGraphic2 createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
switch (fileFormat) {
case PNG:
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
case SVG:
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
case EPS_TEXT:
return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
case HTML5:
return new UGraphicHtml5(colorMapper);
case VDX:
return new UGraphicVdx(colorMapper);
case LATEX:
return new UGraphicTikz(colorMapper);
default:
throw new UnsupportedOperationException(fileFormat.toString());
}
}
public UGraphic2 createUGraphic(final Dimension2D dim) {
return createUGraphic(new ColorMapperIdentity(), 1.0, dim, null, false);
}
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor);
}
final UGraphicSvg ug;
if (mybackcolor instanceof HtmlColorGradient) {
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale);
} else if (backColor == null || backColor.equals(Color.WHITE)) {
ug = new UGraphicSvg(colorMapper, false, scale);
} else {
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale);
}
return ug;
}
private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor);
} else if (mybackcolor instanceof HtmlColorTransparent) {
backColor = null;
}
final EmptyImageBuilder builder;
final Graphics2D graphics2D;
if (rotation) {
builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() * dpiFactor),
backColor);
graphics2D = builder.getGraphics2D();
graphics2D.rotate(-Math.PI / 2);
graphics2D.translate(-builder.getBufferedImage().getHeight(), 0);
} else {
builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor),
backColor);
graphics2D = builder.getGraphics2D();
}
final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor);
ug.setBufferedImage(builder.getBufferedImage());
final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
if (mybackcolor instanceof HtmlColorGradient) {
ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight()));
}
return ug;
}
public final boolean isUseRedForError() {
return useRedForError;
}
}
src/net/sourceforge/plantuml/FileGroup.java 0100644 0000000 0000000 00000012133 12521434550 020101 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
public class FileGroup {
private final List result = new ArrayList();
private final String pattern;
private final List excluded;
private final Option option;
private final static Pattern predirPath = MyPattern.cmpile("^([^*?]*[/\\\\])?(.*)$");
public FileGroup(String pattern, List excluded, Option option) {
this.pattern = pattern;
this.excluded = excluded;
this.option = option;
if (pattern.indexOf("*") == -1 && pattern.indexOf("?") == -1) {
initNoStar();
} else if (pattern.indexOf("**") != -1) {
recurse();
} else {
initWithSimpleStar();
}
Collections.sort(result);
}
private void recurse() {
final Matcher m = predirPath.matcher(pattern);
final boolean ok = m.find();
if (ok == false) {
throw new IllegalArgumentException();
}
final File parent;
if (m.group(1) == null) {
parent = new File(".");
} else {
parent = new File(m.group(1));
}
initWithDoubleStar(parent);
}
private void initNoStar() {
final File f = new File(pattern);
if (f.isDirectory()) {
addSimpleDirectory(f);
} else if (f.isFile()) {
addResultFile(f);
}
}
private void addResultFile(final File f) {
final String path = getNormalizedPath(f);
for (String x : excluded) {
if (path.matches(toRegexp(x))) {
return;
}
}
result.add(f);
}
private void addSimpleDirectory(File dir) {
if (OptionFlags.getInstance().isWord()) {
addSimpleDirectory(dir, "(?i)^.*_extr\\d+\\.txt$");
} else {
addSimpleDirectory(dir, option.getPattern());
}
}
private void addSimpleDirectory(File dir, String pattern) {
if (dir.isDirectory() == false) {
throw new IllegalArgumentException("dir=" + dir);
}
for (File f : dir.listFiles()) {
if (f.getName().matches(pattern)) {
addResultFile(f);
}
}
}
private static String getNormalizedPath(File f) {
return f.getPath().replace('\\', '/');
}
private final static Pattern noStarInDirectory = MyPattern.cmpile("^(?:([^*?]*)[/\\\\])?([^/\\\\]*)$");
private void initWithSimpleStar() {
assert pattern.indexOf("**") == -1;
final Matcher m = noStarInDirectory.matcher(pattern);
if (m.find()) {
File dir = new File(".");
if (m.group(1) != null) {
final String dirPart = m.group(1);
dir = new File(dirPart);
}
final String filesPart = m.group(2);
addSimpleDirectory(dir, toRegexp(filesPart));
} else {
recurse();
}
}
private void initWithDoubleStar(File currentDir) {
for (File f : currentDir.listFiles()) {
if (f.isDirectory()) {
initWithDoubleStar(f);
} else if (f.isFile()) {
final String path = getNormalizedPath(f);
if (path.matches(toRegexp(pattern))) {
addResultFile(f);
}
}
}
}
public List getFiles() {
return Collections.unmodifiableList(result);
}
public static String toRegexp(String pattern) {
pattern = pattern.replace("\\", "/");
pattern = pattern.replace(".", "\\.");
pattern = pattern.replace("?", "[^/]");
pattern = pattern.replace("/**/", "(/|/.{0,}/)");
pattern = pattern.replace("**", ".{0,}");
pattern = pattern.replace("*", "[^/]{0,}");
pattern = "(?i)^(\\./)?" + pattern + "$";
return pattern;
}
}
src/net/sourceforge/plantuml/FileSystem.java 0100644 0000000 0000000 00000007203 12521434550 020273 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class FileSystem {
private final static FileSystem singleton = new FileSystem();
private final ThreadLocal currentDir = new ThreadLocal();
private FileSystem() {
reset();
}
public static FileSystem getInstance() {
return singleton;
}
public void setCurrentDir(File dir) {
if (dir == null) {
throw new IllegalArgumentException();
}
Log.info("Setting current dir: " + dir);
this.currentDir.set(dir);
}
public File getCurrentDir() {
return this.currentDir.get();
}
public File getFile(String nameOrPath) throws IOException {
final File dir = currentDir.get();
if (dir == null || isAbsolute(nameOrPath)) {
return new File(nameOrPath).getCanonicalFile();
}
final File filecurrent = new File(dir.getAbsoluteFile(), nameOrPath);
if (filecurrent.exists()) {
return filecurrent.getCanonicalFile();
}
for (File d : getPath("plantuml.include.path")) {
final File file = new File(d, nameOrPath);
if (file.exists()) {
return file.getCanonicalFile();
}
}
for (File d : getPath("java.class.path")) {
final File file = new File(d, nameOrPath);
if (file.exists()) {
return file.getCanonicalFile();
}
}
return filecurrent;
}
private List getPath(String prop) {
final List result = new ArrayList();
final String paths = System.getProperty(prop);
if (paths == null) {
return result;
}
final StringTokenizer st = new StringTokenizer(paths, System.getProperty("path.separator"));
while (st.hasMoreTokens()) {
final File f = new File(st.nextToken());
if (f.exists() && f.isDirectory()) {
result.add(f);
}
}
return result;
}
private boolean isAbsolute(String nameOrPath) {
final File f = new File(nameOrPath);
return f.isAbsolute();
}
public void reset() {
setCurrentDir(new File("."));
}
}
src/net/sourceforge/plantuml/FileUtils.java 0100644 0000000 0000000 00000007741 12521434550 020116 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicInteger;
// Used by the Eclipse Plugin, so do not change package location.
public class FileUtils {
private static AtomicInteger counter;
public static void resetCounter() {
counter = new AtomicInteger(0);
}
static public File createTempFile(String prefix, String suffix) throws IOException {
if (suffix.startsWith(".") == false) {
throw new IllegalArgumentException();
}
if (prefix == null) {
throw new IllegalArgumentException();
}
final File f;
if (counter == null) {
f = File.createTempFile(prefix, suffix);
} else {
final String name = prefix + counter.addAndGet(1) + suffix;
f = new File(name);
}
Log.info("Creating temporary file: " + f);
if (OptionFlags.getInstance().isKeepTmpFiles() == false) {
f.deleteOnExit();
}
return f;
}
private static void copyInternal(final InputStream fis, final OutputStream fos) throws IOException {
final byte[] buf = new byte[10240];
int len;
while ((len = fis.read(buf)) > 0) {
fos.write(buf, 0, len);
}
fos.close();
fis.close();
}
static public void copyToFile(File src, File dest) throws IOException {
if (dest.isDirectory()) {
dest = new File(dest, src.getName());
}
final InputStream fis = new BufferedInputStream(new FileInputStream(src));
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(dest));
copyInternal(fis, fos);
}
static public void copyToStream(File src, OutputStream os) throws IOException {
final InputStream fis = new BufferedInputStream(new FileInputStream(src));
final OutputStream fos = new BufferedOutputStream(os);
copyInternal(fis, fos);
}
static public void copyToStream(InputStream is, OutputStream os) throws IOException {
final InputStream fis = new BufferedInputStream(is);
final OutputStream fos = new BufferedOutputStream(os);
copyInternal(fis, fos);
}
static public void copyToFile(byte[] src, File dest) throws IOException {
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(dest));
fos.write(src);
fos.close();
}
}
src/net/sourceforge/plantuml/FileWatcher.java 0100644 0000000 0000000 00000004517 12521434550 020411 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class FileWatcher {
private final Map modified2 = new HashMap();
public FileWatcher(Set files) {
if (files.size() == 0) {
throw new IllegalArgumentException();
}
for (File f : files) {
modified2.put(f, f.lastModified());
}
}
@Override
public String toString() {
return modified2.toString();
}
public boolean hasChanged() {
for (Map.Entry ent : modified2.entrySet()) {
final long nowModified = ent.getKey().lastModified();
if (ent.getValue().longValue() != nowModified) {
return true;
}
}
return false;
}
}
src/net/sourceforge/plantuml/FontParam.java 0100644 0000000 0000000 00000012104 12521434550 020072 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Font;
interface FontParamConstant {
String FAMILY = "SansSerif";
String COLOR = "black";
}
public enum FontParam {
ACTIVITY(12, Font.PLAIN), //
ACTIVITY_DIAMOND(11, Font.PLAIN), //
ACTIVITY_ARROW(11, Font.PLAIN), //
GENERIC_ARROW(13, Font.PLAIN), //
CIRCLED_CHARACTER(17, Font.BOLD, FontParamConstant.COLOR, "Monospaced"), //
OBJECT_ATTRIBUTE(10, Font.PLAIN), //
OBJECT(12, Font.PLAIN), //
OBJECT_STEREOTYPE(12, Font.ITALIC), //
CLASS_ATTRIBUTE(10, Font.PLAIN), //
CLASS(12, Font.PLAIN), //
CLASS_STEREOTYPE(12, Font.ITALIC), //
COMPONENT(14, Font.PLAIN), //
INTERFACE(14, Font.PLAIN), //
INTERFACE_STEREOTYPE(14, Font.ITALIC), //
COMPONENT_STEREOTYPE(14, Font.ITALIC), //
NOTE(13, Font.PLAIN), //
PACKAGE(14, Font.PLAIN), //
ACTOR(14, Font.PLAIN), //
ARTIFACT(14, Font.PLAIN), //
CLOUD(14, Font.PLAIN), //
FOLDER(14, Font.PLAIN), //
FRAME(14, Font.PLAIN), //
STORAGE(14, Font.PLAIN), //
BOUNDARY(14, Font.PLAIN), //
CONTROL(14, Font.PLAIN), //
ENTITY(14, Font.PLAIN), //
AGENT(14, Font.PLAIN), //
RECTANGLE(14, Font.PLAIN), //
NODE(14, Font.PLAIN), //
DATABASE(14, Font.PLAIN), //
QUEUE(14, Font.PLAIN), //
SEQUENCE_ARROW(13, Font.PLAIN), //
SEQUENCE_BOX(13, Font.BOLD), //
SEQUENCE_DIVIDER(13, Font.BOLD), //
SEQUENCE_REFERENCE(13, Font.PLAIN), //
SEQUENCE_DELAY(11, Font.PLAIN), //
SEQUENCE_GROUP(11, Font.BOLD), //
SEQUENCE_GROUP_HEADER(13, Font.BOLD), //
PARTICIPANT(14, Font.PLAIN), //
SEQUENCE_TITLE(14, Font.BOLD), //
STATE(14, Font.PLAIN), //
STATE_ATTRIBUTE(12, Font.PLAIN), //
LEGEND(14, Font.PLAIN), //
TITLE(18, Font.PLAIN), //
FOOTER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
HEADER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
USECASE(14, Font.PLAIN), //
USECASE_STEREOTYPE(14, Font.ITALIC), //
ARTIFACT_STEREOTYPE(14, Font.ITALIC), //
CLOUD_STEREOTYPE(14, Font.ITALIC), //
STORAGE_STEREOTYPE(14, Font.ITALIC), //
BOUNDARY_STEREOTYPE(14, Font.ITALIC), //
CONTROL_STEREOTYPE(14, Font.ITALIC), //
ENTITY_STEREOTYPE(14, Font.ITALIC), //
AGENT_STEREOTYPE(14, Font.ITALIC), //
RECTANGLE_STEREOTYPE(14, Font.ITALIC), //
NODE_STEREOTYPE(14, Font.ITALIC), //
FOLDER_STEREOTYPE(14, Font.ITALIC), //
FRAME_STEREOTYPE(14, Font.ITALIC), //
DATABASE_STEREOTYPE(14, Font.ITALIC), //
QUEUE_STEREOTYPE(14, Font.ITALIC), //
ACTOR_STEREOTYPE(14, Font.ITALIC), //
SEQUENCE_STEREOTYPE(14, Font.ITALIC); //
private final int defaultSize;
private final int fontStyle;
private final String defaultColor;
private final String defaultFamily;
private FontParam(int defaultSize, int fontStyle, String defaultColor, String defaultFamily) {
this.defaultSize = defaultSize;
this.fontStyle = fontStyle;
this.defaultColor = defaultColor;
this.defaultFamily = defaultFamily;
}
private FontParam(int defaultSize, int fontStyle) {
this(defaultSize, fontStyle, FontParamConstant.COLOR, FontParamConstant.FAMILY);
}
public final int getDefaultSize(ISkinParam skinParam) {
if (this == CLASS_ATTRIBUTE) {
return 11;
}
return defaultSize;
}
public final int getDefaultFontStyle(ISkinParam skinParam, boolean inPackageTitle) {
if (this == STATE) {
return fontStyle;
}
if (inPackageTitle || this == PACKAGE) {
return Font.BOLD;
}
return fontStyle;
}
public final String getDefaultColor() {
return defaultColor;
}
public String getDefaultFamily() {
return defaultFamily;
}
}
src/net/sourceforge/plantuml/GeneratedImage.java 0100644 0000000 0000000 00000005743 12521434550 021057 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import net.sourceforge.plantuml.core.Diagram;
public class GeneratedImage implements Comparable {
private final File pngFile;
private final String description;
private final BlockUml blockUml;
public GeneratedImage(File pngFile, String description, BlockUml blockUml) {
this.blockUml = blockUml;
this.pngFile = pngFile;
this.description = description;
}
public File getPngFile() {
return pngFile;
}
public String getDescription() {
return description;
}
public int lineErrorRaw() {
final Diagram system = blockUml.getDiagram();
if (system instanceof PSystemError) {
return ((PSystemError) system).getHigherErrorPosition() + blockUml.getStartLine();
}
return -1;
}
@Override
public String toString() {
return pngFile.getAbsolutePath() + " " + description;
}
public int compareTo(GeneratedImage this2) {
final int cmp = this.pngFile.compareTo(this2.pngFile);
if (cmp != 0) {
return cmp;
}
return this.description.compareTo(this2.description);
}
@Override
public int hashCode() {
return pngFile.hashCode() + description.hashCode();
}
@Override
public boolean equals(Object obj) {
final GeneratedImage this2 = (GeneratedImage) obj;
return this2.pngFile.equals(this.pngFile) && this2.description.equals(this.description);
}
}
src/net/sourceforge/plantuml/Hideable.java 0100644 0000000 0000000 00000003267 12521434552 017714 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public interface Hideable {
public boolean isHidden();
}
src/net/sourceforge/plantuml/ISkinParam.java 0100644 0000000 0000000 00000010077 12521434552 020212 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.graphic.SkinParameter;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
public interface ISkinParam extends ISkinSimple {
public HtmlColor getHyperlinkColor();
public boolean useUnderlineForHyperlink();
public HtmlColor getBackgroundColor();
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable);
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype);
public UStroke getThickness(LineParam param, Stereotype stereotype);
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle);
public HorizontalAlignment getHorizontalAlignment(AlignParam param);
public HorizontalAlignment getDefaultTextAlignment();
public int getCircledCharacterRadius();
public int classAttributeIconSize();
public ColorMapper getColorMapper();
public int getDpi();
public DotSplines getDotSplines();
public GraphvizLayoutStrategy getStrategy();
public boolean shadowing();
public boolean shadowing2(SkinParameter skinParameter);
public PackageStyle getPackageStyle();
public boolean useUml2ForComponent();
public boolean stereotypePositionTop();
public boolean useSwimlanes(UmlDiagramType type);
public double getNodesep();
public double getRanksep();
public double getRoundCorner();
public double maxMessageSize();
public boolean strictUmlStyle();
public boolean forceSequenceParticipantUnderlined();
public ConditionStyle getConditionStyle();
public double minClassWidth();
public boolean sameClassWidth();
public Rankdir getRankdir();
public boolean useOctagonForActivity(Stereotype stereotype);
public IHtmlColorSet getIHtmlColorSet();
public int groupInheritance();
public boolean useGuillemet();
public boolean handwritten();
}
src/net/sourceforge/plantuml/ISkinSimple.java 0100644 0000000 0000000 00000003375 12521434552 020406 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public interface ISkinSimple extends SpriteContainer {
public String getValue(String key);
public double getPadding();
}
src/net/sourceforge/plantuml/ISourceFileReader.java 0100644 0000000 0000000 00000003574 12521434552 021514 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.util.List;
public interface ISourceFileReader {
public List getGeneratedImages() throws IOException;
public List getEncodedUrl() throws IOException;
public boolean hasError();
}
src/net/sourceforge/plantuml/LineConfigurable.java 0100644 0000000 0000000 00000003747 12521434552 021432 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.ugraphic.UStroke;
public interface LineConfigurable {
public HtmlColor getSpecificLineColor();
public void setSpecificLineColor(HtmlColor specificLinecolor);
public UStroke getSpecificLineStroke();
public void setSpecificLineStroke(UStroke specificLineStoke);
}
src/net/sourceforge/plantuml/LineParam.java 0100644 0000000 0000000 00000003736 12521434552 020070 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public enum LineParam {
// sequenceBoundaryBorder,
sequenceActorBorder,
sequenceDividerBorder,
// sequenceGroupBorder(0.1),
// sequenceReferenceBorder(0.1),
sequenceLifeLineBorder,
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
classBorder, objectBorder,
packageBorder;
// sequenceBoxBorder(0.1);
}
src/net/sourceforge/plantuml/Log.java 0100644 0000000 0000000 00000007251 12521434552 016735 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public abstract class Log {
private static final long start = System.currentTimeMillis();
public synchronized static void debug(String s) {
}
public synchronized static void info(String s) {
if (OptionFlags.getInstance().isVerbose()) {
System.out.println(format(s));
}
}
public synchronized static void error(String s) {
System.err.println(s);
}
private static String format(String s) {
final long delta = System.currentTimeMillis() - start;
// final HealthCheck healthCheck = Performance.getHealthCheck();
// final long cpu = healthCheck.jvmCpuTime() / 1000L / 1000L;
// final long dot = healthCheck.dotTime().getSum();
final long freeMemory = Runtime.getRuntime().freeMemory();
final long maxMemory = Runtime.getRuntime().maxMemory();
final long totalMemory = Runtime.getRuntime().totalMemory();
final long usedMemory = totalMemory - freeMemory;
final int threadActiveCount = Thread.activeCount();
final StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(delta / 1000L);
sb.append(".");
sb.append(String.format("%03d", delta % 1000L));
// if (cpu != -1) {
// sb.append(" - ");
// sb.append(cpu / 1000L);
// sb.append(".");
// sb.append(String.format("%03d", cpu % 1000L));
// }
// sb.append(" - ");
// sb.append(dot / 1000L);
// sb.append(".");
// sb.append(String.format("%03d", dot % 1000L));
// sb.append("(");
// sb.append(healthCheck.dotTime().getNb());
// sb.append(")");
sb.append(" - ");
final long total = totalMemory / 1024 / 1024;
final long free = freeMemory / 1024 / 1024;
sb.append(total);
sb.append(" Mo) ");
sb.append(free);
sb.append(" Mo - ");
sb.append(s);
return sb.toString();
}
public static void println(Object s) {
if (header2.get() == null) {
System.err.println("L = " + s);
} else {
System.err.println(header2.get() + " " + s);
}
}
private static final ThreadLocal header2 = new ThreadLocal();
public static void header(String s) {
header2.set(s);
}
}
src/net/sourceforge/plantuml/NewpagedDiagram.java 0100644 0000000 0000000 00000010537 12521434552 021234 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
public class NewpagedDiagram extends AbstractPSystem {
private final List diagrams = new ArrayList();
public NewpagedDiagram(AbstractPSystem diag1, AbstractPSystem diag2) {
if (diag1 instanceof NewpagedDiagram) {
throw new IllegalArgumentException();
}
if (diag2 instanceof NewpagedDiagram) {
throw new IllegalArgumentException();
}
this.diagrams.add(diag1);
this.diagrams.add(diag2);
}
@Override
public String toString() {
return super.toString() + " SIZE=" + diagrams.size() + " " + diagrams;
}
public CommandExecutionResult executeCommand(Command cmd, List lines) {
final int nb = diagrams.size();
final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines);
if (tmp.getNewDiagram() instanceof NewpagedDiagram) {
final NewpagedDiagram new1 = (NewpagedDiagram) tmp.getNewDiagram();
// System.err.println("this=" + this);
// System.err.println("new1=" + new1);
if (new1.size() != 2) {
throw new IllegalStateException();
}
if (new1.diagrams.get(0) != this.diagrams.get(nb - 1)) {
throw new IllegalStateException();
}
this.diagrams.add(new1.diagrams.get(1));
return tmp.withDiagram(this);
}
return tmp;
}
private int size() {
return diagrams.size();
}
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
return diagrams.get(num).exportDiagram(os, 0, fileFormat);
}
public int getNbImages() {
int nb = 0;
for (Diagram d : diagrams) {
nb += d.getNbImages();
}
return nb;
}
public DiagramDescription getDescription() {
final StringBuilder sb = new StringBuilder();
for (Diagram d : diagrams) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(d.getDescription());
}
return new DiagramDescriptionImpl(sb.toString(), getClass());
}
public String getWarningOrError() {
final StringBuilder sb = new StringBuilder();
for (Diagram d : diagrams) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(d.getWarningOrError());
}
return sb.toString();
}
@Override
public void makeDiagramReady() {
super.makeDiagramReady();
for (Diagram diagram : diagrams) {
((AbstractPSystem) diagram).makeDiagramReady();
}
}
}
src/net/sourceforge/plantuml/NullOutputStream.java 0100644 0000000 0000000 00000004413 12521434552 021520 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.io.OutputStream;
// Modified by Maxime Sinclair
public class NullOutputStream extends OutputStream {
/**
* Writes to nowhere
*/
@Override
public void write(int b) throws IOException {
// Do nothing silently
}
/**
* Overridden for performance reason
*/
@Override
public void write(byte b[]) throws IOException {
// Do nothing silently
}
/**
* Overridden for performance reason
*/
@Override
public void write(byte b[], int off, int len) throws IOException {
// Do nothing silently
}
}
src/net/sourceforge/plantuml/Option.java 0100644 0000000 0000000 00000032512 12521434554 017464 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.preproc.Defines;
public class Option {
private final List excludes = new ArrayList();
private final List config = new ArrayList();
private final Map defines = new LinkedHashMap();
private String charset;
private boolean computeurl = false;
private boolean decodeurl = false;
private boolean pipe = false;
private boolean syntax = false;
private boolean checkOnly = false;
private boolean failfast = false;
private boolean failfast2 = false;
private boolean pattern = false;
private boolean duration = false;
private int nbThreads = 0;
private int ftpPort = -1;
private File outputDir = null;
private File outputFile = null;
private final List result = new ArrayList();
public Option() {
}
private FileFormat fileFormat = FileFormat.PNG;
public FileFormat getFileFormat() {
return fileFormat;
}
public void setFileFormat(FileFormat fileFormat) {
this.fileFormat = fileFormat;
}
public Option(String... arg) throws InterruptedException, IOException {
if (arg.length == 0) {
OptionFlags.getInstance().setGui(true);
}
for (int i = 0; i < arg.length; i++) {
String s = arg[i];
if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
setFileFormat(FileFormat.SVG);
} else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) {
setFileFormat(FileFormat.HTML);
} else if (s.equalsIgnoreCase("-txmi") || s.equalsIgnoreCase("-xmi")) {
setFileFormat(FileFormat.XMI_STANDARD);
} else if (s.equalsIgnoreCase("-txmi:argo") || s.equalsIgnoreCase("-xmi:argo")) {
setFileFormat(FileFormat.XMI_ARGO);
} else if (s.equalsIgnoreCase("-txmi:star") || s.equalsIgnoreCase("-xmi:star")) {
setFileFormat(FileFormat.XMI_STAR);
} else if (s.equalsIgnoreCase("-teps") || s.equalsIgnoreCase("-eps")) {
setFileFormat(FileFormat.EPS);
} else if (s.equalsIgnoreCase("-teps:text") || s.equalsIgnoreCase("-eps:text")) {
setFileFormat(FileFormat.EPS_TEXT);
} else if (s.equalsIgnoreCase("-ttxt") || s.equalsIgnoreCase("-txt")) {
setFileFormat(FileFormat.ATXT);
} else if (s.equalsIgnoreCase("-tutxt") || s.equalsIgnoreCase("-utxt")) {
setFileFormat(FileFormat.UTXT);
} else if (s.equalsIgnoreCase("-png") || s.equalsIgnoreCase("-tpng")) {
setFileFormat(FileFormat.PNG);
} else if (s.equalsIgnoreCase("-vdx") || s.equalsIgnoreCase("-tvdx")) {
setFileFormat(FileFormat.VDX);
} else if (s.equalsIgnoreCase("-latex") || s.equalsIgnoreCase("-tlatex")) {
setFileFormat(FileFormat.LATEX);
} else if (s.equalsIgnoreCase("-base64") || s.equalsIgnoreCase("-tbase64")) {
setFileFormat(FileFormat.BASE64);
} else if (s.equalsIgnoreCase("-pdf") || s.equalsIgnoreCase("-tpdf")) {
setFileFormat(FileFormat.PDF);
} else if (s.equalsIgnoreCase("-overwrite")) {
OptionFlags.getInstance().setOverwrite(true);
} else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) {
i++;
if (i == arg.length) {
continue;
}
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-ofile")) {
i++;
if (i == arg.length) {
continue;
}
outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) {
i++;
if (i == arg.length) {
continue;
}
OptionFlags.getInstance().setDotExecutable(
StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-charset")) {
i++;
if (i == arg.length) {
continue;
}
charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
} else if (s.startsWith("-o") && s.length() > 3) {
s = s.substring(2);
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
} else if (s.equalsIgnoreCase("-recurse") || s.equalsIgnoreCase("-r")) {
// recurse = true;
} else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) {
i++;
if (i == arg.length) {
continue;
}
excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) {
i++;
if (i == arg.length) {
continue;
}
final String nb = arg[i];
if ("auto".equalsIgnoreCase(nb)) {
this.nbThreads = defaultNbThreads();
} else if (nb.matches("\\d+")) {
this.nbThreads = Integer.parseInt(nb);
}
} else if (s.equalsIgnoreCase("-failfast")) {
this.failfast = true;
} else if (s.equalsIgnoreCase("-failfast2")) {
this.failfast2 = true;
} else if (s.equalsIgnoreCase("-checkonly")) {
this.checkOnly = true;
} else if (s.equalsIgnoreCase("-config")) {
i++;
if (i == arg.length) {
continue;
}
initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-computeurl") || s.equalsIgnoreCase("-encodeurl")) {
this.computeurl = true;
} else if (s.startsWith("-x")) {
s = s.substring(2);
excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
} else if (s.equalsIgnoreCase("-verbose") || s.equalsIgnoreCase("-v")) {
OptionFlags.getInstance().setVerbose(true);
} else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
pipe = true;
} else if (s.equalsIgnoreCase("-pattern")) {
pattern = true;
} else if (s.equalsIgnoreCase("-syntax")) {
syntax = true;
OptionFlags.getInstance().setQuiet(true);
} else if (s.equalsIgnoreCase("-duration")) {
duration = true;
} else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) {
OptionFlags.getInstance().setKeepTmpFiles(true);
} else if (s.equalsIgnoreCase("-metadata")) {
OptionFlags.getInstance().setMetadata(true);
} else if (s.equalsIgnoreCase("-logdata")) {
i++;
if (i == arg.length) {
continue;
}
OptionFlags.getInstance().setLogData(
new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])));
} else if (s.equalsIgnoreCase("-word")) {
OptionFlags.getInstance().setWord(true);
OptionFlags.getInstance().setQuiet(true);
} else if (s.equalsIgnoreCase("-quiet")) {
OptionFlags.getInstance().setQuiet(true);
} else if (s.equalsIgnoreCase("-decodeurl")) {
this.decodeurl = true;
} else if (s.equalsIgnoreCase("-version")) {
OptionPrint.printVersion();
} else if (s.matches("(?i)^-li[sc][ea]n[sc]e\\s*$")) {
OptionPrint.printLicense();
} else if (s.equalsIgnoreCase("-checkversion")) {
OptionPrint.checkVersion();
} else if (s.startsWith("-D")) {
manageDefine(s.substring(2));
} else if (s.startsWith("-S")) {
manageSkinParam(s.substring(2));
} else if (s.equalsIgnoreCase("-testdot")) {
OptionPrint.printTestDot();
} else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author") || s.equalsIgnoreCase("-authors")) {
OptionPrint.printAbout();
} else if (s.equalsIgnoreCase("-help") || s.equalsIgnoreCase("-h") || s.equalsIgnoreCase("-?")) {
OptionPrint.printHelp();
} else if (s.equalsIgnoreCase("-language")) {
OptionPrint.printLanguage();
} else if (s.equalsIgnoreCase("-gui")) {
OptionFlags.getInstance().setGui(true);
} else if (s.equalsIgnoreCase("-encodesprite")) {
OptionFlags.getInstance().setEncodesprite(true);
} else if (s.equalsIgnoreCase("-nosuggestengine")) {
OptionFlags.getInstance().setUseSuggestEngine(false);
} else if (s.equalsIgnoreCase("-printfonts")) {
OptionFlags.getInstance().setPrintFonts(true);
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
final int x = s.indexOf(':');
if (x == -1) {
this.ftpPort = 4242;
} else {
this.ftpPort = Integer.parseInt(s.substring(x + 1));
}
} else if (s.startsWith("-c")) {
s = s.substring(2);
config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
} else {
result.add(s);
}
}
}
public int getFtpPort() {
return ftpPort;
}
public void initConfig(String filename) throws IOException {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(filename));
String s = null;
while ((s = br.readLine()) != null) {
config.add(s);
}
} finally {
if (br != null) {
br.close();
}
}
}
private void manageDefine(String s) {
final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher m = p.matcher(s);
if (m.find()) {
define(m.group(1), m.group(2));
}
}
private void manageSkinParam(String s) {
final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher m = p.matcher(s);
if (m.find()) {
skinParam(m.group(1), m.group(2));
}
}
private void skinParam(String var, String value) {
if (var != null && value != null) {
config.add("skinparamlocked " + var + " " + value);
}
}
public final File getOutputDir() {
return outputDir;
}
public final static String getPattern() {
return "(?i)^.*\\.(txt|tex|java|htm|html|c|h|cpp|apt|pu)$";
}
public void setOutputDir(File f) {
outputDir = f;
}
public final List getExcludes() {
return Collections.unmodifiableList(excludes);
}
public Defines getDefaultDefines() {
final Defines result = new Defines();
for (Map.Entry ent : defines.entrySet()) {
result.define(ent.getKey(), Arrays.asList(ent.getValue()));
}
return result;
}
public void define(String name, String value) {
defines.put(name, value);
}
public List getConfig() {
return Collections.unmodifiableList(config);
}
public final List getResult() {
return Collections.unmodifiableList(result);
}
public final String getCharset() {
return charset;
}
public void setCharset(String s) {
this.charset = s;
}
public final boolean isComputeurl() {
return computeurl;
}
public final boolean isDecodeurl() {
return decodeurl;
}
public final boolean isPipe() {
return pipe;
}
public final boolean isSyntax() {
return syntax;
}
public final boolean isPattern() {
return pattern;
}
public FileFormatOption getFileFormatOption() {
return new FileFormatOption(getFileFormat());
}
public final boolean isDuration() {
return duration;
}
public final int getNbThreads() {
return nbThreads;
}
public final void setNbThreads(int nb) {
this.nbThreads = nb;
}
public static int defaultNbThreads() {
return Runtime.getRuntime().availableProcessors();
}
public final boolean isCheckOnly() {
return checkOnly;
}
public final void setCheckOnly(boolean checkOnly) {
this.checkOnly = checkOnly;
}
public final boolean isFailfastOrFailfast2() {
return failfast || failfast2;
}
public final boolean isFailfast2() {
return failfast2;
}
public final void setFailfast(boolean failfast) {
this.failfast = failfast;
}
public final void setFailfast2(boolean failfast2) {
this.failfast2 = failfast2;
}
public final File getOutputFile() {
return outputFile;
}
}
src/net/sourceforge/plantuml/OptionFlags.java 0100644 0000000 0000000 00000016762 12521434554 020452 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.concurrent.atomic.AtomicBoolean;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
public class OptionFlags {
// static public final boolean PBBACK = false;
// static public boolean GRAPHVIZCACHE = false;
static public final boolean TRACE_DOT = false;
static public boolean ALLOW_INCLUDE = true;
static public final boolean USE_HECTOR = false;
static public boolean ADD_NICE_FOR_DOT = false;
static public final boolean STRICT_SELFMESSAGE_POSITION = true;
static public final boolean FORCE_TEOZ = false;
static public final boolean USE_INTERFACE_EYE1 = false;
static public final boolean USE_INTERFACE_EYE2 = false;
static public final boolean SWI2 = false;
public void reset() {
reset(false);
}
private void reset(boolean exit) {
keepTmpFiles = false;
verbose = false;
metadata = false;
word = false;
systemExit = exit;
dotExecutable = null;
gui = false;
quiet = false;
checkDotError = false;
printFonts = false;
useSuggestEngine = true;
// failOnError = false;
encodesprite = false;
// PIC_LINE = false;
}
public boolean useJavaInsteadOfDot() {
return false;
}
private static final OptionFlags singleton = new OptionFlags();
private boolean keepTmpFiles;
private boolean verbose;
private boolean metadata;
private boolean word;
private boolean systemExit;
private String dotExecutable;
private boolean gui;
private boolean quiet;
private boolean checkDotError;
private boolean printFonts;
private boolean useSuggestEngine;
// private boolean failOnError;
private boolean encodesprite;
private boolean overwrite;
private File logData;
private OptionFlags() {
reset(true);
}
public static OptionFlags getInstance() {
return singleton;
}
public synchronized final boolean isKeepTmpFiles() {
return keepTmpFiles;
}
public synchronized final void setKeepTmpFiles(boolean keepTmpFiles) {
this.keepTmpFiles = keepTmpFiles;
}
public final boolean isVerbose() {
return verbose;
}
public final void setVerbose(boolean verbose) {
this.verbose = verbose;
}
public final boolean isMetadata() {
return metadata;
}
public final void setMetadata(boolean metadata) {
this.metadata = metadata;
}
public final boolean isWord() {
return word;
}
public final void setWord(boolean word) {
this.word = word;
}
public final boolean isSystemExit() {
return systemExit;
}
public final void setSystemExit(boolean systemExit) {
this.systemExit = systemExit;
}
public final String getDotExecutable() {
return dotExecutable;
}
public final void setDotExecutable(String dotExecutable) {
this.dotExecutable = dotExecutable;
}
public final boolean isGui() {
return gui;
}
public final void setGui(boolean gui) {
this.gui = gui;
}
public final boolean isQuiet() {
return quiet;
}
public final void setQuiet(boolean quiet) {
this.quiet = quiet;
}
public final boolean isCheckDotError() {
return checkDotError;
}
public final void setCheckDotError(boolean checkDotError) {
this.checkDotError = checkDotError;
}
private final AtomicBoolean logDataInitized = new AtomicBoolean(false);
public void logData(File file, Diagram system) {
final String warnOrError = system.getWarningOrError();
if (warnOrError == null) {
return;
}
synchronized (logDataInitized) {
if (logData == null && logDataInitized.get() == false) {
final String s = GraphvizUtils.getenvLogData();
if (s != null) {
setLogData(new File(s));
}
logDataInitized.set(true);
}
if (logData == null) {
return;
}
// final PSystemError systemError = (PSystemError) system;
PrintStream ps = null;
try {
ps = new PrintStream(new FileOutputStream(logData, true));
ps.println("Start of " + file.getName());
ps.println(warnOrError);
ps.println("End of " + file.getName());
ps.println();
} catch (FileNotFoundException e) {
Log.error("Cannot open " + logData);
e.printStackTrace();
} finally {
if (ps != null) {
ps.close();
}
}
}
}
// public static void logErrorFile(final PSystemError systemError, PrintStream ps) {
// ps.println(systemError.getDescription());
// for (CharSequence t : systemError.getTitle()) {
// ps.println(t);
// }
// systemError.print(ps);
// for (String s : systemError.getSuggest()) {
// ps.println(s);
// }
// }
public final void setLogData(File logData) {
this.logData = logData;
logData.delete();
PrintStream ps = null;
try {
ps = new PrintStream(new FileOutputStream(logData));
ps.println();
} catch (FileNotFoundException e) {
Log.error("Cannot open " + logData);
e.printStackTrace();
} finally {
if (ps != null) {
ps.close();
}
}
}
public final boolean isPrintFonts() {
return printFonts;
}
public final void setPrintFonts(boolean printFonts) {
this.printFonts = printFonts;
}
public final boolean isUseSuggestEngine() {
return useSuggestEngine;
}
public final void setUseSuggestEngine(boolean useSuggestEngine) {
this.useSuggestEngine = useSuggestEngine;
}
// public final boolean isFailOnError() {
// return failOnError;
// }
//
// public final void setFailOnError(boolean failOnError) {
// this.failOnError = failOnError;
// }
public final boolean isEncodesprite() {
return encodesprite;
}
public final void setEncodesprite(boolean encodesprite) {
this.encodesprite = encodesprite;
}
public final boolean isOverwrite() {
return overwrite;
}
public final void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}
}
src/net/sourceforge/plantuml/OptionPrint.java 0100644 0000000 0000000 00000023765 12521434554 020513 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.Properties;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.syntax.LanguageDescriptor;
import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.PSystemVersion;
import net.sourceforge.plantuml.version.Version;
public class OptionPrint {
static public void printTestDot() throws InterruptedException {
for (String s : GraphvizUtils.getTestDotStrings(false)) {
System.out.println(s);
}
exit();
}
static public void printHelp() throws InterruptedException {
final String charset = Charset.defaultCharset().displayName();
System.out.println("Usage: java -jar plantuml.jar [options] -gui");
System.out.println("\t(to execute the GUI)");
System.out.println(" or java -jar plantuml.jar [options] [file/dir] [file/dir] [file/dir]");
System.out.println("\t(to process files or directories)");
System.out.println();
System.out.println("You can use the following wildcards in files/dirs:");
System.out.println("\t*\tmeans any characters but '" + File.separator + "'");
System.out.println("\t?\tone and only one character but '" + File.separator + "'");
System.out.println("\t**\tmeans any characters (used to recurse through directories)");
System.out.println();
System.out.println("where options include:");
System.out.println(" -gui\t\tTo run the graphical user interface");
System.out.println(" -tpng\t\tTo generate images using PNG format (default)");
System.out.println(" -tsvg\t\tTo generate images using SVG format");
System.out.println(" -teps\t\tTo generate images using EPS format");
System.out.println(" -tpdf\t\tTo generate images using PDF format");
System.out.println(" -tvdx\t\tTo generate images using VDX format");
System.out.println(" -txmi\t\tTo generate XMI file for class diagram");
System.out.println(" -thtml\t\tTo generate HTML files for class diagram");
System.out.println(" -ttxt\t\tTo generate images with ASCII art");
System.out.println(" -tutxt\t\tTo generate images with ASCII art using Unicode characters");
System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory");
System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used");
System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used");
System.out.println(" -r[ecurse]\t\trecurse through directories");
System.out.println(" -config \"file\"\tTo read the provided config file before each diagram");
System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")");
System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern");
System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images");
System.out.println(" -version\t\tTo display information about PlantUML and Java versions");
System.out.println(" -checkversion\tTo check if a newer version is available for download");
System.out.println(" -v[erbose]\t\tTo have log information");
System.out.println(" -quiet\t\tTo NOT print error message into the console");
// Log.println(" -forcegd\t\tTo force dot to use GD PNG library");
// Log.println(" -forcecairo\t\tTo force dot to use Cairo PNG library");
System.out.println(" -keepfiles\t\tTo NOT delete temporary files after process");
System.out.println(" -h[elp]\t\tTo display this help message");
System.out.println(" -testdot\t\tTo test the installation of graphviz");
System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable");
System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation");
System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image");
System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file");
System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL");
System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images");
System.out.println(" -language\t\tTo print the list of PlantUML keywords");
System.out.println(" -nosuggestengine\tTo disable the suggest engine when errors in diagrams");
System.out.println(" -checkonly\t\tTo check the syntax of files without generating images");
System.out.println(" -failfast\t\tTo stop processing as soon as a syntax error in diagram occurs");
System.out.println(" -failfast2\t\tTo do a first syntax check before processing files, to fail even faster");
System.out.println(" -pattern\t\tTo print the list of Regular Expression used by PlantUML");
System.out.println(" -duration\t\tTo print the duration of complete diagrams processing");
System.out.println(" -nbthread N\t\tTo use (N) threads for processing");
System.out.println(" -nbthread auto\tTo use " + Option.defaultNbThreads() + " threads for processing");
System.out.println(" -author[s]\t\tTo print information about PlantUML authors");
System.out.println(" -overwrite\t\tTo allow to overwrite read only files");
System.out.println(" -printfonts\t\tTo print fonts available on your system");
System.out.println();
System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT.");
exit();
}
static private void exit() throws InterruptedException {
if (OptionFlags.getInstance().isSystemExit()) {
System.exit(0);
}
throw new InterruptedException("exit");
}
public static void printLicense() throws InterruptedException {
for (String s : License.getCurrent().getText()) {
System.out.println(s);
}
exit();
}
public static void printVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("(" + License.getCurrent() + " source distribution)");
final Properties p = System.getProperties();
System.out.println(p.getProperty("java.runtime.name"));
System.out.println(p.getProperty("java.vm.name"));
System.out.println(p.getProperty("java.runtime.version"));
System.out.println(p.getProperty("os.name"));
System.out.println();
for (String s : GraphvizUtils.getTestDotStrings(false)) {
System.out.println(s);
}
exit();
}
public static void checkVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
final int lastversion = PSystemVersion.extractDownloadableVersion(null, null);
if (lastversion == -1) {
System.out.println("Error");
System.out.println("Cannot connect to http://plantuml.sourceforge.net/");
System.out.println("Maybe you should set your proxy ?");
} else if (lastversion == 0) {
System.out.println("Error");
System.out.println("Cannot retrieve last version from http://plantuml.sourceforge.net/");
} else {
System.out.println("Last available version for download : " + lastversion);
System.out.println();
if (Version.version() >= lastversion) {
System.out.println("Your version is up to date.");
} else {
System.out.println("A newer version is available for download.");
}
}
exit();
}
public static void printAbout() throws InterruptedException {
// Duplicate in PSystemVersion
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
System.out.println("Original idea: Arnaud Roques");
System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier");
System.out.println("Word Add-in: Adriaan van den Brand");
System.out.println("Eclipse Plugin: Claude Durif & Anne Pecoil");
System.out.println("Servlet & XWiki: Maxime Sinclair");
System.out.println("Site design: Raphael Cotisson");
System.out.println("Logo: Benjamin Croizet");
System.out.println();
System.out.println("http://plantuml.sourceforge.net");
exit();
}
public static void printLanguage() throws InterruptedException {
new LanguageDescriptor().print(System.out);
exit();
}
}
src/net/sourceforge/plantuml/PSystemBuilder.java 0100644 0000000 0000000 00000016077 12521434556 021141 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3;
import net.sourceforge.plantuml.api.PSystemFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.PSystemCreoleFactory;
import net.sourceforge.plantuml.cute.PSystemCuteFactory;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
import net.sourceforge.plantuml.directdot.PSystemDotFactory;
import net.sourceforge.plantuml.donors.PSystemDonorsFactory;
import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
import net.sourceforge.plantuml.eggs.PSystemPathFactory;
import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
import net.sourceforge.plantuml.font.PSystemListFontsFactory;
import net.sourceforge.plantuml.jungle.PSystemTreeFactory;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory;
import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
import net.sourceforge.plantuml.project2.PSystemProjectFactory2;
import net.sourceforge.plantuml.salt.PSystemSaltFactory;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.PSystemLicenseFactory;
import net.sourceforge.plantuml.version.PSystemVersionFactory;
public class PSystemBuilder {
public static final long startTime = System.currentTimeMillis();
final public Diagram createPSystem(final List extends CharSequence> strings) {
final List factories = getAllFactories();
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings.get(0).toString());
final UmlSource umlSource = new UmlSource(strings, type == DiagramType.UML);
final DiagramType diagramType = umlSource.getDiagramType();
final List errors = new ArrayList();
for (PSystemFactory systemFactory : factories) {
if (diagramType != systemFactory.getDiagramType()) {
continue;
}
final Diagram sys = systemFactory.createSystem(umlSource);
if (isOk(sys)) {
return sys;
}
errors.add((PSystemError) sys);
}
final PSystemError err = merge(errors);
// if (OptionFlags.getInstance().isQuiet() == false) {
// err.print(System.err);
// }
return err;
}
private List getAllFactories() {
final List factories = new ArrayList();
factories.add(new SequenceDiagramFactory());
factories.add(new ClassDiagramFactory());
factories.add(new ActivityDiagramFactory());
factories.add(new DescriptionDiagramFactory());
factories.add(new StateDiagramFactory());
factories.add(new ActivityDiagramFactory3());
factories.add(new CompositeDiagramFactory());
factories.add(new ObjectDiagramFactory());
factories.add(new PostIdDiagramFactory());
factories.add(new PrintSkinFactory());
factories.add(new PSystemLicenseFactory());
factories.add(new PSystemVersionFactory());
factories.add(new PSystemDonorsFactory());
factories.add(new PSystemListFontsFactory());
factories.add(new PSystemOpenIconicFactory());
factories.add(new PSystemListOpenIconicFactory());
factories.add(new PSystemSaltFactory(DiagramType.SALT));
factories.add(new PSystemSaltFactory(DiagramType.UML));
factories.add(new PSystemDotFactory(DiagramType.DOT));
factories.add(new PSystemDotFactory(DiagramType.UML));
factories.add(new PSystemCreoleFactory());
factories.add(new PSystemEggFactory());
factories.add(new PSystemAppleTwoFactory());
factories.add(new PSystemRIPFactory());
factories.add(new PSystemLostFactory());
factories.add(new PSystemPathFactory());
factories.add(new PSystemOregonFactory());
factories.add(new PSystemCharlieFactory());
factories.add(new PSystemProjectFactory2());
factories.add(new FlowDiagramFactory());
factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
factories.add(new PSystemCuteFactory(DiagramType.CUTE));
return factories;
}
private PSystemError merge(Collection ps) {
UmlSource source = null;
final List errors = new ArrayList();
for (PSystemError system : ps) {
if (system.getSource() != null && source == null) {
source = system.getSource();
}
errors.addAll(system.getErrorsUml());
}
if (source == null) {
throw new IllegalStateException();
}
return new PSystemError(source, errors);
}
private boolean isOk(Diagram ps) {
if (ps == null || ps instanceof PSystemError) {
return false;
}
return true;
}
}
src/net/sourceforge/plantuml/PSystemError.java 0100644 0000000 0000000 00000023167 12521434556 020642 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class PSystemError extends AbstractPSystem {
private String getSuggestColor(boolean useRed) {
if (useRed) {
return "black";
}
return "white";
}
private String getRed(boolean useRed) {
if (useRed) {
return "#CD0A0A";
}
return "red";
}
private final int higherErrorPosition;
private final List printedErrors;
public PSystemError(UmlSource source, List all) {
this.setSource(source);
final int higherErrorPositionExecution = getHigherErrorPosition(ErrorUmlType.EXECUTION_ERROR, all);
final int higherErrorPositionSyntax = getHigherErrorPosition(ErrorUmlType.SYNTAX_ERROR, all);
if (higherErrorPositionExecution == Integer.MIN_VALUE && higherErrorPositionSyntax == Integer.MIN_VALUE) {
throw new IllegalStateException();
}
if (higherErrorPositionExecution >= higherErrorPositionSyntax) {
higherErrorPosition = higherErrorPositionExecution;
printedErrors = getErrorsAt(higherErrorPositionExecution, ErrorUmlType.EXECUTION_ERROR, all);
} else {
assert higherErrorPositionSyntax > higherErrorPositionExecution;
higherErrorPosition = higherErrorPositionSyntax;
printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all);
}
}
public PSystemError(UmlSource source, ErrorUml singleError) {
this(source, Collections.singletonList(singleError));
}
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
final UGraphicTxt ugt = new UGraphicTxt();
final UmlCharArea area = ugt.getCharArea();
area.drawStringsLR(getTextStrings(), 0, 0);
area.print(new PrintStream(os));
return new ImageDataSimple(1, 1);
}
final boolean useRed = fileFormat.isUseRedForError();
final GraphicStrings result = GraphicStrings.createDefault(getHtmlStrings(useRed), useRed);
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false);
imageBuilder.addUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
}
private List getTextStrings() {
final List result = new ArrayList();
final int limit = 4;
int start;
final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) {
start = 0;
} else {
if (skip == 1) {
result.add("... (skipping 1 line) ...");
} else {
result.add("... (skipping " + skip + " lines) ...");
}
start = higherErrorPosition - limit + 1;
}
for (int i = start; i < higherErrorPosition; i++) {
result.add(getSource().getLine(i));
}
final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine);
if (StringUtils.isNotEmpty(err)) {
result.add(err);
}
final StringBuilder underscore = new StringBuilder();
for (int i = 0; i < errorLine.length(); i++) {
underscore.append("^");
}
result.add(underscore.toString());
final Collection textErrors = new LinkedHashSet();
for (ErrorUml er : printedErrors) {
textErrors.add(er.getError());
}
for (String er : textErrors) {
result.add(" " + er);
}
boolean first = true;
for (String s : getSuggest()) {
if (first) {
result.add(" " + s);
} else {
result.add(s);
}
first = false;
}
return result;
}
private List getHtmlStrings(boolean useRed) {
final List htmlStrings = new ArrayList();
final int limit = 4;
int start;
final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) {
start = 0;
} else {
if (skip == 1) {
htmlStrings.add("... (skipping 1 line) ...");
} else {
htmlStrings.add("... (skipping " + skip + " lines) ...");
}
start = higherErrorPosition - limit + 1;
}
for (int i = start; i < higherErrorPosition; i++) {
htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
}
final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine);
if (StringUtils.isNotEmpty(err)) {
htmlStrings.add("" + err + "");
}
// final StringBuilder underscore = new StringBuilder();
// for (int i = 0; i < errorLine.length(); i++) {
// underscore.append("^");
// }
final Collection textErrors = new LinkedHashSet();
for (ErrorUml er : printedErrors) {
textErrors.add(er.getError());
}
for (String er : textErrors) {
htmlStrings.add(" " + er + "");
}
boolean first = true;
for (String s : getSuggest()) {
if (first) {
htmlStrings.add(" " + s + "");
} else {
htmlStrings.add("" + StringUtils.hideComparatorCharacters(s)
+ "");
}
first = false;
}
return htmlStrings;
}
public List getSuggest() {
boolean suggested = false;
for (ErrorUml er : printedErrors) {
if (er.hasSuggest()) {
suggested = true;
}
}
if (suggested == false) {
return Collections.emptyList();
}
final List result = new ArrayList();
result.add("Did you mean:");
for (ErrorUml er : printedErrors) {
if (er.hasSuggest()) {
result.add(er.getSuggest().getSuggestedLine());
}
}
return Collections.unmodifiableList(result);
}
private Collection getErrors(ErrorUmlType type, List all) {
final Collection result = new LinkedHashSet();
for (ErrorUml error : all) {
if (error.getType() == type) {
result.add(error);
}
}
return result;
}
private int getHigherErrorPosition(ErrorUmlType type, List all) {
int max = Integer.MIN_VALUE;
for (ErrorUml error : getErrors(type, all)) {
if (error.getPosition() > max) {
max = error.getPosition();
}
}
// if (max == Integer.MIN_VALUE) {
// throw new IllegalStateException();
// }
return max;
}
private List getErrorsAt(int position, ErrorUmlType type, List all) {
final List result = new ArrayList();
for (ErrorUml error : getErrors(type, all)) {
if (error.getPosition() == position && StringUtils.isNotEmpty(error.getError())) {
result.add(error);
}
}
return result;
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Error)", getClass());
}
public final int getHigherErrorPosition() {
return higherErrorPosition;
}
public final Collection getErrorsUml() {
return Collections.unmodifiableCollection(printedErrors);
}
@Override
public String getWarningOrError() {
final StringBuilder sb = new StringBuilder();
sb.append(getDescription());
sb.append('\n');
for (CharSequence t : getTitle()) {
sb.append(t);
sb.append('\n');
}
sb.append('\n');
for (String s : getSuggest()) {
sb.append(s);
sb.append('\n');
}
return sb.toString();
}
}
src/net/sourceforge/plantuml/PSystemUtils.java 0100644 0000000 0000000 00000020205 12521434556 020637 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker;
import net.sourceforge.plantuml.png.PngSplitter;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class PSystemUtils {
public static List exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption)
throws IOException {
if (system instanceof NewpagedDiagram) {
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
}
if (system instanceof SequenceDiagram) {
return exportDiagramsSequence((SequenceDiagram) system, suggestedFile, fileFormatOption);
}
if (system instanceof CucaDiagram) {
return exportDiagramsCuca((CucaDiagram) system, suggestedFile, fileFormatOption);
}
if (system instanceof ActivityDiagram3) {
return exportDiagramsActivityDiagram3((ActivityDiagram3) system, suggestedFile, fileFormatOption);
}
return exportDiagramsDefault(system, suggestedFile, fileFormatOption);
}
private static List exportDiagramsNewpaged(NewpagedDiagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
final List result = new ArrayList();
final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) {
final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i);
if (canFileBeWritten(f) == false) {
return result;
}
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
// ImageData cmap = null;
try {
/* cmap = */system.exportDiagram(fos, i, fileFormat);
} finally {
fos.close();
}
// if (system.hasUrl() && cmap != null && cmap.containsCMapData()) {
// system.exportCmap(suggestedFile, cmap);
// }
Log.info("File size : " + f.length());
result.add(f);
}
return result;
}
public static boolean canFileBeWritten(final File f) {
Log.info("Creating file: " + f);
if (f.exists() && f.canWrite() == false) {
if (OptionFlags.getInstance().isOverwrite()) {
Log.info("Overwrite " + f);
f.setWritable(true);
f.delete();
return true;
}
Log.error("Cannot write to file " + f);
return false;
}
return true;
}
static private List exportDiagramsDefault(Diagram system, File suggestedFile, FileFormatOption fileFormat)
throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
OutputStream os = null;
try {
if (canFileBeWritten(suggestedFile) == false) {
return Collections.emptyList();
}
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
// system.exportDiagram(os, null, 0, fileFormat);
system.exportDiagram(os, 0, fileFormat);
} finally {
if (os != null) {
os.close();
}
}
return Arrays.asList(suggestedFile);
}
static private List exportDiagramsActivityDiagram3(ActivityDiagram3 system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
OutputStream os = null;
ImageData cmap = null;
try {
if (canFileBeWritten(suggestedFile) == false) {
return Collections.emptyList();
}
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
cmap = system.exportDiagram(os, 0, fileFormat);
} finally {
if (os != null) {
os.close();
}
}
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
return Arrays.asList(suggestedFile);
}
private static List exportDiagramsSequence(SequenceDiagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
final List result = new ArrayList();
final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) {
final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i);
if (canFileBeWritten(suggestedFile) == false) {
return result;
}
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
ImageData cmap = null;
try {
cmap = system.exportDiagram(fos, i, fileFormat);
} finally {
fos.close();
}
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
Log.info("File size : " + f.length());
result.add(f);
}
return result;
}
static public List exportDiagramsCuca(CucaDiagram system, File suggestedFile, FileFormatOption fileFormat)
throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
if (fileFormat.getFileFormat() == FileFormat.HTML) {
return createFilesHtml(system, suggestedFile);
}
ImageData cmap = null;
OutputStream os = null;
try {
if (canFileBeWritten(suggestedFile) == false) {
return Collections.emptyList();
}
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
cmap = system.exportDiagram(os, 0, fileFormat);
} finally {
if (os != null) {
os.close();
}
}
List result = Arrays.asList(suggestedFile);
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
if (fileFormat.getFileFormat() == FileFormat.PNG) {
result = new PngSplitter(suggestedFile, system.getHorizontalPages(), system.getVerticalPages(),
system.getMetadata(), system.getDpi(fileFormat), fileFormat.isWithMetadata()).getFiles();
}
return result;
}
private static List createFilesHtml(CucaDiagram system, File suggestedFile) throws IOException {
final String name = suggestedFile.getName();
final int idx = name.lastIndexOf('.');
final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx));
final CucaDiagramHtmlMaker maker = new CucaDiagramHtmlMaker(system, dir);
return maker.create();
}
}
src/net/sourceforge/plantuml/Pragma.java 0100644 0000000 0000000 00000005121 12521434556 017421 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.StringUtils;
public class Pragma {
private final Map values = new LinkedHashMap();
public void define(String name, String value) {
values.put(name, value);
if (name.equalsIgnoreCase("graphviz_dot")) {
OptionFlags.getInstance().setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value));
}
}
public boolean isDefine(String name) {
return values.containsKey(name);
}
public void undefine(String name) {
values.remove(name);
}
public String getValue(String name) {
return values.get(name);
}
public boolean horizontalLineBetweenDifferentPackageAllowed() {
return isDefine("horizontallinebetweendifferentpackageallowed");
}
public boolean useTeozLayout() {
final String teoz = getValue("teoz");
return "true".equalsIgnoreCase(teoz) || "on".equalsIgnoreCase(teoz);
}
}
src/net/sourceforge/plantuml/Removeable.java 0100644 0000000 0000000 00000003272 12521434556 020300 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public interface Removeable {
public boolean isRemoved();
}
src/net/sourceforge/plantuml/Run.java 0100644 0000000 0000000 00000033650 12521434556 016766 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.imageio.ImageIO;
import javax.swing.UIManager;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
import net.sourceforge.plantuml.ftp.FtpServer;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
import net.sourceforge.plantuml.swing.MainWindow2;
import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel;
import net.sourceforge.plantuml.ugraphic.SpriteUtils;
import net.sourceforge.plantuml.version.Version;
public class Run {
public static void main(String[] argsArray) throws IOException, InterruptedException {
final long start = System.currentTimeMillis();
final Option option = new Option(argsArray);
if (OptionFlags.getInstance().isEncodesprite()) {
encodeSprite(option.getResult());
return;
}
if (OptionFlags.getInstance().isVerbose()) {
Log.info("PlantUML Version " + Version.versionString());
Log.info("GraphicsEnvironment.isHeadless() " + GraphicsEnvironment.isHeadless());
}
if (GraphicsEnvironment.isHeadless()) {
Log.info("Forcing -Djava.awt.headless=true");
System.setProperty("java.awt.headless", "true");
Log.info("java.awt.headless set as true");
}
if (OptionFlags.getInstance().isPrintFonts()) {
printFonts();
return;
}
if (option.getFtpPort() != -1) {
goFtp(option);
return;
}
boolean error = false;
boolean forceQuit = false;
if (option.isPattern()) {
managePattern();
} else if (OptionFlags.getInstance().isGui()) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
final List list = option.getResult();
File dir = null;
if (list.size() == 1) {
final File f = new File(list.get(0));
if (f.exists() && f.isDirectory()) {
dir = f;
}
}
new MainWindow2(option, dir);
} else if (option.isPipe() || option.isSyntax()) {
managePipe(option);
forceQuit = true;
} else if (option.isFailfast2()) {
final long start2 = System.currentTimeMillis();
option.setCheckOnly(true);
error = manageAllFiles(option);
option.setCheckOnly(false);
if (option.isDuration()) {
final double duration = (System.currentTimeMillis() - start2) / 1000.0;
Log.error("Check Duration = " + duration + " seconds");
}
if (error == false) {
error = manageAllFiles(option);
}
forceQuit = true;
} else {
error = manageAllFiles(option);
forceQuit = true;
}
if (option.isDuration()) {
final double duration = (System.currentTimeMillis() - start) / 1000.0;
Log.error("Duration = " + duration + " seconds");
}
if (error) {
Log.error("Some diagram description contains errors");
System.exit(1);
}
if (forceQuit && OptionFlags.getInstance().isSystemExit()) {
System.exit(0);
}
}
private static void encodeSprite(List result) throws IOException {
SpriteGrayLevel level = SpriteGrayLevel.GRAY_16;
boolean compressed = false;
final File f;
if (result.size() > 1 && result.get(0).matches("(4|8|16)z?")) {
if (result.get(0).startsWith("8")) {
level = SpriteGrayLevel.GRAY_8;
}
if (result.get(0).startsWith("4")) {
level = SpriteGrayLevel.GRAY_4;
}
compressed = StringUtils.goLowerCase(result.get(0)).endsWith("z");
f = new File(result.get(1));
} else {
f = new File(result.get(0));
}
final BufferedImage im = ImageIO.read(f);
final String name = getSpriteName(f);
final String s = compressed ? SpriteUtils.encodeCompressed(im, name, level) : SpriteUtils.encode(im, name,
level);
System.out.println(s);
}
private static String getSpriteName(File f) {
final String s = getSpriteNameInternal(f);
if (s.length() == 0) {
return "test";
}
return s;
}
private static String getSpriteNameInternal(File f) {
final StringBuilder sb = new StringBuilder();
for (char c : f.getName().toCharArray()) {
if (("" + c).matches("[\\p{L}0-9_]")) {
sb.append(c);
} else {
return sb.toString();
}
}
return sb.toString();
}
private static void goFtp(Option option) throws IOException {
final int ftpPort = option.getFtpPort();
System.err.println("ftpPort=" + ftpPort);
final FtpServer ftpServer = new FtpServer(ftpPort, option.getFileFormat());
ftpServer.go();
}
public static void printFonts() {
final Font fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (Font f : fonts) {
System.out.println("f=" + f + "/" + f.getPSName() + "/" + f.getName() + "/" + f.getFontName() + "/"
+ f.getFamily());
}
final String name[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for (String n : name) {
System.out.println("n=" + n);
}
}
private static void managePattern() {
printPattern(new SequenceDiagramFactory());
printPattern(new ClassDiagramFactory());
printPattern(new ActivityDiagramFactory());
printPattern(new DescriptionDiagramFactory());
// printPattern(new ComponentDiagramFactory());
printPattern(new StateDiagramFactory());
printPattern(new ObjectDiagramFactory());
}
private static void printPattern(UmlDiagramFactory factory) {
System.out.println();
System.out.println(factory.getClass().getSimpleName().replaceAll("Factory", ""));
final List descriptions = factory.getDescription();
for (String s : descriptions) {
System.out.println(s);
}
}
private static void managePipe(Option option) throws IOException {
final String charset = option.getCharset();
final BufferedReader br;
if (charset == null) {
br = new BufferedReader(new InputStreamReader(System.in));
} else {
br = new BufferedReader(new InputStreamReader(System.in, charset));
}
managePipe(option, br, System.out);
}
public static void managePipe(Option option, final BufferedReader br, final PrintStream ps) throws IOException {
final StringBuilder sb = new StringBuilder();
String s = null;
while ((s = br.readLine()) != null) {
sb.append(s);
sb.append("\n");
}
String source = sb.toString();
if (source.contains("@startuml") == false) {
source = "@startuml\n" + source + "\n@enduml";
}
final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source, option.getConfig());
if (option.isSyntax()) {
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
if (system instanceof UmlDiagram) {
ps.println(((UmlDiagram) system).getUmlDiagramType().name());
ps.println(system.getDescription());
} else if (system instanceof PSystemError) {
ps.println("ERROR");
final PSystemError sys = (PSystemError) system;
ps.println(sys.getHigherErrorPosition());
for (ErrorUml er : sys.getErrorsUml()) {
ps.println(er.getError());
}
} else {
ps.println("OTHER");
ps.println(system.getDescription());
}
} else if (option.isPipe()) {
sourceStringReader.generateImage(ps, 0, option.getFileFormatOption());
}
}
private static boolean manageAllFiles(Option option) throws IOException, InterruptedException {
File lockFile = null;
try {
if (OptionFlags.getInstance().isWord()) {
final File dir = new File(option.getResult().get(0));
final File javaIsRunningFile = new File(dir, "javaisrunning.tmp");
javaIsRunningFile.delete();
lockFile = new File(dir, "javaumllock.tmp");
}
return processArgs(option);
} finally {
if (lockFile != null) {
lockFile.delete();
}
}
}
private static boolean processArgs(Option option) throws IOException, InterruptedException {
if (option.isDecodeurl() == false && option.getNbThreads() > 0 && option.isCheckOnly() == false
&& OptionFlags.getInstance().isMetadata() == false) {
return multithread(option);
}
boolean errorGlobal = false;
for (String s : option.getResult()) {
if (option.isDecodeurl()) {
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
System.out.println("@startuml");
System.out.println(transcoder.decode(s));
System.out.println("@enduml");
} else {
final FileGroup group = new FileGroup(s, option.getExcludes(), option);
for (File f : group.getFiles()) {
try {
final boolean error = manageFileInternal(f, option);
if (error) {
errorGlobal = true;
}
if (error && option.isFailfastOrFailfast2()) {
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return errorGlobal;
}
private static boolean multithread(final Option option) throws InterruptedException {
Log.info("Using several threads: " + option.getNbThreads());
final ExecutorService executor = Executors.newFixedThreadPool(option.getNbThreads());
final AtomicBoolean errors = new AtomicBoolean(false);
for (String s : option.getResult()) {
final FileGroup group = new FileGroup(s, option.getExcludes(), option);
for (final File f : group.getFiles()) {
executor.submit(new Runnable() {
public void run() {
if (errors.get() && option.isFailfastOrFailfast2()) {
return;
}
try {
final boolean error = manageFileInternal(f, option);
if (error) {
errors.set(true);
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
}
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
return errors.get();
}
private static boolean manageFileInternal(File f, Option option) throws IOException, InterruptedException {
if (OptionFlags.getInstance().isMetadata()) {
System.out.println("------------------------");
System.out.println(f);
// new Metadata().readAndDisplayMetadata(f);
System.out.println();
System.out.println(new MetadataTag(f, "plantuml").getData());
System.out.println("------------------------");
return false;
}
final ISourceFileReader sourceFileReader;
if (option.getOutputFile() == null) {
sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f, option.getOutputDir(),
option.getConfig(), option.getCharset(), option.getFileFormatOption());
} else {
sourceFileReader = new SourceFileReader2(option.getDefaultDefines(), f, option.getOutputFile(),
option.getConfig(), option.getCharset(), option.getFileFormatOption());
}
if (option.isComputeurl()) {
final List urls = sourceFileReader.getEncodedUrl();
for (String s : urls) {
System.out.println(s);
}
return false;
}
if (option.isCheckOnly()) {
final boolean hasError = sourceFileReader.hasError();
final List result = sourceFileReader.getGeneratedImages();
hasErrors(f, result);
return hasError;
}
final List result = sourceFileReader.getGeneratedImages();
return hasErrors(f, result);
}
private static boolean hasErrors(File f, final List list) throws IOException {
boolean result = false;
for (GeneratedImage i : list) {
final int lineError = i.lineErrorRaw();
if (lineError != -1) {
Log.error("Error line " + lineError + " in file: " + f.getCanonicalPath());
result = true;
}
}
return result;
}
}
src/net/sourceforge/plantuml/Scale.java 0100644 0000000 0000000 00000003315 12521434557 017245 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public interface Scale {
public double getScale(double width, double height);
}
src/net/sourceforge/plantuml/ScaleHeight.java 0100644 0000000 0000000 00000003564 12521434557 020404 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class ScaleHeight implements Scale {
private final double maxHeight;
public ScaleHeight(double maxHeight) {
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
return maxHeight / height;
}
}
src/net/sourceforge/plantuml/ScaleSimple.java 0100644 0000000 0000000 00000003532 12521434557 020420 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class ScaleSimple implements Scale {
private final double scale;
public ScaleSimple(double scale) {
this.scale = scale;
}
public double getScale(double width, double height) {
return scale;
}
}
src/net/sourceforge/plantuml/ScaleWidth.java 0100644 0000000 0000000 00000003554 12521434557 020252 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class ScaleWidth implements Scale {
private final double maxWidth;
public ScaleWidth(double maxWidth) {
this.maxWidth = maxWidth;
}
public double getScale(double width, double height) {
return maxWidth / width;
}
}
src/net/sourceforge/plantuml/ScaleWidthAndHeight.java 0100644 0000000 0000000 00000004155 12521434557 022024 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class ScaleWidthAndHeight implements Scale {
private final double maxWidth;
private final double maxHeight;
public ScaleWidthAndHeight(double maxWidth, double maxHeight) {
this.maxWidth = maxWidth;
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
final double scale1 = maxWidth / width;
final double scale2 = maxHeight / height;
// if (scale1 > 1 && scale2 > 1) {
// return 1;
// }
return Math.min(scale1, scale2);
}
}
src/net/sourceforge/plantuml/SignatureUtils.java 0100644 0000000 0000000 00000007104 12521434557 021200 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import net.sourceforge.plantuml.code.AsciiEncoder;
public class SignatureUtils {
public static String getSignature(String s) {
try {
final AsciiEncoder coder = new AsciiEncoder();
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
msgDigest.update(s.getBytes("UTF-8"));
final byte[] digest = msgDigest.digest();
return coder.encode(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new UnsupportedOperationException(e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
throw new UnsupportedOperationException(e);
}
}
public static String getSignatureWithoutImgSrc(String s) {
s = getSignature(purge(s));
return s;
}
public static String purge(String s) {
final String regex = "(?i)\\";
s = s.replaceAll(regex, "");
final String regex2 = "(?i)image=\"(?:[^\"]+[/\\\\])?([^/\\\\\\d.]+)\\d*(\\.\\w+)\"";
s = s.replaceAll(regex2, "image=\"$1$2\"");
return s;
}
public static String getSignature(File f) throws IOException {
try {
final AsciiEncoder coder = new AsciiEncoder();
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
final FileInputStream is = new FileInputStream(f);
int read = -1;
while ((read = is.read()) != -1) {
msgDigest.update((byte) read);
}
is.close();
final byte[] digest = msgDigest.digest();
return coder.encode(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new UnsupportedOperationException(e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
throw new UnsupportedOperationException(e);
}
}
}
src/net/sourceforge/plantuml/SingleLine.java 0100644 0000000 0000000 00000003401 12521434557 020243 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.core.Diagram;
public interface SingleLine {
Diagram getSystemFromSingleLine(String singleLine);
}
src/net/sourceforge/plantuml/SkinParam.java 0100644 0000000 0000000 00000047415 12521434560 020106 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Font;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.graphic.SkinParameter;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ColorMapperMonochrome;
import net.sourceforge.plantuml.ugraphic.Sprite;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
public class SkinParam implements ISkinParam {
private final Map params = new HashMap();
private Rankdir rankdir = Rankdir.TOP_TO_BOTTOM;
public void setParam(String key, String value) {
params.put(cleanForKey(key), value.trim());
}
private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
private static final Pattern stereoPattern = MyPattern.cmpile(stereoPatternString);
// public SkinParam() {
//
// }
public static SkinParam noShadowing() {
final SkinParam result = new SkinParam();
result.setParam("shadowing", "false");
return result;
}
// public SkinParam(String type) {
// if (type == null) {
// setParam("shadowing", "false");
// }
// }
static String cleanForKey(String key) {
key = StringUtils.goLowerCase(key).trim();
key = key.replaceAll("_|\\.|\\s", "");
key = replaceSmart(key, "partition", "package");
key = replaceSmart(key, "sequenceparticipant", "participant");
key = replaceSmart(key, "sequenceactor", "actor");
if (key.contains("arrow")) {
key = key.replaceAll("activityarrow|objectarrow|classarrow|componentarrow|statearrow|usecasearrow",
"genericarrow");
}
// // key = key.replaceAll("activityarrow", "genericarrow");
// // key = key.replaceAll("objectarrow", "genericarrow");
// // key = key.replaceAll("classarrow", "genericarrow");
// // key = key.replaceAll("componentarrow", "genericarrow");
// // key = key.replaceAll("statearrow", "genericarrow");
// // key = key.replaceAll("usecasearrow", "genericarrow");
final Matcher m = stereoPattern.matcher(key);
if (m.find()) {
final String s = m.group(1);
key = key.replaceAll(stereoPatternString, "");
key += "<<" + s + ">>";
}
return key;
}
private static String replaceSmart(String s, String src, String target) {
if (s.contains(src) == false) {
return s;
}
return s.replaceAll(src, target);
}
public HtmlColor getHyperlinkColor() {
final HtmlColor result = getHtmlColor(ColorParam.hyperlink, null, false);
if (result == null) {
return HtmlColorUtils.BLUE;
}
return result;
}
public HtmlColor getBackgroundColor() {
final HtmlColor result = getHtmlColor(ColorParam.background, null, false);
if (result == null) {
return HtmlColorUtils.WHITE;
}
return result;
}
public String getValue(String key) {
return params.get(cleanForKey(key));
}
static String humanName(String key) {
final StringBuilder sb = new StringBuilder();
boolean upper = true;
for (int i = 0; i < key.length(); i++) {
final char c = key.charAt(i);
if (c == '_') {
upper = true;
} else {
sb.append(upper ? StringUtils.goUpperCase(c) : StringUtils.goLowerCase(c));
upper = false;
}
}
return sb.toString();
}
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "color" + stereotype.getLabel(false));
if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) {
return getIHtmlColorSet().getColorIfValid(value2);
}
}
final String value = getValue(getParamName(param, clickable));
final boolean acceptTransparent = param == ColorParam.background;
if (value == null) {
return null;
}
return getIHtmlColorSet().getColorIfValid(value, acceptTransparent);
}
private String getParamName(ColorParam param, boolean clickable) {
String n = param.name();
if (clickable && n.endsWith("Background")) {
n = n.replaceAll("Background", "ClickableBackground");
} else if (clickable && n.endsWith("Border")) {
n = n.replaceAll("Border", "ClickableBorder");
}
return n + "color";
}
private void checkStereotype(Stereotype stereotype) {
// if (stereotype.startsWith("<<") == false || stereotype.endsWith(">>") == false) {
// throw new IllegalArgumentException();
// }
}
private int getFontSize(FontParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "fontsize" + stereotype.getLabel(false));
if (value2 != null && value2.matches("\\d+")) {
return Integer.parseInt(value2);
}
}
String value = getValue(param.name() + "fontsize");
if (value == null || value.matches("\\d+") == false) {
value = getValue("defaultfontsize");
}
if (value == null || value.matches("\\d+") == false) {
return param.getDefaultSize(this);
}
return Integer.parseInt(value);
}
private String getFontFamily(FontParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "fontname" + stereotype.getLabel(false));
if (value2 != null) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value2);
}
}
// Times, Helvetica, Courier or Symbol
String value = getValue(param.name() + "fontname");
if (value != null) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
}
if (param != FontParam.CIRCLED_CHARACTER) {
value = getValue("defaultfontname");
if (value != null) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
}
}
return param.getDefaultFamily();
}
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
value = getValue(param.name() + "fontcolor" + stereotype.getLabel(false));
}
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = getValue(param.name() + "fontcolor");
}
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = getValue("defaultfontcolor");
}
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = param.getDefaultColor();
}
return getIHtmlColorSet().getColorIfValid(value);
}
private int getFontStyle(FontParam param, Stereotype stereotype, boolean inPackageTitle) {
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
value = getValue(param.name() + "fontstyle" + stereotype.getLabel(false));
}
if (value == null) {
value = getValue(param.name() + "fontstyle");
}
if (value == null) {
value = getValue("defaultfontstyle");
}
if (value == null) {
return param.getDefaultFontStyle(this, inPackageTitle);
}
int result = Font.PLAIN;
if (StringUtils.goLowerCase(value).contains("bold")) {
result = result | Font.BOLD;
}
if (StringUtils.goLowerCase(value).contains("italic")) {
result = result | Font.ITALIC;
}
return result;
}
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
if (stereotype != null) {
checkStereotype(stereotype);
}
final String fontFamily = getFontFamily(fontParam, stereotype);
final int fontStyle = getFontStyle(fontParam, stereotype, inPackageTitle);
final int fontSize = getFontSize(fontParam, stereotype);
return new UFont(fontFamily, fontStyle, fontSize);
}
public int getCircledCharacterRadius() {
final String value = getValue("circledcharacterradius");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
// return 11;
// Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER));
// Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER)/3);
return getFontSize(FontParam.CIRCLED_CHARACTER, null) / 3 + 6;
}
public int classAttributeIconSize() {
final String value = getValue("classAttributeIconSize");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 10;
}
private boolean isMonochrome() {
return "true".equals(getValue("monochrome"));
}
public static Collection getPossibleValues() {
final Set result = new TreeSet();
result.add("Monochrome");
// result.add("BackgroundColor");
result.add("CircledCharacterRadius");
result.add("ClassAttributeIconSize");
result.add("DefaultFontName");
result.add("DefaultFontStyle");
result.add("DefaultFontSize");
result.add("DefaultFontColor");
for (FontParam p : EnumSet.allOf(FontParam.class)) {
final String h = humanName(p.name());
result.add(h + "FontStyle");
result.add(h + "FontName");
result.add(h + "FontSize");
result.add(h + "FontColor");
}
for (ColorParam p : EnumSet.allOf(ColorParam.class)) {
final String h = capitalize(p.name());
result.add(h + "Color");
}
for (LineParam p : EnumSet.allOf(LineParam.class)) {
final String h = capitalize(p.name());
result.add(h + "Thickness");
}
return Collections.unmodifiableSet(result);
}
private static String capitalize(String name) {
return StringUtils.goUpperCase(name.substring(0, 1)) + name.substring(1);
}
public int getDpi() {
final String value = getValue("dpi");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 96;
}
public DotSplines getDotSplines() {
final String value = getValue("linetype");
if ("polyline".equalsIgnoreCase(value)) {
return DotSplines.POLYLINE;
}
if ("ortho".equalsIgnoreCase(value)) {
return DotSplines.ORTHO;
}
return DotSplines.SPLINES;
}
public GraphvizLayoutStrategy getStrategy() {
final String value = getValue("layout");
if ("neato".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.NEATO;
}
if ("circo".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.CIRCO;
}
if ("fdp".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.FDP;
}
if ("twopi".equalsIgnoreCase(value)) {
return GraphvizLayoutStrategy.TWOPI;
}
return GraphvizLayoutStrategy.DOT;
}
public HorizontalAlignment getHorizontalAlignment(AlignParam param) {
final String value;
switch (param) {
case SEQUENCE_MESSAGE_ALIGN:
value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 0);
break;
case SEQUENCE_MESSAGETEXT_ALIGN:
value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 1);
break;
default:
value = getValue(param.name());
}
final HorizontalAlignment result = HorizontalAlignment.fromString(value);
if (result == null) {
return param.getDefaultValue();
}
return result;
}
public HorizontalAlignment getDefaultTextAlignment() {
final String value = getValue("defaulttextalignment");
final HorizontalAlignment result = HorizontalAlignment.fromString(value);
if (result == null) {
return HorizontalAlignment.CENTER;
}
return result;
}
private String getArg(String value, int i) {
if (value == null) {
return null;
}
final String[] split = value.split(":");
if (i >= split.length) {
return split[0];
}
return split[i];
}
public ColorMapper getColorMapper() {
if (isMonochrome()) {
return new ColorMapperMonochrome();
}
return new ColorMapperIdentity();
}
public boolean shadowing() {
final String value = getValue("shadowing");
if ("false".equalsIgnoreCase(value)) {
return false;
}
if ("true".equalsIgnoreCase(value)) {
return true;
}
if (strictUmlStyle()) {
return false;
}
return true;
}
public boolean shadowing2(SkinParameter skinParameter) {
if (skinParameter == null) {
throw new IllegalArgumentException();
}
final String name = skinParameter.getUpperCaseName();
final String value = getValue(name + "shadowing");
if (value == null) {
return shadowing();
}
if ("false".equalsIgnoreCase(value)) {
return false;
}
if ("true".equalsIgnoreCase(value)) {
return true;
}
if (strictUmlStyle()) {
return false;
}
return true;
}
public PackageStyle getPackageStyle() {
final String value = getValue("packageStyle");
final PackageStyle p = PackageStyle.fromString(value);
if (p == null) {
return PackageStyle.FOLDER;
}
return p;
}
private final Map sprites = new HashMap();
public void addSprite(String name, Sprite sprite) {
sprites.put(name, sprite);
}
public Sprite getSprite(String name) {
return sprites.get(name);
}
public boolean useUml2ForComponent() {
if (strictUmlStyle()) {
return true;
}
final String value = getValue("componentstyle");
return "uml2".equalsIgnoreCase(value);
}
public boolean stereotypePositionTop() {
final String value = getValue("stereotypePosition");
if ("bottom".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public boolean useSwimlanes(UmlDiagramType type) {
if (type != UmlDiagramType.ACTIVITY) {
return false;
}
if ("true".equalsIgnoreCase(getValue("swimlane"))) {
return true;
}
if ("true".equalsIgnoreCase(getValue("swimlanes"))) {
return true;
}
return false;
}
public double getNodesep() {
final String value = getValue("nodesep");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public double getRanksep() {
final String value = getValue("ranksep");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public double getRoundCorner() {
final String value = getValue("roundcorner");
if (value != null && value.matches("\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public UStroke getThickness(LineParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "thickness" + stereotype.getLabel(false));
if (value2 != null && value2.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value2));
}
}
final String value = getValue(param.name() + "thickness");
if (value != null && value.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value));
}
return null;
}
public double maxMessageSize() {
final String value = getValue("maxmessagesize");
if (value != null && value.matches("-?\\d+")) {
return Double.parseDouble(value);
}
return 0;
}
public boolean strictUmlStyle() {
final String value = getValue("style");
if ("strictuml".equalsIgnoreCase(value)) {
return true;
}
return false;
}
public boolean forceSequenceParticipantUnderlined() {
final String value = getValue("sequenceParticipant");
if ("underline".equalsIgnoreCase(value)) {
return true;
}
return false;
}
public ConditionStyle getConditionStyle() {
final String value = getValue("conditionStyle");
final ConditionStyle p = ConditionStyle.fromString(value);
if (p == null) {
return ConditionStyle.INSIDE;
}
return p;
}
public double minClassWidth() {
final String value = getValue("minclasswidth");
if (value != null && value.matches("\\d+")) {
return Integer.parseInt(value);
}
return 0;
}
public boolean sameClassWidth() {
return "true".equals(getValue("sameclasswidth"));
}
public final Rankdir getRankdir() {
return rankdir;
}
public final void setRankdir(Rankdir rankdir) {
this.rankdir = rankdir;
}
public boolean useOctagonForActivity(Stereotype stereotype) {
String value = getValue("activityshape");
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue("activityshape" + stereotype.getLabel(false));
if (value2 != null) {
value = value2;
}
}
if ("roundedbox".equalsIgnoreCase(value)) {
return false;
}
if ("octagon".equalsIgnoreCase(value)) {
return true;
}
return false;
}
private final IHtmlColorSet htmlColorSet = new HtmlColorSetSimple();
public IHtmlColorSet getIHtmlColorSet() {
return htmlColorSet;
}
public boolean useUnderlineForHyperlink() {
final String value = getValue("hyperlinkunderline");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public double getPadding() {
final String value = getValue("padding");
if (value != null && value.matches("\\d+(\\.\\d+)?")) {
return Double.parseDouble(value);
}
return 0;
}
public int groupInheritance() {
final String value = getValue("groupinheritance");
int result = Integer.MAX_VALUE;
if (value != null && value.matches("\\d+")) {
result = Integer.parseInt(value);
}
if (result <= 1) {
result = Integer.MAX_VALUE;
}
return result;
}
public boolean useGuillemet() {
final String value = getValue("guillemet");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public boolean handwritten() {
final String value = getValue("handwritten");
if ("true".equalsIgnoreCase(value)) {
return true;
}
return false;
}
}
src/net/sourceforge/plantuml/SkinParamBackcolored.java 0100644 0000000 0000000 00000006370 12521434560 022232 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamBackcolored extends SkinParamDelegator {
final private HtmlColor backColorElement;
final private HtmlColor backColorGeneral;
final private boolean forceClickage;
public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement) {
this(skinParam, backColorElement, null, false);
}
public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, boolean forceClickage) {
this(skinParam, backColorElement, null, forceClickage);
}
public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, HtmlColor backColorGeneral) {
this(skinParam, backColorElement, backColorGeneral, false);
}
public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, HtmlColor backColorGeneral,
boolean forceClickage) {
super(skinParam);
this.forceClickage = forceClickage;
this.backColorElement = backColorElement;
this.backColorGeneral = backColorGeneral;
}
public HtmlColor getBackgroundColor() {
if (backColorGeneral != null) {
return backColorGeneral;
}
return super.getBackgroundColor();
}
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (param.isBackground() && backColorElement != null) {
return backColorElement;
}
if (forceClickage) {
final HtmlColor c1 = super.getHtmlColor(param, stereotype, true);
if (c1 != null) {
return c1;
}
// clickable = true;
}
return super.getHtmlColor(param, stereotype, clickable);
}
}
src/net/sourceforge/plantuml/SkinParamBackcoloredReference.java 0100644 0000000 0000000 00000005273 12521434560 024052 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamBackcoloredReference extends SkinParamDelegator {
final private HtmlColor sequenceReferenceHeaderBackground;
final private HtmlColor sequenceReferenceBackground;
public SkinParamBackcoloredReference(ISkinParam skinParam, HtmlColor sequenceReferenceHeaderBackground,
HtmlColor sequenceReferenceBackground) {
super(skinParam);
this.sequenceReferenceBackground = sequenceReferenceBackground;
this.sequenceReferenceHeaderBackground = sequenceReferenceHeaderBackground;
}
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (param == ColorParam.sequenceReferenceHeaderBackground && sequenceReferenceHeaderBackground != null) {
return sequenceReferenceHeaderBackground;
}
if (param == ColorParam.sequenceReferenceBackground && sequenceReferenceBackground != null) {
return sequenceReferenceBackground;
}
return super.getHtmlColor(param, stereotype, clickable);
}
}
src/net/sourceforge/plantuml/SkinParamDelegator.java 0100644 0000000 0000000 00000014235 12521434560 021727 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.graphic.SkinParameter;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.Sprite;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
public class SkinParamDelegator implements ISkinParam {
final private ISkinParam skinParam;
public SkinParamDelegator(ISkinParam skinParam) {
this.skinParam = skinParam;
}
public HtmlColor getHyperlinkColor() {
return skinParam.getHyperlinkColor();
}
public HtmlColor getBackgroundColor() {
return skinParam.getBackgroundColor();
}
public int getCircledCharacterRadius() {
return skinParam.getCircledCharacterRadius();
}
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
return skinParam.getFont(fontParam, stereotype, false);
}
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
return skinParam.getFontHtmlColor(param, stereotype);
}
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
return skinParam.getHtmlColor(param, stereotype, clickable);
}
public String getValue(String key) {
return skinParam.getValue(key);
}
public int classAttributeIconSize() {
return skinParam.classAttributeIconSize();
}
public int getDpi() {
return skinParam.getDpi();
}
public DotSplines getDotSplines() {
return skinParam.getDotSplines();
}
public GraphvizLayoutStrategy getStrategy() {
return skinParam.getStrategy();
}
public HorizontalAlignment getHorizontalAlignment(AlignParam param) {
return skinParam.getHorizontalAlignment(param);
}
public ColorMapper getColorMapper() {
return skinParam.getColorMapper();
}
public boolean shadowing() {
return skinParam.shadowing();
}
public boolean shadowing2(SkinParameter skinParameter) {
return skinParam.shadowing2(skinParameter);
}
public PackageStyle getPackageStyle() {
return skinParam.getPackageStyle();
}
public Sprite getSprite(String name) {
return skinParam.getSprite(name);
}
public boolean useUml2ForComponent() {
return skinParam.useUml2ForComponent();
}
public boolean stereotypePositionTop() {
return skinParam.stereotypePositionTop();
}
public boolean useSwimlanes(UmlDiagramType type) {
return skinParam.useSwimlanes(type);
}
public double getNodesep() {
return skinParam.getNodesep();
}
public double getRanksep() {
return skinParam.getRanksep();
}
public double getRoundCorner() {
return skinParam.getRoundCorner();
}
public UStroke getThickness(LineParam param, Stereotype stereotype) {
return skinParam.getThickness(param, stereotype);
}
public double maxMessageSize() {
return skinParam.maxMessageSize();
}
public boolean strictUmlStyle() {
return skinParam.strictUmlStyle();
}
public boolean forceSequenceParticipantUnderlined() {
return skinParam.forceSequenceParticipantUnderlined();
}
public ConditionStyle getConditionStyle() {
return skinParam.getConditionStyle();
}
public double minClassWidth() {
return skinParam.minClassWidth();
}
public boolean sameClassWidth() {
return skinParam.sameClassWidth();
}
public Rankdir getRankdir() {
return skinParam.getRankdir();
}
public boolean useOctagonForActivity(Stereotype stereotype) {
return skinParam.useOctagonForActivity(stereotype);
}
public IHtmlColorSet getIHtmlColorSet() {
return skinParam.getIHtmlColorSet();
}
public boolean useUnderlineForHyperlink() {
return skinParam.useUnderlineForHyperlink();
}
public HorizontalAlignment getDefaultTextAlignment() {
return skinParam.getDefaultTextAlignment();
}
public double getPadding() {
return skinParam.getPadding();
}
public int groupInheritance() {
return skinParam.groupInheritance();
}
public boolean useGuillemet() {
return skinParam.useGuillemet();
}
public boolean handwritten() {
return skinParam.handwritten();
}
}
src/net/sourceforge/plantuml/SkinParamForecolored.java 0100644 0000000 0000000 00000004022 12521434560 022255 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamForecolored extends SkinParamDelegator {
final private HtmlColor forecolor;
public SkinParamForecolored(ISkinParam skinParam, HtmlColor forecolor) {
super(skinParam);
this.forecolor = forecolor;
}
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
return forecolor;
}
}
src/net/sourceforge/plantuml/SkinParamSameClassWidth.java 0100644 0000000 0000000 00000003620 12521434560 022670 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
public class SkinParamSameClassWidth extends SkinParamDelegator {
final private double width;
public SkinParamSameClassWidth(ISkinParam skinParam, double width) {
super(skinParam);
this.width = width;
}
public double minClassWidth() {
return width;
}
}
src/net/sourceforge/plantuml/SkinParamUtils.java 0100644 0000000 0000000 00000004604 12521434560 021120 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UFont;
public class SkinParamUtils {
private static final Rose rose = new Rose();
public static UFont getFont(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
return skinParam.getFont(fontParam, stereo, false);
}
public static HtmlColor getFontColor(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
return skinParam.getFontHtmlColor(fontParam, stereo);
}
public static HtmlColor getColor(ISkinParam skinParam, ColorParam colorParam, Stereotype stereo) {
return rose.getHtmlColor(skinParam, colorParam, stereo);
}
}
src/net/sourceforge/plantuml/SourceFileReader.java 0100644 0000000 0000000 00000015427 12521434560 021402 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines;
public class SourceFileReader implements ISourceFileReader {
private final File file;
private final File outputDirectory;
private final BlockUmlBuilder builder;
private FileFormatOption fileFormatOption;
public SourceFileReader(File file) throws IOException {
this(file, file.getAbsoluteFile().getParentFile());
}
public SourceFileReader(File file, File outputDirectory, String charset) throws IOException {
this(new Defines(), file, outputDirectory, Collections. emptyList(), charset, new FileFormatOption(
FileFormat.PNG));
}
public SourceFileReader(final File file, File outputDirectory) throws IOException {
this(new Defines(), file, outputDirectory, Collections. emptyList(), null, new FileFormatOption(
FileFormat.PNG));
}
public SourceFileReader(final File file, File outputDirectory, FileFormatOption fileFormatOption)
throws IOException {
this(new Defines(), file, outputDirectory, Collections. emptyList(), null, fileFormatOption);
}
public SourceFileReader(Defines defines, final File file, File outputDirectory, List config,
String charset, FileFormatOption fileFormatOption) throws IOException {
this.file = file;
this.fileFormatOption = fileFormatOption;
if (file.exists() == false) {
throw new IllegalArgumentException();
}
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
if (outputDirectory == null) {
outputDirectory = file.getAbsoluteFile().getParentFile();
} else if (outputDirectory.isAbsolute() == false) {
outputDirectory = FileSystem.getInstance().getFile(outputDirectory.getPath());
}
if (outputDirectory.exists() == false) {
outputDirectory.mkdirs();
}
this.outputDirectory = outputDirectory;
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
.getParentFile());
}
public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) {
if (b.getDiagram() instanceof PSystemError) {
return true;
}
}
return false;
}
public List getGeneratedImages() throws IOException {
Log.info("Reading file: " + file);
int cpt = 0;
final List result = new ArrayList();
for (BlockUml blockUml : builder.getBlockUmls()) {
String newName = blockUml.getFilename();
if (newName == null) {
newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
}
final File suggested = new File(outputDirectory, newName);
suggested.getParentFile().mkdirs();
final Diagram system = blockUml.getDiagram();
final List exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption);
OptionFlags.getInstance().logData(file, system);
for (File f : exportDiagrams) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
if (OptionFlags.getInstance().isWord()) {
final String warnOrError = system.getWarningOrError();
if (warnOrError != null) {
final String name = f.getName().substring(0, f.getName().length() - 4) + ".err";
final File errorFile = new File(f.getParentFile(), name);
final PrintStream ps = new PrintStream(new FileOutputStream(errorFile));
ps.print(warnOrError);
ps.close();
}
}
final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
result.add(generatedImage);
}
}
Log.info("Number of image(s): " + result.size());
return Collections.unmodifiableList(result);
}
public List getEncodedUrl() throws IOException {
final List result = new ArrayList();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {
final String source = blockUml.getDiagram().getSource().getPlainString();
final String encoded = transcoder.encode(source);
result.add(encoded);
}
return Collections.unmodifiableList(result);
}
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
if (charset == null) {
Log.info("Using default charset");
return new InputStreamReader(new FileInputStream(file));
}
Log.info("Using charset " + charset);
return new InputStreamReader(new FileInputStream(file), charset);
}
public final void setFileFormatOption(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
}
public final Set getIncludedFiles() {
return builder.getIncludedFiles();
}
}
src/net/sourceforge/plantuml/SourceFileReader2.java 0100644 0000000 0000000 00000011571 12521434560 021460 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines;
public class SourceFileReader2 implements ISourceFileReader {
private final File file;
private final File outputFile;
private final BlockUmlBuilder builder;
private FileFormatOption fileFormatOption;
public SourceFileReader2(Defines defines, final File file, File outputFile, List config, String charset,
FileFormatOption fileFormatOption) throws IOException {
this.file = file;
this.fileFormatOption = fileFormatOption;
this.outputFile = outputFile;
if (file.exists() == false) {
throw new IllegalArgumentException();
}
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
.getParentFile());
}
public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) {
if (b.getDiagram() instanceof PSystemError) {
return true;
}
}
return false;
}
public List getGeneratedImages() throws IOException {
Log.info("Reading file: " + file);
final List result = new ArrayList();
for (BlockUml blockUml : builder.getBlockUmls()) {
final File suggested = outputFile;
final Diagram system = blockUml.getDiagram();
OptionFlags.getInstance().logData(file, system);
for (File f : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
result.add(generatedImage);
}
}
Log.info("Number of image(s): " + result.size());
return Collections.unmodifiableList(result);
}
public List getEncodedUrl() throws IOException {
final List result = new ArrayList();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {
final String source = blockUml.getDiagram().getSource().getPlainString();
final String encoded = transcoder.encode(source);
result.add(encoded);
}
return Collections.unmodifiableList(result);
}
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
if (charset == null) {
Log.info("Using default charset");
return new InputStreamReader(new FileInputStream(file));
}
Log.info("Using charset " + charset);
return new InputStreamReader(new FileInputStream(file), charset);
}
public final void setFileFormatOption(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
}
public final Set getIncludedFiles() {
return builder.getIncludedFiles();
}
}
src/net/sourceforge/plantuml/SourceStringReader.java 0100644 0000000 0000000 00000015611 12521434560 021764 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class SourceStringReader {
final private List blocks;
public SourceStringReader(String source) {
this(new Defines(), source, Collections. emptyList());
}
public SourceStringReader(String source, String charset) {
this(new Defines(), source, "UTF-8", Collections. emptyList());
}
public SourceStringReader(Defines defines, String source, List config) {
this(defines, source, "UTF-8", config);
}
public SourceStringReader(Defines defines, String source, String charset, List config) {
// WARNING GLOBAL LOCK HERE
synchronized (SourceStringReader.class) {
try {
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
null);
this.blocks = builder.getBlockUmls();
} catch (IOException e) {
Log.error("error " + e);
throw new IllegalStateException(e);
}
}
}
public String generateImage(OutputStream os) throws IOException {
return generateImage(os, 0);
}
public String generateImage(File f) throws IOException {
final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
final String result = generateImage(os, 0);
os.close();
return result;
}
public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
return generateImage(os, 0, fileFormatOption);
}
public String generateImage(OutputStream os, int numImage) throws IOException {
return generateImage(os, numImage, new FileFormatOption(FileFormat.PNG));
}
public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException {
if (blocks.size() == 0) {
noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
if (imageData.containsCMapData()) {
return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
}
return system.getDescription().getDescription();
}
numImage -= nbInSystem;
}
Log.error("numImage is too big = " + numImage);
return null;
}
private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
final GraphicStrings error = GraphicStrings.createDefault(Arrays.asList("No @startuml found"),
fileFormatOption.isUseRedForError());
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
null, 0, 0, null, false);
imageBuilder.addUDrawable(error);
imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
}
public DiagramDescription generateDiagramDescription(OutputStream os) throws IOException {
return generateDiagramDescription(os, 0);
}
public DiagramDescription generateDiagramDescription(File f) throws IOException {
final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
final DiagramDescription result = generateDiagramDescription(os, 0);
os.close();
return result;
}
public DiagramDescription generateDiagramDescription(OutputStream os, FileFormatOption fileFormatOption)
throws IOException {
return generateDiagramDescription(os, 0, fileFormatOption);
}
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage) throws IOException {
return generateDiagramDescription(os, numImage, new FileFormatOption(FileFormat.PNG));
}
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage,
FileFormatOption fileFormatOption) throws IOException {
if (blocks.size() == 0) {
noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
if (imageData.containsCMapData()) {
return ((DiagramDescriptionImpl) system.getDescription()).withCMapData(imageData
.getCMapData("plantuml"));
}
return system.getDescription();
}
numImage -= nbInSystem;
}
Log.error("numImage is too big = " + numImage);
return null;
}
public final List getBlocks() {
return Collections.unmodifiableList(blocks);
}
}
src/net/sourceforge/plantuml/SpecificBackcolorable.java 0100644 0000000 0000000 00000003513 12521434560 022401 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HtmlColor;
public interface SpecificBackcolorable {
public HtmlColor getSpecificBackColor();
public void setSpecificBackcolor(HtmlColor specificBackcolor);
}
src/net/sourceforge/plantuml/SpriteContainer.java 0100644 0000000 0000000 00000003440 12521434560 021320 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.ugraphic.Sprite;
public interface SpriteContainer {
public Sprite getSprite(String name);
public boolean useGuillemet();
}
src/net/sourceforge/plantuml/SpriteContainerEmpty.java 0100644 0000000 0000000 00000003743 12521434560 022345 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.ugraphic.Sprite;
public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
public Sprite getSprite(String name) {
return null;
}
public String getValue(String key) {
return null;
}
public double getPadding() {
return 0;
}
public boolean useGuillemet() {
return false;
}
}
src/net/sourceforge/plantuml/StringUtils.java 0100644 0000000 0000000 00000033605 12521434560 020504 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.UncommentReadLine;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
// Do not move
public class StringUtils {
public static String getPlateformDependentAbsolutePath(File file) {
return file.getAbsolutePath();
}
public static List getWithNewlines2(Code s) {
return getWithNewlines2(s.getFullName());
}
public static List getWithNewlines2(String s) {
if (s == null) {
return null;
}
final List result = new ArrayList();
final StringBuilder current = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i);
if (c == '\\' && i < s.length() - 1) {
final char c2 = s.charAt(i + 1);
i++;
if (c2 == 'n') {
result.add(current.toString());
current.setLength(0);
} else if (c2 == 't') {
current.append('\t');
} else if (c2 == '\\') {
current.append(c2);
}
} else {
current.append(c);
}
}
result.add(current.toString());
return Collections.unmodifiableList(result);
}
public static String getMergedLines(List extends CharSequence> strings) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < strings.size(); i++) {
sb.append(strings.get(i));
if (i < strings.size() - 1) {
sb.append("\\n");
}
}
return sb.toString();
}
final static public List getSplit(Pattern pattern, String line) {
final Matcher m = pattern.matcher(line);
if (m.find() == false) {
return null;
}
final List result = new ArrayList();
for (int i = 1; i <= m.groupCount(); i++) {
result.add(m.group(i));
}
return result;
}
public static boolean isNotEmpty(String input) {
return input != null && input.trim().length() > 0;
}
public static boolean isNotEmpty(List extends CharSequence> input) {
return input != null && input.size() > 0;
}
public static boolean isEmpty(String input) {
return input == null || input.trim().length() == 0;
}
public static String manageHtml(String s) {
s = s.replace("<", "<");
s = s.replace(">", ">");
return s;
}
public static String unicode(String s) {
final StringBuilder result = new StringBuilder();
for (char c : s.toCharArray()) {
if (c > 127 || c == '&' || c == '|') {
final int i = c;
result.append("" + i + ";");
} else {
result.append(c);
}
}
return result.toString();
}
public static String unicodeForHtml(String s) {
final StringBuilder result = new StringBuilder();
for (char c : s.toCharArray()) {
if (c > 127 || c == '&' || c == '|' || c == '<' || c == '>') {
final int i = c;
result.append("" + i + ";");
} else {
result.append(c);
}
}
return result.toString();
}
public static String unicodeForHtml(Display display) {
final StringBuilder result = new StringBuilder();
for (int i = 0; i < display.size(); i++) {
result.append(unicodeForHtml(display.get(i).toString()));
if (i < display.size() - 1) {
result.append(" ");
}
}
return result.toString();
}
public static String manageArrowForSequence(String s) {
s = s.replace('=', '-').toLowerCase();
return s;
}
public static String capitalize(String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}
public static String goUpperCase(String s) {
return s.toUpperCase(Locale.ENGLISH);
}
public static char goUpperCase(char c) {
return goUpperCase("" + c).charAt(0);
}
public static String goLowerCase(String s) {
return s.toLowerCase(Locale.ENGLISH);
}
public static char goLowerCase(char c) {
return goLowerCase("" + c).charAt(0);
}
public static String manageArrowForCuca(String s) {
final Direction dir = getArrowDirection(s);
s = s.replace('=', '-');
s = s.replaceAll("\\w*", "");
if (dir == Direction.LEFT || dir == Direction.RIGHT) {
s = s.replaceAll("-+", "-");
}
if (s.length() == 2 && (dir == Direction.UP || dir == Direction.DOWN)) {
s = s.replaceFirst("-", "--");
}
return s;
}
public static String manageQueueForCuca(String s) {
final Direction dir = getQueueDirection(s);
s = s.replace('=', '-');
s = s.replaceAll("\\w*", "");
if (dir == Direction.LEFT || dir == Direction.RIGHT) {
s = s.replaceAll("-+", "-");
}
if (s.length() == 1 && (dir == Direction.UP || dir == Direction.DOWN)) {
s = s.replaceFirst("-", "--");
}
return s;
}
public static Direction getArrowDirection(String s) {
if (s.endsWith(">")) {
return getQueueDirection(s.substring(0, s.length() - 1));
}
if (s.startsWith("<")) {
if (s.length() == 2) {
return Direction.LEFT;
}
return Direction.UP;
}
throw new IllegalArgumentException(s);
}
public static Direction getQueueDirection(String s) {
if (s.indexOf('<') != -1 || s.indexOf('>') != -1) {
throw new IllegalArgumentException(s);
}
s = s.toLowerCase();
if (s.contains("left")) {
return Direction.LEFT;
}
if (s.contains("right")) {
return Direction.RIGHT;
}
if (s.contains("up")) {
return Direction.UP;
}
if (s.contains("down")) {
return Direction.DOWN;
}
if (s.contains("l")) {
return Direction.LEFT;
}
if (s.contains("r")) {
return Direction.RIGHT;
}
if (s.contains("u")) {
return Direction.UP;
}
if (s.contains("d")) {
return Direction.DOWN;
}
if (s.length() == 1) {
return Direction.RIGHT;
}
return Direction.DOWN;
}
// public static Code eventuallyRemoveStartingAndEndingDoubleQuote(Code s) {
// return Code.of(eventuallyRemoveStartingAndEndingDoubleQuote(s.getCode()));
// }
public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s, String format) {
if (format.contains("\"") && s.length() > 1 && isDoubleQuote(s.charAt(0))
&& isDoubleQuote(s.charAt(s.length() - 1))) {
return s.substring(1, s.length() - 1);
}
if (format.contains("(") && s.startsWith("(") && s.endsWith(")")) {
return s.substring(1, s.length() - 1);
}
if (format.contains("[") && s.startsWith("[") && s.endsWith("]")) {
return s.substring(1, s.length() - 1);
}
if (format.contains(":") && s.startsWith(":") && s.endsWith(":")) {
return s.substring(1, s.length() - 1);
}
return s;
}
public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s) {
return eventuallyRemoveStartingAndEndingDoubleQuote(s, "\"([:");
}
private static boolean isDoubleQuote(char c) {
return c == '\"' || c == '\u201c' || c == '\u201d' || c == '\u00ab' || c == '\u00bb';
}
public static boolean isCJK(char c) {
final Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
Log.println("block=" + block);
return false;
}
public static char hiddenLesserThan() {
return '\u0005';
}
public static char hiddenBiggerThan() {
return '\u0006';
}
public static String hideComparatorCharacters(String s) {
s = s.replace('<', hiddenLesserThan());
s = s.replace('>', hiddenBiggerThan());
return s;
}
public static String showComparatorCharacters(String s) {
s = s.replace(hiddenLesserThan(), '<');
s = s.replace(hiddenBiggerThan(), '>');
return s;
}
public static int getWidth(List extends CharSequence> stringsToDisplay) {
int result = 1;
for (CharSequence s : stringsToDisplay) {
if (result < s.length()) {
result = s.length();
}
}
return result;
}
public static int getWidth(Display stringsToDisplay) {
int result = 1;
for (CharSequence s : stringsToDisplay) {
if (result < s.length()) {
result = s.length();
}
}
return result;
}
public static int getHeight(List extends CharSequence> stringsToDisplay) {
return stringsToDisplay.size();
}
public static int getHeight(Display stringsToDisplay) {
return stringsToDisplay.size();
}
private static void removeFirstColumn(List data) {
for (int i = 0; i < data.size(); i++) {
final String s = data.get(i);
if (s.length() > 0) {
data.set(i, s.substring(1));
}
}
}
private static boolean firstColumnRemovable(List data) {
boolean allEmpty = true;
for (String s : data) {
if (s.length() == 0) {
continue;
}
allEmpty = false;
final char c = s.charAt(0);
if (c != ' ' && c != '\t') {
return false;
}
}
return allEmpty == false;
}
public static List removeEmptyColumns(List data) {
if (firstColumnRemovable(data) == false) {
return data;
}
final List result = new ArrayList(data);
do {
removeFirstColumn(result);
} while (firstColumnRemovable(result));
return result;
}
public static void trim(List data, boolean removeEmptyLines) {
for (int i = 0; i < data.size(); i++) {
final String s = data.get(i);
data.set(i, s.trim());
}
if (removeEmptyLines) {
for (final Iterator it = data.iterator(); it.hasNext();) {
if (it.next().length() == 0) {
it.remove();
}
}
}
}
public static String uncommentSource(String source) {
final StringReader sr = new StringReader(source);
final UncommentReadLine un = new UncommentReadLine(new ReadLineReader(sr));
final StringBuilder sb = new StringBuilder();
String s = null;
try {
while ((s = un.readLine()) != null) {
sb.append(s);
sb.append('\n');
}
} catch (IOException e) {
Log.error("Error " + e);
throw new IllegalStateException(e.toString());
}
sr.close();
return sb.toString();
}
public static boolean isDiagramCacheable(String uml) {
uml = uml.toLowerCase();
if (uml.startsWith("@startuml\nversion\n")) {
return false;
}
if (uml.startsWith("@startuml\ncheckversion")) {
return false;
}
if (uml.startsWith("@startuml\ntestdot\n")) {
return false;
}
if (uml.startsWith("@startuml\nsudoku\n")) {
return false;
}
return true;
}
public static List splitComma(String s) {
s = s.trim();
// if (s.matches("([\\p{L}0-9_.]+|[%g][^%g]+[%g])(\\s*,\\s*([\\p{L}0-9_.]+|[%g][^%g]+[%g]))*") == false) {
// throw new IllegalArgumentException();
// }
final List result = new ArrayList();
final Pattern p = MyPattern.cmpile("([\\p{L}0-9_.]+|[%g][^%g]+[%g])");
final Matcher m = p.matcher(s);
while (m.find()) {
result.add(eventuallyRemoveStartingAndEndingDoubleQuote(m.group(0)));
}
return Collections.unmodifiableList(result);
}
public static String getAsHtml(Color color) {
if (color == null) {
return null;
}
return getAsHtml(color.getRGB());
}
public static String getAsSvg(ColorMapper mapper, HtmlColor color) {
if (color == null) {
return "none";
}
if (color instanceof HtmlColorTransparent) {
return "#FFFFFF";
}
return getAsHtml(mapper.getMappedColor(color));
}
public static String getAsHtml(int color) {
final int v = 0xFFFFFF & color;
String s = "000000" + Integer.toHexString(v).toUpperCase();
s = s.substring(s.length() - 6);
return "#" + s;
}
public static String getUid(String uid1, int uid2) {
return uid1 + String.format("%04d", uid2);
}
public static boolean isMethod(String s) {
return s.contains("(") || s.contains(")");
}
public static List merge(List l1, List l2) {
final List result = new ArrayList(l1);
result.addAll(l2);
return Collections.unmodifiableList(result);
}
public static boolean endsWithBackslash(final String s) {
return s.endsWith("\\") && s.endsWith("\\\\") == false;
}
// http://docs.oracle.com/javase/tutorial/i18n/format/dateFormat.html
}
src/net/sourceforge/plantuml/UmlDiagram.java 0100644 0000000 0000000 00000034245 12521434562 020242 0 ustar 00 0000000 0000000 /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* Licensed under The MIT License (Massachusetts Institute of Technology License)
*
* See http://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Author: Arnaud Roques
*/
package net.sourceforge.plantuml;
import java.awt.Font;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.script.ScriptException;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.anim.AnimationDecoder;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.fun.IconLoader;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.QuoteUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.pdf.PdfConverter;
import net.sourceforge.plantuml.svek.EmptySvgException;
import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.Sprite;
import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.version.Version;
public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
private boolean rotation;
private boolean hideUnlinkedData;
private int minwidth = Integer.MAX_VALUE;
private Display title;
private Display header;
private Display footer;
private Display legend = null;
private HorizontalAlignment legendAlignment = HorizontalAlignment.CENTER;
private VerticalAlignment legendVerticalAlignment = VerticalAlignment.BOTTOM;
private HorizontalAlignment headerAlignment = HorizontalAlignment.RIGHT;
private HorizontalAlignment footerAlignment = HorizontalAlignment.CENTER;
private final Pragma pragma = new Pragma();
private Scale scale;
private Animation animation;
private final SkinParam skinParam = new SkinParam();
final public void setTitle(Display strings) {
this.title = strings;
}
final public Display getTitle() {
return title;
}
final public int getMinwidth() {
return minwidth;
}
final public void setMinwidth(int minwidth) {
this.minwidth = minwidth;
}
final public boolean isRotation() {
return rotation;
}
final public void setRotation(boolean rotation) {
this.rotation = rotation;
}
public final ISkinParam getSkinParam() {
return skinParam;
}
public void setParam(String key, String value) {
skinParam.setParam(StringUtils.goLowerCase(key), value);
}
public final Display getHeader() {
return header;
}
public final void setHeader(Display header) {
this.header = header;
}
public final Display getFooter() {
return footer;
}
public final void setFooter(Display footer) {
this.footer = footer;
}
public final HorizontalAlignment getHeaderAlignment() {
return headerAlignment;
}
public final void setHeaderAlignment(HorizontalAlignment headerAlignment) {
this.headerAlignment = headerAlignment;
}
public final HorizontalAlignment getFooterAlignment() {
return footerAlignment;
}
public final void setFooterAlignment(HorizontalAlignment footerAlignment) {
this.footerAlignment = footerAlignment;
}
abstract public UmlDiagramType getUmlDiagramType();
public Pragma getPragma() {
return pragma;
}
final public void setScale(Scale scale) {
this.scale = scale;
}
final public Scale getScale() {
return scale;
}
final public void setAnimation(List animationData) {
try {
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
this.animation = Animation.create(animationDecoder.decode());
} catch (ScriptException e) {
e.printStackTrace();
}
}
final public Animation getAnimation() {
return animation;
}
public final double getDpiFactor(FileFormatOption fileFormatOption) {
if (getSkinParam().getDpi() == 96) {
return 1.0;
}
return getSkinParam().getDpi() / 96.0;
}
public final int getDpi(FileFormatOption fileFormatOption) {
return getSkinParam().getDpi();
}
public final boolean isHideUnlinkedData() {
return hideUnlinkedData;
}
public final void setHideUnlinkedData(boolean hideUnlinkedData) {
this.hideUnlinkedData = hideUnlinkedData;
}
final public ImageData exportDiagram(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
return exportDiagramInternalPdf(os, index);
}
try {
final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption);
this.lastInfo = new Dimension2DDouble(imageData.getWidth(), imageData.getHeight());
return imageData;
} catch (UnparsableGraphvizException e) {
e.printStackTrace();
exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion(), e.getDebugData());
} catch (Exception e) {
e.printStackTrace();
exportDiagramError(os, e, fileFormatOption, null, null);
}
return new ImageDataSimple();
}
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
String graphvizVersion, String svg) throws IOException {
final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
final List strings = getFailureText(exception, graphvizVersion);
final String flash = getFlashData();
for (StackTraceElement ste : exception.getStackTrace()) {
strings.add(" " + ste.toString());
}
if (exception.getCause() != null) {
final Throwable cause = exception.getCause();
strings.add(" ");
strings.add("Caused by " + cause.toString());
for (StackTraceElement ste : cause.getStackTrace()) {
strings.add(" " + ste.toString());
}
}
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, getSkinParam().handwritten());
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(flash);
if (im != null) {
GraphvizCrash.addDecodeHint(strings);
}
final GraphicStrings graphicStrings = new GraphicStrings(strings, font, HtmlColorUtils.BLACK,
HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
if (im == null) {
imageBuilder.addUDrawable(graphicStrings);
} else {
imageBuilder.addUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {
graphicStrings.drawU(ug);
final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight();
ug = ug.apply(new UTranslate(0, height));
ug.draw(new UImage(im));
}
});
}
imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
}
private String getFlashData() {
// for (Map.Entry