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

Version 5658

This commit is contained in:
Arnaud Roques 2010-11-25 22:12:39 +01:00
parent 042fad1353
commit 543e0271f4
65 changed files with 2709 additions and 427 deletions

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 3824 $
* Revision $Revision: 5579 $
*
*/
package net.sourceforge.plantuml;
@ -44,6 +44,7 @@ public class EmptyImageBuilder {
private final Graphics2D g2d;
public EmptyImageBuilder(int width, int height, Color background) {
Log.info("Creating image " + width + "x" + height);
im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
g2d = im.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

View File

@ -28,11 +28,12 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5536 $
* Revision $Revision: 5616 $
*
*/
package net.sourceforge.plantuml.classdiagram;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.cucadiagram.Entity;
import net.sourceforge.plantuml.cucadiagram.EntityType;
@ -85,7 +86,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
@Override
public IEntity getOrCreateClass(String code) {
return getOrCreateEntity(code, EntityType.CLASS);
return getOrCreateEntity(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code), EntityType.CLASS);
}
final public IEntity getOrCreateClass(String code, EntityType type) {

View File

@ -28,14 +28,14 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5472 $
* Revision $Revision: 5613 $
*
*/
package net.sourceforge.plantuml.classdiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClass;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClassMultilines;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClass2;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClassMultilines2;
import net.sourceforge.plantuml.classdiagram.command.CommandEndNamespace;
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow;
import net.sourceforge.plantuml.classdiagram.command.CommandImport;
@ -70,7 +70,8 @@ public class ClassDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommand(new CommandPage(system));
addCommand(new CommandAddMethod(system));
addCommand(new CommandCreateEntityClass(system));
//addCommand(new CommandCreateEntityClass(system));
addCommand(new CommandCreateEntityClass2(system));
addCommand(new CommandCreateNote(system));
addCommand(new CommandPackage(system));
@ -89,7 +90,8 @@ public class ClassDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommand(new CommandMultilinesClassNote(system));
addCommand(new CommandMultilinesStandaloneNote(system));
addCommand(new CommandCreateEntityClassMultilines(system));
// addCommand(new CommandCreateEntityClassMultilines(system));
addCommand(new CommandCreateEntityClassMultilines2(system));
addCommand(new CommandHideShow(system));

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5019 $
* Revision $Revision: 5618 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
@ -44,7 +44,7 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
public CommandAddMethod(ClassDiagram diagram) {
super(diagram, "(?i)^([\\p{L}0-9_.]+)\\s*:\\s*(.*)$");
super(diagram, "(?i)^([\\p{L}0-9_.]+|\"[^\"]+\")\\s*:\\s*(.*)$");
}
@Override

View File

@ -0,0 +1,120 @@
/* ========================================================================
* 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: 5075 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
import java.util.Map;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.cucadiagram.Entity;
import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
public class CommandCreateEntityClass2 extends SingleLineCommand2<ClassDiagram> {
public CommandCreateEntityClass2(ClassDiagram diagram) {
super(diagram, getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"),
new RegexLeaf("TYPE", "(interface|enum|abstract\\s+class|abstract|class)\\s+"),
new RegexOr(
new RegexLeaf("NAME1", "(?:\"([^\"]+)\"\\s+as\\s+)?(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)"),
new RegexLeaf("NAME2", "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s+as\\s+\"([^\"]+)\""),
new RegexLeaf("NAME3", "\"([^\"]+)\"")),
new RegexLeaf("STEREO", "(?:\\s*([\\<\\[]{2}.*[\\>\\]]{2}))?"),
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
final EntityType type = EntityType.getEntityType(arg.get("TYPE").get(0).toUpperCase());
final String code;
final String display;
if (arg.get("NAME1").get(1) != null) {
code = arg.get("NAME1").get(1);
display = arg.get("NAME1").get(0);
} else if (arg.get("NAME3").get(0) != null) {
code = arg.get("NAME3").get(0);
display = arg.get("NAME3").get(0);
} else {
code = arg.get("NAME2").get(0);
display = arg.get("NAME2").get(1);
}
final String stereotype = arg.get("STEREO").get(0);
final Entity entity;
if (getSystem().entityExist(code)) {
entity = (Entity) getSystem().getOrCreateEntity(code, type);
entity.muteToType(type);
} else {
entity = getSystem().createEntity(code, display, type);
}
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, getSystem().getSkinParam().getCircledCharacterRadius(),
getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER)));
}
return CommandExecutionResult.ok();
}
// @Override
// protected CommandExecutionResult executeArg(List<String> arg) {
// final String arg0 = arg.get(0).toUpperCase();
// final EntityType type = EntityType.getEntityType(arg0);
// final String code = arg.get(2);
// final String display = arg.get(1);
// final String stereotype = arg.get(3);
// final Entity entity;
// if (getSystem().entityExist(code)) {
// // return CommandExecutionResult.error("Class already exists : "
// // + code);
// entity = (Entity) getSystem().getOrCreateEntity(code, type);
// entity.muteToType(type);
// } else {
// entity = getSystem().createEntity(code, display, type);
// }
// if (stereotype != null) {
// entity.setStereotype(new Stereotype(stereotype, getSystem().getSkinParam().getCircledCharacterRadius(),
// getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER)));
// }
// return CommandExecutionResult.ok();
// }
}

View File

@ -0,0 +1,115 @@
/* ========================================================================
* 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: 4161 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.cucadiagram.Entity;
import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandCreateEntityClassMultilines2 extends CommandMultilines2<ClassDiagram> {
public CommandCreateEntityClassMultilines2(ClassDiagram diagram) {
super(diagram, getRegexConcat(), "(?i)^\\s*\\}\\s*$");
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"),
new RegexLeaf("TYPE", "(interface|enum|abstract\\s+class|abstract|class)\\s+"),
new RegexOr(
new RegexLeaf("NAME1", "(?:\"([^\"]+)\"\\s+as\\s+)?(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)"),
new RegexLeaf("NAME2", "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s+as\\s+\"([^\"]+)\""),
new RegexLeaf("NAME3", "\"([^\"]+)\"")),
new RegexLeaf("STEREO", "(?:\\s*([\\<\\[]{2}.*[\\>\\]]{2}))?"),
new RegexLeaf("\\s*\\{\\s*$"));
}
public CommandExecutionResult execute(List<String> lines) {
final Map<String, RegexPartialMatch> line0 = getStartingPattern().matcher(lines.get(0));
final Entity entity = executeArg0(line0);
if (entity == null) {
return CommandExecutionResult.error("No such entity");
}
for (String s : lines.subList(1, lines.size() - 1)) {
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
getSystem().setVisibilityModifierPresent(true);
}
entity.addFieldOrMethod(s);
}
return CommandExecutionResult.ok();
}
private Entity executeArg0(Map<String, RegexPartialMatch> arg) {
final EntityType type = EntityType.getEntityType(arg.get("TYPE").get(0).toUpperCase());
final String code;
final String display;
if (arg.get("NAME1").get(1) != null) {
code = arg.get("NAME1").get(1);
display = arg.get("NAME1").get(0);
} else if (arg.get("NAME3").get(0) != null) {
code = arg.get("NAME3").get(0);
display = arg.get("NAME3").get(0);
} else {
code = arg.get("NAME2").get(0);
display = arg.get("NAME2").get(1);
}
final String stereotype = arg.get("STEREO").get(0);
if (getSystem().entityExist(code)) {
final Entity result = (Entity) getSystem().getOrCreateClass(code);
result.muteToType(type);
return result;
}
final Entity entity = getSystem().createEntity(code, display, type);
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, getSystem().getSkinParam().getCircledCharacterRadius(),
getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER)));
}
return entity;
}
}

View File

@ -56,7 +56,7 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
public CommandHideShow(ClassDiagram classDiagram) {
super(
classDiagram,
"(?i)^(hide|show)\\s+(?:(class|interface|enum|abstract|[\\p{L}0-9_.]+|\\<\\<.*\\>\\>)\\s+)*?(?:(empty)\\s+)?(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)$");
"(?i)^(hide|show)\\s+(?:(class|interface|enum|abstract|[\\p{L}0-9_.]+|\"[^\"]+\"|\\<\\<.*\\>\\>)\\s+)*?(?:(empty)\\s+)?(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)$");
}
private final EntityGender emptyByGender(Set<EntityPortion> portion) {

View File

@ -64,7 +64,7 @@ final public class CommandLinkClass2 extends SingleLineCommand2<AbstractClassOrO
new RegexLeaf("HEADER", "^(?:@(\\d+)\\s+)?"),
new RegexOr(
new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "\\s+)?"
+ "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)"),
+ "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|\"[^\"]+\")"),
new RegexLeaf("COUPLE1",
"\\(\\s*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s*,\\s*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s*\\)")),
new RegexLeaf("\\s*"),
@ -83,7 +83,7 @@ final public class CommandLinkClass2 extends SingleLineCommand2<AbstractClassOrO
new RegexLeaf("\\s*"),
new RegexOr(
new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "\\s+)?"
+ "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)"),
+ "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|\"[^\"]+\")"),
new RegexLeaf("COUPLE2",
"\\(\\s*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s*,\\s*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)\\s*\\)")),
new RegexLeaf("\\s*"), new RegexLeaf("LABEL_LINK", "(?::\\s*([^\"]+))?$"));
@ -101,14 +101,16 @@ final public class CommandLinkClass2 extends SingleLineCommand2<AbstractClassOrO
@Override
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
final String ent1 = arg.get("ENT1").get(1);
final String ent2 = arg.get("ENT2").get(1);
String ent1 = arg.get("ENT1").get(1);
String ent2 = arg.get("ENT2").get(1);
if (ent1 == null) {
return executeArgSpecial1(arg);
}
if (ent2 == null) {
return executeArgSpecial2(arg);
}
ent1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent1);
ent2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent2);
if (getSystem().isGroup(ent1) && getSystem().isGroup(ent2)) {
return executePackageLink(arg);
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4239 $
* Revision $Revision: 5616 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
@ -39,7 +39,7 @@ import net.sourceforge.plantuml.command.AbstractCommandMultilinesNoteEntity;
public class CommandMultilinesClassNote extends AbstractCommandMultilinesNoteEntity {
public CommandMultilinesClassNote(final AbstractEntityDiagram system) {
super(system, "(?i)^note\\s+(right|left|top|bottom)\\s+(?:of\\s+)?([\\p{L}0-9_.]+)\\s*(#\\w+)?$");
super(system, "(?i)^note\\s+(right|left|top|bottom)\\s+(?:of\\s+)?([\\p{L}0-9_.]+|\"[^\"]+\")\\s*(#\\w+)?$");
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5019 $
* Revision $Revision: 5654 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
@ -45,7 +45,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype;
public class CommandStereotype extends SingleLineCommand<ClassDiagram> {
public CommandStereotype(ClassDiagram classDiagram) {
super(classDiagram, "(?i)^([\\p{L}0-9_.]+)\\s*(\\<\\<.*\\>\\>)$");
super(classDiagram, "(?i)^([\\p{L}0-9_.]+|\"[^\"]+\")\\s*(\\<\\<.*\\>\\>)$");
}
@Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.cucadiagram.Entity;
public class CommandUrl extends SingleLineCommand<ClassDiagram> {
public CommandUrl(ClassDiagram classDiagram) {
super(classDiagram, "(?i)^url\\s*(?:of|for)?\\s+([\\p{L}0-9_.]+)\\s+(?:is)?\\s*\\[\\[(.*)\\]\\]$");
super(classDiagram, "(?i)^url\\s*(?:of|for)?\\s+([\\p{L}0-9_.]+|\"[^\"]+\")\\s+(?:is)?\\s*\\[\\[(.*)\\]\\]$");
}
@Override

View File

@ -0,0 +1,111 @@
/* ========================================================================
* 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: 5041 $
*
*/
package net.sourceforge.plantuml.command;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.PSystem;
import net.sourceforge.plantuml.command.regex.RegexConcat;
public abstract class CommandMultilines2<S extends PSystem> implements Command {
private final S system;
private final RegexConcat starting;
private final Pattern ending;
public CommandMultilines2(final S system, RegexConcat patternStart, String patternEnd) {
if (patternStart.getPattern().startsWith("^") == false || patternStart.getPattern().endsWith("$") == false) {
throw new IllegalArgumentException("Bad pattern " + patternStart.getPattern());
}
if (patternEnd.startsWith("(?i)^") == false || patternEnd.endsWith("$") == false) {
throw new IllegalArgumentException("Bad pattern " + patternEnd);
}
this.system = system;
this.starting = patternStart;
this.ending = Pattern.compile(patternEnd);
}
final public CommandControl isValid(List<String> lines) {
if (isCommandForbidden()) {
return CommandControl.NOT_OK;
}
//Matcher m1 = starting.matcher(lines.get(0));
final boolean result1 = starting.match(lines.get(0));
if (result1 == false) {
return CommandControl.NOT_OK;
}
if (lines.size() == 1) {
return CommandControl.OK_PARTIAL;
}
Matcher m1 = ending.matcher(lines.get(lines.size() - 1));
if (m1.matches() == false) {
return CommandControl.OK_PARTIAL;
}
actionIfCommandValid();
return CommandControl.OK;
}
protected boolean isCommandForbidden() {
return false;
}
protected void actionIfCommandValid() {
}
protected S getSystem() {
return system;
}
protected final RegexConcat getStartingPattern() {
return starting;
}
protected final Pattern getEnding() {
return ending;
}
public boolean isDeprecated(List<String> line) {
return false;
}
public String getHelpMessageForDeprecated(List<String> lines) {
return null;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5019 $
* Revision $Revision: 5616 $
*
*/
package net.sourceforge.plantuml.command;
@ -49,7 +49,7 @@ final public class CommandNoteEntity extends SingleLineCommand<AbstractEntityDia
public CommandNoteEntity(AbstractEntityDiagram classDiagram) {
super(
classDiagram,
"(?i)^note\\s+(right|left|top|bottom)\\s+of\\s+([\\p{L}0-9_.]+|\\((?!\\*\\))[^\\)]+\\)|\\[[^\\]*]+[^\\]]*\\]|\\(\\)\\s*[\\p{L}0-9_.]+|\\(\\)\\s*\"[^\"]+\"|:[^:]+:)"
"(?i)^note\\s+(right|left|top|bottom)\\s+of\\s+([\\p{L}0-9_.]+|\\((?!\\*\\))[^\\)]+\\)|\\[[^\\]*]+[^\\]]*\\]|\\(\\)\\s*[\\p{L}0-9_.]+|\\(\\)\\s*\"[^\"]+\"|:[^:]+:|\"[^\"]+\")"
+ "\\s*(#\\w+)?\\s*:\\s*(.*)$");
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5540 $
* Revision $Revision: 5584 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
@ -291,7 +291,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return maker.createFiles(suggestedFile);
}
public static boolean BETA = false;
public static boolean BETA;
final public void createFile(OutputStream os, int index, FileFormat fileFormat) throws IOException {
if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
@ -484,5 +484,5 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
public int getNbImages() {
return this.horizontalPages * this.verticalPages;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5186 $
* Revision $Revision: 5593 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
@ -94,14 +94,14 @@ public class Entity implements IEntity {
public void addFieldOrMethod(String s) {
if (isMethod(s)) {
methods2.add(new Member(s));
methods2.add(new Member(s, true));
} else {
addField(s);
}
}
public void addField(String s) {
fields2.add(new Member(s));
fields2.add(new Member(s, false));
}
public void addField(Member s) {

View File

@ -28,13 +28,23 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5425 $
* Revision $Revision: 5649 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.util.Arrays;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.cucadiagram.dot.DrawFile;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
public class Link implements Imaged {
@ -245,4 +255,26 @@ public class Link implements Imaged {
return false;
}
public double getMarginDecors1(StringBounder stringBounder, Font fontQualif) {
final double q = getQualifierMargin(stringBounder, fontQualif, qualifier1);
final LinkDecor decor = type.getDecor1();
return decor.getSize() + q;
}
public double getMarginDecors2(StringBounder stringBounder, Font fontQualif) {
final double q = getQualifierMargin(stringBounder, fontQualif, qualifier2);
final LinkDecor decor = type.getDecor2();
return decor.getSize() + q;
}
private double getQualifierMargin(StringBounder stringBounder, Font fontQualif, String qualif) {
if (qualif != null) {
final TextBlock b = TextBlockUtils.create(Arrays.asList(qualif), fontQualif, Color.BLACK,
HorizontalAlignement.LEFT);
final Dimension2D dim = b.calculateDimension(stringBounder);
return Math.max(dim.getWidth(), dim.getHeight());
}
return 0;
}
}

View File

@ -46,7 +46,9 @@ public class Member {
private boolean publicModifier;
private boolean packagePrivateModifier;
public Member(String display) {
private final VisibilityModifier visibilityModifier;
public Member(String display, boolean isMethod) {
final String lower = display.toLowerCase();
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
this.abstractModifier = lower.contains("{abstract}");
@ -54,9 +56,11 @@ public class Member {
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
updateVisibility(display.charAt(0));
visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
this.display = displayClean.substring(1).trim();
} else {
this.display = displayClean;
visibilityModifier = null;
}
assert VisibilityModifier.isVisibilityCharacter(this.display.charAt(0)) == false;
@ -85,12 +89,10 @@ public class Member {
return getDisplayWithoutVisibilityChar();
}
public String getDisplayWithoutVisibilityChar() {
assert VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
return display;
}
public String getDisplayWithVisibilityChar() {
if (isPrivate()) {
@ -147,4 +149,8 @@ public class Member {
return packagePrivateModifier;
}
public final VisibilityModifier getVisibilityModifier() {
return visibilityModifier;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5503 $
* Revision $Revision: 5655 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -391,14 +391,14 @@ public final class CucaDiagramFileMaker {
final byte[] imageData = getImageData(dotString, cmap);
if (isPngHeader(imageData, 0) == false) {
createError(os, imageData.length, FileFormat.PNG, "No PNG header found",
"Try -forcegd or -forcecairo flag");
if (imageData.length == 0) {
createError(os, imageData.length, FileFormat.PNG, "imageData.length == 0");
return null;
}
if (imageData.length == 0) {
createError(os, imageData.length, FileFormat.PNG, "imageData.length == 0");
if (isPngHeader(imageData, 0) == false) {
createError(os, imageData.length, FileFormat.PNG, "No PNG header found",
"Try -forcegd or -forcecairo flag");
return null;
}

View File

@ -113,7 +113,7 @@ public final class CucaDiagramFileMakerBeta {
final PlayField playField = new PlayField(diagram.getSkinParam());
final Collection<IEntity> entities = getFirstLevelEntities();
System.err.println("entities=" + entities);
// System.err.println("entities=" + entities);
// final Collection<Link> links = getLinks(entities);
final Collection<Link> links = diagram.getLinks();
@ -148,32 +148,32 @@ public final class CucaDiagramFileMakerBeta {
private Collection<IEntity> getFirstLevelEntities() {
final Collection<IEntity> result = new HashSet<IEntity>();
diagram.computeAutonomyOfGroups();
System.err.println("diagramEntities = " + diagram.entities());
System.err.println("diagramGroups = " + diagram.getGroups());
// System.err.println("diagramEntities = " + diagram.entities());
// System.err.println("diagramGroups = " + diagram.getGroups());
addEntitiesOfGroup(result, null);
return result;
}
private void addEntitiesOfGroup(final Collection<IEntity> result, Group parent) {
System.err.println("addEntitiesOfGroup parent=" + parent);
// System.err.println("addEntitiesOfGroup parent=" + parent);
for (IEntity ent : diagram.entities().values()) {
if (ent.getParent() == parent) {
result.add(ent);
System.err.println("addingA " + ent);
// System.err.println("addingA " + ent);
}
}
final Collection<Group> groups = parent == null ? diagram.getGroups() : parent.getChildren();
for (Group g : groups) {
System.err.println("g=" + g + " parent = " + g.getParent());
// System.err.println("g=" + g + " parent = " + g.getParent());
if (g.isAutonom() == false) {
addEntitiesOfGroup(result, g);
result.add(g.getEntityCluster());
System.err.println("addingB " + g.getEntityCluster());
// System.err.println("addingB " + g.getEntityCluster());
} else if (g.getParent() == parent) {
assert g.isAutonom();
assert result.contains(g.getEntityCluster()) == false;
result.add(g.getEntityCluster());
System.err.println("addingC " + g.getEntityCluster());
// System.err.println("addingC " + g.getEntityCluster());
}
}

View File

@ -75,7 +75,7 @@ public final class CucaDiagramTxtMaker {
this.diagram = diagram;
this.fileFormat = fileFormat;
final Cluster root = new Cluster(null);
final Cluster root = new Cluster(null, 0, 0);
int uid = 0;
final Map<Entity, Block> blocks = new HashMap<Entity, Block>();
@ -85,7 +85,7 @@ public final class CucaDiagramTxtMaker {
// ug.translate(0, getHeight(ent) + 1);
final double width = getWidth(ent) * getXPixelPerChar();
final double height = getHeight(ent) * getYPixelPerChar();
final Block b = new Block(uid++, width, height);
final Block b = new Block(uid++, width, height, null);
root.addBloc(b);
blocks.put(ent, b);
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5575 $
* Revision $Revision: 5581 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -125,9 +125,9 @@ final public class DotMaker implements GraphvizMaker {
private void initPrintWriter(StringBuilder sb) {
Log.info("Entities = "+data.getEntities().size());
final boolean huge = data.getEntities().size()>800;
Log.info("Entities = " + data.getEntities().size());
final boolean huge = data.getEntities().size() > 800;
sb.append("digraph unix {");
if (isJunit == false) {
for (String s : dotStrings) {
@ -139,16 +139,15 @@ final public class DotMaker implements GraphvizMaker {
sb.append("size=\"400,400;\"");
} else {
sb.append("ratio=auto;");
// sb.append("concentrate=true;");
}
sb.append("compound=true;");
sb.append("remincross=true;");
// sb.append("concentrate=true;");
sb.append("searchsize=500;");
if (data.getRankdir() == Rankdir.LEFT_TO_RIGHT) {
sb.append("rankdir=LR;");
}
}
private Collection<IEntity> getUnpackagedEntities() {
final List<IEntity> result = new ArrayList<IEntity>();
@ -638,10 +637,10 @@ final public class DotMaker implements GraphvizMaker {
}
private void eventuallySameRank(StringBuilder sb, Group entityPackage, Link link) {
// if (workAroundDotBug()) {
// throw new UnsupportedOperationException("workAroundDotBug");
// // return;
// }
// if (workAroundDotBug()) {
// throw new UnsupportedOperationException("workAroundDotBug");
// // return;
// }
final int len = link.getLength();
if (len == 1 && link.getEntity1().getParent() == entityPackage
&& link.getEntity2().getParent() == entityPackage) {

View File

@ -34,10 +34,12 @@
package net.sourceforge.plantuml.cucadiagram.dot;
import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@ -54,13 +56,16 @@ import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.Group;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.posimo.Block;
import net.sourceforge.plantuml.posimo.Cluster;
import net.sourceforge.plantuml.posimo.EntityImageBlock;
import net.sourceforge.plantuml.posimo.EntityImageClass2;
import net.sourceforge.plantuml.posimo.EntityImageNote2;
import net.sourceforge.plantuml.posimo.Frame;
import net.sourceforge.plantuml.posimo.GraphvizSolverB;
import net.sourceforge.plantuml.posimo.IEntityImageBlock;
@ -79,20 +84,22 @@ public final class PlayField {
private final Rose rose = new Rose();
private final ISkinParam skinParam;
private final Cluster root = new Cluster(null);
private final Cluster root = new Cluster(null, 0, 0);
private final Map<Path, Link> paths = new LinkedHashMap<Path, Link>();
private final Map<IEntity, MargedBlock> blocks = new HashMap<IEntity, MargedBlock>();
private final Map<IEntity, Cluster> clusters = new HashMap<IEntity, Cluster>();
private final Map<IEntity, Frame> frames = new HashMap<IEntity, Frame>();
final private double marginLabel = 6;
final private Font fontQualif;
public PlayField(ISkinParam skinParam) {
this.skinParam = skinParam;
this.fontQualif = skinParam.getFont(FontParam.CLASS_ARROW);
}
public void initInternal(Collection<IEntity> entities,
Collection<Link> links, StringBounder stringBounder) {
public void initInternal(Collection<IEntity> entities, Collection<Link> links, StringBounder stringBounder) {
if (blocks.size() != 0 || paths.size() != 0 /* || images.size() != 0 */
|| clusters.size() != 0) {
throw new IllegalStateException();
@ -105,38 +112,39 @@ public final class PlayField {
}
for (IEntity ent : entities) {
if (ent.getType() == EntityType.GROUP
&& ent.getParent().isAutonom() == false) {
clusters.put(ent, new Cluster(root));
System.err.println("Creating cluster for " + ent + " "
+ clusters.get(ent));
if (ent.getType() == EntityType.GROUP && ent.getParent().isAutonom() == false) {
// final IEntityImageBlock title = createClusterTitle();
// final Frame frame = new Frame(StringUtils.getWithNewlines(ent.getDisplay()), Color.BLACK, skinParam
// .getFont(FontParam.CLASS), rose.getHtmlColor(skinParam, ColorParam.classBorder).getColor());
final Frame frame = new Frame(StringUtils.getWithNewlines(ent.getDisplay()), skinParam);
frames.put(ent, frame);
// final Dimension2D dimTitle =
// title.getDimension(stringBounder);
final Dimension2D dimTitle = frame.getTextDim(stringBounder);
clusters.put(ent, new Cluster(root, dimTitle.getWidth(), dimTitle.getHeight()));
}
}
for (IEntity ent : entities) {
System.err.println("ENT=" + ent);
if (ent.getType() == EntityType.GROUP
&& ent.getParent().isAutonom() == false) {
// System.err.println("ENT=" + ent);
if (ent.getType() == EntityType.GROUP && ent.getParent().isAutonom() == false) {
assert clusters.containsKey(ent);
continue;
}
assert clusters.containsKey(ent) == false;
Cluster parentCluster = root;
if (ent.getType() != EntityType.GROUP && ent.getParent() != null) {
parentCluster = clusters
.get(ent.getParent().getEntityCluster());
parentCluster = clusters.get(ent.getParent().getEntityCluster());
if (parentCluster == null) {
parentCluster = root;
}
}
final IEntityImageBlock entityImageBlock = createEntityImageBlock(
links, ent);
final IEntityImageBlock entityImageBlock = createEntityImageBlock(links, ent);
// final Dimension2D d =
// entityImageBlock.getDimension(stringBounder);
// final Block b = new Block(uid++, d.getWidth() + 2 *
// marginDecorator, d.getHeight() + 2 * marginDecorator);
final MargedBlock b = new MargedBlock(stringBounder,
entityImageBlock, getMargin(ent, links));
final MargedBlock b = new MargedBlock(stringBounder, entityImageBlock, getMargin(stringBounder, ent, links), parentCluster);
blocks.put(ent, b);
// images.put(ent, entityImageBlock);
@ -150,42 +158,40 @@ public final class PlayField {
}
for (Link link : links) {
System.err.println("LINK=" + link);
if (entities.contains(link.getEntity1())
&& entities.contains(link.getEntity2())) {
// System.err.println("LINK=" + link);
if (entities.contains(link.getEntity1()) && entities.contains(link.getEntity2())) {
final Block b1 = getToto(link.getEntity1());
final Block b2 = getToto(link.getEntity2());
final Label label;
if (link.getLabel() == null) {
label = null;
} else {
final LabelImage labelImage = new LabelImage(link, rose,
skinParam);
final Dimension2D dim = Dimension2DDouble.delta(labelImage
.getDimension(stringBounder), marginLabel);
final LabelImage labelImage = new LabelImage(link, rose, skinParam);
final Dimension2D dim = Dimension2DDouble
.delta(labelImage.getDimension(stringBounder), marginLabel);
label = new Label(dim.getWidth(), dim.getHeight());
}
final Path p = new Path(b1, b2, label);
final Path p = new Path(b1, b2, label, link.getLength());
paths.put(p, link);
}
}
}
private int getMargin(IEntity ent, Collection<Link> links) {
int result = 0;
private double getMargin(StringBounder stringBounder, IEntity ent, Collection<Link> links) {
double result = 0;
for (Link link : links) {
if (link.getEntity2()==ent) {
final LinkDecor decor = link.getType().getDecor1();
result = Math.max(result, decor.getSize());
if (link.getEntity2() == ent) {
// final LinkDecor decor = link.getType().getDecor1();
result = Math.max(result, link.getMarginDecors2(stringBounder, fontQualif));
}
if (link.getEntity1()==ent) {
final LinkDecor decor = link.getType().getDecor2();
result = Math.max(result, decor.getSize());
if (link.getEntity1() == ent) {
// final LinkDecor decor = link.getType().getDecor2();
result = Math.max(result, link.getMarginDecors1(stringBounder, fontQualif));
}
}
return result;
//return 40;
// return 40;
}
private Block getToto(IEntity ent) {
@ -207,27 +213,20 @@ public final class PlayField {
public void drawInternal(UGraphic ug) {
for (Map.Entry<IEntity, Cluster> ent : clusters.entrySet()) {
final Frame frame = new Frame(StringUtils.getWithNewlines(ent
.getKey().getDisplay()), Color.BLACK, skinParam
.getFont(FontParam.CLASS), rose.getHtmlColor(skinParam,
ColorParam.classBorder).getColor());
final Frame frame = frames.get(ent.getKey());
final Rectangle2D rect = PositionableUtils.convert(ent.getValue());
final double oldX = ug.getTranslateX();
final double oldY = ug.getTranslateY();
ug.translate(rect.getX(), rect.getY());
frame.drawU(ug, new Dimension2DDouble(rect.getWidth(), rect
.getHeight()), null);
frame.drawU(ug, new Dimension2DDouble(rect.getWidth(), rect.getHeight()), null);
ug.setTranslate(oldX, oldY);
}
for (Map.Entry<Path, Link> ent : paths.entrySet()) {
final LinkType type = ent.getValue().getType();
final PathDrawerInterface pathDrawer = PathDrawerInterface.create(
new Rose(), skinParam, type);
final PathDrawerInterface pathDrawer = PathDrawerInterface.create(skinParam, type);
final Path p = ent.getKey();
ug.getParam().setColor(
rose.getHtmlColor(skinParam, ColorParam.classBorder)
.getColor());
ug.getParam().setColor(rose.getHtmlColor(skinParam, ColorParam.classBorder).getColor());
// pathDrawer.drawPathBefore(ug, PositionableUtils.addMargin(p
// .getStart(), -marginDecorator, -marginDecorator),
// PositionableUtils.addMargin(p.getEnd(), -marginDecorator,
@ -245,20 +244,34 @@ public final class PlayField {
}
for (Map.Entry<Path, Link> ent : paths.entrySet()) {
final LinkType type = ent.getValue().getType();
final PathDrawerInterface pathDrawer = PathDrawerInterface.create(
new Rose(), skinParam, type);
final Link link = ent.getValue();
final LinkType type = link.getType();
final PathDrawerInterface pathDrawer = PathDrawerInterface.create(skinParam, type);
final Path p = ent.getKey();
ug.getParam().setColor(
rose.getHtmlColor(skinParam, ColorParam.classBorder)
.getColor());
ug.getParam().setColor(rose.getHtmlColor(skinParam, ColorParam.classBorder).getColor());
// pathDrawer.drawPathAfter(ug, PositionableUtils.addMargin(p
// .getStart(), -marginDecorator, -marginDecorator),
// PositionableUtils.addMargin(p.getEnd(), -marginDecorator,
// -marginDecorator), p);
pathDrawer.drawPathAfter(ug, getMargedBlock(p.getStart())
.getImagePosition(), getMargedBlock(p.getEnd())
pathDrawer.drawPathAfter(ug, getMargedBlock(p.getStart()).getImagePosition(), getMargedBlock(p.getEnd())
.getImagePosition(), p);
final String qual1 = link.getQualifier1();
if (qual1 != null) {
final TextBlock b = TextBlockUtils.create(Arrays.asList(qual1), fontQualif,
skinParam.getFontHtmlColor(FontParam.CLASS_ARROW).getColor(), HorizontalAlignement.LEFT);
final Point2D pos = p.getDotPath().getStartPoint();
b.drawU(ug, pos.getX(), pos.getY());
}
final String qual2 = link.getQualifier2();
if (qual2 != null) {
final TextBlock b = TextBlockUtils.create(Arrays.asList(qual2), fontQualif,
skinParam.getFontHtmlColor(FontParam.CLASS_ARROW).getColor(), HorizontalAlignement.LEFT);
final Point2D pos = p.getDotPath().getEndPoint();
b.drawU(ug, pos.getX(), pos.getY());
}
}
}
@ -273,9 +286,8 @@ public final class PlayField {
public Dimension2D solve() throws IOException, InterruptedException {
final GraphvizSolverB solver = new GraphvizSolverB();
System.err.println("sub=" + root.getSubClusters());
final Dimension2D dim = Dimension2DDouble.delta(solver.solve(root,
paths.keySet()), 20);
// System.err.println("sub=" + root.getSubClusters());
final Dimension2D dim = Dimension2DDouble.delta(solver.solve(root, paths.keySet()), 20);
return dim;
}
@ -286,29 +298,28 @@ public final class PlayField {
ug.getParam().setColor(Color.GREEN);
ug.getParam().setBackcolor(null);
final Dimension2D dim = label.getSize();
ug.draw(pos.getX(), pos.getY(), new URectangle(dim.getWidth(), dim
.getHeight()));
final LabelImage labelImage = new LabelImage(paths.get(p), rose,
skinParam);
final Dimension2D dimImage = labelImage.getDimension(ug
.getStringBounder());
ug.draw(pos.getX(), pos.getY(), new URectangle(dimImage.getWidth(),
dimImage.getHeight()));
ug.draw(pos.getX(), pos.getY(), new URectangle(dim.getWidth(), dim.getHeight()));
final LabelImage labelImage = new LabelImage(paths.get(p), rose, skinParam);
final Dimension2D dimImage = labelImage.getDimension(ug.getStringBounder());
ug.draw(pos.getX(), pos.getY(), new URectangle(dimImage.getWidth(), dimImage.getHeight()));
}
final LabelImage labelImage = new LabelImage(paths.get(p), rose,
skinParam);
final LabelImage labelImage = new LabelImage(paths.get(p), rose, skinParam);
labelImage.drawU(ug, pos.getX(), pos.getY());
}
private IEntityImageBlock createEntityImageBlock(Collection<Link> links,
IEntity ent) {
if (ent.getType() == EntityType.CLASS
|| ent.getType() == EntityType.ABSTRACT_CLASS
|| ent.getType() == EntityType.INTERFACE
|| ent.getType() == EntityType.ENUM) {
return new EntityImageClass2(ent, rose, skinParam, links);
private IEntityImageBlock createEntityImageBlock(Collection<Link> links, IEntity ent) {
if (ent.getType() == EntityType.CLASS || ent.getType() == EntityType.ABSTRACT_CLASS
|| ent.getType() == EntityType.INTERFACE || ent.getType() == EntityType.ENUM) {
return new EntityImageClass2(ent, skinParam, links);
}
return new EntityImageBlock(ent, rose, skinParam, links);
if (ent.getType() == EntityType.NOTE) {
return new EntityImageNote2(ent, skinParam, links);
}
return new EntityImageBlock(ent, rose, skinParam, links, FontParam.PACKAGE);
}
private IEntityImageBlock createClusterTitle() {
return null;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 3829 $
* Revision $Revision: 5650 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -49,6 +49,8 @@ public class ProcessRunner {
public ProcessRunner(String cmd) {
this.cmd = cmd;
}
static private int cpt = 0;
public void run(byte in[], OutputStream redirection) throws IOException, InterruptedException {
final Process process = Runtime.getRuntime().exec(cmd);
@ -66,6 +68,7 @@ public class ProcessRunner {
outStream.join(10000L);
this.out = outStream.sb.toString();
this.error = errorStream.sb.toString();
Log.info("RUN nb = "+(++cpt));
}
static class ThreadStream extends Thread {

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5386 $
* Revision $Revision: 5609 $
*
*/
package net.sourceforge.plantuml.graph;

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5386 $
* Revision $Revision: 5609 $
*
*/
package net.sourceforge.plantuml.graph;
@ -48,6 +48,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.StringBounderUtils;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class MethodsOrFieldsArea {
@ -58,10 +59,14 @@ public class MethodsOrFieldsArea {
public MethodsOrFieldsArea(List<Member> attributes, Font font) {
this.font = font;
for (Member att : attributes) {
this.strings.add(att.getDisplayWithVisibilityChar());
this.strings.add(att.getDisplayWithoutVisibilityChar());
}
}
public VisibilityModifier getVisibilityModifier() {
throw new UnsupportedOperationException();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
double x = 0;
double y = 0;

View File

@ -0,0 +1,157 @@
/* ========================================================================
* 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: 5608 $
*
*/
package net.sourceforge.plantuml.graph;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.Member;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyVisibility;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Left;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGroup;
public class MethodsOrFieldsArea2 {
private final Font font;
private final List<Member> members = new ArrayList<Member>();
private final ISkinParam skinParam;
private final Color color;
private final Rose rose = new Rose();
public MethodsOrFieldsArea2(List<Member> attributes, FontParam fontParam, ISkinParam skinParam) {
this.members.addAll(attributes);
this.skinParam = skinParam;
this.font = skinParam.getFont(fontParam);
this.color = rose.getFontColor(skinParam, FontParam.CLASS_ATTRIBUTE);
}
private boolean hasSmallIcon() {
for (Member m : members) {
if (m.getVisibilityModifier() != null) {
return true;
}
}
return false;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
double x = 0;
double y = 0;
for (Member m : members) {
final String s = m.getDisplayWithoutVisibilityChar();
final TextBlock bloc = createTextBlock(s);
final Dimension2D dim = bloc.calculateDimension(stringBounder);
y += dim.getHeight();
x = Math.max(dim.getWidth(), x);
}
if (hasSmallIcon()) {
x += skinParam.getCircledCharacterRadius();
}
return new Dimension2DDouble(x, y);
}
private TextBlock createTextBlock(String s) {
return TextBlockUtils.create(Arrays.asList(s), font, color, HorizontalAlignement.LEFT);
}
public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) {
throw new UnsupportedOperationException();
}
public void draw(UGraphic ug, double x, double y) {
final Dimension2D dim = calculateDimension(ug.getStringBounder());
final UGroup group;
if (hasSmallIcon()) {
group = new UGroup(new PlacementStrategyVisibility(ug.getStringBounder(),
skinParam.getCircledCharacterRadius()));
for (Member att : members) {
final String s = att.getDisplayWithoutVisibilityChar();
final TextBlock bloc = createTextBlock(s);
final VisibilityModifier modifier = att.getVisibilityModifier();
group.add(getUBlock(modifier));
group.add(bloc);
}
} else {
group = new UGroup(new PlacementStrategyY1Y2Left(ug.getStringBounder()));
for (Member att : members) {
final String s = att.getDisplayWithoutVisibilityChar();
final TextBlock bloc = createTextBlock(s);
group.add(bloc);
}
}
group.drawU(ug, x, y, dim.getWidth(), dim.getHeight());
}
private TextBlock getUBlock(final VisibilityModifier modifier) {
if (modifier == null) {
return new TextBlock() {
public void drawU(UGraphic ug, double x, double y) {
}
public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) {
throw new UnsupportedOperationException();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(1, 1);
}
};
}
final Color back = modifier.getBackground() == null ? null : rose.getHtmlColor(skinParam,
modifier.getBackground()).getColor();
final Color fore = rose.getHtmlColor(skinParam, modifier.getForeground()).getColor();
final TextBlock uBlock = modifier.getUBlock(skinParam.getCircledCharacterRadius(), fore, back);
return uBlock;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4917 $
* Revision $Revision: 5594 $
*
*/
package net.sourceforge.plantuml.graphic;
@ -42,6 +42,7 @@ import java.awt.font.TextLayout;
import java.awt.geom.Dimension2D;
import java.awt.geom.PathIterator;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.skin.UDrawable;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -49,7 +50,7 @@ import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.USegmentType;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
public class CircledCharacter implements UDrawable {
public class CircledCharacter implements UDrawable, TextBlock {
private final String c;
private final Font font;
@ -77,8 +78,8 @@ public class CircledCharacter implements UDrawable {
ug.getParam().setColor(circle);
}
// final Color circleToUse = circle == null ? ug.getParam().getColor() : circle;
// ug.getParam().setColor(circleToUse);
// final Color circleToUse = circle == null ? ug.getParam().getColor() : circle;
// ug.getParam().setColor(circleToUse);
ug.getParam().setBackcolor(innerCircle);
@ -133,4 +134,12 @@ public class CircledCharacter implements UDrawable {
return result;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder));
}
public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) {
throw new UnsupportedOperationException();
}
}

View File

@ -37,29 +37,26 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.rose.Rose;
abstract class AbstractEntityImage2 implements IEntityImageBlock {
private final IEntity entity;
private final ISkinParam skinParam;
private final Rose rose = new Rose();
final private Color red = new Color(Integer.parseInt("A80036", 16));
final private Color yellow = new Color(Integer.parseInt("FEFECE", 16));
private final Color yellowNote = new Color(Integer.parseInt("FBFB77", 16));
final private Font font14 = new Font("SansSerif", Font.PLAIN, 14);
final private Font font17 = new Font("Courier", Font.BOLD, 17);
final private Color green = new Color(Integer.parseInt("ADD1B2", 16));
final private Color violet = new Color(Integer.parseInt("B4A7E5", 16));
final private Color blue = new Color(Integer.parseInt("A9DCDF", 16));
final private Color rose = new Color(Integer.parseInt("EB937F", 16));
public AbstractEntityImage2(IEntity entity) {
public AbstractEntityImage2(IEntity entity, ISkinParam skinParam) {
if (entity == null) {
throw new IllegalArgumentException("entity null");
}
this.entity = entity;
this.skinParam = skinParam;
}
public abstract Dimension2D getDimension(StringBounder stringBounder);
@ -68,39 +65,19 @@ abstract class AbstractEntityImage2 implements IEntityImageBlock {
return entity;
}
protected final Color getRed() {
return red;
protected Font getFont(FontParam fontParam) {
return skinParam.getFont(fontParam);
}
protected final Color getYellow() {
return yellow;
protected Color getFontColor(FontParam fontParam) {
return skinParam.getFontHtmlColor(fontParam).getColor();
}
protected final Font getFont17() {
return font17;
protected final Color getColor(ColorParam colorParam) {
return rose.getHtmlColor(skinParam, colorParam).getColor();
}
protected final Font getFont14() {
return font14;
}
protected final Color getGreen() {
return green;
}
protected final Color getViolet() {
return violet;
}
protected final Color getBlue() {
return blue;
}
protected final Color getRose() {
return rose;
}
protected final Color getYellowNote() {
return yellowNote;
protected final ISkinParam getSkinParam() {
return skinParam;
}
}

View File

@ -160,8 +160,14 @@ public class BezierUtils {
copy.x2 = mx;
copy.y2 = my;
}
if (dist(copy) < 1) {
return new Point2D.Double(mx, my);
if (dist(copy) < 0.1) {
if (contains1) {
return new Point2D.Double(copy.x2, copy.y2);
}
if (contains2) {
return new Point2D.Double(copy.x1, copy.y1);
}
throw new IllegalStateException();
}
}
}

View File

@ -46,11 +46,13 @@ public class Block implements Clusterable {
private final double height;
private double x;
private double y;
private final Cluster parent;
public Block(int uid, double width, double height) {
public Block(int uid, double width, double height, Cluster parent) {
this.uid = uid;
this.width = width;
this.height = height;
this.parent = parent;
}
@Override
@ -67,8 +69,7 @@ public class Block implements Clusterable {
}
public Cluster getParent() {
// TODO Auto-generated method stub
return null;
return parent;
}
public Point2D getPosition() {

View File

@ -53,9 +53,18 @@ public class Cluster implements Clusterable {
private double y;
private double width;
private double height;
private final double titleWidth;
private final double titleHeight;
public Cluster(Cluster parent) {
// public Cluster(Cluster parent) {
// this(parent, 100, 20);
// }
//
public Cluster(Cluster parent, double titleWidth, double titleHeight) {
this.parent = parent;
this.titleWidth = titleWidth;
this.titleHeight = titleHeight;
if (parent != null) {
parent.children.add(this);
}
@ -134,5 +143,13 @@ public class Cluster implements Clusterable {
this.height = height;
}
public final double getTitleWidth() {
return titleWidth;
}
public final double getTitleHeight() {
return titleHeight;
}
}

View File

@ -37,9 +37,11 @@ import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -70,19 +72,32 @@ public class DotPath implements UShape {
private final double x;
private final double y;
// @Override
// public String toString() {
// return "[" + x1 + "," + y1 + " " + x2 + "," + y2 + " " + x + "," + y + "]";
// }
// @Override
// public String toString() {
// return "[" + x1 + "," + y1 + " " + x2 + "," + y2 + " " + x + "," + y
// + "]";
// }
}
private final List<CubicCurve2D.Double> beziers = new ArrayList<CubicCurve2D.Double>();
//private final String print;
// private final String print;
public Point2D getStartPoint() {
return beziers.get(0).getP1();
}
public MinMax getMinMax() {
final MinMax result = new MinMax();
for (CubicCurve2D.Double c : beziers) {
result.manage(c.x1, c.y1);
result.manage(c.x2, c.y2);
result.manage(c.ctrlx1, c.ctrly1);
result.manage(c.ctrlx2, c.ctrly2);
}
return result;
}
public DotPath() {
this(new ArrayList<CubicCurve2D.Double>());
}
@ -90,13 +105,53 @@ public class DotPath implements UShape {
public Point2D getEndPoint() {
return beziers.get(beziers.size() - 1).getP2();
}
public Line2D getEndTangeante() {
final CubicCurve2D.Double last = beziers.get(beziers.size() - 1);
double dx = last.x2 - last.ctrlx2;
double dy = last.y2 - last.ctrly2;
if (dx == 0 && dy == 0) {
dx = last.x2 - last.x1;
dy = last.y2 - last.y1;
}
return new Line2D.Double(last.x2, last.y2, last.x2 + dx, last.y2 + dy);
}
public double getEndAngle() {
final Line2D tan = getEndTangeante();
final double theta1 = Math.atan2(tan.getY2() - tan.getY1(), tan.getX2() - tan.getX1());
return theta1;
}
public double getStartAngle() {
final Line2D tan = getStartTangeante();
final double theta1 = Math.atan2(tan.getY2() - tan.getY1(), tan.getX2() - tan.getX1());
return theta1;
}
public Line2D getStartTangeante() {
final CubicCurve2D.Double first = beziers.get(0);
double dx = first.ctrlx1 - first.x1;
double dy = first.ctrly1 - first.y1;
if (dx == 0 && dy == 0) {
dx = first.x2 - first.x1;
dy = first.y2 - first.y1;
}
return new Line2D.Double(first.x1, first.y1, first.x1 + dx, first.y1 + dy);
}
public DotPath addBefore(CubicCurve2D.Double before) {
final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
copy.add(0, before);
return new DotPath(copy);
}
public DotPath addBefore(DotPath other) {
final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
copy.addAll(0, other.beziers);
return new DotPath(copy);
}
public DotPath addAfter(CubicCurve2D.Double after) {
final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
copy.add(after);
@ -109,15 +164,16 @@ public class DotPath implements UShape {
return new DotPath(copy);
}
private DotPath(List<CubicCurve2D.Double> beziers) {
this.beziers.addAll(beziers);
//this.print = super.toString();
// this.print = super.toString();
}
// @Override
// public String toString() {
// return print;
// }
// @Override
// public String toString() {
// return print;
// }
public DotPath(String init, double deltaY) {
if (init.startsWith("M") == false) {
@ -164,14 +220,15 @@ public class DotPath implements UShape {
return result;
}
// public void drawOld(Graphics2D g2d, double x, double y) {
// for (CubicCurve2D.Double bez : beziers) {
// bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
// + bez.ctrly2, x + bez.x2, y + bez.y2);
// g2d.draw(bez);
// }
// }
//
// public void drawOld(Graphics2D g2d, double x, double y) {
// for (CubicCurve2D.Double bez : beziers) {
// bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y +
// bez.ctrly1, x + bez.ctrlx2, y
// + bez.ctrly2, x + bez.x2, y + bez.y2);
// g2d.draw(bez);
// }
// }
//
public void draw(Graphics2D g2d, double x, double y) {
final GeneralPath p = new GeneralPath();
for (CubicCurve2D.Double bez : beziers) {
@ -275,11 +332,35 @@ public class DotPath implements UShape {
}
}
private String toString(CubicCurve2D.Double c) {
static String toString(CubicCurve2D.Double c) {
return "(" + c.x1 + "," + c.y1 + ") " + "(" + c.ctrlx1 + "," + c.ctrly1 + ") " + "(" + c.ctrlx2 + ","
+ c.ctrly2 + ") " + "(" + c.x2 + "," + c.y2 + ") ";
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
for (CubicCurve2D.Double c : beziers) {
sb.append(toString(c));
}
return sb.toString();
}
public static CubicCurve2D.Double reverse(CubicCurve2D curv) {
return new CubicCurve2D.Double(curv.getX2(), curv.getY2(), curv.getCtrlX2(), curv.getCtrlY2(),
curv.getCtrlX1(), curv.getCtrlY1(), curv.getX1(), curv.getY1());
}
public DotPath reverse() {
final List<CubicCurve2D.Double> reverse = new ArrayList<CubicCurve2D.Double>(beziers);
Collections.reverse(reverse);
final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>();
for (CubicCurve2D.Double cub : reverse) {
copy.add(reverse(cub));
}
return new DotPath(copy);
}
}

View File

@ -46,9 +46,14 @@ public class DotxMaker {
this.paths = paths;
}
public String createDotString() {
public String createDotString(String... dotStrings) {
final StringBuilder sb = new StringBuilder();
sb.append("digraph unix {");
for (String s : dotStrings) {
sb.append(s);
}
sb.append("compound=true;");
printCluster(sb, root);
@ -63,11 +68,16 @@ public class DotxMaker {
}
private void printCluster(StringBuilder sb, Cluster cl) {
if (cl.getContents().size() == 0) {
if (cl.getContents().size() == 0 && cl.getSubClusters().size() == 0) {
throw new IllegalStateException(cl.toString());
}
for (Cluster sub : cl.getSubClusters()) {
sb.append("subgraph cluster" + sub.getUid() + " {");
if (sub.getTitleWidth() > 0 && sub.getTitleHeight() > 0) {
sb.append("label=<<TABLE FIXEDSIZE=\"TRUE\" WIDTH=\"" + sub.getTitleWidth() + "\" HEIGHT=\""
+ sub.getTitleHeight() + "\"><TR><TD></TD></TR></TABLE>>");
}
printCluster(sb, sub);
sb.append("}");
@ -83,8 +93,11 @@ public class DotxMaker {
throw new IllegalArgumentException();
}
final StringBuilder sb = new StringBuilder("b" + p.getStart().getUid() + " -> b" + p.getEnd().getUid());
//sb.append(" [dir=none, arrowhead=none, headclip=false, tailclip=false");
sb.append(" [dir=none, arrowhead=none, headclip=true, tailclip=true");
final int len = p.getLength();
if (len >= 3) {
sb.append(",minlen=" + (len - 1));
}
if (p.getLabel() == null) {
sb.append("]");
} else {
@ -94,7 +107,12 @@ public class DotxMaker {
}
if (p.getLength() <= 1) {
sb.append("{rank=same; b" + p.getStart().getUid() + "; b" + p.getEnd().getUid() + "}");
final boolean samePackage = p.getStart().getParent() == p.getEnd().getParent();
if (samePackage == false) {
System.err.println("!!!!!!!!!!!!!!!!!TURNING ARROUND DOT BUG!!!!!!!!!!!!!!!!!!");
} else {
sb.append("{rank=same; b" + p.getStart().getUid() + "; b" + p.getEnd().getUid() + "}");
}
}
return sb.toString();

View File

@ -62,24 +62,46 @@ public class EntityImageBlock implements IEntityImageBlock {
private final IEntity entity;
private final ISkinParam param;
private final Rose rose;
private final int margin = 6;
// private final int margin = 6;
private final TextBlock name;
private final Collection<Link> links;
private PlayField playField;
private Frame frame;
private Dimension2D dimension;
public EntityImageBlock(IEntity entity, Rose rose, ISkinParam param, Collection<Link> links) {
public EntityImageBlock(IEntity entity, Rose rose, ISkinParam param, Collection<Link> links, FontParam titleParam) {
this.entity = entity;
this.param = param;
this.rose = rose;
this.links = links;
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), param
.getFont(FontParam.CLASS), Color.BLACK, HorizontalAlignement.CENTER);
if (StringUtils.isNotEmpty(entity.getDisplay())) {
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()),
param.getFont(titleParam), Color.BLACK, HorizontalAlignement.CENTER);
} else {
this.name = null;
}
}
public Dimension2D getDimension(StringBounder stringBounder) {
if (dimension == null) {
dimension = getDimensionSlow(stringBounder);
if (name != null) {
final Dimension2D dimName = name.calculateDimension(stringBounder);
final double widthName = dimName.getWidth();
if (widthName > dimension.getWidth()) {
dimension = new Dimension2DDouble(widthName, dimension.getHeight());
}
}
}
return dimension;
}
private Dimension2D getDimensionSlow(StringBounder stringBounder) {
initPlayField(stringBounder);
Dimension2D dim;
if (playField == null) {
@ -99,7 +121,8 @@ public class EntityImageBlock implements IEntityImageBlock {
throw new RuntimeException();
}
}
return Dimension2DDouble.delta(dim, margin * 2);
return dim;
// return Dimension2DDouble.delta(dim, margin * 2);
}
private void initPlayField(StringBounder stringBounder) {
@ -109,13 +132,14 @@ public class EntityImageBlock implements IEntityImageBlock {
this.playField = new PlayField(param);
final Collection<IEntity> entities = new ArrayList<IEntity>();
for (IEntity ent : entity.getParent().entities().values()) {
//entities.add(EntityUtils.withNoParent(ent));
// entities.add(EntityUtils.withNoParent(ent));
entities.add(ent);
}
playField.initInternal(entities, links, stringBounder);
this.frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
.getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
// this.frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
// .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
this.frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), param);
}
@ -127,15 +151,17 @@ public class EntityImageBlock implements IEntityImageBlock {
final double heightTotal = dim.getHeight() + 2 * marginHeight;
final URectangle rect = new URectangle(widthTotal, heightTotal);
//if (entity.getParent() == null) {
// if (entity.getParent() == null) {
if (entity.getType() != EntityType.GROUP) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBackground).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
ug.draw(xTheoricalPosition - marginWidth, yTheoricalPosition - marginHeight, rect);
name.drawU(ug, xTheoricalPosition + margin, yTheoricalPosition + margin);
// name.drawU(ug, xTheoricalPosition + margin, yTheoricalPosition + margin);
name.drawU(ug, xTheoricalPosition + 0, yTheoricalPosition + 0);
} else {
final Frame frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
.getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
// final Frame frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
// .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
final Frame frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), param);
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background).getColor());
ug.getParam().setColor(null);
@ -149,8 +175,11 @@ public class EntityImageBlock implements IEntityImageBlock {
// -yTheoricalPosition + marginHeight);
ug.setTranslate(oldX, oldY);
playField.drawInternal(UGraphicUtils.translate(ug, xTheoricalPosition + margin, yTheoricalPosition + margin
+ frame.getPreferredHeight(ug.getStringBounder())));
// playField.drawInternal(UGraphicUtils.translate(ug, xTheoricalPosition + margin, yTheoricalPosition +
// margin
// + frame.getPreferredHeight(ug.getStringBounder())));
playField.drawInternal(UGraphicUtils.translate(ug, xTheoricalPosition + 0,
yTheoricalPosition + 0 + frame.getPreferredHeight(ug.getStringBounder())));
}
}
}

View File

@ -34,87 +34,133 @@
package net.sourceforge.plantuml.posimo;
import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.graph.MethodsOrFieldsArea;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graph.MethodsOrFieldsArea2;
import net.sourceforge.plantuml.graphic.CircledCharacter;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyX1Y2Y3;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGroup;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
public class EntityImageClass2 extends AbstractEntityImage2 {
final private TextBlock name;
final private MethodsOrFieldsArea methods;
final private MethodsOrFieldsArea fields;
final private TextBlock stereo;
final private MethodsOrFieldsArea2 methods;
final private MethodsOrFieldsArea2 fields;
final private CircledCharacter circledCharacter;
// private final int xMargin = 0;
// private final int yMargin = 0;
// public static final int MARGIN = 20;
public EntityImageClass2(IEntity entity, Rose rose, ISkinParam skinParam, Collection<Link> links) {
super(entity);
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK,
HorizontalAlignement.CENTER);
this.methods = new MethodsOrFieldsArea(entity.methods2(), getFont14());
this.fields = new MethodsOrFieldsArea(entity.fields2(), getFont14());
public EntityImageClass2(IEntity entity, ISkinParam skinParam, Collection<Link> links) {
super(entity, skinParam);
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont(FontParam.CLASS),
Color.BLACK, HorizontalAlignement.CENTER);
final Stereotype stereotype = entity.getStereotype();
if (stereotype == null || stereotype.getLabel() == null) {
this.stereo = null;
} else {
this.stereo = TextBlockUtils.create(StringUtils.getWithNewlines(stereotype.getLabel()),
getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE),
HorizontalAlignement.CENTER);
}
this.methods = new MethodsOrFieldsArea2(entity.methods2(), FontParam.CLASS_ATTRIBUTE, skinParam);
this.fields = new MethodsOrFieldsArea2(entity.fields2(), FontParam.CLASS_ATTRIBUTE, skinParam);
circledCharacter = getCircledCharacter(entity);
}
private CircledCharacter getCircledCharacter(IEntity entity) {
// if (entity.getStereotype() != null) {
// return new CircledCharacter(entity.getStereotype().getCharacter(),
// font, entity.getStereotype().getColor(),
// red, Color.BLACK);
// }
final double radius = 10;
final Stereotype stereotype = entity.getStereotype();
if (stereotype != null && stereotype.getCharacter() != 0) {
final Color classBorder = getColor(ColorParam.classBorder);
final Font font = getFont(FontParam.CIRCLED_CHARACTER);
return new CircledCharacter(stereotype.getCharacter(), getSkinParam().getCircledCharacterRadius(), font,
stereotype.getColor(), classBorder, getFontColor(FontParam.CIRCLED_CHARACTER));
}
if (entity.getType() == EntityType.ABSTRACT_CLASS) {
return new CircledCharacter('A', radius, getFont17(), getBlue(), getRed(), Color.BLACK);
return new CircledCharacter('A', getSkinParam().getCircledCharacterRadius(),
getFont(FontParam.CIRCLED_CHARACTER), getColor(ColorParam.stereotypeABackground),
getColor(ColorParam.classBorder), getFontColor(FontParam.CIRCLED_CHARACTER));
}
if (entity.getType() == EntityType.CLASS) {
return new CircledCharacter('C', radius, getFont17(), getGreen(), getRed(), Color.BLACK);
return new CircledCharacter('C', getSkinParam().getCircledCharacterRadius(),
getFont(FontParam.CIRCLED_CHARACTER), getColor(ColorParam.stereotypeCBackground),
getColor(ColorParam.classBorder), getFontColor(FontParam.CIRCLED_CHARACTER));
}
if (entity.getType() == EntityType.INTERFACE) {
return new CircledCharacter('I', radius, getFont17(), getViolet(), getRed(), Color.BLACK);
return new CircledCharacter('I', getSkinParam().getCircledCharacterRadius(),
getFont(FontParam.CIRCLED_CHARACTER), getColor(ColorParam.stereotypeIBackground),
getColor(ColorParam.classBorder), getFontColor(FontParam.CIRCLED_CHARACTER));
}
if (entity.getType() == EntityType.ENUM) {
return new CircledCharacter('E', radius, getFont17(), getRose(), getRed(), Color.BLACK);
return new CircledCharacter('E', getSkinParam().getCircledCharacterRadius(),
getFont(FontParam.CIRCLED_CHARACTER), getColor(ColorParam.stereotypeEBackground),
getColor(ColorParam.classBorder), getFontColor(FontParam.CIRCLED_CHARACTER));
}
assert false;
return null;
}
private int xMarginFieldsOrMethod = 5;
private int marginEmptyFieldsOrMethod = 13;
@Override
public Dimension2D getDimension(StringBounder stringBounder) {
final Dimension2D dimName = getNameDimension(stringBounder);
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final Dimension2D dimMethods = methods.calculateDimension(stringBounder);
final Dimension2D dimFields = fields.calculateDimension(stringBounder);
final double width = Math.max(Math.max(dimMethods.getWidth(), dimFields.getWidth()), dimName.getWidth());
final double height = dimMethods.getHeight() + dimFields.getHeight() + dimName.getHeight();
final double width = Math.max(
Math.max(dimMethods.getWidth() + 2 * xMarginFieldsOrMethod, dimFields.getWidth() + 2
* xMarginFieldsOrMethod), dimTitle.getWidth() + 2 * xMarginCircle);
final double height = getMethodOrFieldHeight(dimMethods) + getMethodOrFieldHeight(dimFields)
+ dimTitle.getHeight();
return new Dimension2DDouble(width, height);
}
private Dimension2D getNameDimension(StringBounder stringBounder) {
final Dimension2D nameDim = name.calculateDimension(stringBounder);
if (circledCharacter == null) {
return nameDim;
private double getMethodOrFieldHeight(final Dimension2D dim) {
final double fieldsHeight = dim.getHeight();
if (fieldsHeight == 0) {
return marginEmptyFieldsOrMethod;
}
return new Dimension2DDouble(nameDim.getWidth() + getCircledWidth(stringBounder), Math.max(nameDim.getHeight(),
circledCharacter.getPreferredHeight(stringBounder)));
return fieldsHeight;
}
private int xMarginCircle = 5;
private int yMarginCircle = 5;
private Dimension2D getTitleDimension(StringBounder stringBounder) {
final Dimension2D nameAndStereo = getNameAndSteretypeDimension(stringBounder);
if (circledCharacter == null) {
return nameAndStereo;
}
return new Dimension2DDouble(nameAndStereo.getWidth() + getCircledWidth(stringBounder), Math.max(
nameAndStereo.getHeight(), circledCharacter.getPreferredHeight(stringBounder) + 2 * yMarginCircle));
}
private Dimension2D getNameAndSteretypeDimension(StringBounder stringBounder) {
final Dimension2D nameDim = name.calculateDimension(stringBounder);
final Dimension2D stereoDim = stereo == null ? new Dimension2DDouble(0, 0) : stereo
.calculateDimension(stringBounder);
final Dimension2D nameAndStereo = new Dimension2DDouble(Math.max(nameDim.getWidth(), stereoDim.getWidth()),
nameDim.getHeight() + stereoDim.getHeight());
return nameAndStereo;
}
private double getCircledWidth(StringBounder stringBounder) {
@ -126,38 +172,45 @@ public class EntityImageClass2 extends AbstractEntityImage2 {
public void drawU(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double marginWidth,
double marginHeight) {
final Dimension2D dimTotal = getDimension(ug.getStringBounder());
final Dimension2D dimName = getNameDimension(ug.getStringBounder());
final Dimension2D dimFields = fields.calculateDimension(ug.getStringBounder());
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = getDimension(stringBounder);
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double widthTotal = dimTotal.getWidth();
final double heightTotal = dimTotal.getHeight();
final URectangle rect = new URectangle(widthTotal, heightTotal);
ug.getParam().setColor(getRed());
ug.getParam().setBackcolor(getYellow());
ug.getParam().setColor(getColor(ColorParam.classBorder));
ug.getParam().setBackcolor(getColor(ColorParam.classBackground));
double x = xTheoricalPosition;
double y = yTheoricalPosition;
ug.draw(x, y, rect);
if (circledCharacter != null) {
circledCharacter.drawU(ug, x, y);
x += circledCharacter.getPreferredWidth(ug.getStringBounder());
final UGroup header;
if (circledCharacter == null) {
header = new UGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
} else {
header = new UGroup(new PlacementStrategyX1Y2Y3(ug.getStringBounder()));
header.add(circledCharacter);
}
name.drawU(ug, x, y);
if (stereo != null) {
header.add(stereo);
}
header.add(name);
header.drawU(ug, x, y, dimTotal.getWidth(), dimTitle.getHeight());
y += dimName.getHeight();
y += dimTitle.getHeight();
x = xTheoricalPosition;
ug.getParam().setColor(getRed());
ug.getParam().setColor(getColor(ColorParam.classBorder));
ug.draw(x, y, new ULine(widthTotal, 0));
fields.draw(ug, x, y);
fields.draw(ug, x + xMarginFieldsOrMethod, y);
y += dimFields.getHeight();
ug.getParam().setColor(getRed());
y += getMethodOrFieldHeight(fields.calculateDimension(stringBounder));
ug.getParam().setColor(getColor(ColorParam.classBorder));
ug.draw(x, y, new ULine(widthTotal, 0));
methods.draw(ug, x, y);
methods.draw(ug, x + xMarginFieldsOrMethod, y);
}
}

View File

@ -0,0 +1,84 @@
/* ========================================================================
* 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: 5183 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamBackcolored;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class EntityImageNote2 extends AbstractEntityImage2 {
private final Component comp;
public EntityImageNote2(IEntity entity, ISkinParam skinParam,
Collection<Link> links) {
super(entity, skinParam);
final Rose skin = new Rose();
comp = skin.createComponent(ComponentType.NOTE, skinParam, StringUtils
.getWithNewlines(entity.getDisplay()));
}
@Override
public Dimension2D getDimension(StringBounder stringBounder) {
final double height = comp.getPreferredHeight(stringBounder);
final double width = comp.getPreferredWidth(stringBounder);
return new Dimension2DDouble(width, height);
}
public void drawU(UGraphic ug, double xTheoricalPosition,
double yTheoricalPosition, double marginWidth, double marginHeight) {
final double dx = ug.getTranslateX();
final double dy = ug.getTranslateY();
ug.translate(xTheoricalPosition, yTheoricalPosition);
comp.drawU(ug, getDimension(ug.getStringBounder()), new SimpleContext2D(false));
ug.setTranslate(dx, dy);
}
}

View File

@ -38,34 +38,46 @@ import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
public class Frame implements Component {
private final List<String> name;
private final Color textColor;
private final Color lineColor;
private final Font font;
private final ISkinParam skinParam;
private final Rose rose = new Rose();
public Frame(List<String> name, Color textColor, Font font, Color lineColor) {
// private final Color textColor;
// private final Color lineColor;
// private final Font font;
public Frame(List<String> name, ISkinParam skinParam) {
this.name = name;
this.textColor = textColor;
this.lineColor = lineColor;
this.font = font;
this.skinParam = skinParam;
// this.textColor = textColor;
// this.lineColor = lineColor;
// this.font = font;
}
public void drawU(UGraphic ug, Dimension2D dimensionToUse, Context2D context) {
final Color lineColor = rose.getHtmlColor(skinParam, ColorParam.packageBorder).getColor();
ug.getParam().setColor(lineColor);
ug.getParam().setBackcolor(null);
ug.getParam().setStroke(new UStroke(1.4));
ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
ug.getParam().setStroke(new UStroke());
final TextBlock textBlock = createTextBloc();
textBlock.drawU(ug, 2, 2);
@ -80,7 +92,9 @@ public class Frame implements Component {
poly.addPoint(0, y);
poly.addPoint(0, 0);
ug.getParam().setColor(lineColor);
ug.getParam().setStroke(new UStroke(1.4));
ug.draw(0, 0, poly);
ug.getParam().setStroke(new UStroke());
}
@ -94,12 +108,14 @@ public class Frame implements Component {
return dim.getWidth() + 8;
}
private Dimension2D getTextDim(StringBounder stringBounder) {
public Dimension2D getTextDim(StringBounder stringBounder) {
final TextBlock bloc = createTextBloc();
return bloc.calculateDimension(stringBounder);
}
private TextBlock createTextBloc() {
final Font font = skinParam.getFont(FontParam.PACKAGE);
final Color textColor = skinParam.getFontHtmlColor(FontParam.PACKAGE).getColor();
final TextBlock bloc = TextBlockUtils.create(name, font, textColor, HorizontalAlignement.LEFT);
return bloc;
}

View File

@ -87,12 +87,14 @@ public class GraphvizSolverB {
}
public Dimension2D solve(Cluster root, Collection<Path> paths) throws IOException, InterruptedException {
final String dotString = new DotxMaker(root, paths).createDotString();
final String dotString = new DotxMaker(root, paths).createDotString("nodesep=0.2;", "ranksep=0.2;");
if (OptionFlags.getInstance().isKeepTmpFiles()) {
traceDotString(dotString);
}
final MinMax minMax = new MinMax();
// System.err.println("dotString=" + dotString);
// exportPng(dotString, new File("png", "test1.png"));
@ -126,6 +128,7 @@ public class GraphvizSolverB {
final List<Point2D.Double> pointsList = extractPointsList(s, p1);
b.setX(getMinX(pointsList));
b.setY(getMinY(pointsList) + height);
minMax.manage(b.getPosition());
}
for (Cluster cl : root.getSubClusters()) {
@ -141,6 +144,7 @@ public class GraphvizSolverB {
final double h = getMaxY(pointsList) - getMinY(pointsList);
cl.setHeight(h);
cl.setWidth(w);
minMax.manage(cl.getPosition());
}
for (Path p : paths) {
@ -154,16 +158,23 @@ public class GraphvizSolverB {
final int p2 = s.indexOf(" d=\"", p1);
final int p3 = s.indexOf("\"", p2 + " d=\"".length());
final String points = s.substring(p2 + " d=\"".length(), p3);
p.setDotPath(new DotPath(points, height));
final DotPath dotPath = new DotPath(points, height);
p.setDotPath(dotPath);
minMax.manage(dotPath.getMinMax());
// System.err.println("pointsList=" + pointsList);
if (p.getLabel() != null) {
final List<Point2D.Double> pointsList = extractPointsList(s, p1);
p.setLabelPosition(getMinX(pointsList), getMinY(pointsList) + height);
final double x = getMinX(pointsList);
final double y = getMinY(pointsList) + height;
p.setLabelPosition(x, y);
minMax.manage(x, y);
}
}
System.err.println("minMax=" + minMax);
return new Dimension2DDouble(width, height);
}

View File

@ -0,0 +1,81 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class LineRectIntersection {
private final Point2D inter;
public LineRectIntersection(Line2D line, Rectangle2D rect) {
final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
final Point2D inter1 = new LineSegmentIntersection(new Line2D.Double(p1, p2), line).getIntersection();
final Point2D inter2 = new LineSegmentIntersection(new Line2D.Double(p2, p3), line).getIntersection();
final Point2D inter3 = new LineSegmentIntersection(new Line2D.Double(p3, p4), line).getIntersection();
final Point2D inter4 = new LineSegmentIntersection(new Line2D.Double(p4, p1), line).getIntersection();
final Point2D o = line.getP1();
inter = getCloser(o, inter1, inter2, inter3, inter4);
}
public static Point2D getCloser(final Point2D o, final Point2D... other) {
double minDist = Double.MAX_VALUE;
Point2D result = null;
for (Point2D pt : other) {
if (pt != null) {
final double dist = pt.distanceSq(o);
if (dist < minDist) {
minDist = dist;
result = pt;
}
}
}
return result;
}
public final Point2D getIntersection() {
return inter;
}
}

View File

@ -0,0 +1,79 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
public class LineSegmentIntersection {
private final Point2D inter;
// http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
public LineSegmentIntersection(Line2D segment, Line2D lineB) {
final double x1 = segment.getX1();
final double y1 = segment.getY1();
final double x2 = segment.getX2();
final double y2 = segment.getY2();
final double x3 = lineB.getX1();
final double y3 = lineB.getY1();
final double x4 = lineB.getX2();
final double y4 = lineB.getY2();
final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
if (den == 0) {
inter = null;
} else {
final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
final double uA = uA1 / den;
final double x = x1 + uA * (x2 - x1);
final double y = y1 + uA * (y2 - y1);
if (uA >= 0 && uA <= 1) {
inter = new Point2D.Double(x, y);
} else {
inter = null;
}
}
}
public final Point2D getIntersection() {
return inter;
}
}

View File

@ -42,25 +42,25 @@ public class MargedBlock {
private final Block block;
private final IEntityImageBlock imageBlock;
private final int marginDecorator;
private final double marginDecorator;
private final Dimension2D imageDimension;
static private int uid = 1;
public MargedBlock(StringBounder stringBounder, IEntityImageBlock imageBlock, int marginDecorator) {
public MargedBlock(StringBounder stringBounder, IEntityImageBlock imageBlock, double marginDecorator, Cluster parent) {
this.imageBlock = imageBlock;
this.marginDecorator = marginDecorator;
this.imageDimension = imageBlock.getDimension(stringBounder);
this.block = new Block(uid++, imageDimension.getWidth() + 2
* marginDecorator, imageDimension.getHeight() + 2
* marginDecorator);
* marginDecorator, parent);
}
public Block getBlock() {
return block;
}
public int getMarginDecorator() {
public double getMarginDecorator() {
return marginDecorator;
}

View File

@ -0,0 +1,65 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Point2D;
public class MinMax {
private double minX = Double.MAX_VALUE;
private double minY = Double.MAX_VALUE;
public void manage(double x, double y) {
if (x < minX) {
minX = x;
}
if (y < minY) {
minY = y;
}
}
public void manage(Point2D p) {
manage(p.getX(), p.getY());
}
public void manage(MinMax other) {
manage(other.minX, other.minY);
}
@Override
public String toString() {
return "minX=" + minX + " minY=" + minY;
}
}

View File

@ -49,6 +49,9 @@ public class Path {
if (start == null || end == null) {
throw new IllegalArgumentException();
}
if (length < 1) {
throw new IllegalArgumentException("length=" + length);
}
this.start = start;
this.end = end;
this.label = label;

View File

@ -34,9 +34,7 @@
package net.sourceforge.plantuml.posimo;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Collection;
import java.util.Map;
@ -57,8 +55,8 @@ public class PathDrawerInterface implements PathDrawer {
private final ISkinParam param;
private final LinkType linkType;
public static PathDrawerInterface create(Rose rose, ISkinParam param, LinkType linkType) {
return new PathDrawerInterface(rose, param, linkType);
public static PathDrawerInterface create(ISkinParam param, LinkType linkType) {
return new PathDrawerInterface(new Rose(), param, linkType);
}
private PathDrawerInterface(Rose rose, ISkinParam param, LinkType linkType) {
@ -68,10 +66,10 @@ public class PathDrawerInterface implements PathDrawer {
}
public void drawPathBefore(UGraphic ug, Positionable start, Positionable end, Path path) {
//// final DotPath dotPath = path.getDotPath();
//// goDash(ug);
//// ug.draw(0, 0, dotPath);
//// noDash(ug);
// // final DotPath dotPath = path.getDotPath();
// // goDash(ug);
// // ug.draw(0, 0, dotPath);
// // noDash(ug);
}
private void noDash(UGraphic ug) {
@ -84,109 +82,58 @@ public class PathDrawerInterface implements PathDrawer {
public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path) {
DotPath dotPath = path.getDotPath();
final Racorder racorder = new RacorderOrthogonal();
//final Racorder racorder = new RacorderInToCenter();
//final Racorder racorder = new RacorderFollowTangeante();
final Rectangle2D startRect = PositionableUtils.convert(start);
final double xstartCenter = startRect.getCenterX();
final double ystartCenter = startRect.getCenterY();
final Rectangle2D endRect = PositionableUtils.convert(end);
final double xendCenter = endRect.getCenterX();
final double yendCenter = endRect.getCenterY();
final Point2D endPath = dotPath.getEndPoint();
final DotPath in = racorder.getRacordIn(PositionableUtils.convert(end), dotPath.getEndTangeante());
// final Point2D inPoint = in.getFrontierIntersection(end);
final Point2D inPoint = in.getEndPoint();
// final double theta1_ = in.getEndAngle() + Math.PI / 2;
// System.err.println("theta1_=" + theta1_ + " " + theta1_ * 180 /
// Math.PI);
final double theta1 = atan2(endPath, inPoint);
// System.err.println("theta1=" + theta1 + " " + theta1 * 180 /
// Math.PI);
final Point2D middle1 = drawSymbol(ug, theta1, inPoint, linkType.getDecor1());
final Point2D startCenter = new Point2D.Double(xstartCenter, ystartCenter);
final Point2D startPoint = dotPath.getStartPoint();
final Point2D endPoint = dotPath.getEndPoint();
final Point2D p1 = BezierUtils.intersect(new Line2D.Double(startPoint, startCenter), startRect);
final Point2D endCenter = new Point2D.Double(xendCenter, yendCenter);
final Point2D p2 = BezierUtils.intersect(new Line2D.Double(endPoint, endCenter), endRect);
final Point2D startPath = dotPath.getStartPoint();
final DotPath out = racorder.getRacordOut(PositionableUtils.convert(start), dotPath.getStartTangeante());
// final Point2D outPoint = out.getFrontierIntersection(start);
final Point2D outPoint = out.getStartPoint();
// final double theta2_ = out.getStartAngle() - Math.PI / 2;
// System.err.println("theta2_=" + theta2_ + " " + theta2_ * 180 /
// Math.PI);
final double theta2 = atan2(startPath, outPoint);
// System.err.println("theta2=" + theta2 + " " + theta2 * 180 /
// Math.PI);
final Point2D middle2 = drawSymbol(ug, theta2, outPoint, linkType.getDecor2());
CubicCurve2D.Double after = null;
if (linkType.getDecor1() == LinkDecor.SQUARRE) {
drawSquare(ug, p1.getX(), p1.getY());
} else {
if (linkType.getDecor1() == LinkDecor.EXTENDS) {
final Point2D middle = drawExtends(ug, p2.getX(), p2.getY(), endPoint);
after = getLine(endPoint, middle);
} else if (linkType.getDecor1() == LinkDecor.AGREGATION) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
final Point2D middle = drawDiamond(ug, p2.getX(), p2.getY(), endPoint);
after = getLine(endPoint, middle);
} else if (linkType.getDecor1() == LinkDecor.COMPOSITION) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
ug.getParam().setColor(null);
final Point2D middle = drawDiamond(ug, p2.getX(), p2.getY(), endPoint);
after = getLine(endPoint, middle);
} else if (linkType.getDecor1() == LinkDecor.NONE) {
after = getLine(endPoint, p2);
} else if (linkType.getDecor1() == LinkDecor.ARROW) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
final Point2D middle = drawArrow(ug, p2.getX(), p2.getY(), endPoint);
after = getLine(endPoint, middle);
}
}
if (after != null) {
if (middle1 != null) {
final CubicCurve2D.Double after = getLine(endPath, middle1);
dotPath = dotPath.addAfter(after);
//dotPath = dotPath.addAfter(in);
}
CubicCurve2D.Double before = null;
if (linkType.getDecor2() == LinkDecor.SQUARRE) {
drawSquare(ug, p2.getX(), p2.getY());
} else {
if (linkType.getDecor2() == LinkDecor.EXTENDS) {
final Point2D middle = drawExtends(ug, p1.getX(), p1.getY(),
startPoint);
before = getLine(middle, startPoint);
} else if (linkType.getDecor2() == LinkDecor.AGREGATION) {
ug.getParam().setBackcolor(
rose.getHtmlColor(param, ColorParam.background)
.getColor());
ug.getParam().setColor(
rose.getHtmlColor(param, ColorParam.classBorder)
.getColor());
final Point2D middle = drawDiamond(ug, p1.getX(), p1.getY(), startPoint);
before = getLine(middle, startPoint);
} else if (linkType.getDecor2() == LinkDecor.COMPOSITION) {
ug.getParam().setBackcolor(
rose.getHtmlColor(param, ColorParam.classBorder)
.getColor());
ug.getParam().setColor(null);
final Point2D middle = drawDiamond(ug, p1.getX(), p1.getY(), startPoint);
before = getLine(middle, startPoint);
} else if (linkType.getDecor2() == LinkDecor.NONE) {
before = getLine(p1, startPoint);
} else if (linkType.getDecor2() == LinkDecor.ARROW) {
ug.getParam().setBackcolor(
rose.getHtmlColor(param, ColorParam.classBorder)
.getColor());
ug.getParam().setColor(
rose.getHtmlColor(param, ColorParam.classBorder)
.getColor());
final Point2D middle = drawArrow(ug, p1.getX(), p1.getY(), startPoint);
before = getLine(middle, startPoint);
}
}
if (before != null) {
if (middle2 != null) {
final CubicCurve2D.Double before = getLine(middle2, startPath);
dotPath = dotPath.addBefore(before);
//dotPath = dotPath.addBefore(out);
}
final LinkStyle style = linkType.getStyle();
if (style == LinkStyle.INTERFACE_PROVIDER || style == LinkStyle.INTERFACE_USER) {
final Decor decor = new DecorInterfaceProvider(style);
final Map<Point2D, Double> all = dotPath.somePoints();
final Point2D p = getFarest(p1, p2, all.keySet());
final Point2D p = getFarest(outPoint, inPoint, all.keySet());
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
decor.drawDecor(ug, p, all.get(p));
}
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
if (linkType.isDashed()) {
goDash(ug);
@ -197,10 +144,44 @@ public class PathDrawerInterface implements PathDrawer {
}
}
private double atan2(final Point2D endPath, final Point2D inPoint) {
final double y = -endPath.getX() + inPoint.getX();
final double x = endPath.getY() - inPoint.getY();
final double angle = Math.atan2(y, x);
System.err.println("x=" + x + " y=" + y + " angle=" + angle + " " + angle * 180.0 / Math.PI);
return angle;
}
private Point2D drawSymbol(UGraphic ug, double theta, final Point2D position, LinkDecor decor) {
Point2D middle1 = null;
// final double theta = Math.atan2(
// -direction.getX() + position.getX(), direction.getY()
// - position.getY());
if (decor == LinkDecor.SQUARRE) {
middle1 = drawSquare(ug, position.getX(), position.getY());
} else if (decor == LinkDecor.EXTENDS) {
middle1 = drawExtends(ug, position.getX(), position.getY(), theta);
} else if (decor == LinkDecor.AGREGATION) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
middle1 = drawDiamond(ug, position.getX(), position.getY(), theta);
} else if (decor == LinkDecor.COMPOSITION) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
ug.getParam().setColor(null);
middle1 = drawDiamond(ug, position.getX(), position.getY(), theta);
} else if (decor == LinkDecor.NONE) {
middle1 = position;
} else if (decor == LinkDecor.ARROW) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
middle1 = drawArrow(ug, position.getX(), position.getY(), theta);
}
return middle1;
}
private CubicCurve2D.Double getLine(final Point2D p1, Point2D p2) {
return new CubicCurve2D.Double(p1.getX(), p1
.getY(), p1.getX(), p1.getY(), p2
.getX(), p2.getY(), p2.getX(), p2.getY());
return new CubicCurve2D.Double(p1.getX(), p1.getY(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), p2.getX(), p2
.getY());
}
private static Point2D getFarest(Point2D p1, Point2D p2, Collection<Point2D> all) {
@ -224,22 +205,24 @@ public class PathDrawerInterface implements PathDrawer {
return result;
}
private void drawSquare(UGraphic ug, double centerX, double centerY) {
private Point2D drawSquare(UGraphic ug, double centerX, double centerY) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBackground).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
final double width = 10;
final double height = 10;
ug.draw(centerX - width / 2, centerY - height / 2, new URectangle(width, height));
return new Point2D.Double(centerX, centerY);
}
private Point2D drawExtends(UGraphic ug, double x, double y, Point2D pathPoint) {
Point2D drawExtends(UGraphic ug, double x, double y, double theta) {
ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background).getColor());
ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder).getColor());
final double width = 18;
final double height = 26;
final double theta = Math.atan2(-pathPoint.getX() + x, pathPoint.getY() - y);
// final double theta = Math.atan2(-pathPoint.getX() + x,
// pathPoint.getY() - y);
final UPolygon triangle = new UPolygon();
triangle.addPoint(0, 1);
@ -248,29 +231,17 @@ public class PathDrawerInterface implements PathDrawer {
triangle.rotate(theta);
ug.draw(x, y, triangle);
//ug.getParam().setColor(Color.BLACK);
final Point2D middle = BezierUtils.middle(triangle.getPoints().get(1), triangle.getPoints().get(2));
middle.setLocation(middle.getX() + x, middle.getY() + y);
//drawLine2(ug, pathPoint, middle);
// return new CubicCurve2D.Double(middle.getX(), middle.getY(), middle.getX(), middle.getY(),
// pathPoint.getX(), pathPoint.getY(),pathPoint.getX(), pathPoint.getY());
return middle;
}
// private void drawLine(UGraphic ug, Point2D p1, Point2D p2) {
//// ug.getParam().setColor(Color.BLACK);
//// final ULine line = new ULine(p2.getX() - p1.getX(), p2.getY() - p1.getY());
//// goDash(ug);
//// ug.draw(p1.getX(), p1.getY(), line);
//// noDash(ug);
// }
private Point2D drawDiamond(UGraphic ug, double x, double y, Point2D pathPoint) {
private Point2D drawDiamond(UGraphic ug, double x, double y, double theta) {
final double width = 10;
final double height = 14;
final double theta = Math.atan2(-pathPoint.getX() + x, pathPoint.getY() - y);
// final double theta = Math.atan2(-pathPoint.getX() + x,
// pathPoint.getY() - y);
final UPolygon triangle = new UPolygon();
triangle.addPoint(0, 0);
@ -280,21 +251,19 @@ public class PathDrawerInterface implements PathDrawer {
triangle.rotate(theta);
ug.draw(x, y, triangle);
// ug.getParam().setColor(Color.BLACK);
final Point2D middle = triangle.getPoints().get(2);
middle.setLocation(middle.getX() + x, middle.getY() + y);
// final ULine line = new ULine(pathPoint.getX() - middle.getX(), pathPoint.getY() - middle.getY());
// ug.draw(middle.getX(), middle.getY(), line);
return middle;
}
private Point2D drawArrow(UGraphic ug, double x, double y, Point2D pathPoint) {
final double width = 16;
final double height = 16;
final double height2 = 7;
private Point2D drawArrow(UGraphic ug, double x, double y, double theta) {
final double width = 12;
final double height = 10;
final double height2 = 4;
final double theta = Math.atan2(-pathPoint.getX() + x, pathPoint.getY() - y);
// final double theta = Math.atan2(-pathPoint.getX() + x,
// pathPoint.getY() - y);
final UPolygon triangle = new UPolygon();
triangle.addPoint(0, 0);
@ -304,10 +273,8 @@ public class PathDrawerInterface implements PathDrawer {
triangle.rotate(theta);
ug.draw(x, y, triangle);
// ug.getParam().setColor(Color.BLACK);
final Point2D middle = triangle.getPoints().get(2);
middle.setLocation(middle.getX() + x, middle.getY() + y);
// drawLine(ug, pathPoint, middle);
return middle;
}

View File

@ -82,4 +82,8 @@ public class PositionableUtils {
};
}
static Rectangle2D move(Rectangle2D rect, double dx, double dy) {
return new Rectangle2D.Double(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight());
}
}

View File

@ -0,0 +1,42 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
public interface Racorder {
public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante);
public DotPath getRacordOut(Rectangle2D rect, Line2D tangeante);
}

View File

@ -0,0 +1,56 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
public abstract class RacorderAbstract implements Racorder {
public final DotPath getRacordOut(Rectangle2D rect, Line2D tangeante) {
tangeante = symetric(tangeante);
return getRacordIn(rect, tangeante).reverse();
}
private static Line2D symetric(Line2D line) {
final double x1 = line.getX1();
final double y1 = line.getY1();
final double x2 = line.getX2();
final double y2 = line.getY2();
final double dx = x2 - x1;
final double dy = y2 - y1;
return new Line2D.Double(x1, y1, x1 - dx, y1 - dy);
}
}

View File

@ -0,0 +1,71 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class RacorderFollowTangeante extends RacorderAbstract implements Racorder {
public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
// System.err.println("rect x=" + rect.getX() + " y=" + rect.getY() + " w=" + rect.getWidth() + " h="
// + rect.getHeight());
// System.err.println("tangeante (" + tangeante.getX1() + "," + tangeante.getY1() + ") (" + tangeante.getX2()
// + "," + tangeante.getY2() + ")");
final DotPath result = new DotPath();
// final Point2D inter = BezierUtils.intersect((Line2D.Double)
// tangeante, rect);
Point2D inter = new LineRectIntersection(tangeante, rect).getIntersection();
// System.err.println("inter=" + inter);
if (inter == null) {
final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4);
}
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
return result.addAfter(curv);
}
}

View File

@ -0,0 +1,56 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class RacorderFollowTangeanteOld extends RacorderAbstract implements Racorder {
public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
final DotPath result = new DotPath();
final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center);
final Point2D inter = BezierUtils.intersect(line, rect);
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), tangeante
.getX2(), tangeante.getY2(), tangeante.getX2(), tangeante.getY2(), inter.getX(), inter.getY());
return result.addAfter(curv);
}
}

View File

@ -0,0 +1,55 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class RacorderInToCenter extends RacorderAbstract implements Racorder {
public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
final DotPath result = new DotPath();
final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center);
final Point2D inter = BezierUtils.intersect(line, rect);
final CubicCurve2D.Double curv = new CubicCurve2D.Double(line.getX1(), line.getY1(), line.getX1(),
line.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
return result.addAfter(curv);
}
}

View File

@ -0,0 +1,81 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class RacorderOrthogonal extends RacorderAbstract implements Racorder {
public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
final Point2D in = tangeante.getP1();
final DotPath result = new DotPath();
Point2D inter = null;
if (in.getX() > rect.getMinX() && in.getX() < rect.getMaxX()) {
if (in.getY() < rect.getMinY()) {
inter = new Point2D.Double(in.getX(), rect.getMinY());
} else if (in.getY() > rect.getMaxY()) {
inter = new Point2D.Double(in.getX(), rect.getMaxY());
} else {
throw new IllegalArgumentException();
}
} else if (in.getY() > rect.getMinY() && in.getY() < rect.getMaxY()) {
if (in.getX() < rect.getMinX()) {
inter = new Point2D.Double(rect.getMinX(), in.getY());
} else if (in.getX() > rect.getMaxX()) {
inter = new Point2D.Double(rect.getMaxX(), in.getY());
} else {
throw new IllegalArgumentException();
}
} else {
final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4);
}
final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
return result.addAfter(curv);
}
}

View File

@ -0,0 +1,71 @@
/* ========================================================================
* 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: 4236 $
*
*/
package net.sourceforge.plantuml.posimo;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
public class TwoLinesIntersection {
private final Point2D inter;
public TwoLinesIntersection(Line2D lineA, Line2D lineB) {
final double x1 = lineA.getX1();
final double y1 = lineA.getY1();
final double x2 = lineA.getX2();
final double y2 = lineA.getY2();
final double x3 = lineB.getX1();
final double y3 = lineB.getY1();
final double x4 = lineB.getX2();
final double y4 = lineB.getY2();
final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
final double uA = uA1 / den;
// final double uB1 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
// uB = uB1 / den;
final double x = x1 + uA * (x2 - x1);
final double y = y1 + uA * (y2 - y1);
inter = new Point2D.Double(x, y);
}
public final Point2D getIntersection() {
return inter;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5275 $
* Revision $Revision: 5636 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@ -82,7 +82,7 @@ class LifeLine {
if (y < last.y) {
throw new IllegalArgumentException();
}
if (y==last.y && type != last.type) {
if (y == last.y && type != last.type) {
throw new IllegalArgumentException();
}
}
@ -119,8 +119,12 @@ class LifeLine {
level++;
} else {
level--;
if (level < 0) {
level = 0;
}
}
}
assert level >= 0;
return level;
}
@ -192,10 +196,9 @@ class LifeLine {
return new Segment(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor);
}
public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) {
final StringBounder stringBounder = ug.getStringBounder();
final double atX = ug.getTranslateX();
final double atY = ug.getTranslateY();

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5114 $
* Revision $Revision: 5636 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@ -65,7 +65,7 @@ public class LivingParticipantBox implements InGroupable {
final double left = lifeLine.getLeftShift(y);
assert left >= 0;
final double right = lifeLine.getRightShift(y);
assert right >= 0;
assert right >= 0 : "right=" + right;
final double centerX = participantBox.getCenterX(stringBounder);
// System.err.println("Attention, null for segment");
return new Segment(centerX - left, centerX + right, null);

View File

@ -34,8 +34,13 @@
package net.sourceforge.plantuml.skin;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
@ -50,12 +55,12 @@ public enum VisibilityModifier {
ColorParam.iconPackage, ColorParam.iconPackageBackground), PUBLIC_METHOD(ColorParam.iconPublic,
ColorParam.iconPublicBackground);
private final ColorParam foreground;
private final ColorParam background;
private final ColorParam foregroundParam;
private final ColorParam backgroundParam;
private VisibilityModifier(ColorParam foreground, ColorParam background) {
this.foreground = foreground;
this.background = background;
this.foregroundParam = foreground;
this.backgroundParam = background;
}
public UDrawable getUDrawable(final int size, final Color foregroundColor, final Color backgoundColor) {
@ -66,6 +71,27 @@ public enum VisibilityModifier {
};
}
public TextBlock getUBlock(final int size, final Color foregroundColor, final Color backgoundColor) {
return new TextBlock() {
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(size + 1, size + 1);
}
public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) {
throw new UnsupportedOperationException();
}
public void drawU(UGraphic ug, double x, double y) {
final double tx = ug.getTranslateX();
final double ty = ug.getTranslateY();
ug.translate(x, y);
drawInternal(ug, size, foregroundColor, backgoundColor);
ug.setTranslate(tx, ty);
}
};
}
private void drawInternal(UGraphic ug, int size, final Color foregroundColor, final Color backgoundColor) {
ug.getParam().setBackcolor(backgoundColor);
ug.getParam().setColor(foregroundColor);
@ -198,11 +224,11 @@ public enum VisibilityModifier {
}
public final ColorParam getForeground() {
return foreground;
return foregroundParam;
}
public final ColorParam getBackground() {
return background;
return backgroundParam;
}
}

View File

@ -0,0 +1,109 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public abstract class AbstractPlacementStrategy implements PlacementStrategy {
private final StringBounder stringBounder;
private final Map<TextBlock, Dimension2D> dimensions = new LinkedHashMap<TextBlock, Dimension2D>();
public AbstractPlacementStrategy(StringBounder stringBounder) {
this.stringBounder = stringBounder;
}
public void add(TextBlock block) {
this.dimensions.put(block, block.calculateDimension(stringBounder));
}
protected Map<TextBlock, Dimension2D> getDimensions() {
return dimensions;
}
protected double getSumWidth() {
return getSumWidth(dimensions.values().iterator());
}
protected double getSumHeight() {
return getSumHeight(dimensions.values().iterator());
}
protected double getMaxHeight() {
return getMaxHeight(dimensions.values().iterator());
}
protected double getMaxWidth() {
return getMaxWidth(dimensions.values().iterator());
}
protected double getSumWidth(Iterator<Dimension2D> it) {
double result = 0;
while (it.hasNext()) {
result += it.next().getWidth();
}
return result;
}
protected double getSumHeight(Iterator<Dimension2D> it) {
double result = 0;
while (it.hasNext()) {
result += it.next().getHeight();
}
return result;
}
protected double getMaxWidth(Iterator<Dimension2D> it) {
double result = 0;
while (it.hasNext()) {
result = Math.max(result, it.next().getWidth());
}
return result;
}
protected double getMaxHeight(Iterator<Dimension2D> it) {
double result = 0;
while (it.hasNext()) {
result = Math.max(result, it.next().getHeight());
}
return result;
}
}

View File

@ -0,0 +1,47 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Point2D;
import java.util.Map;
import net.sourceforge.plantuml.graphic.TextBlock;
public interface PlacementStrategy {
public void add(TextBlock block);
public Map<TextBlock, Point2D> getPositions(double width, double height);
}

View File

@ -0,0 +1,70 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyVisibility extends AbstractPlacementStrategy {
private final int col2;
public PlacementStrategyVisibility(StringBounder stringBounder, int col2) {
super(stringBounder);
this.col2 = col2;
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double y = 0;
for (Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator(); it.hasNext();) {
Map.Entry<TextBlock, Dimension2D> ent1 = it.next();
Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
final double height1 = ent1.getValue().getHeight();
final double height2 = ent2.getValue().getHeight();
final double maxHeight = Math.max(height1, height2);
result.put(ent1.getKey(), new Point2D.Double(0, 2 + y + (maxHeight - height1) / 2));
result.put(ent2.getKey(), new Point2D.Double(col2, y + (maxHeight - height2) / 2));
y += maxHeight;
}
return result;
}
}

View File

@ -0,0 +1,65 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyX1X2 extends AbstractPlacementStrategy {
public PlacementStrategyX1X2(StringBounder stringBounder) {
super(stringBounder);
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
double usedWidth = getSumWidth();
//double maxHeight = getMaxHeight();
final double space = (width - usedWidth) / (getDimensions().size() + 1);
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double x = space;
for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
final double y = (height - ent.getValue().getHeight()) / 2;
result.put(ent.getKey(), new Point2D.Double(x, y));
x += ent.getValue().getWidth() + space;
}
return result;
}
}

View File

@ -0,0 +1,84 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyX1Y2Y3 extends AbstractPlacementStrategy {
public PlacementStrategyX1Y2Y3(StringBounder stringBounder) {
super(stringBounder);
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
final Dimension2D first = getDimensions().values().iterator().next();
double maxWidthButFirst = getMaxWidth(butFirst());
double sumHeightButFirst = getSumHeight(butFirst());
final double space = (width - first.getWidth() - maxWidthButFirst) / 5;
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double x = space * 2;
final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator();
final Map.Entry<TextBlock, Dimension2D> ent = it.next();
double y = (height - ent.getValue().getHeight()) / 2;
result.put(ent.getKey(), new Point2D.Double(x, y));
x += ent.getValue().getWidth() + space;
y = (height - sumHeightButFirst) / 2;
while (it.hasNext()) {
final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
result.put(ent2.getKey(), new Point2D.Double(x, y));
y += ent2.getValue().getHeight();
}
return result;
}
private Iterator<Dimension2D> butFirst() {
final Iterator<Dimension2D> iterator = getDimensions().values().iterator();
iterator.next();
return iterator;
}
}

View File

@ -0,0 +1,65 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyY1Y2 extends AbstractPlacementStrategy {
public PlacementStrategyY1Y2(StringBounder stringBounder) {
super(stringBounder);
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
double usedHeight = getSumHeight();
//double maxWidth = getMaxWidth();
final double space = (height - usedHeight) / (getDimensions().size() + 1);
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double y = space;
for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
final double x = (width - ent.getValue().getWidth()) / 2;
result.put(ent.getKey(), new Point2D.Double(x, y));
y += ent.getValue().getHeight() + space;
}
return result;
}
}

View File

@ -0,0 +1,65 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyY1Y2Left extends AbstractPlacementStrategy {
public PlacementStrategyY1Y2Left(StringBounder stringBounder) {
super(stringBounder);
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
double usedHeight = getSumHeight();
//double maxWidth = getMaxWidth();
final double space = (height - usedHeight) / (getDimensions().size() + 1);
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double y = space;
for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
final double x = 0;
result.put(ent.getKey(), new Point2D.Double(x, y));
y += ent.getValue().getHeight() + space;
}
return result;
}
}

View File

@ -0,0 +1,63 @@
/* ========================================================================
* 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: 3837 $
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.Map;
import net.sourceforge.plantuml.graphic.TextBlock;
public class UGroup {
private final PlacementStrategy placementStrategy;
public UGroup(PlacementStrategy placementStrategy) {
this.placementStrategy = placementStrategy;
}
public void drawU(UGraphic ug, double x, double y, double width, double height) {
for (Map.Entry<TextBlock, Point2D> ent : placementStrategy.getPositions(width, height).entrySet()) {
final TextBlock block = ent.getKey();
final Point2D pos = ent.getValue();
block.drawU(ug, x + pos.getX(), y + pos.getY());
}
}
public void add(TextBlock block) {
placementStrategy.add(block);
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5539 $
* Revision $Revision: 5659 $
*
*/
package net.sourceforge.plantuml.version;
@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
public class Version {
public static int version() {
return 5538;
return 5658;
}
public static long compileTime() {
return 1288721031328L;
return 1290708052921L;
}
}

187
src/pom.xml Normal file
View File

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
========================================================================
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.]
Script Author: Julien Eluard
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.0.5636-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
<description>
PlantUML is a component that allows to quickly write :
* sequence diagram,
* use case diagram,
* class diagram,
* activity diagram,
* component diagram,
* state diagram
* object diagram
</description>
<url>http://plantuml.sourceforge.net</url>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<licenses>
<license>
<name>The GNU General Public License</name>
<url>http://www.gnu.org/licenses/gpl.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>http://plantuml.svn.sourceforge.net/viewvc/plantuml</url>
<connection>https://plantuml.svn.sourceforge.net/svnroot/plantuml</connection>
</scm>
<issueManagement>
<system>Sourceforge</system>
<url>http://sourceforge.net/tracker/?group_id=259736</url>
</issueManagement>
<developers>
<developer>
<id>arnaud.roques</id>
<name>Arnaud Roques</name>
<email>plantuml@gmail.com</email>
</developer>
</developers>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src</directory>
<includes>
<include>net/sourceforge/plantuml/version/logo.png</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<debug>false</debug>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>net.sourceforge.plantuml.Run</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>