1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

Version 6242

This commit is contained in:
Arnaud Roques 2011-03-26 13:37:27 +01:00
parent a53403952e
commit 7347fc27af
34 changed files with 722 additions and 221 deletions

View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>6210-SNAPSHOT</version>
<version>6242-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -69,12 +69,6 @@ final public class BlockUmlBuilder {
return s.equals("@enduml") || s.startsWith("@enduml ");
}
private boolean isIgnoredLine(final String s) {
// return s.length() == 0 || s.startsWith("#") || s.startsWith("'");
// return s.length() == 0 || s.startsWith("'");
return s.startsWith("'");
}
public static boolean isArobaseStartuml(String s) {
s = s.trim();
return s.equals("@startuml") || s.startsWith("@startuml ");
@ -87,7 +81,7 @@ final public class BlockUmlBuilder {
if (isArobaseStartuml(s)) {
current = new ArrayList<String>();
}
if (current != null && isIgnoredLine(s.trim()) == false) {
if (current != null) {
current.add(s);
}
if (isArobaseEnduml(s) && current != null) {

View File

@ -0,0 +1,58 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5890 $
*
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
import net.sourceforge.plantuml.command.CommandComment;
import net.sourceforge.plantuml.command.CommandMultilinesComment;
import net.sourceforge.plantuml.command.CommandNope;
public class EmptyDiagramFactory extends AbstractUmlSystemCommandFactory {
private PSystemError system;
public PSystemError getSystem() {
return system;
}
@Override
protected void initCommands() {
// system = new PSystemError();
addCommand(new CommandNope(null));
addCommand(new CommandComment(null));
addCommand(new CommandMultilinesComment(null));
}
}

View File

@ -35,6 +35,8 @@ package net.sourceforge.plantuml;
import java.awt.Font;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
public interface ISkinParam {
@ -66,5 +68,9 @@ public interface ISkinParam {
public int getDpi();
public boolean useOctagonForActivity();
public DotSplines getDotSplines();
public GraphvizLayoutStrategy getStrategy();
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6188 $
* Revision $Revision: 6234 $
*
*/
package net.sourceforge.plantuml;
@ -39,34 +39,23 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.activitydiagram2.ActivityDiagramFactory2;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
import net.sourceforge.plantuml.componentdiagram.ComponentDiagramFactory;
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
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.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory;
import net.sourceforge.plantuml.swing.MainWindow;
import net.sourceforge.plantuml.usecasediagram.UsecaseDiagramFactory;
import net.sourceforge.plantuml.version.PSystemVersionFactory;
public class Run {

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6141 $
* Revision $Revision: 6228 $
*
*/
package net.sourceforge.plantuml;
@ -44,6 +44,8 @@ import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParam implements ISkinParam {
@ -264,12 +266,44 @@ public class SkinParam implements ISkinParam {
}
public boolean useOctagonForActivity() {
// activityShape roundedbox
final String value = getValue("activityshape");
if ("roundedbox".equalsIgnoreCase(value)) {
return false;
}
return true;
if ("octagon".equalsIgnoreCase(value)) {
return true;
}
return false;
}
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;
}
}

View File

@ -35,6 +35,8 @@ package net.sourceforge.plantuml;
import java.awt.Font;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamBackcolored implements ISkinParam {
@ -115,4 +117,12 @@ public class SkinParamBackcolored implements ISkinParam {
public boolean useOctagonForActivity() {
return skinParam.useOctagonForActivity();
}
public DotSplines getDotSplines() {
return skinParam.getDotSplines();
}
public GraphvizLayoutStrategy getStrategy() {
return skinParam.getStrategy();
}
}

View File

@ -33,6 +33,7 @@
*/
package net.sourceforge.plantuml;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -88,6 +89,9 @@ final public class UmlSource {
if (BlockUmlBuilder.isArobaseEnduml(s)) {
continue;
}
if (s.matches("\\s*'.*")) {
continue;
}
if (s.trim().length() != 0) {
return false;
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6191 $
* Revision $Revision: 6214 $
*
*/
package net.sourceforge.plantuml.command;
@ -84,6 +84,7 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF
final protected void addCommonCommands(UmlDiagram system) {
addCommand(new CommandNope(system));
addCommand(new CommandComment(system));
addCommand(new CommandMultilinesComment(system));
addCommand(new CommandPragma(system));
addCommand(new CommandTitle(system));

View File

@ -0,0 +1,51 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4762 $
*
*/
package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
public class CommandComment extends SingleLineCommand<UmlDiagram> {
public CommandComment(UmlDiagram diagram) {
super(diagram, "(?i)^\\s*('.*||/'.*'/\\s*)$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
return CommandExecutionResult.ok();
}
}

View File

@ -75,7 +75,7 @@ public abstract class CommandMultilines2<S extends PSystem> implements Command {
return CommandControl.OK_PARTIAL;
}
Matcher m1 = ending.matcher(lines.get(lines.size() - 1).trim());
final Matcher m1 = ending.matcher(lines.get(lines.size() - 1).trim());
if (m1.matches() == false) {
return CommandControl.OK_PARTIAL;
}

View File

@ -44,7 +44,6 @@ public class CommandMultilinesComment extends CommandMultilines<UmlDiagram> {
}
public CommandExecutionResult execute(List<String> lines) {
System.err.println(lines);
return CommandExecutionResult.ok();
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6199 $
* Revision $Revision: 6229 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
@ -59,7 +59,6 @@ import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMaker;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMakerBeta;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramPngMaker3;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
@ -514,15 +513,4 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
public final Set<VisibilityModifier> getHides() {
return Collections.unmodifiableSet(hides);
}
private GraphvizLayoutStrategy strategy = GraphvizLayoutStrategy.DOT;
public void setStrategy(GraphvizLayoutStrategy strategy) {
this.strategy = strategy;
}
public GraphvizLayoutStrategy getStrategy() {
return strategy;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6197 $
* Revision $Revision: 6241 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -57,8 +57,6 @@ import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder;
@ -82,6 +80,7 @@ import net.sourceforge.plantuml.cucadiagram.Imaged;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.eps.EpsTitler;
import net.sourceforge.plantuml.eps.SvgToEpsConverter;
import net.sourceforge.plantuml.graphic.CircledCharacter;
import net.sourceforge.plantuml.graphic.GraphicStrings;
@ -102,6 +101,7 @@ import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.StickMan;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.statediagram.StateDiagram;
import net.sourceforge.plantuml.svg.SvgTitler;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
@ -586,6 +586,38 @@ public final class CucaDiagramFileMaker {
return svgTitler.addTitleSvg(svg, width, height);
}
private String addTitleEps(String eps) throws IOException {
final Color titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.TITLE, null).getColor();
final String fontFamily = getSkinParam().getFontFamily(FontParam.TITLE, null);
final int fontSize = getSkinParam().getFontSize(FontParam.TITLE, null);
final EpsTitler epsTitler = new EpsTitler(titleColor, diagram.getTitle(), fontSize, fontFamily,
HorizontalAlignement.CENTER, VerticalPosition.TOP, 3);
this.deltaY += epsTitler.getHeight();
return epsTitler.addTitleEps(eps);
}
private String addFooterEps(String eps) throws IOException {
final Color titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null).getColor();
final String fontFamily = getSkinParam().getFontFamily(FontParam.FOOTER, null);
final int fontSize = getSkinParam().getFontSize(FontParam.FOOTER, null);
final EpsTitler epsTitler = new EpsTitler(titleColor, diagram.getFooter(), fontSize, fontFamily, diagram
.getFooterAlignement(), VerticalPosition.BOTTOM, 3);
return epsTitler.addTitleEps(eps);
}
private String addHeaderEps(String eps) throws IOException {
final Color titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null).getColor();
final String fontFamily = getSkinParam().getFontFamily(FontParam.HEADER, null);
final int fontSize = getSkinParam().getFontSize(FontParam.HEADER, null);
final EpsTitler epsTitler = new EpsTitler(titleColor, diagram.getHeader(), fontSize, fontFamily, diagram
.getHeaderAlignement(), VerticalPosition.TOP, 3);
this.deltaY += epsTitler.getHeight();
return epsTitler.addTitleEps(eps);
}
private String addHeaderSvg(String svg, double width, double height) throws IOException {
final Color titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null).getColor();
final String fontFamily = getSkinParam().getFontFamily(FontParam.HEADER, null);
@ -891,6 +923,18 @@ public final class CucaDiagramFileMaker {
if (isUnderline) {
eps = new UnderlineTrickEps(eps).getString();
}
if (diagram.getTitle() != null) {
eps = addTitleEps(eps);
}
if (diagram.getFooter() != null) {
eps = addFooterEps(eps);
}
if (diagram.getHeader() != null) {
eps = addHeaderEps(eps);
}
os.write(eps.getBytes("UTF-8"));
// final Dimension2D dim = getDimensionSvg(svg);
//
@ -931,7 +975,6 @@ public final class CucaDiagramFileMaker {
// mImage.appendTail(sb);
// svg = sb.toString();
os.write(eps.getBytes("UTF-8"));
} finally {
// cleanTemporaryFiles(diagram.entities().values());
@ -963,13 +1006,16 @@ public final class CucaDiagramFileMaker {
if (diagram.getUmlDiagramType() == UmlDiagramType.CLASS || diagram.getUmlDiagramType() == UmlDiagramType.OBJECT) {
dotData.setStaticImagesMap(staticFilesMap);
if (diagram.isVisibilityModifierPresent()) {
dotData.setVisibilityModifierPresent(true);
}
}
return diagram.getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
if (diagram.getUmlDiagramType() == UmlDiagramType.STATE) {
dotData.setHideEmptyDescription(((StateDiagram) diagram).isHideEmptyDescription());
}
return diagram.getSkinParam().getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
// return new DotMaker(dotData, dotStrings, fileFormat);
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5813 $
* Revision $Revision: 6222 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -262,5 +262,17 @@ final public class DotData implements PortionShower {
public final void setDpi(int dpi) {
this.dpi = dpi;
}
private boolean hideEmptyDescription = false;
public final void setHideEmptyDescription(boolean hideEmptyDescription) {
this.hideEmptyDescription = hideEmptyDescription;
}
public final boolean isHideEmptyDescription() {
return hideEmptyDescription;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6195 $
* Revision $Revision: 6230 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -168,6 +168,24 @@ final public class DotMaker implements GraphvizMaker {
}
// sb.append("ordering=out;");
sb.append("compound=true;");
final DotSplines dotSplines = data.getSkinParam().getDotSplines();
final GraphvizLayoutStrategy strategy = data.getSkinParam().getStrategy();
if (dotSplines == DotSplines.ORTHO) {
sb.append("splines=ortho;");
} else if (dotSplines == DotSplines.POLYLINE) {
sb.append("splines=polyline;");
} else if (strategy != GraphvizLayoutStrategy.DOT) {
sb.append("splines=true;");
}
// if (strategy == GraphvizLayoutStrategy.NEATO) {
// sb.append("overlap=false;");
// }
if (strategy != GraphvizLayoutStrategy.DOT) {
sb.append("layout=" + strategy.name().toLowerCase() + ";");
sb.append("overlap=false;");
}
sb.append("remincross=true;");
sb.append("searchsize=500;");
if (data.getRankdir() == Rankdir.LEFT_TO_RIGHT) {
@ -1051,7 +1069,7 @@ final public class DotMaker implements GraphvizMaker {
sb.append("</TABLE>");
}
if (entity.getFieldsToDisplay().size() == 0 && cFile == null) {
if (data.isHideEmptyDescription() == false && entity.getFieldsToDisplay().size() == 0 && cFile == null) {
sb.append("|");
}

View File

@ -0,0 +1,39 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6222 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
public enum DotSplines {
POLYLINE, ORTHO, SPLINES
}

View File

@ -40,21 +40,21 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.OptionFlags;
public enum GraphvizLayoutStrategy {
DOT, NEATO;
DOT, NEATO, FDP, TWOPI, CIRCO;
public GraphvizMaker getGraphvizMaker(DotData data,
List<String> dotStrings, FileFormat fileFormat) {
if (this == DOT) {
// if (this == DOT) {
return new DotMaker(data, dotStrings, fileFormat);
}
throw new UnsupportedOperationException(this.toString());
// }
// throw new UnsupportedOperationException(this.toString());
}
public File getSystemForcedExecutable() {
if (this == DOT) {
// if (this == DOT) {
return getSystemForcedDot();
}
throw new UnsupportedOperationException(this.toString());
// }
// throw new UnsupportedOperationException(this.toString());
}
private File getSystemForcedDot() {

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6197 $
* Revision $Revision: 6228 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -217,7 +217,7 @@ public final class GroupPngMaker {
// dotData.putAllImagesLink(imagesLink);
// return new DotMaker(dotData, dotStrings, fileFormat);
return diagram.getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
return diagram.getSkinParam().getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
}
private List<Link> getPureInnerLinks() {

View File

@ -38,6 +38,7 @@ import java.awt.geom.PathIterator;
import java.awt.image.BufferedImage;
import java.util.Date;
import java.util.Locale;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.ugraphic.UGradient;
@ -66,25 +67,26 @@ public class EpsGraphics {
header.append("%%Creator: PlantUML\n");
header.append("%%Title: noTitle\n");
header.append("%%CreationDate: " + new Date() + "\n");
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add"));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 2 index mul 7 index add"));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 3 index mul 7 index add"));
setcolorgradient.add(new PostScriptCommandRaw("setrgbcolor"));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add", true));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 2 index mul 7 index add", true));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 3 index mul 7 index add", true));
setcolorgradient.add(new PostScriptCommandRaw("setrgbcolor", true));
// setcolorgradient.add(new PostScriptCommandRaw("0 7 1 {pop} for"));
setcolorgradient.add(new PostScriptCommandRaw("pop pop pop pop pop pop pop "));
setcolorgradient.add(new PostScriptCommandRaw("pop pop pop pop pop pop pop ", true));
simplerect.add(new PostScriptCommandRaw("newpath moveto 1 index 0 rlineto"));
simplerect.add(new PostScriptCommandRaw("0 exch rlineto"));
simplerect.add(new PostScriptCommandRaw("neg 0 rlineto"));
simplerect.add(new PostScriptCommandRaw("newpath moveto 1 index 0 rlineto", true));
simplerect.add(new PostScriptCommandRaw("0 exch rlineto", true));
simplerect.add(new PostScriptCommandRaw("neg 0 rlineto", true));
roundrect.add(new PostScriptCommandRaw("newpath"));
roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 2 index add 2 index 180 270 arc"));
roundrect
.add(new PostScriptCommandRaw("2 index 5 index add 1 index sub 2 index 2 index add 2 index 270 0 arc"));
roundrect.add(new PostScriptCommandRaw("newpath", true));
roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 2 index add 2 index 180 270 arc", true));
roundrect.add(new PostScriptCommandRaw("2 index 5 index add 1 index sub 2 index 2 index add 2 index 270 0 arc",
true));
roundrect.add(new PostScriptCommandRaw(
"2 index 5 index add 1 index sub 2 index 5 index add 2 index sub 2 index 0 90 arc"));
roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 5 index add 2 index sub 2 index 90 180 arc"));
roundrect.add(new PostScriptCommandRaw("pop pop pop pop pop "));
"2 index 5 index add 1 index sub 2 index 5 index add 2 index sub 2 index 0 90 arc", true));
roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 5 index add 2 index sub 2 index 90 180 arc",
true));
roundrect.add(new PostScriptCommandRaw("pop pop pop pop pop ", true));
}
private boolean closeDone = false;
@ -127,13 +129,13 @@ public class EpsGraphics {
header.append(roundrect.getPostStringDefinition());
}
append("grestore");
append("grestore", true);
// if(isClipSet())
// writer.write("grestore\n");
append("showpage");
append("%%EOF");
append("showpage", true);
append("%%EOF", true);
closeDone = true;
}
@ -174,18 +176,18 @@ public class EpsGraphics {
ensureVisible(x1, y1);
ensureVisible(x2, y2);
if (strokeDasharray != null) {
append("[" + strokeDasharray + "] 0 setdash");
append("[" + strokeDasharray + "] 0 setdash", true);
}
checkCloseDone();
append(strokeWidth + " setlinewidth");
append(strokeWidth + " setlinewidth", true);
appendColor(color);
append("newpath");
append(format(x1) + " " + format(y1) + " moveto");
append(format(x2 - x1) + " " + format(y2 - y1) + " rlineto");
append("closepath stroke");
append("newpath", true);
append(format(x1) + " " + format(y1) + " moveto", true);
append(format(x2 - x1) + " " + format(y2 - y1) + " rlineto", true);
append("closepath stroke", true);
ensureVisible(Math.max(x1, x2), Math.max(y1, y2));
if (strokeDasharray != null) {
append("[] 0 setdash");
append("[] 0 setdash", true);
}
}
@ -195,37 +197,37 @@ public class EpsGraphics {
double lastY = 0;
if (fillcolor != null) {
appendColor(fillcolor);
append("newpath");
append("newpath", true);
for (int i = 0; i < points.length; i += 2) {
ensureVisible(points[i], points[i + 1]);
if (i == 0) {
append(format(points[i]) + " " + format(points[i + 1]) + " moveto");
append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
} else {
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto");
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
}
lastX = points[i];
lastY = points[i + 1];
}
append(format(points[0]) + " " + format(points[1]) + " lineto");
append("closepath eofill");
append(format(points[0]) + " " + format(points[1]) + " lineto", true);
append("closepath eofill", true);
}
if (color != null) {
append(strokeWidth + " setlinewidth");
append(strokeWidth + " setlinewidth", true);
appendColor(color);
append("newpath");
append("newpath", true);
for (int i = 0; i < points.length; i += 2) {
ensureVisible(points[i], points[i + 1]);
if (i == 0) {
append(format(points[i]) + " " + format(points[i + 1]) + " moveto");
append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
} else {
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto");
append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
}
lastX = points[i];
lastY = points[i + 1];
}
append(format(points[0]) + " " + format(points[1]) + " lineto");
append("closepath stroke");
append(format(points[0]) + " " + format(points[1]) + " lineto", true);
append("closepath stroke", true);
}
}
@ -237,14 +239,14 @@ public class EpsGraphics {
if (fillcolor != null) {
appendColor(fillcolor);
epsRectangleInternal(x, y, width, height, rx, ry);
append("closepath eofill");
append("closepath eofill", true);
}
if (color != null) {
append(strokeWidth + " setlinewidth");
append(strokeWidth + " setlinewidth", true);
appendColor(color);
epsRectangleInternal(x, y, width, height, rx, ry);
append("closepath stroke");
append("closepath stroke", true);
}
}
@ -258,49 +260,49 @@ public class EpsGraphics {
simplerectUsed = true;
appendColorShort(gr.getColor1());
appendColorShort(gr.getColor2());
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y));
append("100 -1 1 {");
append("100 div");
append("newpath");
append("2 index 2 index moveto");
append("dup 5 index mul 2 mul dup 0 rlineto");
append("neg 4 index 2 index mul 2 mul rlineto");
append("closepath eoclip");
append("10 index 10 index 10 index");
append("10 index 10 index 10 index");
append("6 index setcolorgradient");
append("4 index 4 index 4 index 4 index simplerect");
append("closepath eofill");
append("pop");
append("} for");
append("pop pop pop pop");
append("pop pop pop");
append("pop pop pop");
append("initclip");
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y), true);
append("100 -1 1 {", true);
append("100 div", true);
append("newpath", true);
append("2 index 2 index moveto", true);
append("dup 5 index mul 2 mul dup 0 rlineto", true);
append("neg 4 index 2 index mul 2 mul rlineto", true);
append("closepath eoclip", true);
append("10 index 10 index 10 index", true);
append("10 index 10 index 10 index", true);
append("6 index setcolorgradient", true);
append("4 index 4 index 4 index 4 index simplerect", true);
append("closepath eofill", true);
append("pop", true);
append("} for", true);
append("pop pop pop pop", true);
append("pop pop pop", true);
append("pop pop pop", true);
append("initclip", true);
} else {
roundrectUsed = true;
appendColorShort(gr.getColor1());
appendColorShort(gr.getColor2());
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " "
+ format((rx + ry) / 2));
append("100 -1 1 {");
append("100 div");
append("newpath");
append("3 index 3 index moveto");
append("dup 6 index mul 2 mul dup 0 rlineto");
append("neg 5 index 2 index mul 2 mul rlineto");
append("closepath eoclip");
append("11 index 11 index 11 index");
append("11 index 11 index 11 index");
append("6 index setcolorgradient");
append("5 index 5 index 5 index 5 index 5 index roundrect");
append("closepath eofill");
append("pop");
append("} for");
append("pop pop pop pop pop");
append("pop pop pop");
append("pop pop pop");
append("initclip");
+ format((rx + ry) / 2), true);
append("100 -1 1 {", true);
append("100 div", true);
append("newpath", true);
append("3 index 3 index moveto", true);
append("dup 6 index mul 2 mul dup 0 rlineto", true);
append("neg 5 index 2 index mul 2 mul rlineto", true);
append("closepath eoclip", true);
append("11 index 11 index 11 index", true);
append("11 index 11 index 11 index", true);
append("6 index setcolorgradient", true);
append("5 index 5 index 5 index 5 index 5 index roundrect", true);
append("closepath eofill", true);
append("pop", true);
append("} for", true);
append("pop pop pop pop pop", true);
append("pop pop pop", true);
append("pop pop pop", true);
append("initclip", true);
}
}
@ -314,12 +316,12 @@ public class EpsGraphics {
private void roundRectangle(double x, double y, double width, double height, double rx, double ry) {
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " " + format((rx + ry) / 2)
+ " roundrect");
+ " roundrect", true);
roundrectUsed = true;
}
private void simpleRectangle(double x, double y, double width, double height) {
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect");
append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect", true);
simplerectUsed = true;
}
@ -331,17 +333,17 @@ public class EpsGraphics {
}
if (fillcolor != null) {
appendColor(fillcolor);
append("newpath");
append(format(x) + " " + format(y) + " " + format(xRadius) + " 0 360 arc");
append("closepath eofill");
append("newpath", true);
append(format(x) + " " + format(y) + " " + format(xRadius) + " 0 360 arc", true);
append("closepath eofill", true);
}
if (color != null) {
append(strokeWidth + " setlinewidth");
append(strokeWidth + " setlinewidth", true);
appendColor(color);
append("newpath");
append(format(x) + " " + format(y) + " " + format(xRadius) + " 0 360 arc");
append("closepath stroke");
append("newpath", true);
append(format(x) + " " + format(y) + " " + format(xRadius) + " 0 360 arc", true);
append("closepath stroke", true);
}
}
@ -349,14 +351,14 @@ public class EpsGraphics {
final double r = c.getRed() / 255.0;
final double g = c.getGreen() / 255.0;
final double b = c.getBlue() / 255.0;
append(format(r) + " " + format(g) + " " + format(b) + " setrgbcolor");
append(format(r) + " " + format(g) + " " + format(b) + " setrgbcolor", true);
}
protected void appendColorShort(Color c) {
final double r = c.getRed() / 255.0;
final double g = c.getGreen() / 255.0;
final double b = c.getBlue() / 255.0;
append(format(r) + " " + format(g) + " " + format(b));
append(format(r) + " " + format(g) + " " + format(b), true);
}
public static String format(double x) {
@ -371,8 +373,8 @@ public class EpsGraphics {
return s;
}
protected void append(String s) {
if (s.indexOf(" ") != -1) {
protected void append(String s, boolean checkConsistence) {
if (checkConsistence && s.indexOf(" ") != -1) {
throw new IllegalArgumentException(s);
}
body.append(s + "\n");
@ -380,18 +382,18 @@ public class EpsGraphics {
// FONT
public void moveto(double x1, double y1) {
append(format(x1) + " " + format(y1) + " moveto");
append(format(x1) + " " + format(y1) + " moveto", true);
ensureVisible(x1, y1);
}
public void lineto(double x1, double y1) {
append(format(x1) + " " + format(y1) + " lineto");
append(format(x1) + " " + format(y1) + " lineto", true);
ensureVisible(x1, y1);
}
public void curveto(double x1, double y1, double x2, double y2, double x3, double y3) {
append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " "
+ format(y3) + " curveto");
+ format(y3) + " curveto", true);
ensureVisible(x1, y1);
ensureVisible(x2, y2);
ensureVisible(x3, y3);
@ -399,40 +401,40 @@ public class EpsGraphics {
public void quadto(double x1, double y1, double x2, double y2) {
append(format(x1) + " " + format(y1) + " " + format(x1) + " " + format(y1) + " " + format(x2) + " "
+ format(y2) + " curveto");
+ format(y2) + " curveto", true);
ensureVisible(x1, y1);
ensureVisible(x2, y2);
}
public void newpath() {
append("0 setlinewidth");
append("[] 0 setdash");
append("0 setlinewidth", true);
append("[] 0 setdash", true);
appendColor(color);
append("newpath");
append("newpath", true);
}
public void closepath() {
append("closepath");
append("closepath", true);
}
public void fill(int windingRule) {
append("%fill");
append("%fill", true);
if (windingRule == PathIterator.WIND_EVEN_ODD) {
append("eofill");
append("eofill", true);
} else if (windingRule == PathIterator.WIND_NON_ZERO) {
append("fill");
append("fill", true);
}
}
public void drawImage(BufferedImage image, double x, double y) {
final int width = image.getWidth();
final int height = image.getHeight();
append("gsave");
append(format(x) + " " + format(y) + " translate");
append(format(width) + " " + format(height) + " scale");
append("" + width + " " + height + " 8 [" + width + " 0 0 -" + height + " 0 " + height + "]");
append("gsave", true);
append(format(x) + " " + format(y) + " translate", true);
append(format(width) + " " + format(height) + " scale", true);
append("" + width + " " + height + " 8 [" + width + " 0 0 -" + height + " 0 " + height + "]", true);
// append("" + width + " " + height + " 8 [0 0 0 0 0 0]");
append("{<");
append("{<", true);
final StringBuilder sb = new StringBuilder();
for (int j = height - 1; j >= 0; j--) {
for (int i = 0; i < width; i++) {
@ -441,11 +443,11 @@ public class EpsGraphics {
sb.append(hexString);
}
}
append(sb.toString());
append(sb.toString(), true);
// append(">} image");
append(">} false 3 colorimage");
append(">} false 3 colorimage", true);
ensureVisible(x + width, y + height);
append("grestore");
append("grestore", true);
}
static String getRgb(int x) {
@ -453,4 +455,28 @@ public class EpsGraphics {
return s.substring(s.length() - 6);
}
public void drawEps(String eps, double x, double y) {
final int idx = eps.indexOf("%%BoundingBox:");
if (idx == -1) {
throw new IllegalArgumentException();
}
final StringTokenizer st = new StringTokenizer(eps.substring(idx + "%%BoundingBox:".length()), " \n\t\r");
final int x1 = Integer.parseInt(st.nextToken());
final int y1 = Integer.parseInt(st.nextToken());
final int x2 = Integer.parseInt(st.nextToken());
final int y2 = Integer.parseInt(st.nextToken());
assert x2 >= x1;
assert y2 >= y1;
append("gsave", true);
final double dx = x - x1;
final double dy = y + y2;
append(format(dx) + " " + format(dy) + " translate", true);
append("1 -1 scale", true);
append(eps, false);
ensureVisible(x + (x2 - x1), y + (y2 - y1));
append("grestore", true);
}
}

View File

@ -44,15 +44,15 @@ public class EpsGraphicsMacro extends EpsGraphics {
public EpsGraphicsMacro() {
super();
rquadto.add(new PostScriptCommandRaw("3 index 3 index 4 2 roll rcurveto"));
rquadto.add(new PostScriptCommandRaw("3 index 3 index 4 2 roll rcurveto", true));
}
@Override
protected void append(String s) {
if (s.indexOf(" ") != -1) {
protected void append(String s, boolean checkConsistence) {
if (checkConsistence && s.indexOf(" ") != -1) {
throw new IllegalArgumentException(s);
}
data.add(new PostScriptCommandRaw(s));
data.add(new PostScriptCommandRaw(s, checkConsistence));
}
@Override
@ -74,24 +74,24 @@ public class EpsGraphicsMacro extends EpsGraphics {
@Override
public void newpath() {
append("0 setlinewidth");
append("[] 0 setdash");
append("0 setlinewidth", true);
append("[] 0 setdash", true);
appendColor(getColor());
append("newpath");
append("newpath", true);
}
@Override
public void closepath() {
macroInProgress.add(new PostScriptCommandRaw("closepath"));
macroInProgress.add(new PostScriptCommandRaw("closepath", true));
closeMacro();
}
@Override
public void fill(int windingRule) {
if (windingRule == PathIterator.WIND_EVEN_ODD) {
append("eofill");
append("eofill", true);
} else if (windingRule == PathIterator.WIND_NON_ZERO) {
append("fill");
append("fill", true);
}
}
@ -155,10 +155,10 @@ public class EpsGraphicsMacro extends EpsGraphics {
final String existingName = macros.get(macroInProgress);
if (existingName == null) {
macros.put(macroInProgress, macroInProgress.getName());
append(macroName());
append(macroName(), true);
macroCpt++;
} else {
append(existingName);
append(existingName, true);
}
macroInProgress = null;
}

View File

@ -0,0 +1,173 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4173 $
*
*/
package net.sourceforge.plantuml.eps;
import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.util.List;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.VerticalPosition;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
public final class EpsTitler {
private final Color textColor;
private final List<String> text;
// private final int fontSize;
// private final String fontFamily;
private final HorizontalAlignement horizontalAlignement;
private final VerticalPosition verticalPosition;
private final int margin;
private final TextBlock textBloc;
public EpsTitler(Color textColor, List<String> text, int fontSize, String fontFamily,
HorizontalAlignement horizontalAlignement, VerticalPosition verticalPosition, int margin) {
this.textColor = textColor;
this.text = text;
// this.fontSize = fontSize;
// this.fontFamily = fontFamily;
this.horizontalAlignement = horizontalAlignement;
this.verticalPosition = verticalPosition;
this.margin = margin;
if (text == null || text.size() == 0) {
textBloc = null;
} else {
final Font normalFont = new Font(fontFamily, Font.PLAIN, fontSize);
textBloc = TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor),
HorizontalAlignement.LEFT);
}
}
public double getHeight() {
if (textBloc == null) {
return 0;
}
return textBloc.calculateDimension(new UGraphicEps(EpsStrategy.getDefault()).getStringBounder()).getHeight()
+ margin;
}
public String addTitleEps(String eps) throws IOException {
if (text == null || text.size() == 0) {
return eps;
}
final int idx = eps.indexOf("%%BoundingBox:");
if (idx == -1) {
throw new IllegalArgumentException();
}
final StringTokenizer st = new StringTokenizer(eps.substring(idx + "%%BoundingBox:".length()), " \n\t\r");
final int x1 = Integer.parseInt(st.nextToken());
final int y1 = Integer.parseInt(st.nextToken());
final int x2 = Integer.parseInt(st.nextToken());
final int y2 = Integer.parseInt(st.nextToken());
assert x2 >= x1;
assert y2 >= y1;
final double width = x2 - x1;
final double height = y2 - y1;
final UGraphicEps uGraphicEps = new UGraphicEps(EpsStrategy.getDefault());
final Dimension2D dimText = textBloc.calculateDimension(uGraphicEps.getStringBounder());
final double xpos;
if (horizontalAlignement == HorizontalAlignement.LEFT) {
xpos = 2;
} else if (horizontalAlignement == HorizontalAlignement.RIGHT) {
xpos = width - dimText.getWidth() - 2;
} else if (horizontalAlignement == HorizontalAlignement.CENTER) {
xpos = (width - dimText.getWidth()) / 2;
} else {
xpos = 0;
assert false;
}
final double yText;
if (verticalPosition == VerticalPosition.TOP) {
yText = 0;
} else {
yText = height + margin;
}
textBloc.drawU(uGraphicEps, xpos, yText);
final double yImage;
if (verticalPosition == VerticalPosition.TOP) {
yImage = dimText.getHeight();
} else {
yImage = 0;
}
uGraphicEps.drawEps(eps, 0, yImage);
uGraphicEps.close();
return uGraphicEps.getEPSCode();
// String svgTitle = CucaDiagramFileMaker.getSvg(uGraphicSvg);
// svgTitle = svgTitle.replaceFirst("(?i)<g>", "<g
// transform=\"translate(0 0)\">");
//
// if (verticalPosition == VerticalPosition.TOP) {
// final Pattern p =
// Pattern.compile("(?i)translate\\((\\d+)\\s+(\\d+)");
// final Matcher m = p.matcher(svg);
//
// final StringBuffer sb = new StringBuffer();
// while (m.find()) {
// final int tx = Integer.parseInt(m.group(1));
// final int ty = Integer.parseInt(m.group(2)) + (int)
// (dimText.getHeight()) + margin;
// m.appendReplacement(sb, "translate(" + tx + " " + ty);
// }
// m.appendTail(sb);
// svg = sb.toString();
// }
//
// final int x = svg.indexOf("<g ");
// if (x == -1) {
// throw new IllegalStateException();
// }
// svg = svg.substring(0, x) + svgTitle + svg.substring(x);
//
// return svg;
}
}

View File

@ -37,8 +37,8 @@ public class PostScriptCommandRaw implements PostScriptCommand {
final private String cmd;
public PostScriptCommandRaw(String cmd) {
if (cmd.indexOf('\n') != -1) {
public PostScriptCommandRaw(String cmd, boolean checkConsistence) {
if (checkConsistence && cmd.indexOf('\n') != -1) {
throw new IllegalArgumentException(cmd);
}
this.cmd = cmd;

View File

@ -28,13 +28,12 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6107 $
* Revision $Revision: 6219 $
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Set;
@ -51,7 +50,7 @@ class PreprocessorInclude implements ReadLine {
private int numLine = 0;
private PreprocessorInclude included = null;
private final Set<File> filesUsed;
public PreprocessorInclude(ReadLine reader, Set<File> filesUsed) {
@ -84,16 +83,35 @@ class PreprocessorInclude implements ReadLine {
}
private String manageInclude(Matcher m) throws IOException, FileNotFoundException {
final String fileName = m.group(1);
private String manageInclude(Matcher m) throws IOException {
String fileName = m.group(1);
final int idx = fileName.lastIndexOf('!');
String suf = null;
if (idx != -1) {
suf = fileName.substring(idx + 1);
fileName = fileName.substring(0, idx);
}
final File f = FileSystem.getInstance().getFile(fileName);
if (f.exists()) {
filesUsed.add(f);
included = new PreprocessorInclude(new ReadLineReader(new FileReader(f)), filesUsed);
included = new PreprocessorInclude(getReaderInclude(f, suf), filesUsed);
} else {
return "Cannot include " + f.getAbsolutePath();
}
return this.readLine();
}
private ReadLine getReaderInclude(final File f, String suf) throws IOException {
if (StartumlExtractReader.containsStartuml(f)) {
int bloc = 0;
if (suf != null && suf.matches("\\d+")) {
bloc = Integer.parseInt(suf);
}
return new StartumlExtractReader(f, bloc);
}
return new ReadLineReader(new FileReader(f));
}
public int getLineNumber() {
return numLine;
}

View File

@ -38,21 +38,44 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import net.sourceforge.plantuml.BlockUmlBuilder;
public class StartumlExtractReader implements ReadLine {
private final ReadLine raw;
private boolean finished = false;
public StartumlExtractReader(File f, int num) throws FileNotFoundException {
public StartumlExtractReader(File f, int num) throws IOException {
if (num < 0) {
throw new IllegalArgumentException();
}
raw = getReadLine(f);
String s = null;
while ((s = raw.readLine()) != null) {
if (BlockUmlBuilder.isArobaseStartuml(s)) {
if (num == 0) {
return;
}
num--;
}
}
finished = true;
}
private static ReadLine getReadLine(File f) throws FileNotFoundException {
return new UncommentReadLine(new ReadLineReader(new FileReader(f)));
}
static public boolean containsStartuml(File f) throws IOException {
ReadLine r = null;
try {
r = getReadLine(f);
String s = null;
while ((s = r.readLine()) != null) {
if (BlockUmlBuilder.isArobaseStartuml(s)) {
return true;
}
}
} finally {
if (r != null) {
r.close();
@ -61,12 +84,16 @@ public class StartumlExtractReader implements ReadLine {
return false;
}
private static ReadLine getReadLine(File f) throws FileNotFoundException {
return new UncommentReadLine(new ReadLineReader(new FileReader(f)));
}
public String readLine() throws IOException {
return raw.readLine();
if (finished) {
return null;
}
final String result = raw.readLine();
if (result != null && BlockUmlBuilder.isArobaseEnduml(result)) {
finished = true;
return null;
}
return result;
}
public void close() throws IOException {

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6198 $
* Revision $Revision: 6214 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@ -174,7 +174,6 @@ class DrawableSetInitializer {
final double x1 = drawableSet.getX1(pe);
final double x2 = drawableSet.getX2(stringBounder, pe);
final double missing = preferredWidth - (x2 - x1);
System.err.println("x1=" + x1 + " x2=" + x2 + " preferredWidth=" + preferredWidth + " missing=" + missing);
if (missing>0) {
constraintSet
.pushToLeftParticipantBox(missing / 2, first, true);

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5977 $
* Revision $Revision: 6242 $
*
*/
package net.sourceforge.plantuml.skin.bluemodern;
@ -62,7 +62,7 @@ public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArr
ug.getParam().setBackcolor(getForegroundColor());
ug.getParam().setColor(getForegroundColor());
final int x2 = (int) arrowWidth;
final double x2 = arrowWidth - 3;
if (getArrowConfiguration().isDotted()) {
stroke(ug, 5, 2);

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5937 $
* Revision $Revision: 6242 $
*
*/
package net.sourceforge.plantuml.skin.rose;
@ -62,7 +62,7 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow {
final double textHeight = getTextHeight(stringBounder);
ug.getParam().setColor(getForegroundColor());
final double x2 = arrowWidth;
final double x2 = arrowWidth - 3;
if (getArrowConfiguration().isDotted()) {
stroke(ug, 2, 2);

View File

@ -28,14 +28,11 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6095 $
* Revision $Revision: 6221 $
*
*/
package net.sourceforge.plantuml.statediagram;
import java.util.Arrays;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
@ -106,6 +103,16 @@ public class StateDiagram extends AbstractEntityDiagram {
return UmlDiagramType.STATE;
}
private boolean hideEmptyDescription = false;
public final void setHideEmptyDescription(boolean hideEmptyDescription) {
this.hideEmptyDescription = hideEmptyDescription;
}
public final boolean isHideEmptyDescription() {
return hideEmptyDescription;
}
// @Override
// final protected List<String> getDotStrings() {
// return Arrays.asList("nodesep=1.95;", "ranksep=1.8;", "edge [fontsize=11,labelfontsize=11];",

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5493 $
* Revision $Revision: 6221 $
*
*/
package net.sourceforge.plantuml.statediagram;
@ -43,6 +43,7 @@ import net.sourceforge.plantuml.statediagram.command.CommandCreatePackageState2;
import net.sourceforge.plantuml.statediagram.command.CommandCreateState;
import net.sourceforge.plantuml.statediagram.command.CommandCreateState2;
import net.sourceforge.plantuml.statediagram.command.CommandEndState;
import net.sourceforge.plantuml.statediagram.command.CommandHideEmptyDescription;
import net.sourceforge.plantuml.statediagram.command.CommandLinkState2;
import net.sourceforge.plantuml.usecasediagram.command.CommandRankDirUsecase;
@ -69,6 +70,7 @@ public class StateDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommand(new CommandAddField(system));
addCommand(new CommandConcurrentState(system));
addCommand(new CommandMultilinesClassNote(system));
addCommand(new CommandHideEmptyDescription(system));
addCommand(new CommandNoteEntity(system));
addCommonCommands(system);

View File

@ -27,28 +27,27 @@
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4762 $
*
*/
package net.sourceforge.plantuml.usecasediagram.command;
package net.sourceforge.plantuml.statediagram.command;
import java.util.List;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.statediagram.StateDiagram;
public class CommandSetStrategy extends SingleLineCommand<CucaDiagram> {
public class CommandHideEmptyDescription extends SingleLineCommand<StateDiagram> {
public CommandSetStrategy(CucaDiagram diagram) {
super(
diagram,
"(?i)^layout with neato$");
public CommandHideEmptyDescription(StateDiagram diagram) {
super(diagram, "(?i)^(hide|show)\\s+empty\\s+description$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
getSystem().setStrategy(GraphvizLayoutStrategy.NEATO);
getSystem().setHideEmptyDescription(arg.get(0).equalsIgnoreCase("hide"));
return CommandExecutionResult.ok();
}

View File

@ -93,6 +93,10 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
public StringBounder getStringBounder() {
return stringBounder;
}
public void drawEps(String eps, double x, double y) {
this.getGraphicObject().drawEps(eps, x, y);
}
public void setClip(UClip clip) {
this.clip = clip;

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.usecasediagram.command.CommandCreateUsecase2;
import net.sourceforge.plantuml.usecasediagram.command.CommandLinkUsecase2;
import net.sourceforge.plantuml.usecasediagram.command.CommandMultilinesUsecaseNoteEntity;
import net.sourceforge.plantuml.usecasediagram.command.CommandRankDirUsecase;
import net.sourceforge.plantuml.usecasediagram.command.CommandSetStrategy;
public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
@ -63,7 +62,7 @@ public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommonCommands(system);
addCommand(new CommandPage(system));
//addCommand(new CommandLinkUsecase(system));
// addCommand(new CommandLinkUsecase(system));
addCommand(new CommandLinkUsecase2(system));
addCommand(new CommandPackage(system));
@ -78,7 +77,5 @@ public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommand(new CommandMultilinesUsecaseNoteEntity(system));
addCommand(new CommandMultilinesStandaloneNote(system));
addCommand(new CommandSetStrategy(system));
}
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6211 $
* Revision $Revision: 6243 $
*
*/
package net.sourceforge.plantuml.version;
@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
public class Version {
public static int version() {
return 6210;
return 6242;
}
public static long compileTime() {
return 1300656476468L;
return 1301142337781L;
}
}