mirror of
https://github.com/octoleo/plantuml.git
synced 2025-01-03 07:12:29 +00:00
version 8022
This commit is contained in:
parent
b6ea839fa1
commit
3e922a6f3c
1334
src/net/sourceforge/plantuml/AnimatedGifEncoder.java
Normal file
1334
src/net/sourceforge/plantuml/AnimatedGifEncoder.java
Normal file
File diff suppressed because it is too large
Load Diff
90
src/net/sourceforge/plantuml/CounterOutputStream.java
Normal file
90
src/net/sourceforge/plantuml/CounterOutputStream.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4780 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
public class CounterOutputStream extends OutputStream {
|
||||||
|
|
||||||
|
private int length;
|
||||||
|
private final OutputStream os;
|
||||||
|
|
||||||
|
public CounterOutputStream(OutputStream os) {
|
||||||
|
this.os = os;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to nowhere
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
os.write(b);
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden for performance reason
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void write(byte b[]) throws IOException {
|
||||||
|
os.write(b);
|
||||||
|
length += b.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden for performance reason
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void write(byte b[], int off, int len) throws IOException {
|
||||||
|
os.write(b, off, len);
|
||||||
|
length += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
os.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
src/net/sourceforge/plantuml/ISkinSimple.java
Normal file
43
src/net/sourceforge/plantuml/ISkinSimple.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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;
|
||||||
|
|
||||||
|
public interface ISkinSimple extends SpriteContainer {
|
||||||
|
|
||||||
|
public String getValue(String key);
|
||||||
|
|
||||||
|
public double getPadding();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||||
|
|
||||||
|
public class InstructionGoto extends MonoSwimable implements Instruction {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public InstructionGoto(Swimlane swimlane, String name) {
|
||||||
|
super(swimlane);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ftile createFtile(FtileFactory factory) {
|
||||||
|
return new FtileGoto(factory.shadowing(), getSwimlaneIn(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Instruction other) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public boolean kill() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkRendering getInLinkRendering() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNote(Display note, NotePosition position) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
165
src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
Normal file
165
src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||||
|
|
||||||
|
public class InstructionIf implements Instruction {
|
||||||
|
|
||||||
|
private final List<Branch> thens = new ArrayList<Branch>();
|
||||||
|
private Branch elseBranch;
|
||||||
|
private final ISkinParam skinParam;
|
||||||
|
|
||||||
|
private final Instruction parent;
|
||||||
|
|
||||||
|
private Branch current;
|
||||||
|
private final LinkRendering inlinkRendering;
|
||||||
|
|
||||||
|
private final Swimlane swimlane;
|
||||||
|
|
||||||
|
public InstructionIf(Swimlane swimlane, Instruction parent, Display labelTest, Display whenThen,
|
||||||
|
LinkRendering inlinkRendering, HtmlColor color, ISkinParam skinParam) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.skinParam = skinParam;
|
||||||
|
|
||||||
|
this.inlinkRendering = inlinkRendering;
|
||||||
|
this.swimlane = swimlane;
|
||||||
|
this.thens.add(new Branch(swimlane, whenThen, labelTest, color));
|
||||||
|
this.current = this.thens.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Instruction ins) {
|
||||||
|
current.add(ins);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Display note;
|
||||||
|
private NotePosition position;
|
||||||
|
|
||||||
|
public Ftile createFtile(FtileFactory factory) {
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
branch.updateFtile(factory);
|
||||||
|
}
|
||||||
|
if (elseBranch == null) {
|
||||||
|
this.elseBranch = new Branch(swimlane, null, null, null);
|
||||||
|
}
|
||||||
|
elseBranch.updateFtile(factory);
|
||||||
|
Ftile result = factory.createIf(swimlane, thens, elseBranch);
|
||||||
|
if (note != null) {
|
||||||
|
result = new FtileWithNoteOpale(result, note, position, skinParam, false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instruction getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean swithToElse2(Display whenElse, LinkRendering nextLinkRenderer) {
|
||||||
|
if (elseBranch != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.current.setInlinkRendering(nextLinkRenderer);
|
||||||
|
this.elseBranch = new Branch(swimlane, whenElse, null, null);
|
||||||
|
this.current = elseBranch;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) {
|
||||||
|
if (elseBranch != null) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
this.current.setInlinkRendering(nextLinkRenderer);
|
||||||
|
this.current = new Branch(swimlane, whenThen, test, color);
|
||||||
|
this.thens.add(current);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endif(LinkRendering nextLinkRenderer) {
|
||||||
|
if (elseBranch == null) {
|
||||||
|
this.elseBranch = new Branch(swimlane, null, null, null);
|
||||||
|
}
|
||||||
|
this.current.setInlinkRendering(nextLinkRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
final public boolean kill() {
|
||||||
|
return current.kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkRendering getInLinkRendering() {
|
||||||
|
return inlinkRendering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNote(Display note, NotePosition position) {
|
||||||
|
if (current.isEmpty()) {
|
||||||
|
this.note = note;
|
||||||
|
this.position = position;
|
||||||
|
} else {
|
||||||
|
current.addNote(note, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||||
|
if (swimlane != null) {
|
||||||
|
result.add(swimlane);
|
||||||
|
}
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
result.addAll(branch.getSwimlanes());
|
||||||
|
}
|
||||||
|
result.addAll(elseBranch.getSwimlanes());
|
||||||
|
return Collections.unmodifiableSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return swimlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return swimlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||||
|
|
||||||
|
public class InstructionLabel extends MonoSwimable implements Instruction {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public InstructionLabel(Swimlane swimlane, String name) {
|
||||||
|
super(swimlane);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ftile createFtile(FtileFactory factory) {
|
||||||
|
return new FtileLabel(factory.shadowing(), getSwimlaneIn(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Instruction other) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public boolean kill() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkRendering getInLinkRendering() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNote(Display note, NotePosition position) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||||
|
|
||||||
|
public class InstructionPartition implements Instruction {
|
||||||
|
|
||||||
|
private final InstructionList list = new InstructionList();
|
||||||
|
private final Instruction parent;
|
||||||
|
|
||||||
|
public InstructionPartition(Instruction parent, String partitionTitle) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instruction getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
return list.getSwimlanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return list.getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return list.getSwimlaneOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ftile createFtile(FtileFactory factory) {
|
||||||
|
return list.createFtile(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Instruction other) {
|
||||||
|
list.add(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean kill() {
|
||||||
|
return list.kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkRendering getInLinkRendering() {
|
||||||
|
return list.getInLinkRendering();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNote(Display note, NotePosition position) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 12235 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
|
import net.sourceforge.plantuml.command.SingleLineCommand;
|
||||||
|
|
||||||
|
public class CommandEndPartition3 extends SingleLineCommand<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandEndPartition3() {
|
||||||
|
super("(?i)^(\\})$");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, List<String> arg) {
|
||||||
|
// final IEntity currentPackage = diagram.getCurrentGroup();
|
||||||
|
// if (currentPackage == null) {
|
||||||
|
// return CommandExecutionResult.error("No partition defined");
|
||||||
|
// }
|
||||||
|
return diagram.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
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.RegexResult;
|
||||||
|
|
||||||
|
public class CommandGoto extends SingleLineCommand2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandGoto() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegexConcat getRegexConcat() {
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("goto"), //
|
||||||
|
new RegexLeaf("[%s]+"), //
|
||||||
|
new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
|
||||||
|
new RegexLeaf(";?"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
|
||||||
|
final String name = arg.get("NAME", 0);
|
||||||
|
return diagram.addGoto(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
|
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||||
|
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||||
|
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
|
public class CommandIf2Multilines extends CommandMultilines2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandIf2Multilines() {
|
||||||
|
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPatternEnd() {
|
||||||
|
return "(?i)^(.*?)\\)[%s]*(?:then[%s]*(?:\\((.+?)\\))?)?;?$";
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegexConcat getRegexConcat() {
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
|
||||||
|
new RegexLeaf("if"), //
|
||||||
|
new RegexLeaf("[%s]*"), //
|
||||||
|
new RegexLeaf("\\("), //
|
||||||
|
new RegexLeaf("TEST", "([^)]*)$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||||
|
StringUtils.trim(lines, false);
|
||||||
|
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||||
|
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||||
|
lines.get(lines.size() - 1));
|
||||||
|
|
||||||
|
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||||
|
|
||||||
|
final String test = line0.get("TEST", 0);
|
||||||
|
Display testDisplay = Display.getWithNewlines(test);
|
||||||
|
for (int i = 1; i < lines.size() - 1; i++) {
|
||||||
|
testDisplay = testDisplay.add(lines.get(i));
|
||||||
|
}
|
||||||
|
final String trailTest = lineLast.get(0);
|
||||||
|
if (StringUtils.isEmpty(trailTest) == false) {
|
||||||
|
testDisplay = testDisplay.add(trailTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
diagram.startIf(testDisplay, Display.getWithNewlines(lineLast.get(1)), color);
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
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.RegexResult;
|
||||||
|
|
||||||
|
public class CommandLabel extends SingleLineCommand2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandLabel() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegexConcat getRegexConcat() {
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("label"), //
|
||||||
|
new RegexLeaf("[%s]+"), //
|
||||||
|
new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
|
||||||
|
new RegexLeaf(";?"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
|
||||||
|
|
||||||
|
final String name = arg.get("NAME", 0);
|
||||||
|
return diagram.addLabel(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
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.RegexResult;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
|
||||||
|
public class CommandNolink extends SingleLineCommand2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandNolink() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegexConcat getRegexConcat() {
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("nolink"), //
|
||||||
|
new RegexLeaf(";?"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
|
||||||
|
// diagram.setColorNextArrow(color);
|
||||||
|
diagram.setLabelNextArrow(Display.getWithNewlines("NOLINK"));
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 12235 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
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.RegexResult;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
|
public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandPartition3() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegexConcat getRegexConcat() {
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("partition"), //
|
||||||
|
new RegexLeaf("[%s]+"), //
|
||||||
|
new RegexLeaf("BACKCOLOR", "(?:(#\\w+)[%s]+)?"), //
|
||||||
|
new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), //
|
||||||
|
new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
|
||||||
|
new RegexLeaf("[%s]*\\{?$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
|
||||||
|
final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
|
||||||
|
final HtmlColor backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACKCOLOR", 0));
|
||||||
|
final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet()
|
||||||
|
.getColorIfValid(arg.get("TITLECOLOR", 0));
|
||||||
|
diagram.startGroup(Display.getWithNewlines(partitionTitle), backColor, titleColor);
|
||||||
|
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class FtileGeometry extends Dimension2D {
|
||||||
|
|
||||||
|
private final double width;
|
||||||
|
private final double height;
|
||||||
|
private final double left;
|
||||||
|
private final double inY;
|
||||||
|
private final double outY;
|
||||||
|
|
||||||
|
public FtileGeometry(Dimension2D dim, double left, double inY) {
|
||||||
|
this(dim.getWidth(), dim.getHeight(), left, inY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry(double width, double height, double left, double inY) {
|
||||||
|
this(width, height, left, inY, Double.MIN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + width + "x" + height + " left=" + left + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSize(double width, double height) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry(double width, double height, double left, double inY, double outY) {
|
||||||
|
this.left = left;
|
||||||
|
this.inY = inY;
|
||||||
|
this.outY = outY;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry(Dimension2D dim, double left, double inY, double outY) {
|
||||||
|
this(dim.getWidth(), dim.getHeight(), left, inY, outY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPointOut() {
|
||||||
|
return outY != Double.MIN_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointIn() {
|
||||||
|
return new Point2D.Double(left, inY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointOut() {
|
||||||
|
if (outY == Double.MIN_NORMAL) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
return new Point2D.Double(left, outY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry withoutPointOut() {
|
||||||
|
return new FtileGeometry(width, height, left, inY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry translate(UTranslate translate) {
|
||||||
|
final double dx = translate.getDx();
|
||||||
|
final double dy = translate.getDy();
|
||||||
|
if (this.outY == Double.MIN_NORMAL) {
|
||||||
|
return new FtileGeometry(width, height, left + dx, inY + dy);
|
||||||
|
}
|
||||||
|
return new FtileGeometry(width, height, left + dx, inY + dy, outY + dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getInY() {
|
||||||
|
return inY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getLeft() {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getOutY() {
|
||||||
|
return outY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry addDim(double deltaWidth, double deltaHeight) {
|
||||||
|
return new FtileGeometry(width + deltaWidth, height + deltaHeight, left, inY, outY + deltaHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry addMarginX(double marginx) {
|
||||||
|
return new FtileGeometry(width + 2 * marginx, height, left + marginx, inY, outY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry fixedHeight(double fixedHeight) {
|
||||||
|
return new FtileGeometry(width, fixedHeight, left, inY, outY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry appendBottom(FtileGeometry other) {
|
||||||
|
return new FtileGeometryMerger(this, other).getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
public class FtileGeometryMerger {
|
||||||
|
|
||||||
|
private final FtileGeometry result;
|
||||||
|
|
||||||
|
public FtileGeometryMerger(FtileGeometry geo1, FtileGeometry geo2) {
|
||||||
|
final double left = Math.max(geo1.getLeft(), geo2.getLeft());
|
||||||
|
final double dx1 = left - geo1.getLeft();
|
||||||
|
final double dx2 = left - geo2.getLeft();
|
||||||
|
final double width = Math.max(geo1.getWidth() + dx1, geo2.getWidth() + dx2);
|
||||||
|
final double height = geo1.getHeight() + geo2.getHeight();
|
||||||
|
|
||||||
|
if (geo2.hasPointOut()) {
|
||||||
|
result = new FtileGeometry(width, height, left, geo1.getInY(), geo2.getOutY() + geo1.getHeight());
|
||||||
|
} else {
|
||||||
|
result = new FtileGeometry(width, height, left, geo1.getInY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final FtileGeometry getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
|
||||||
|
public class FtileGoto extends FtileEmpty {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public FtileGoto(boolean shadowing, Swimlane swimlane, String name) {
|
||||||
|
super(shadowing, swimlane);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
return super.calculateDimension(stringBounder).withoutPointOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
public class FtileLabel extends FtileEmpty {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public FtileLabel(boolean shadowing, Swimlane swimlane, String name) {
|
||||||
|
super(shadowing, swimlane);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class FtileMargedVertically extends FtileDecorate {
|
||||||
|
|
||||||
|
private final double margin1;
|
||||||
|
private final double margin2;
|
||||||
|
|
||||||
|
public FtileMargedVertically(Ftile tile, double margin1, double margin2) {
|
||||||
|
super(tile);
|
||||||
|
this.margin1 = margin1;
|
||||||
|
this.margin2 = margin2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
if (margin1 > 0) {
|
||||||
|
ug = ug.apply(new UTranslate(0, margin1));
|
||||||
|
}
|
||||||
|
ug.draw(getFtileDelegated());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry orig = getFtileDelegated().calculateDimension(stringBounder);
|
||||||
|
return new FtileGeometry(orig.getWidth(), orig.getHeight() + margin1 + margin2, orig.getLeft(), orig.getInY()
|
||||||
|
+ margin1, orig.getOutY() + margin1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Url;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class FtileWithUrl extends FtileDecorate {
|
||||||
|
|
||||||
|
private final Url url;
|
||||||
|
|
||||||
|
public FtileWithUrl(Ftile ftile, Url url) {
|
||||||
|
super(ftile);
|
||||||
|
if (url == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
ug.startUrl(url);
|
||||||
|
getFtileDelegated().drawU(ug);
|
||||||
|
ug.closeAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorGoto;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class GotoInterceptor implements TextBlock {
|
||||||
|
|
||||||
|
private final TextBlock swinlanes;
|
||||||
|
|
||||||
|
public GotoInterceptor(TextBlock swinlanes) {
|
||||||
|
this.swinlanes = swinlanes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
new UGraphicInterceptorGoto(ug).draw(swinlanes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return swinlanes.calculateDimension(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 10266 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class TextBlockInterceptorUDrawable implements TextBlock {
|
||||||
|
|
||||||
|
private final TextBlock textBlock;
|
||||||
|
|
||||||
|
public TextBlockInterceptorUDrawable(TextBlock textBlock) {
|
||||||
|
this.textBlock = textBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
textBlock.drawU(new UGraphicInterceptorUDrawable2(ug, new HashMap<String, UTranslate>()));
|
||||||
|
ug.flushUg();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return TextBlockUtils.getMinMax(this, stringBounder).getDimension();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 10266 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.graphic.UGraphicDelegator;
|
||||||
|
import net.sourceforge.plantuml.svek.UGraphicForSnake;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class UGraphicInterceptorUDrawable2 extends UGraphicDelegator {
|
||||||
|
|
||||||
|
private final Map<String, UTranslate> positions;
|
||||||
|
|
||||||
|
public UGraphicInterceptorUDrawable2(UGraphic ug, Map<String, UTranslate> positions) {
|
||||||
|
super(ug);
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(UShape shape) {
|
||||||
|
if (shape instanceof Ftile) {
|
||||||
|
final Ftile ftile = (Ftile) shape;
|
||||||
|
// System.err.println("ftile=" + ftile);
|
||||||
|
ftile.drawU(this);
|
||||||
|
if (ftile instanceof FtileLabel) {
|
||||||
|
positions.put(((FtileLabel) ftile).getName(), getPosition());
|
||||||
|
// System.err.println("ug=" + getUg().getClass());
|
||||||
|
}
|
||||||
|
if (ftile instanceof FtileGoto) {
|
||||||
|
// System.err.println("positions=" + positions);
|
||||||
|
drawGoto((FtileGoto) ftile);
|
||||||
|
}
|
||||||
|
} else if (shape instanceof UDrawable) {
|
||||||
|
final UDrawable drawable = (UDrawable) shape;
|
||||||
|
drawable.drawU(this);
|
||||||
|
} else {
|
||||||
|
getUg().draw(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getPosition() {
|
||||||
|
return ((UGraphicForSnake) getUg()).getTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawGoto(FtileGoto ftile) {
|
||||||
|
final FtileGeometry geom = ftile.calculateDimension(getStringBounder());
|
||||||
|
final Point2D pt = geom.getPointIn();
|
||||||
|
UGraphic ugGoto = getUg().apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
|
||||||
|
new UChangeBackColor(HtmlColorUtils.GREEN));
|
||||||
|
ugGoto = ugGoto.apply(new UTranslate(pt));
|
||||||
|
final UTranslate posNow = getPosition();
|
||||||
|
final UTranslate dest = positions.get(ftile.getName());
|
||||||
|
final double dx = dest.getDx() - posNow.getDx();
|
||||||
|
final double dy = dest.getDy() - posNow.getDy();
|
||||||
|
ugGoto.draw(new UEllipse(3, 3));
|
||||||
|
ugGoto.apply(new UTranslate(dx, dy)).draw(new UEllipse(3, 3));
|
||||||
|
ugGoto.draw(new ULine(dx, 0));
|
||||||
|
ugGoto.apply(new UTranslate(dx, 0)).draw(new ULine(0, dy));
|
||||||
|
// ugGoto.draw(new ULine(dx, dy));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UGraphic apply(UChange change) {
|
||||||
|
return new UGraphicInterceptorUDrawable2(getUg().apply(change), positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
|
import net.sourceforge.plantuml.FontParam;
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.creole.CreoleParser;
|
||||||
|
import net.sourceforge.plantuml.creole.Sheet;
|
||||||
|
import net.sourceforge.plantuml.creole.SheetBlock1;
|
||||||
|
import net.sourceforge.plantuml.creole.SheetBlock2;
|
||||||
|
import net.sourceforge.plantuml.creole.Stencil;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.skin.rose.Rose;
|
||||||
|
import net.sourceforge.plantuml.svek.image.Opale;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
|
||||||
|
public class FloatingNote implements Stencil, TextBlock {
|
||||||
|
|
||||||
|
private final Opale opale;
|
||||||
|
|
||||||
|
public FloatingNote(Display note, ISkinParam skinParam) {
|
||||||
|
|
||||||
|
final Rose rose = new Rose();
|
||||||
|
final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
|
||||||
|
final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
|
||||||
|
|
||||||
|
final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground);
|
||||||
|
final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder);
|
||||||
|
|
||||||
|
final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
|
||||||
|
|
||||||
|
final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note);
|
||||||
|
final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
|
||||||
|
this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(), false);
|
||||||
|
|
||||||
|
// this.text = sheetBlock2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
opale.drawU(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return opale.calculateDimension(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingX(StringBounder stringBounder, double y) {
|
||||||
|
return -opale.getMarginX1();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndingX(StringBounder stringBounder, double y) {
|
||||||
|
return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.Url;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithUrl;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox;
|
||||||
|
|
||||||
|
public class FtileFactoryDelegatorAddUrl extends FtileFactoryDelegator {
|
||||||
|
|
||||||
|
public FtileFactoryDelegatorAddUrl(FtileFactory factory, ISkinParam skinParam) {
|
||||||
|
super(factory, skinParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Ftile addUrl(Ftile ftile, Url url) {
|
||||||
|
if (ftile instanceof FtileBox) {
|
||||||
|
return new FtileWithUrl(ftile, url);
|
||||||
|
}
|
||||||
|
return ftile;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,318 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.FontParam;
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
|
||||||
|
import net.sourceforge.plantuml.creole.CreoleParser;
|
||||||
|
import net.sourceforge.plantuml.creole.Sheet;
|
||||||
|
import net.sourceforge.plantuml.creole.SheetBlock1;
|
||||||
|
import net.sourceforge.plantuml.creole.SheetBlock2;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.svek.ConditionStyle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
class FtileIfAndStop extends AbstractFtile {
|
||||||
|
|
||||||
|
private final Ftile tile1;
|
||||||
|
private final Ftile diamond1;
|
||||||
|
private final Ftile stop2;
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
private FtileIfAndStop(Ftile diamond1, Ftile tile1, HtmlColor arrowColor, Ftile stopFtile) {
|
||||||
|
super(tile1.shadowing());
|
||||||
|
this.diamond1 = diamond1;
|
||||||
|
this.tile1 = tile1;
|
||||||
|
this.stop2 = stopFtile;
|
||||||
|
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||||
|
if (getSwimlaneIn() != null) {
|
||||||
|
result.add(getSwimlaneIn());
|
||||||
|
}
|
||||||
|
result.addAll(tile1.getSwimlanes());
|
||||||
|
return Collections.unmodifiableSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return diamond1.getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, UFont fontTest,
|
||||||
|
HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch nonStop,
|
||||||
|
ISkinParam skinParam, StringBounder stringBounder, Display labelTest) {
|
||||||
|
|
||||||
|
backColor = HtmlColorUtils.BLUE;
|
||||||
|
|
||||||
|
// final Ftile tileNonStop = new FtileMinWidth(nonStop.getFtile(), 30);
|
||||||
|
final Ftile tileNonStop = nonStop.getFtile();
|
||||||
|
|
||||||
|
final HtmlColor fontColor = skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null);
|
||||||
|
|
||||||
|
final FontConfiguration fcArrow = new FontConfiguration(fontArrow, fontColor, skinParam.getHyperlinkColor(),
|
||||||
|
skinParam.useUnderlineForHyperlink());
|
||||||
|
final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor, skinParam.getHyperlinkColor(),
|
||||||
|
skinParam.useUnderlineForHyperlink());
|
||||||
|
|
||||||
|
final Ftile stopFtile = ftileFactory.stop(swimlane);
|
||||||
|
|
||||||
|
// final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
|
||||||
|
// ftileFactory);
|
||||||
|
// final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
|
||||||
|
// ftileFactory);
|
||||||
|
|
||||||
|
final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest);
|
||||||
|
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
|
||||||
|
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5));
|
||||||
|
|
||||||
|
final Ftile diamond1;
|
||||||
|
if (conditionStyle == ConditionStyle.INSIDE) {
|
||||||
|
diamond1 = new FtileDiamondInside(tileNonStop.shadowing(), backColor, borderColor, swimlane, tbTest);
|
||||||
|
// .withWest(tb1).withEast(tb2);
|
||||||
|
} else if (conditionStyle == ConditionStyle.DIAMOND) {
|
||||||
|
diamond1 = new FtileDiamond(tileNonStop.shadowing(), backColor, borderColor, swimlane).withNorth(tbTest);
|
||||||
|
// .withWest(tb1).withEast(tb2).withNorth(tbTest);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// final Ftile diamond2;
|
||||||
|
// if (tile1.calculateDimension(stringBounder).hasPointOut()
|
||||||
|
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
// diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane);
|
||||||
|
// } else {
|
||||||
|
// diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
|
||||||
|
// swimlane, swimlane);
|
||||||
|
// }
|
||||||
|
final FtileIfAndStop result = new FtileIfAndStop(diamond1, tileNonStop, arrowColor, stopFtile);
|
||||||
|
|
||||||
|
final List<Connection> conns = new ArrayList<Connection>();
|
||||||
|
conns.add(result.new ConnectionHorizontal(arrowColor));
|
||||||
|
// conns.add(result.new ConnectionHorizontalThenVertical(tile2));
|
||||||
|
// if (tile1.calculateDimension(stringBounder).hasPointOut()
|
||||||
|
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
// conns.add(result.new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor()));
|
||||||
|
// conns.add(result.new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor()));
|
||||||
|
// } else if (tile1.calculateDimension(stringBounder).hasPointOut()
|
||||||
|
// && tile2.calculateDimension(stringBounder).hasPointOut() == false) {
|
||||||
|
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor()));
|
||||||
|
// } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false
|
||||||
|
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor()));
|
||||||
|
// }
|
||||||
|
return FtileUtils.addConnection(result, conns);
|
||||||
|
// return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslate1(StringBounder stringBounder) {
|
||||||
|
// final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
final FtileGeometry dimTotal = calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
final double x1 = calculateDimension(stringBounder).getLeft() - dim1.getLeft();
|
||||||
|
// final double y1 = (dimTotal.getHeight() - 2 * h - dim1.getHeight()) / 2 + h;
|
||||||
|
final double y1 = dimDiamond1.getHeight() + getSuppHeight();
|
||||||
|
return new UTranslate(x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSuppHeight() {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
|
||||||
|
final double y1 = 0;
|
||||||
|
final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||||
|
// final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2;
|
||||||
|
final double x1 = calculateDimension(stringBounder).getLeft() - dimDiamond1.getWidth() / 2;
|
||||||
|
return new UTranslate(x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslateStop(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||||
|
final Dimension2D dimStop = stop2.calculateDimension(stringBounder);
|
||||||
|
final double y1 = (dimDiamond1.getHeight() - dimStop.getHeight()) / 2;
|
||||||
|
final double x1 = calculateDimension(stringBounder).getLeft() + dimDiamond1.getWidth() / 2
|
||||||
|
+ getDiamondStopDistance();
|
||||||
|
return new UTranslate(x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getDiamondStopDistance() {
|
||||||
|
return 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionHorizontal extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionHorizontal(HtmlColor color) {
|
||||||
|
super(diamond1, stop2);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
final Point2D p2 = getP2(stringBounder);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToRight());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimDiamond1 = getFtile1().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
|
||||||
|
|
||||||
|
return getTranslateDiamond1(stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP2(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimStop = getFtile2().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(0, dimStop.getHeight() / 2);
|
||||||
|
return getTranslateStop(stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||||
|
if (child == diamond1) {
|
||||||
|
return getTranslateDiamond1(stringBounder);
|
||||||
|
}
|
||||||
|
if (child == tile1) {
|
||||||
|
return getTranslate1(stringBounder);
|
||||||
|
}
|
||||||
|
// if (child == tile2) {
|
||||||
|
// return getTranslate2(stringBounder);
|
||||||
|
// }
|
||||||
|
// if (child == diamond2) {
|
||||||
|
// return getTranslateDiamond2(stringBounder);
|
||||||
|
// }
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
|
||||||
|
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
|
||||||
|
ug.apply(getTranslate1(stringBounder)).draw(tile1);
|
||||||
|
ug.apply(getTranslateStop(stringBounder)).draw(stop2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder).addDim(0,
|
||||||
|
getDiamondStopDistance() + dimStop2.getWidth());
|
||||||
|
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||||
|
return dimDiamond1.appendBottom(dim1).addDim(0, getSuppHeight());
|
||||||
|
|
||||||
|
// final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
// if (tile1.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
// return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
|
||||||
|
// }
|
||||||
|
// return new FtileGeometry(dimTotal, getLeft(stringBounder), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// private Dimension2D calculateDimensionInternal;
|
||||||
|
//
|
||||||
|
// private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
|
||||||
|
// if (calculateDimensionInternal == null) {
|
||||||
|
// calculateDimensionInternal = calculateDimensionInternalSlow(stringBounder);
|
||||||
|
// }
|
||||||
|
// return calculateDimensionInternal;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) {
|
||||||
|
// final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
|
||||||
|
// final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||||
|
// final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
|
||||||
|
// final double width = Math.max(dim1.getWidth(),
|
||||||
|
// dimDiamond1.getWidth() + getDiamondStopDistance() + dimStop2.getWidth());
|
||||||
|
// return new Dimension2DDouble(width + 30, dim1.getHeight() + dimDiamond1.getHeight() + 40);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private double getLeft(StringBounder stringBounder) {
|
||||||
|
// // return calculateDimension(stringBounder).getLeft();
|
||||||
|
// return tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
|
||||||
|
// // final double left1 =
|
||||||
|
// tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
|
||||||
|
// // // final double left2 =
|
||||||
|
// // // tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
|
||||||
|
// // // return (left1 + left2) / 2;
|
||||||
|
// // return left1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,515 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.svek.ConditionStyle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
class FtileIfLong extends AbstractFtile {
|
||||||
|
|
||||||
|
private final double xSeparation = 20;
|
||||||
|
|
||||||
|
private final List<Ftile> tiles;
|
||||||
|
private final Ftile tile2;
|
||||||
|
private final List<Ftile> diamonds;
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
private FtileIfLong(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, HtmlColor arrowColor) {
|
||||||
|
super(tiles.get(0).shadowing() || tile2.shadowing());
|
||||||
|
this.diamonds = diamonds;
|
||||||
|
this.tiles = tiles;
|
||||||
|
this.tile2 = tile2;
|
||||||
|
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||||
|
if (getSwimlaneIn() != null) {
|
||||||
|
result.add(getSwimlaneIn());
|
||||||
|
}
|
||||||
|
for (Ftile tile : tiles) {
|
||||||
|
result.addAll(tile.getSwimlanes());
|
||||||
|
}
|
||||||
|
result.addAll(tile2.getSwimlanes());
|
||||||
|
return Collections.unmodifiableSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return diamonds.get(0).getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
|
||||||
|
HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens,
|
||||||
|
Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
|
||||||
|
|
||||||
|
final List<Ftile> tiles = new ArrayList<Ftile>();
|
||||||
|
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
tiles.add(new FtileMinWidth(branch.getFtile(), 30));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
|
||||||
|
|
||||||
|
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
|
||||||
|
useUnderlineForHyperlink);
|
||||||
|
|
||||||
|
final List<Ftile> diamonds = new ArrayList<Ftile>();
|
||||||
|
final List<Connection> conns = new ArrayList<Connection>();
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
FtileDiamondInside diamond = new FtileDiamondInside(branch.shadowing(), backColor, borderColor, swimlane,
|
||||||
|
tbTest);
|
||||||
|
diamond = diamond.withNorth(tb1);
|
||||||
|
diamonds.add(diamond);
|
||||||
|
}
|
||||||
|
|
||||||
|
final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
final int last = diamonds.size() - 1;
|
||||||
|
diamonds.set(last, ((FtileDiamondInside) diamonds.get(last)).withEast(tb2));
|
||||||
|
|
||||||
|
final FtileIfLong result = new FtileIfLong(diamonds, tiles, tile2, arrowColor);
|
||||||
|
|
||||||
|
for (int i = 0; i < thens.size(); i++) {
|
||||||
|
final Ftile ftile = tiles.get(i);
|
||||||
|
final Ftile diam = diamonds.get(i);
|
||||||
|
|
||||||
|
final HtmlColor color = thens.get(i).getInlinkRenderingColor();
|
||||||
|
conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
|
||||||
|
conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < diamonds.size() - 1; i++) {
|
||||||
|
final Ftile diam1 = diamonds.get(i);
|
||||||
|
final Ftile diam2 = diamonds.get(i + 1);
|
||||||
|
conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
|
||||||
|
}
|
||||||
|
conns.add(result.new ConnectionIn(arrowColor));
|
||||||
|
conns.add(result.new ConnectionLastElseIn(arrowColor));
|
||||||
|
conns.add(result.new ConnectionLastElseOut(arrowColor));
|
||||||
|
conns.add(result.new ConnectionHline(arrowColor));
|
||||||
|
|
||||||
|
return FtileUtils.addConnection(result, conns);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionHorizontal extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
|
||||||
|
super(diam1, diam2);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
final Point2D p2 = getP2(stringBounder);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToRight());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
|
||||||
|
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP2(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(0, dimDiamond1.getOutY() / 2);
|
||||||
|
return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionIn(HtmlColor arrowColor) {
|
||||||
|
super(null, diamonds.get(0));
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
|
||||||
|
final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
final Point2D p1 = calculateDimension(ug.getStringBounder()).getPointIn();
|
||||||
|
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2.getX(), p1.getY());
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionLastElseIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionLastElseIn(HtmlColor arrowColor) {
|
||||||
|
super(diamonds.get(diamonds.size() - 1), tile2);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final Point2D p1 = getP1(ug.getStringBounder());
|
||||||
|
final UTranslate tr2 = getTranslate2(ug.getStringBounder());
|
||||||
|
final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2.getX(), p1.getY());
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionLastElseOut extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionLastElseOut(HtmlColor arrowColor) {
|
||||||
|
super(tile2, null);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final UTranslate tr1 = getTranslate2(stringBounder);
|
||||||
|
final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
|
||||||
|
if (dim.hasPointOut() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Point2D p1 = tr1.getTranslated(dim.getPointOut());
|
||||||
|
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
|
||||||
|
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionVerticalIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
|
||||||
|
super(diamond, tile);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
final Point2D p2 = getP2(stringBounder);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP2(StringBounder stringBounder) {
|
||||||
|
final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
|
||||||
|
return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionVerticalOut extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
|
||||||
|
super(tile, null);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
if (p1 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
|
||||||
|
if (geo.hasPointOut() == false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Point2D p = geo.getPointOut();
|
||||||
|
return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionHline extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionHline(HtmlColor arrowColor) {
|
||||||
|
super(null, null);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
|
||||||
|
|
||||||
|
final List<Ftile> all = new ArrayList<Ftile>(tiles);
|
||||||
|
all.add(tile2);
|
||||||
|
double minX = totalDim.getWidth() / 2;
|
||||||
|
double maxX = totalDim.getWidth() / 2;
|
||||||
|
for (Ftile tmp : all) {
|
||||||
|
if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final UTranslate ut = getTranslateFor(tmp, stringBounder);
|
||||||
|
final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
|
||||||
|
minX = Math.min(minX, out);
|
||||||
|
maxX = Math.max(maxX, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Snake s = new Snake(arrowColor);
|
||||||
|
s.goUnmergeable();
|
||||||
|
final double height = totalDim.getHeight();
|
||||||
|
s.addPoint(minX, height);
|
||||||
|
s.addPoint(maxX, height);
|
||||||
|
ug.draw(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||||
|
if (child == tile2) {
|
||||||
|
return getTranslate2(stringBounder);
|
||||||
|
}
|
||||||
|
if (tiles.contains(child)) {
|
||||||
|
return getTranslate1(child, stringBounder);
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslate2(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
final double x2 = dimTotal.getWidth() - dim2.getWidth();
|
||||||
|
|
||||||
|
final double h = getAllDiamondsHeight(stringBounder);
|
||||||
|
final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
|
||||||
|
|
||||||
|
return new UTranslate(x2, y2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslateDiamond1(Ftile diamond1, StringBounder stringBounder) {
|
||||||
|
double x1 = 0;
|
||||||
|
|
||||||
|
for (Ftile diamond : diamonds) {
|
||||||
|
final FtileGeometry dim1 = dimDiamondAndTile(stringBounder, diamond);
|
||||||
|
if (diamond == diamond1) {
|
||||||
|
final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
|
||||||
|
double xresult = x1 + dim1.getLeft() - dimDiamond.getLeft();
|
||||||
|
return new UTranslate(xresult, 25);
|
||||||
|
}
|
||||||
|
x1 += dim1.getWidth() + xSeparation;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslate1(Ftile tile1, StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
double x1 = 0;
|
||||||
|
|
||||||
|
for (Ftile tile : tiles) {
|
||||||
|
final Dimension2D dim1 = dimDiamondAndTile(stringBounder, tile);
|
||||||
|
if (tile == tile1) {
|
||||||
|
final Dimension2D dimTile = tile.calculateDimension(stringBounder);
|
||||||
|
final double h = getAllDiamondsHeight(stringBounder);
|
||||||
|
final double y1 = (dimTotal.getHeight() - 2 * h - dimTile.getHeight()) / 2 + h;
|
||||||
|
return new UTranslate(x1 + (dim1.getWidth() - dimTile.getWidth()) / 2, y1);
|
||||||
|
}
|
||||||
|
x1 += dim1.getWidth() + xSeparation;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
for (Ftile tile : tiles) {
|
||||||
|
ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
|
||||||
|
}
|
||||||
|
for (Ftile diamond : diamonds) {
|
||||||
|
ug.apply(getTranslateDiamond1(diamond, stringBounder)).draw(diamond);
|
||||||
|
}
|
||||||
|
|
||||||
|
ug.apply(getTranslate2(stringBounder)).draw(tile2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
|
||||||
|
final List<Ftile> all = new ArrayList<Ftile>(tiles);
|
||||||
|
all.add(tile2);
|
||||||
|
for (Ftile tmp : all) {
|
||||||
|
if (tmp.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private FtileGeometry dimDiamondAndTile(StringBounder stringBounder, Ftile tileOrDiamond) {
|
||||||
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
|
final Ftile tile = tiles.get(i);
|
||||||
|
final Ftile diamond = diamonds.get(i);
|
||||||
|
if (tile != tileOrDiamond && diamond != tileOrDiamond) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
|
||||||
|
return dimDiamond.appendBottom(dimTile);
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
|
||||||
|
Dimension2D dimOnlyTiles = new Dimension2DDouble(0, 0);
|
||||||
|
Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
|
||||||
|
Dimension2D dimBoth = new Dimension2DDouble(0, 0);
|
||||||
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
|
final Ftile tile = tiles.get(i);
|
||||||
|
final Ftile diamond = diamonds.get(i);
|
||||||
|
final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
|
||||||
|
final FtileGeometry both = dimDiamond.appendBottom(dimTile);
|
||||||
|
dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile);
|
||||||
|
dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
|
||||||
|
dimBoth = Dimension2DDouble.mergeLR(dimBoth, both);
|
||||||
|
}
|
||||||
|
final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
|
||||||
|
dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile2);
|
||||||
|
dimBoth = Dimension2DDouble.mergeLR(dimBoth, dimTile2);
|
||||||
|
|
||||||
|
final Dimension2D result = new Dimension2DDouble(dimBoth.getWidth(), dimOnlyDiamond.getHeight() * 4
|
||||||
|
+ dimOnlyTiles.getHeight());
|
||||||
|
return Dimension2DDouble.delta(result, xSeparation * tiles.size(), 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getAllDiamondsHeight(StringBounder stringBounder) {
|
||||||
|
Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
|
||||||
|
for (Ftile diamond : diamonds) {
|
||||||
|
final Dimension2D dimDiamond = diamond.calculateDimension(stringBounder);
|
||||||
|
dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
|
||||||
|
}
|
||||||
|
return dimOnlyDiamond.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,510 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.svek.ConditionStyle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
class FtileIfLong2 extends AbstractFtile {
|
||||||
|
|
||||||
|
private final double xSeparation = 20;
|
||||||
|
|
||||||
|
private final List<Ftile> tiles;
|
||||||
|
private final Ftile tile2;
|
||||||
|
private final List<Ftile> diamonds;
|
||||||
|
private final List<Ftile> couples = new ArrayList<Ftile>();
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
private FtileIfLong2(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, HtmlColor arrowColor) {
|
||||||
|
super(tiles.get(0).shadowing() || tile2.shadowing());
|
||||||
|
if (diamonds.size() != tiles.size()) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < diamonds.size(); i++) {
|
||||||
|
couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i)));
|
||||||
|
}
|
||||||
|
this.tile2 = tile2;
|
||||||
|
this.diamonds = new ArrayList<Ftile>(diamonds);
|
||||||
|
this.tiles = new ArrayList<Ftile>(tiles);
|
||||||
|
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Ftile> alignDiamonds(List<Ftile> diamonds, StringBounder stringBounder) {
|
||||||
|
double maxOutY = 0;
|
||||||
|
for (Ftile diamond : diamonds) {
|
||||||
|
maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
|
||||||
|
}
|
||||||
|
final List<Ftile> result = new ArrayList<Ftile>();
|
||||||
|
for (int i = 0; i < diamonds.size(); i++) {
|
||||||
|
Ftile diamond = diamonds.get(i);
|
||||||
|
final double missing = maxOutY - diamond.calculateDimension(stringBounder).getOutY();
|
||||||
|
assert missing >= 0;
|
||||||
|
diamond = FtileUtils.addVerticalMargin(diamond, missing / 2, 20);
|
||||||
|
result.add(diamond);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||||
|
if (getSwimlaneIn() != null) {
|
||||||
|
result.add(getSwimlaneIn());
|
||||||
|
}
|
||||||
|
for (Ftile tile : couples) {
|
||||||
|
result.addAll(tile.getSwimlanes());
|
||||||
|
}
|
||||||
|
result.addAll(tile2.getSwimlanes());
|
||||||
|
return Collections.unmodifiableSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return couples.get(0).getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
|
||||||
|
HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens,
|
||||||
|
Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
|
||||||
|
|
||||||
|
final List<Ftile> tiles = new ArrayList<Ftile>();
|
||||||
|
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
tiles.add(new FtileMinWidth(branch.getFtile(), 30));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
|
||||||
|
|
||||||
|
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
|
||||||
|
useUnderlineForHyperlink);
|
||||||
|
|
||||||
|
List<Ftile> diamonds = new ArrayList<Ftile>();
|
||||||
|
final List<Connection> conns = new ArrayList<Connection>();
|
||||||
|
for (Branch branch : thens) {
|
||||||
|
final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.shadowing(), backColor, borderColor, swimlane,
|
||||||
|
tbTest);
|
||||||
|
diamond = diamond.withNorth(tb1);
|
||||||
|
diamonds.add(diamond);
|
||||||
|
}
|
||||||
|
|
||||||
|
final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
|
||||||
|
ftileFactory);
|
||||||
|
final int last = diamonds.size() - 1;
|
||||||
|
diamonds.set(last, ((FtileDiamondInside2) diamonds.get(last)).withEast(tb2));
|
||||||
|
|
||||||
|
diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder());
|
||||||
|
|
||||||
|
final FtileIfLong2 result = new FtileIfLong2(diamonds, tiles, tile2, arrowColor);
|
||||||
|
|
||||||
|
for (int i = 0; i < thens.size(); i++) {
|
||||||
|
final Ftile ftile = tiles.get(i);
|
||||||
|
final Ftile diam = diamonds.get(i);
|
||||||
|
|
||||||
|
final HtmlColor color = thens.get(i).getInlinkRenderingColor();
|
||||||
|
conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
|
||||||
|
conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < diamonds.size() - 1; i++) {
|
||||||
|
final Ftile diam1 = diamonds.get(i);
|
||||||
|
final Ftile diam2 = diamonds.get(i + 1);
|
||||||
|
conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
|
||||||
|
}
|
||||||
|
conns.add(result.new ConnectionIn(arrowColor));
|
||||||
|
conns.add(result.new ConnectionLastElseIn(arrowColor));
|
||||||
|
conns.add(result.new ConnectionLastElseOut(arrowColor));
|
||||||
|
conns.add(result.new ConnectionHline(arrowColor));
|
||||||
|
|
||||||
|
return FtileUtils.addConnection(result, conns);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionHorizontal extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
|
||||||
|
super(diam1, diam2);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
final Point2D p2 = getP2(stringBounder);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToRight());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
|
||||||
|
stringBounder));
|
||||||
|
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP2(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(0, getYdiamontOutToLeft(dimDiamond1, stringBounder));
|
||||||
|
return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static private double getYdiamontOutToLeft(FtileGeometry dimDiamond1, StringBounder stringBounder) {
|
||||||
|
return (dimDiamond1.getInY() + dimDiamond1.getOutY()) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionIn(HtmlColor arrowColor) {
|
||||||
|
super(null, diamonds.get(0));
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
|
||||||
|
final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
final Point2D p1 = calculateDimensionInternal(ug.getStringBounder()).getPointIn();
|
||||||
|
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2.getX(), p1.getY());
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionLastElseIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionLastElseIn(HtmlColor arrowColor) {
|
||||||
|
super(diamonds.get(diamonds.size() - 1), tile2);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final Point2D p1 = getP1(ug.getStringBounder());
|
||||||
|
final UTranslate tr2 = getTranslate2(ug.getStringBounder());
|
||||||
|
final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2.getX(), p1.getY());
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
|
||||||
|
final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
|
||||||
|
stringBounder));
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionLastElseOut extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionLastElseOut(HtmlColor arrowColor) {
|
||||||
|
super(tile2, null);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final UTranslate tr1 = getTranslate2(stringBounder);
|
||||||
|
final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
|
||||||
|
if (dim.hasPointOut() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Point2D p1 = tr1.getTranslated(dim.getPointOut());
|
||||||
|
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
|
||||||
|
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionVerticalIn extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
|
||||||
|
super(diamond, tile);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
final Point2D p2 = getP2(stringBounder);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
|
||||||
|
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP2(StringBounder stringBounder) {
|
||||||
|
final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
|
||||||
|
return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionVerticalOut extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor color;
|
||||||
|
|
||||||
|
public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
|
||||||
|
super(tile, null);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
|
||||||
|
final Point2D p1 = getP1(stringBounder);
|
||||||
|
if (p1 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
|
||||||
|
|
||||||
|
final Snake snake = new Snake(color, Arrows.asToDown());
|
||||||
|
snake.addPoint(p1);
|
||||||
|
snake.addPoint(p2);
|
||||||
|
ug.draw(snake);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getP1(StringBounder stringBounder) {
|
||||||
|
final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
|
||||||
|
if (geo.hasPointOut() == false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Point2D p = geo.getPointOut();
|
||||||
|
return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionHline extends AbstractConnection {
|
||||||
|
|
||||||
|
private final HtmlColor arrowColor;
|
||||||
|
|
||||||
|
public ConnectionHline(HtmlColor arrowColor) {
|
||||||
|
super(null, null);
|
||||||
|
this.arrowColor = arrowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
|
||||||
|
|
||||||
|
final List<Ftile> all = new ArrayList<Ftile>(couples);
|
||||||
|
all.add(tile2);
|
||||||
|
double minX = totalDim.getWidth() / 2;
|
||||||
|
double maxX = totalDim.getWidth() / 2;
|
||||||
|
for (Ftile tmp : all) {
|
||||||
|
if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final UTranslate ut = getTranslateFor(tmp, stringBounder);
|
||||||
|
final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
|
||||||
|
minX = Math.min(minX, out);
|
||||||
|
maxX = Math.max(maxX, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Snake s = new Snake(arrowColor);
|
||||||
|
s.goUnmergeable();
|
||||||
|
final double height = totalDim.getHeight();
|
||||||
|
s.addPoint(minX, height);
|
||||||
|
s.addPoint(maxX, height);
|
||||||
|
ug.draw(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||||
|
if (child == tile2) {
|
||||||
|
return getTranslate2(stringBounder);
|
||||||
|
}
|
||||||
|
if (couples.contains(child)) {
|
||||||
|
return getTranslateCouple1(child, stringBounder);
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslate2(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
final double x2 = dimTotal.getWidth() - dim2.getWidth();
|
||||||
|
|
||||||
|
final double h = 0; // getAllDiamondsHeight(stringBounder);
|
||||||
|
final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
|
||||||
|
|
||||||
|
return new UTranslate(x2, y2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslateDiamond1(Ftile diamond, StringBounder stringBounder) {
|
||||||
|
final int idx = diamonds.indexOf(diamond);
|
||||||
|
if (idx == -1) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
|
||||||
|
final UTranslate in = couples.get(idx).getTranslateFor(diamond, stringBounder);
|
||||||
|
return trCouple.compose(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
|
||||||
|
final int idx = tiles.indexOf(tile);
|
||||||
|
if (idx == -1) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
|
||||||
|
final UTranslate in = couples.get(idx).getTranslateFor(tile, stringBounder);
|
||||||
|
return trCouple.compose(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UTranslate getTranslateCouple1(Ftile candidat, StringBounder stringBounder) {
|
||||||
|
double x1 = 0;
|
||||||
|
|
||||||
|
for (Ftile couple : couples) {
|
||||||
|
final FtileGeometry dim1 = couple.calculateDimension(stringBounder);
|
||||||
|
if (couple == candidat) {
|
||||||
|
return new UTranslate(x1, 25);
|
||||||
|
}
|
||||||
|
x1 += dim1.getWidth() + xSeparation;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
for (Ftile couple : couples) {
|
||||||
|
ug.apply(getTranslateCouple1(couple, stringBounder)).draw(couple);
|
||||||
|
}
|
||||||
|
|
||||||
|
ug.apply(getTranslate2(stringBounder)).draw(tile2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
|
||||||
|
Dimension2D result = new Dimension2DDouble(0, 0);
|
||||||
|
for (Ftile couple : couples) {
|
||||||
|
result = Dimension2DDouble.mergeLR(result, couple.calculateDimension(stringBounder));
|
||||||
|
}
|
||||||
|
final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
|
||||||
|
result = Dimension2DDouble.mergeLR(result, dimTile2);
|
||||||
|
result = Dimension2DDouble.delta(result, xSeparation * couples.size(), 100);
|
||||||
|
|
||||||
|
return new FtileGeometry(result, result.getWidth() / 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
|
||||||
|
|
||||||
|
final List<Ftile> all = new ArrayList<Ftile>(tiles);
|
||||||
|
all.add(tile2);
|
||||||
|
for (Ftile tmp : all) {
|
||||||
|
if (tmp.calculateDimension(stringBounder).hasPointOut()) {
|
||||||
|
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8475 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
class FtileSplit1 extends AbstractFtile {
|
||||||
|
|
||||||
|
private final List<Ftile> forks = new ArrayList<Ftile>();
|
||||||
|
|
||||||
|
public FtileSplit1(List<Ftile> forks) {
|
||||||
|
super(forks.get(0).shadowing());
|
||||||
|
for (Ftile ftile : forks) {
|
||||||
|
this.forks.add(ftile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return forks.get(0).getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return null;
|
||||||
|
// return getSwimlaneIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
return mergeSwimlanes(forks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<Swimlane> mergeSwimlanes(List<Ftile> tiles) {
|
||||||
|
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||||
|
for (Ftile tile : tiles) {
|
||||||
|
result.addAll(tile.getSwimlanes());
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
|
||||||
|
for (Ftile ftile : forks) {
|
||||||
|
ug.apply(getTranslateFor(ftile, stringBounder)).draw(ftile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
double height = 0;
|
||||||
|
double width = 0;
|
||||||
|
for (Ftile ftile : forks) {
|
||||||
|
final Dimension2D dim = ftile.calculateDimension(stringBounder);
|
||||||
|
if (dim.getWidth() > width) {
|
||||||
|
width = dim.getWidth();
|
||||||
|
}
|
||||||
|
if (dim.getHeight() > height) {
|
||||||
|
height = dim.getHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Dimension2D dimTotal = new Dimension2DDouble(width, height);
|
||||||
|
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) {
|
||||||
|
final Dimension2D dim = searched.calculateDimension(stringBounder);
|
||||||
|
final double xpos = calculateDimension(stringBounder).getWidth() - dim.getWidth();
|
||||||
|
return new UTranslate(xpos / 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 10266 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||||
|
import net.sourceforge.plantuml.graphic.UGraphicDelegator;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
|
|
||||||
|
public class UGraphicInterceptorGoto extends UGraphicDelegator {
|
||||||
|
|
||||||
|
public UGraphicInterceptorGoto(UGraphic ug) {
|
||||||
|
super(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(UShape shape) {
|
||||||
|
System.err.println("inter=" + shape.getClass());
|
||||||
|
|
||||||
|
if (shape instanceof Ftile) {
|
||||||
|
final Ftile foo = (Ftile) shape;
|
||||||
|
foo.drawU(this);
|
||||||
|
} else {
|
||||||
|
getUg().draw(shape);
|
||||||
|
System.err.println("Drawing " + shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UGraphic apply(UChange change) {
|
||||||
|
return new UGraphicInterceptorGoto(getUg().apply(change));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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.activitydiagram3.ftile.vertical;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class FtileDiamondInside2 extends AbstractFtile {
|
||||||
|
|
||||||
|
private final HtmlColor backColor;
|
||||||
|
private final HtmlColor borderColor;
|
||||||
|
private final Swimlane swimlane;
|
||||||
|
private final TextBlock label;
|
||||||
|
private final TextBlock west;
|
||||||
|
private final TextBlock east;
|
||||||
|
private final TextBlock north;
|
||||||
|
private final TextBlock south;
|
||||||
|
|
||||||
|
public FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
|
||||||
|
TextBlock label) {
|
||||||
|
this(shadowing, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
|
||||||
|
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileDiamondInside2 withNorth(TextBlock north) {
|
||||||
|
return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileDiamondInside2 withWest(TextBlock west) {
|
||||||
|
return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileDiamondInside2 withEast(TextBlock east) {
|
||||||
|
return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileDiamondInside2 withSouth(TextBlock south) {
|
||||||
|
return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
|
||||||
|
TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
|
||||||
|
super(shadowing);
|
||||||
|
this.backColor = backColor;
|
||||||
|
this.swimlane = swimlane;
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
this.label = label;
|
||||||
|
this.west = west;
|
||||||
|
this.east = east;
|
||||||
|
this.north = north;
|
||||||
|
this.south = south;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Swimlane> getSwimlanes() {
|
||||||
|
if (swimlane == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
return Collections.singleton(swimlane);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneIn() {
|
||||||
|
return swimlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Swimlane getSwimlaneOut() {
|
||||||
|
return swimlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
|
||||||
|
final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
|
||||||
|
ug = ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor));
|
||||||
|
ug.draw(Diamond.asPolygon(shadowing(), dimTotal.getWidth(), dimTotal.getHeight()));
|
||||||
|
|
||||||
|
north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
|
||||||
|
south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
|
||||||
|
|
||||||
|
final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
|
||||||
|
final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
|
||||||
|
label.drawU(ug.apply(new UTranslate(lx, ly)));
|
||||||
|
|
||||||
|
final Dimension2D dimWeat = west.calculateDimension(stringBounder);
|
||||||
|
west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2)));
|
||||||
|
|
||||||
|
final Dimension2D dimEast = east.calculateDimension(stringBounder);
|
||||||
|
east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||||
|
final Dimension2D diamond = calculateDimensionAlone(stringBounder);
|
||||||
|
final Dimension2D north = this.north.calculateDimension(stringBounder);
|
||||||
|
final double height = diamond.getHeight() + north.getHeight();
|
||||||
|
final double left = diamond.getWidth() / 2;
|
||||||
|
final double width = north.getWidth() > left ? left + north.getWidth() : diamond.getWidth();
|
||||||
|
return new FtileGeometry(width, height, left, 0, diamond.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
|
||||||
|
final Dimension2D dim;
|
||||||
|
if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
|
||||||
|
dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
|
||||||
|
} else {
|
||||||
|
dim = Dimension2DDouble.delta(
|
||||||
|
Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
|
||||||
|
Diamond.diamondHalfSize * 2, 0);
|
||||||
|
}
|
||||||
|
return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
152
src/net/sourceforge/plantuml/anim/AffineTransformation.java
Normal file
152
src/net/sourceforge/plantuml/anim/AffineTransformation.java
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 6170 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.anim;
|
||||||
|
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
|
||||||
|
public class AffineTransformation {
|
||||||
|
|
||||||
|
static private final Pattern rotate = Pattern.compile("rotate\\s+(-?\\d+\\.?\\d*)");
|
||||||
|
static private final Pattern shear = Pattern.compile("shear\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
|
||||||
|
static private final Pattern translate = Pattern.compile("translate\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
|
||||||
|
static private final Pattern scale = Pattern.compile("scale\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
|
||||||
|
static private final Pattern color = Pattern.compile("color\\s+.*");
|
||||||
|
|
||||||
|
private final AffineTransform affineTransform;
|
||||||
|
private Dimension2D dimension;
|
||||||
|
|
||||||
|
private AffineTransformation(AffineTransform affineTransform) {
|
||||||
|
this.affineTransform = affineTransform;
|
||||||
|
if (affineTransform == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AffineTransformation compose(AffineTransformation other) {
|
||||||
|
final AffineTransform tmp = new AffineTransform(this.affineTransform);
|
||||||
|
tmp.concatenate(other.affineTransform);
|
||||||
|
return new AffineTransformation(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AffineTransformation from(AffineTransform affineTransform) {
|
||||||
|
return new AffineTransformation(affineTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AffineTransformation create(String value) {
|
||||||
|
final StringTokenizer st = new StringTokenizer(value, "|");
|
||||||
|
AffineTransformation result = null;
|
||||||
|
while (st.hasMoreTokens()) {
|
||||||
|
final String s = st.nextToken();
|
||||||
|
final AffineTransformation tmp = createSimple(s);
|
||||||
|
if (tmp != null) {
|
||||||
|
if (result == null) {
|
||||||
|
result = tmp;
|
||||||
|
} else {
|
||||||
|
result = result.compose(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AffineTransformation createSimple(String value) {
|
||||||
|
Matcher m = rotate.matcher(value.trim());
|
||||||
|
if (m.find()) {
|
||||||
|
final double angle = Double.parseDouble(m.group(1));
|
||||||
|
return new AffineTransformation(AffineTransform.getRotateInstance(angle * Math.PI / 180.0));
|
||||||
|
}
|
||||||
|
m = shear.matcher(value);
|
||||||
|
if (m.find()) {
|
||||||
|
final double shx = Double.parseDouble(m.group(1));
|
||||||
|
final double shy = Double.parseDouble(m.group(2));
|
||||||
|
return new AffineTransformation(AffineTransform.getShearInstance(shx, shy));
|
||||||
|
}
|
||||||
|
m = translate.matcher(value);
|
||||||
|
if (m.find()) {
|
||||||
|
final double tx = Double.parseDouble(m.group(1));
|
||||||
|
final double ty = Double.parseDouble(m.group(2));
|
||||||
|
return new AffineTransformation(AffineTransform.getTranslateInstance(tx, ty));
|
||||||
|
}
|
||||||
|
m = scale.matcher(value);
|
||||||
|
if (m.find()) {
|
||||||
|
final double scalex = Double.parseDouble(m.group(1));
|
||||||
|
final double scaley = Double.parseDouble(m.group(2));
|
||||||
|
return new AffineTransformation(AffineTransform.getScaleInstance(scalex, scaley));
|
||||||
|
}
|
||||||
|
m = color.matcher(value);
|
||||||
|
if (m.find()) {
|
||||||
|
return new AffineTransformation(new AffineTransform());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final AffineTransform getAffineTransform() {
|
||||||
|
return getAffineTransform(dimension);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AffineTransform getAffineTransform(Dimension2D dimension) {
|
||||||
|
if (dimension == null) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
final AffineTransform at = AffineTransform.getTranslateInstance(dimension.getWidth() / 2,
|
||||||
|
dimension.getHeight() / 2);
|
||||||
|
at.concatenate(affineTransform);
|
||||||
|
at.translate(-dimension.getWidth() / 2, -dimension.getHeight() / 2);
|
||||||
|
|
||||||
|
return at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDimension(Dimension2D dim) {
|
||||||
|
this.dimension = dim;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinMax getMinMax(Dimension2D rect) {
|
||||||
|
MinMax result = MinMax.getEmpty(false);
|
||||||
|
final AffineTransform tmp = getAffineTransform(rect);
|
||||||
|
result = result.addPoint(tmp.transform(new Point2D.Double(0, 0), null));
|
||||||
|
result = result.addPoint(tmp.transform(new Point2D.Double(0, rect.getHeight()), null));
|
||||||
|
result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), 0), null));
|
||||||
|
result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), rect.getHeight()), null));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
97
src/net/sourceforge/plantuml/anim/Animation.java
Normal file
97
src/net/sourceforge/plantuml/anim/Animation.java
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 6170 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.anim;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
|
||||||
|
public class Animation {
|
||||||
|
|
||||||
|
private final List<AffineTransformation> all;
|
||||||
|
|
||||||
|
private Animation(List<AffineTransformation> all) {
|
||||||
|
if (all.size() == 0) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.all = all;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Animation singleton(AffineTransformation affineTransformation) {
|
||||||
|
if (affineTransformation == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Animation(Collections.singletonList(affineTransformation));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Animation create(List<String> descriptions) {
|
||||||
|
final List<AffineTransformation> all = new ArrayList<AffineTransformation>();
|
||||||
|
for (String s : descriptions) {
|
||||||
|
final AffineTransformation tmp = AffineTransformation.create(s);
|
||||||
|
if (tmp != null) {
|
||||||
|
all.add(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Animation(all);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<AffineTransformation> getAll() {
|
||||||
|
return Collections.unmodifiableCollection(all);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDimension(Dimension2D dim) {
|
||||||
|
for (AffineTransformation affineTransform : all) {
|
||||||
|
affineTransform.setDimension(dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AffineTransformation getFirst() {
|
||||||
|
return all.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinMax getMinMax(Dimension2D dim) {
|
||||||
|
MinMax result = MinMax.getEmpty(false);
|
||||||
|
for (AffineTransformation affineTransform : all) {
|
||||||
|
final MinMax m = affineTransform.getMinMax(dim);
|
||||||
|
result = result.addMinMax(m);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
77
src/net/sourceforge/plantuml/anim/AnimationDecoder.java
Normal file
77
src/net/sourceforge/plantuml/anim/AnimationDecoder.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 6170 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.anim;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
|
public class AnimationDecoder {
|
||||||
|
|
||||||
|
private final List<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
|
public AnimationDecoder(List<String> data) throws ScriptException {
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
String line = data.get(i);
|
||||||
|
if (line.matches("^\\s*\\[script\\]\\s*$")) {
|
||||||
|
final StringBuilder scriptText = new StringBuilder();
|
||||||
|
while (true) {
|
||||||
|
i++;
|
||||||
|
line = data.get(i);
|
||||||
|
if (line.matches("^\\s*\\[/script\\]\\s*$")) {
|
||||||
|
final AnimationScript script = new AnimationScript();
|
||||||
|
final String out = script.eval(scriptText.toString());
|
||||||
|
for (final StringTokenizer st = new StringTokenizer(out, "\n"); st.hasMoreTokens();) {
|
||||||
|
result.add(st.nextToken());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
scriptText.append(line);
|
||||||
|
scriptText.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> decode() {
|
||||||
|
return Collections.unmodifiableList(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
src/net/sourceforge/plantuml/anim/AnimationScript.java
Normal file
76
src/net/sourceforge/plantuml/anim/AnimationScript.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 6170 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.anim;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.script.ScriptContext;
|
||||||
|
import javax.script.ScriptEngine;
|
||||||
|
import javax.script.ScriptEngineManager;
|
||||||
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
|
public class AnimationScript {
|
||||||
|
|
||||||
|
private final ScriptEngine engine;
|
||||||
|
|
||||||
|
public AnimationScript() {
|
||||||
|
|
||||||
|
final ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
|
engine = manager.getEngineByName("js");
|
||||||
|
|
||||||
|
// ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
|
// List<ScriptEngineFactory> factories = manager.getEngineFactories();
|
||||||
|
// for (ScriptEngineFactory factory : factories) {
|
||||||
|
// System.out.println("Name : " + factory.getEngineName());
|
||||||
|
// System.out.println("Version : " + factory.getEngineVersion());
|
||||||
|
// System.out.println("Language name : " + factory.getLanguageName());
|
||||||
|
// System.out.println("Language version : " + factory.getLanguageVersion());
|
||||||
|
// System.out.println("Extensions : " + factory.getExtensions());
|
||||||
|
// System.out.println("Mime types : " + factory.getMimeTypes());
|
||||||
|
// System.out.println("Names : " + factory.getNames());
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String eval(String line) throws ScriptException {
|
||||||
|
final ScriptContext context = engine.getContext();
|
||||||
|
final StringWriter sw = new StringWriter();
|
||||||
|
context.setWriter(new PrintWriter(sw));
|
||||||
|
engine.eval(line, context);
|
||||||
|
final String result = sw.toString();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
80
src/net/sourceforge/plantuml/api/CountRate.java
Normal file
80
src/net/sourceforge/plantuml/api/CountRate.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
public final class CountRate {
|
||||||
|
|
||||||
|
private final MagicArray lastMinute = new MagicArray(60);
|
||||||
|
private final MagicArray lastHour = new MagicArray(60);
|
||||||
|
private final MagicArray lastDay = new MagicArray(140);
|
||||||
|
|
||||||
|
public void increment() {
|
||||||
|
final long now = System.currentTimeMillis();
|
||||||
|
lastMinute.incKey(now / 1000L);
|
||||||
|
lastHour.incKey(now / (60 * 1000L));
|
||||||
|
lastDay.incKey(now / (10 * 60 * 1000L));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increment(int value) {
|
||||||
|
final long now = System.currentTimeMillis();
|
||||||
|
lastMinute.incKey(now / 1000L, value);
|
||||||
|
lastHour.incKey(now / (60 * 1000L), value);
|
||||||
|
lastDay.incKey(now / (10 * 60 * 1000L), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perMinute() {
|
||||||
|
return lastMinute.getSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perHour() {
|
||||||
|
return lastHour.getSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perDay() {
|
||||||
|
return lastDay.getSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perMinuteMax() {
|
||||||
|
return lastMinute.getMaxSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perHourMax() {
|
||||||
|
return lastHour.getMaxSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long perDayMax() {
|
||||||
|
return lastDay.getMaxSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
src/net/sourceforge/plantuml/api/INumberAnalyzed.java
Normal file
38
src/net/sourceforge/plantuml/api/INumberAnalyzed.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* 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 aint with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
public interface INumberAnalyzed {
|
||||||
|
|
||||||
|
public int getNb();
|
||||||
|
|
||||||
|
public int getSum();
|
||||||
|
|
||||||
|
public int getMin();
|
||||||
|
|
||||||
|
public int getMax();
|
||||||
|
|
||||||
|
public int getMean();
|
||||||
|
|
||||||
|
}
|
96
src/net/sourceforge/plantuml/api/MagicArray.java
Normal file
96
src/net/sourceforge/plantuml/api/MagicArray.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
public final class MagicArray {
|
||||||
|
|
||||||
|
private final int data[];
|
||||||
|
private final int size;
|
||||||
|
private long lastUpdatedKey = -1;
|
||||||
|
private int lastUpdatedValue;
|
||||||
|
private long sum;
|
||||||
|
private long maxSum;
|
||||||
|
|
||||||
|
public MagicArray(int size) {
|
||||||
|
this.data = new int[size];
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void incKey(long key) {
|
||||||
|
incKey(key, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void incKey(long key, int delta) {
|
||||||
|
if (key < lastUpdatedKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key != lastUpdatedKey) {
|
||||||
|
if (lastUpdatedKey != -1) {
|
||||||
|
setValue(lastUpdatedKey, lastUpdatedValue);
|
||||||
|
for (long i = lastUpdatedKey + 1; i < key; i++) {
|
||||||
|
setValue(i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastUpdatedValue = 0;
|
||||||
|
lastUpdatedKey = key;
|
||||||
|
}
|
||||||
|
lastUpdatedValue += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setValue(long key, int value) {
|
||||||
|
final int i = (int) (key % size);
|
||||||
|
sum += value - data[i];
|
||||||
|
if (sum > maxSum) {
|
||||||
|
maxSum = sum;
|
||||||
|
}
|
||||||
|
data[i] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public long getSum() {
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public long getMaxSum() {
|
||||||
|
return maxSum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getSumSlow() {
|
||||||
|
long tmp = 0;
|
||||||
|
for (int d : data) {
|
||||||
|
tmp += d;
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
src/net/sourceforge/plantuml/api/MyRunnable.java
Normal file
41
src/net/sourceforge/plantuml/api/MyRunnable.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
public interface MyRunnable {
|
||||||
|
|
||||||
|
public void runJob() throws InterruptedException;
|
||||||
|
|
||||||
|
public void cancelJob();
|
||||||
|
}
|
69
src/net/sourceforge/plantuml/api/NiceNumber.java
Normal file
69
src/net/sourceforge/plantuml/api/NiceNumber.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class NiceNumber {
|
||||||
|
|
||||||
|
public static int getNicer(final int value) {
|
||||||
|
if (value <= 18) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if (value < 93) {
|
||||||
|
return ((value + 2) / 5) * 5;
|
||||||
|
}
|
||||||
|
if (value < 100) {
|
||||||
|
return ((value + 5) / 10) * 10;
|
||||||
|
}
|
||||||
|
int m = 1;
|
||||||
|
double head = value;
|
||||||
|
while (head >= 100) {
|
||||||
|
head = head / 10.0;
|
||||||
|
m *= 10;
|
||||||
|
}
|
||||||
|
return getNicer((int) Math.round(head)) * m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String format(final long v) {
|
||||||
|
final DecimalFormat df = new DecimalFormat();
|
||||||
|
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
|
||||||
|
df.setGroupingSize(3);
|
||||||
|
df.setMaximumFractionDigits(0);
|
||||||
|
final String t = df.format(v).replace(',', ' ');
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
89
src/net/sourceforge/plantuml/api/NumberAnalyzed.java
Normal file
89
src/net/sourceforge/plantuml/api/NumberAnalyzed.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* 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 aint with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
public class NumberAnalyzed implements INumberAnalyzed {
|
||||||
|
|
||||||
|
private int nb;
|
||||||
|
private int sum;
|
||||||
|
private int min;
|
||||||
|
private int max;
|
||||||
|
|
||||||
|
public NumberAnalyzed() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private NumberAnalyzed(int nb, int sum, int min, int max) {
|
||||||
|
this.nb = nb;
|
||||||
|
this.sum = sum;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized INumberAnalyzed getCopyImmutable() {
|
||||||
|
final NumberAnalyzed copy = new NumberAnalyzed(nb, sum, min, max);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void addValue(int v) {
|
||||||
|
nb++;
|
||||||
|
if (nb == 1) {
|
||||||
|
sum = v;
|
||||||
|
min = v;
|
||||||
|
max = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sum += v;
|
||||||
|
if (v > max) {
|
||||||
|
max = v;
|
||||||
|
}
|
||||||
|
if (v < min) {
|
||||||
|
min = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public final int getNb() {
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public final int getSum() {
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public final int getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public final int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public final int getMean() {
|
||||||
|
if (nb == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return sum / nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
86
src/net/sourceforge/plantuml/api/TimeoutExecutor.java
Normal file
86
src/net/sourceforge/plantuml/api/TimeoutExecutor.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
public final class TimeoutExecutor {
|
||||||
|
|
||||||
|
private final long ms;
|
||||||
|
|
||||||
|
public TimeoutExecutor(long ms) {
|
||||||
|
this.ms = ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean executeNow(MyRunnable task) {
|
||||||
|
final MyThread mainThread = new MyThread(task);
|
||||||
|
boolean done = false;
|
||||||
|
try {
|
||||||
|
mainThread.start();
|
||||||
|
mainThread.join(ms);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.err.println("TimeoutExecutorA " + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
done = mainThread.done.get();
|
||||||
|
if (done == false) {
|
||||||
|
task.cancelJob();
|
||||||
|
mainThread.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyThread extends Thread {
|
||||||
|
private final MyRunnable task;
|
||||||
|
private final AtomicBoolean done = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
private MyThread(MyRunnable task) {
|
||||||
|
this.task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
task.runJob();
|
||||||
|
done.set(true);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.err.println("TimeoutExecutorB " + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
40
src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
Normal file
40
src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api.mda.option2;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface MDADiagram {
|
||||||
|
public Collection<MDAPackage> getPackages();
|
||||||
|
}
|
39
src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
Normal file
39
src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api.mda.option2;
|
||||||
|
|
||||||
|
public interface MDAEntity {
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
}
|
44
src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
Normal file
44
src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api.mda.option2;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface MDAPackage {
|
||||||
|
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
public Collection<MDAEntity> getEntities();
|
||||||
|
|
||||||
|
}
|
43
src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
Normal file
43
src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api.mda.option2;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.mda.MDADiagramImpl;
|
||||||
|
|
||||||
|
public class MDAUtils {
|
||||||
|
|
||||||
|
public static MDADiagram getMDADiagram(String plantumlDiagramSource) {
|
||||||
|
return MDADiagramImpl.create(plantumlDiagramSource);
|
||||||
|
}
|
||||||
|
}
|
37
src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
Normal file
37
src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9786 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.api.mda.option3;
|
||||||
|
|
||||||
|
public interface MDAVisitor {
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4169 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.asciiart;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.skin.Component;
|
||||||
|
|
||||||
|
public abstract class AbstractComponentText implements Component {
|
||||||
|
|
||||||
|
public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
|
||||||
|
final double w = getPreferredWidth(stringBounder);
|
||||||
|
final double h = getPreferredHeight(stringBounder);
|
||||||
|
return new Dimension2DDouble(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
src/net/sourceforge/plantuml/classdiagram/FullLayout.java
Normal file
60
src/net/sourceforge/plantuml/classdiagram/FullLayout.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 14203 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.classdiagram;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class FullLayout implements UDrawable {
|
||||||
|
|
||||||
|
private final List<RowLayout> all = new ArrayList<RowLayout>();
|
||||||
|
|
||||||
|
public void addRowLayout(RowLayout rawLayout) {
|
||||||
|
this.all.add(rawLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
double y = 0;
|
||||||
|
for (RowLayout rawLayout : all) {
|
||||||
|
rawLayout.drawU(ug.apply(new UTranslate(0, y)));
|
||||||
|
y += rawLayout.getHeight(ug.getStringBounder()) + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
src/net/sourceforge/plantuml/classdiagram/RowLayout.java
Normal file
70
src/net/sourceforge/plantuml/classdiagram/RowLayout.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 14203 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.classdiagram;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class RowLayout implements UDrawable {
|
||||||
|
|
||||||
|
private final List<TextBlock> all = new ArrayList<TextBlock>();
|
||||||
|
|
||||||
|
public void addLeaf(TextBlock entityImageClass) {
|
||||||
|
this.all.add(entityImageClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getHeight(StringBounder stringBounder) {
|
||||||
|
double y = 0;
|
||||||
|
for (TextBlock leaf : all) {
|
||||||
|
y = Math.max(y, leaf.calculateDimension(stringBounder).getHeight());
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
double x = 0;
|
||||||
|
for (TextBlock leaf : all) {
|
||||||
|
leaf.drawU(ug.apply(new UTranslate(x, 0)));
|
||||||
|
x += leaf.calculateDimension(ug.getStringBounder()).getWidth() + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 7715 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.classdiagram.command;
|
||||||
|
|
||||||
|
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.RegexResult;
|
||||||
|
|
||||||
|
public class CommandAllowMixing extends SingleLineCommand2<ClassDiagram> {
|
||||||
|
|
||||||
|
public CommandAllowMixing() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RegexConcat getRegexConcat() {
|
||||||
|
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("allow_mixing"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
|
||||||
|
diagram.setAllowMixing(true);
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,226 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 7715 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.classdiagram.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.FontParam;
|
||||||
|
import net.sourceforge.plantuml.Url;
|
||||||
|
import net.sourceforge.plantuml.UrlBuilder;
|
||||||
|
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||||
|
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.RegexResult;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Code;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.IEntity;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.USymbol;
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
|
public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram> {
|
||||||
|
|
||||||
|
private final Mode mode;
|
||||||
|
|
||||||
|
public static enum Mode {
|
||||||
|
NORMAL_KEYWORD, WITH_MIX_PREFIX
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandCreateElementFull2(Mode mode) {
|
||||||
|
super(getRegexConcat(mode));
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RegexConcat getRegexConcat(Mode mode) {
|
||||||
|
|
||||||
|
String regex = "(?:(actor|usecase|component)[%s]+)";
|
||||||
|
if (mode == Mode.WITH_MIX_PREFIX) {
|
||||||
|
regex = "mix_" + regex;
|
||||||
|
}
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("SYMBOL",
|
||||||
|
// "(?:(artifact|actor|folder|package|rectangle|node|frame|cloud|database|storage|agent|usecase|component|boundary|control|entity|interface|\\(\\))[%s]+)?"),
|
||||||
|
// //
|
||||||
|
regex), //
|
||||||
|
new RegexLeaf("[%s]*"), //
|
||||||
|
new RegexOr(//
|
||||||
|
new RegexLeaf("CODE1", CODE_WITH_QUOTE) //
|
||||||
|
), //
|
||||||
|
new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
|
||||||
|
new RegexLeaf("[%s]*"), //
|
||||||
|
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
||||||
|
new RegexLeaf("[%s]*"), //
|
||||||
|
new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||||
|
private static final String CODE = "(" + CODE_CORE + ")";
|
||||||
|
private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
|
||||||
|
|
||||||
|
private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||||
|
private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
|
||||||
|
private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
final protected boolean isForbidden(String line) {
|
||||||
|
if (line.matches("^[\\p{L}0-9_.]+$")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
|
||||||
|
if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) {
|
||||||
|
return CommandExecutionResult
|
||||||
|
.error("Use 'allow_mixing' if you want to mix classes and other UML elements.");
|
||||||
|
}
|
||||||
|
String codeRaw = arg.getLazzy("CODE", 0);
|
||||||
|
final String displayRaw = arg.getLazzy("DISPLAY", 0);
|
||||||
|
final char codeChar = getCharEncoding(codeRaw);
|
||||||
|
final char codeDisplay = getCharEncoding(displayRaw);
|
||||||
|
final String symbol;
|
||||||
|
if (codeRaw.startsWith("()")) {
|
||||||
|
symbol = "interface";
|
||||||
|
codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
|
||||||
|
} else if (codeChar == '(' || codeDisplay == '(') {
|
||||||
|
symbol = "usecase";
|
||||||
|
} else if (codeChar == ':' || codeDisplay == ':') {
|
||||||
|
symbol = "actor";
|
||||||
|
} else if (codeChar == '[' || codeDisplay == '[') {
|
||||||
|
symbol = "component";
|
||||||
|
} else {
|
||||||
|
symbol = arg.get("SYMBOL", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
final LeafType type;
|
||||||
|
final USymbol usymbol;
|
||||||
|
|
||||||
|
if (symbol == null) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.ACTOR;
|
||||||
|
} else if (symbol.equalsIgnoreCase("artifact")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.ARTIFACT;
|
||||||
|
} else if (symbol.equalsIgnoreCase("folder")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.FOLDER;
|
||||||
|
} else if (symbol.equalsIgnoreCase("package")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.PACKAGE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("rectangle")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.RECTANGLE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("node")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.NODE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("frame")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.FRAME;
|
||||||
|
} else if (symbol.equalsIgnoreCase("cloud")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.CLOUD;
|
||||||
|
} else if (symbol.equalsIgnoreCase("database")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.DATABASE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("storage")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.STORAGE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("agent")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.AGENT;
|
||||||
|
} else if (symbol.equalsIgnoreCase("actor")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.ACTOR;
|
||||||
|
} else if (symbol.equalsIgnoreCase("component")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
|
||||||
|
} else if (symbol.equalsIgnoreCase("boundary")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.BOUNDARY;
|
||||||
|
} else if (symbol.equalsIgnoreCase("control")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.CONTROL;
|
||||||
|
} else if (symbol.equalsIgnoreCase("entity")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.ENTITY_DOMAIN;
|
||||||
|
} else if (symbol.equalsIgnoreCase("interface")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.INTERFACE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("()")) {
|
||||||
|
type = LeafType.DESCRIPTION;
|
||||||
|
usymbol = USymbol.INTERFACE;
|
||||||
|
} else if (symbol.equalsIgnoreCase("usecase")) {
|
||||||
|
type = LeafType.USECASE;
|
||||||
|
usymbol = null;
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
|
||||||
|
String display = displayRaw;
|
||||||
|
if (display == null) {
|
||||||
|
display = code.getFullName();
|
||||||
|
}
|
||||||
|
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
|
||||||
|
final String stereotype = arg.getLazzy("STEREOTYPE", 0);
|
||||||
|
final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
|
||||||
|
entity.setDisplay(Display.getWithNewlines(display));
|
||||||
|
entity.setUSymbol(usymbol);
|
||||||
|
if (stereotype != null) {
|
||||||
|
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
|
||||||
|
.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
|
||||||
|
.getIHtmlColorSet()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final String urlString = arg.get("URL", 0);
|
||||||
|
if (urlString != null) {
|
||||||
|
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||||
|
final Url url = urlBuilder.getUrl(urlString);
|
||||||
|
entity.addUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private char getCharEncoding(final String codeRaw) {
|
||||||
|
return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 7715 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.classdiagram.command;
|
||||||
|
|
||||||
|
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.RegexResult;
|
||||||
|
|
||||||
|
public class CommandLayoutNewLine extends SingleLineCommand2<ClassDiagram> {
|
||||||
|
|
||||||
|
public CommandLayoutNewLine() {
|
||||||
|
super(getRegexConcat());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RegexConcat getRegexConcat() {
|
||||||
|
|
||||||
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("layout_new_line"), //
|
||||||
|
new RegexLeaf("$"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
|
||||||
|
diagram.layoutNewLine();
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.command;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.UmlDiagram;
|
||||||
|
|
||||||
|
public class CommandAffineTransform extends SingleLineCommand<UmlDiagram> {
|
||||||
|
|
||||||
|
public CommandAffineTransform() {
|
||||||
|
super("(?i)^!transformation[%s]+([^{}]*)$");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
|
||||||
|
final String value = arg.get(0);
|
||||||
|
diagram.setAnimation(Collections.singletonList(value));
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 5957 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.UmlDiagram;
|
||||||
|
|
||||||
|
public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagram> {
|
||||||
|
|
||||||
|
public CommandAffineTransformMultiline() {
|
||||||
|
super("(?i)^!transformation[%s]+\\{[%s]*$");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPatternEnd() {
|
||||||
|
return "(?i)^[%s]*!\\}[%s]*$";
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||||
|
final List<String> data = lines.subList(1, lines.size() - 1);
|
||||||
|
diagram.setAnimation(data);
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 12235 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.UmlDiagram;
|
||||||
|
|
||||||
|
public class CommandFootboxIgnored extends SingleLineCommand<UmlDiagram> {
|
||||||
|
|
||||||
|
public CommandFootboxIgnored() {
|
||||||
|
super("(?i)^(hide|show)?[%s]*footbox$");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
}
|
98
src/net/sourceforge/plantuml/command/regex/MyPattern.java
Normal file
98
src/net/sourceforge/plantuml/command/regex/MyPattern.java
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||||
|
* in the United States and other countries.]
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
* Revision $Revision: 4762 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.command.regex;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
// Splitter.java to be finished
|
||||||
|
public abstract class MyPattern {
|
||||||
|
|
||||||
|
public static Pattern cmpile(String p) {
|
||||||
|
p = transformAndCheck(p);
|
||||||
|
return Pattern.compile(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pattern cmpileNockeck(String p) {
|
||||||
|
p = transform(p);
|
||||||
|
return Pattern.compile(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pattern cmpile(String p, int type) {
|
||||||
|
p = transformAndCheck(p);
|
||||||
|
return Pattern.compile(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pattern cmpileNockeck(String p, int type) {
|
||||||
|
p = transform(p);
|
||||||
|
return Pattern.compile(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String transformAndCheck(String p) {
|
||||||
|
// if (p.contains("\\s")) {
|
||||||
|
// Thread.dumpStack();
|
||||||
|
// System.err.println(p);
|
||||||
|
// System.exit(0);
|
||||||
|
// }
|
||||||
|
// if (p.contains("'")) {
|
||||||
|
// Thread.dumpStack();
|
||||||
|
// System.err.println(p);
|
||||||
|
// System.exit(0);
|
||||||
|
// }
|
||||||
|
// if (p.contains("\"")) {
|
||||||
|
// Thread.dumpStack();
|
||||||
|
// System.err.println(p);
|
||||||
|
// System.exit(0);
|
||||||
|
// }
|
||||||
|
p = transform(p);
|
||||||
|
// if (p.contains(" ") || p.contains("%")) {
|
||||||
|
// Thread.dumpStack();
|
||||||
|
// System.err.println(p);
|
||||||
|
// System.exit(0);
|
||||||
|
// }
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String transform(String p) {
|
||||||
|
// Replace ReadLineReader.java
|
||||||
|
p = p.replaceAll("%s", "\\\\s\u00A0"); // space
|
||||||
|
p = p.replaceAll("%q", "'\u2018\u2019"); // quote
|
||||||
|
p = p.replaceAll("%g", "\"\u201c\u201d\u00ab\u00bb"); // double quote
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean mtches(String input, String regex) {
|
||||||
|
return cmpile(regex).matcher(input).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
113
src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
Normal file
113
src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 6009 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.BlockUml;
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.EmbededDiagram;
|
||||||
|
import net.sourceforge.plantuml.FileFormat;
|
||||||
|
import net.sourceforge.plantuml.FileFormatOption;
|
||||||
|
import net.sourceforge.plantuml.core.Diagram;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UImage;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
|
|
||||||
|
class AtomEmbededSystem implements Atom {
|
||||||
|
|
||||||
|
final private List<? extends CharSequence> lines;
|
||||||
|
|
||||||
|
public AtomEmbededSystem(EmbededDiagram sys) {
|
||||||
|
this.lines = sys.getLines().as();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingAltitude(StringBounder stringBounder) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
try {
|
||||||
|
final BufferedImage im = getImage();
|
||||||
|
return new Dimension2DDouble(im.getWidth(), im.getHeight());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new Dimension2DDouble(42, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
try {
|
||||||
|
final BufferedImage im = getImage();
|
||||||
|
final UShape image = new UImage(im);
|
||||||
|
ug.draw(image);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferedImage getImage() throws IOException, InterruptedException {
|
||||||
|
final Diagram system = getSystem();
|
||||||
|
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG));
|
||||||
|
os.close();
|
||||||
|
final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
|
||||||
|
final BufferedImage im = ImageIO.read(is);
|
||||||
|
is.close();
|
||||||
|
return im;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public HorizontalAlignment getHorizontalAlignment() {
|
||||||
|
// return HorizontalAlignment.LEFT;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
private Diagram getSystem() throws IOException, InterruptedException {
|
||||||
|
final BlockUml blockUml = new BlockUml(lines, 0);
|
||||||
|
return blockUml.getDiagram();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
73
src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
Normal file
73
src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.openiconic.OpenIcon;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class AtomOpenIcon implements Atom {
|
||||||
|
|
||||||
|
private final OpenIcon openIcon;
|
||||||
|
private final FontConfiguration fontConfiguration;
|
||||||
|
private final double factor;
|
||||||
|
|
||||||
|
public AtomOpenIcon(OpenIcon openIcon, FontConfiguration fontConfiguration) {
|
||||||
|
this.openIcon = openIcon;
|
||||||
|
this.fontConfiguration = fontConfiguration;
|
||||||
|
this.factor = fontConfiguration.getSize2D() / 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlock asTextBlock() {
|
||||||
|
return TextBlockUtils.withMargin(openIcon.asTextBlock(fontConfiguration.getColor(), factor), 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return asTextBlock().calculateDimension(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingAltitude(StringBounder stringBounder) {
|
||||||
|
return -3 * factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
asTextBlock().drawU(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
65
src/net/sourceforge/plantuml/creole/AtomSpace.java
Normal file
65
src/net/sourceforge/plantuml/creole/AtomSpace.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class AtomSpace implements Atom {
|
||||||
|
|
||||||
|
private final double width;
|
||||||
|
|
||||||
|
public static Atom create(double width) {
|
||||||
|
return new AtomSpace(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AtomSpace(double width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return new Dimension2DDouble(width, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingAltitude(StringBounder stringBounder) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||||
|
import net.sourceforge.plantuml.graphic.Splitter;
|
||||||
|
|
||||||
|
public class CommandCreoleOpenIcon implements Command {
|
||||||
|
|
||||||
|
private final Pattern pattern;
|
||||||
|
|
||||||
|
private CommandCreoleOpenIcon(String p) {
|
||||||
|
this.pattern = MyPattern.cmpile(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Command create() {
|
||||||
|
return new CommandCreoleOpenIcon("^(?i)(" + Splitter.openiconPattern + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int matchingSize(String line) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return m.group(1).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String executeAndGetRemaining(String line, StripeSimple stripe) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
final String src = m.group(2);
|
||||||
|
stripe.addOpenIcon(src);
|
||||||
|
return line.substring(m.group(1).length());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
77
src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
Normal file
77
src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||||
|
|
||||||
|
public class CommandCreoleSpace implements Command {
|
||||||
|
|
||||||
|
private final Pattern pattern;
|
||||||
|
|
||||||
|
private CommandCreoleSpace(String p) {
|
||||||
|
this.pattern = MyPattern.cmpile(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Command create() {
|
||||||
|
return new CommandCreoleSpace("^(?i)(\\<space:(\\d+)/?\\>)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int matchingSize(String line) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return m.group(1).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String executeAndGetRemaining(String line, StripeSimple stripe) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
// final int size = Integer.parseInt(m.group(2));
|
||||||
|
// final FontConfiguration fc1 = stripe.getActualFontConfiguration();
|
||||||
|
// final FontConfiguration fc2 = fc1.changeSize(size);
|
||||||
|
// stripe.setActualFontConfiguration(fc2);
|
||||||
|
// stripe.analyzeAndAdd(m.group(3));
|
||||||
|
final int size = Integer.parseInt(m.group(2));
|
||||||
|
stripe.addSpace(size);
|
||||||
|
// stripe.setActualFontConfiguration(fc1);
|
||||||
|
return line.substring(m.group(1).length());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.Splitter;
|
||||||
|
import net.sourceforge.plantuml.graphic.SvgAttributes;
|
||||||
|
|
||||||
|
public class CommandCreoleSvgAttributeChange implements Command {
|
||||||
|
|
||||||
|
private final Pattern pattern;
|
||||||
|
|
||||||
|
public static final String fontPattern = Splitter.svgAttributePattern;
|
||||||
|
|
||||||
|
public static Command create() {
|
||||||
|
return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*?)\\</text\\>)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Command createEol() {
|
||||||
|
return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*))$");
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandCreoleSvgAttributeChange(String p) {
|
||||||
|
this.pattern = MyPattern.cmpile(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int matchingSize(String line) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return m.group(1).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String executeAndGetRemaining(String line, StripeSimple stripe) {
|
||||||
|
final Matcher m = pattern.matcher(line);
|
||||||
|
if (m.find() == false) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
final FontConfiguration fc1 = stripe.getActualFontConfiguration();
|
||||||
|
FontConfiguration fc2 = fc1;
|
||||||
|
if (m.group(2) != null) {
|
||||||
|
fc2 = fc2.changeAttributes(new SvgAttributes(m.group(2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
stripe.setActualFontConfiguration(fc2);
|
||||||
|
stripe.analyzeAndAdd(m.group(3));
|
||||||
|
stripe.setActualFontConfiguration(fc1);
|
||||||
|
return line.substring(m.group(1).length());
|
||||||
|
}
|
||||||
|
}
|
108
src/net/sourceforge/plantuml/creole/Fission.java
Normal file
108
src/net/sourceforge/plantuml/creole/Fission.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
|
||||||
|
public class Fission {
|
||||||
|
|
||||||
|
private final Stripe stripe;
|
||||||
|
private final double maxWidth;
|
||||||
|
|
||||||
|
public Fission(Stripe stripe, double maxWidth) {
|
||||||
|
this.stripe = stripe;
|
||||||
|
this.maxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Stripe> getSplitted(StringBounder stringBounder) {
|
||||||
|
if (maxWidth == 0) {
|
||||||
|
return Arrays.asList(stripe);
|
||||||
|
}
|
||||||
|
final List<Stripe> result = new ArrayList<Stripe>();
|
||||||
|
StripeSimple current = new StripeSimple();
|
||||||
|
for (Atom a1 : stripe.getAtoms()) {
|
||||||
|
for (Atom atom : getSplitted(stringBounder, a1)) {
|
||||||
|
final double width = atom.calculateDimension(stringBounder).getWidth();
|
||||||
|
if (current.totalWidth + width > maxWidth) {
|
||||||
|
result.add(current);
|
||||||
|
current = new StripeSimple();
|
||||||
|
}
|
||||||
|
current.addAtom(atom, width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (current.totalWidth > 0) {
|
||||||
|
result.add(current);
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Collection<? extends Atom> getSplitted(StringBounder stringBounder, Atom atom) {
|
||||||
|
if (atom instanceof AtomText) {
|
||||||
|
return ((AtomText) atom).getSplitted(stringBounder, maxWidth);
|
||||||
|
}
|
||||||
|
return Collections.singleton(atom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Stripe> getSplittedSimple() {
|
||||||
|
final StripeSimple result = new StripeSimple();
|
||||||
|
for (Atom atom : stripe.getAtoms()) {
|
||||||
|
result.addAtom(atom, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
return Arrays.asList((Stripe) result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class StripeSimple implements Stripe {
|
||||||
|
|
||||||
|
private final List<Atom> atoms = new ArrayList<Atom>();
|
||||||
|
private double totalWidth;
|
||||||
|
|
||||||
|
public List<Atom> getAtoms() {
|
||||||
|
return Collections.unmodifiableList(atoms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAtom(Atom atom, double width) {
|
||||||
|
this.atoms.add(atom);
|
||||||
|
this.totalWidth += width;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
157
src/net/sourceforge/plantuml/creole/SheetBlock1.java
Normal file
157
src/net/sourceforge/plantuml/creole/SheetBlock1.java
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class SheetBlock1 implements TextBlock, Atom, Stencil {
|
||||||
|
|
||||||
|
private final Sheet sheet;
|
||||||
|
private List<Stripe> stripes;
|
||||||
|
private Map<Stripe, Double> heights;
|
||||||
|
private Map<Stripe, Double> widths;
|
||||||
|
private Map<Atom, Position> positions;
|
||||||
|
private MinMax minMax;
|
||||||
|
private final double maxWidth;
|
||||||
|
private final double padding;
|
||||||
|
|
||||||
|
public SheetBlock1(Sheet sheet, double maxWidth, double padding) {
|
||||||
|
this.sheet = sheet;
|
||||||
|
this.maxWidth = maxWidth;
|
||||||
|
this.padding = padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMap(StringBounder stringBounder) {
|
||||||
|
if (positions != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
stripes = new ArrayList<Stripe>();
|
||||||
|
for (Stripe stripe : sheet) {
|
||||||
|
stripes.addAll(new Fission(stripe, maxWidth).getSplitted(stringBounder));
|
||||||
|
}
|
||||||
|
positions = new LinkedHashMap<Atom, Position>();
|
||||||
|
widths = new LinkedHashMap<Stripe, Double>();
|
||||||
|
heights = new LinkedHashMap<Stripe, Double>();
|
||||||
|
minMax = MinMax.getEmpty(true);
|
||||||
|
double y = 0;
|
||||||
|
for (Stripe stripe : stripes) {
|
||||||
|
if (stripe.getAtoms().size() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Sea sea = new Sea(stringBounder);
|
||||||
|
for (Atom atom : stripe.getAtoms()) {
|
||||||
|
sea.add(atom);
|
||||||
|
}
|
||||||
|
sea.doAlign();
|
||||||
|
sea.translateMinYto(y);
|
||||||
|
sea.exportAllPositions(positions);
|
||||||
|
final double width = sea.getWidth();
|
||||||
|
widths.put(stripe, width);
|
||||||
|
minMax = sea.update(minMax);
|
||||||
|
final double height = sea.getHeight();
|
||||||
|
heights.put(stripe, height);
|
||||||
|
y += height;
|
||||||
|
}
|
||||||
|
final int coef;
|
||||||
|
if (sheet.getHorizontalAlignment() == HorizontalAlignment.CENTER) {
|
||||||
|
coef = 2;
|
||||||
|
} else if (sheet.getHorizontalAlignment() == HorizontalAlignment.RIGHT) {
|
||||||
|
coef = 1;
|
||||||
|
} else {
|
||||||
|
coef = 0;
|
||||||
|
}
|
||||||
|
if (coef != 0) {
|
||||||
|
double maxWidth = 0;
|
||||||
|
for (Double v : widths.values()) {
|
||||||
|
if (v > maxWidth) {
|
||||||
|
maxWidth = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map.Entry<Stripe, Double> ent : widths.entrySet()) {
|
||||||
|
final double diff = maxWidth - ent.getValue();
|
||||||
|
if (diff > 0) {
|
||||||
|
for (Atom atom : ent.getKey().getAtoms()) {
|
||||||
|
final Position pos = positions.get(atom);
|
||||||
|
positions.put(atom, pos.translateX(diff / coef));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
initMap(stringBounder);
|
||||||
|
return Dimension2DDouble.delta(minMax.getDimension(), 2 * padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
initMap(ug.getStringBounder());
|
||||||
|
if (padding > 0) {
|
||||||
|
ug = ug.apply(new UTranslate(padding, padding));
|
||||||
|
}
|
||||||
|
for (Stripe stripe : stripes) {
|
||||||
|
for (Atom atom : stripe.getAtoms()) {
|
||||||
|
final Position position = positions.get(atom);
|
||||||
|
atom.drawU(position.translate(ug));
|
||||||
|
// position.drawDebug(ug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingAltitude(StringBounder stringBounder) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingX(StringBounder stringBounder, double y) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndingX(StringBounder stringBounder, double y) {
|
||||||
|
return calculateDimension(stringBounder).getWidth();
|
||||||
|
}
|
||||||
|
}
|
73
src/net/sourceforge/plantuml/creole/SheetBlock2.java
Normal file
73
src/net/sourceforge/plantuml/creole/SheetBlock2.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 11025 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.creole;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
|
||||||
|
public class SheetBlock2 implements TextBlock, Atom {
|
||||||
|
|
||||||
|
private final SheetBlock1 block;
|
||||||
|
private final UStroke defaultStroke;
|
||||||
|
private final Stencil stencil;
|
||||||
|
|
||||||
|
public SheetBlock2(SheetBlock1 block, Stencil stencil, UStroke defaultStroke) {
|
||||||
|
this.block = block;
|
||||||
|
this.stencil = stencil;
|
||||||
|
this.defaultStroke = defaultStroke;
|
||||||
|
if (stencil == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return block.calculateDimension(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
if (stencil != null) {
|
||||||
|
ug = new UGraphicStencil(ug, stencil, defaultStroke);
|
||||||
|
}
|
||||||
|
block.drawU(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartingAltitude(StringBounder stringBounder) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
240
src/net/sourceforge/plantuml/cucadiagram/Display2.java
Normal file
240
src/net/sourceforge/plantuml/cucadiagram/Display2.java
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8218 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cucadiagram;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Url;
|
||||||
|
import net.sourceforge.plantuml.UrlBuilder;
|
||||||
|
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||||
|
|
||||||
|
public class Display2 implements Iterable<CharSequence> {
|
||||||
|
|
||||||
|
private final List<CharSequence> display = new ArrayList<CharSequence>();
|
||||||
|
|
||||||
|
public static Display2 empty() {
|
||||||
|
return new Display2();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Display2 create(CharSequence... s) {
|
||||||
|
if (s.length==1 && s[0]==null) {
|
||||||
|
return empty();
|
||||||
|
}
|
||||||
|
return new Display2(Arrays.asList(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Display2 create(List<? extends CharSequence> other) {
|
||||||
|
return new Display2(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Display2 getWithNewlines(Code s) {
|
||||||
|
return getWithNewlines(s.getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Display2 getWithNewlines(String s) {
|
||||||
|
if (s == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Display2 result = new Display2();
|
||||||
|
result.display.addAll(getWithNewlinesInternal(s));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Display2(List<? extends CharSequence> other) {
|
||||||
|
for (CharSequence s : other) {
|
||||||
|
this.display.addAll(getWithNewlinesInternal(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Display2(Display2 other) {
|
||||||
|
this.display.addAll(other.display);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Display2() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 underlined() {
|
||||||
|
final List<CharSequence> result = new ArrayList<CharSequence>();
|
||||||
|
for (CharSequence line : display) {
|
||||||
|
result.add("<u>" + line);
|
||||||
|
}
|
||||||
|
return new Display2(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return display.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return display.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return this.display.equals(((Display2) other).display);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 addAll(Display2 other) {
|
||||||
|
final Display2 result = new Display2(this);
|
||||||
|
result.display.addAll(other.display);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 addFirst(CharSequence s) {
|
||||||
|
final Display2 result = new Display2(this);
|
||||||
|
result.display.addAll(0, getWithNewlinesInternal(s));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 add(CharSequence s) {
|
||||||
|
final Display2 result = new Display2(this);
|
||||||
|
result.display.addAll(getWithNewlinesInternal(s));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean firstColumnRemovable() {
|
||||||
|
boolean allEmpty = true;
|
||||||
|
for (CharSequence s : this) {
|
||||||
|
if (s.length() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
allEmpty = false;
|
||||||
|
final char c = s.charAt(0);
|
||||||
|
if (c != ' ' && c != '\t') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allEmpty == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 removeEmptyColumns() {
|
||||||
|
if (firstColumnRemovable() == false) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final Display2 result = new Display2(this);
|
||||||
|
do {
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
final CharSequence s = result.get(i);
|
||||||
|
if (s.length() > 0) {
|
||||||
|
result.display.set(i, s.toString().substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (result.firstColumnRemovable());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return display.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence get(int i) {
|
||||||
|
return display.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<CharSequence> iterator() {
|
||||||
|
return Collections.unmodifiableList(display).iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 subList(int i, int size) {
|
||||||
|
final Display2 result = new Display2();
|
||||||
|
result.display.addAll(display.subList(i, size));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<? extends CharSequence> as() {
|
||||||
|
return Collections.unmodifiableList(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getWithNewlinesInternal(CharSequence s) {
|
||||||
|
final List<String> result = new ArrayList<String>();
|
||||||
|
final StringBuilder current = new StringBuilder();
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
final char c = s.charAt(i);
|
||||||
|
if (c == '\\' && i < s.length() - 1) {
|
||||||
|
final char c2 = s.charAt(i + 1);
|
||||||
|
i++;
|
||||||
|
if (c2 == 'n') {
|
||||||
|
result.add(current.toString());
|
||||||
|
current.setLength(0);
|
||||||
|
} else if (c2 == 't') {
|
||||||
|
current.append('\t');
|
||||||
|
} else if (c2 == '\\') {
|
||||||
|
current.append(c2);
|
||||||
|
} else {
|
||||||
|
current.append(c);
|
||||||
|
current.append(c2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
current.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(current.toString());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Url initUrl() {
|
||||||
|
if (this.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||||
|
return urlBuilder.getUrl(this.get(0).toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Display2 removeUrl(Url url) {
|
||||||
|
if (url == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final Display2 result = new Display2();
|
||||||
|
result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
|
||||||
|
result.display.addAll(this.subList(1, this.size()).display);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUrl() {
|
||||||
|
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);
|
||||||
|
for (CharSequence s : this) {
|
||||||
|
if (urlBuilder.getUrl(s.toString()) != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
77
src/net/sourceforge/plantuml/cucadiagram/Ident.java
Normal file
77
src/net/sourceforge/plantuml/cucadiagram/Ident.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8770 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cucadiagram;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
|
public class Ident implements Comparable<Ident> {
|
||||||
|
|
||||||
|
private final String ident;
|
||||||
|
|
||||||
|
private Ident(String ident) {
|
||||||
|
if (ident == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.ident = ident;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ident of(String code) {
|
||||||
|
return new Ident(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ident;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return ident.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
final Ident other = (Ident) obj;
|
||||||
|
return this.ident.equals(other.ident);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Ident other) {
|
||||||
|
return this.ident.compareTo(other.ident);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Ident eventuallyRemoveStartingAndEndingDoubleQuote() {
|
||||||
|
return Ident.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
90
src/net/sourceforge/plantuml/cucadiagram/LongCode.java
Normal file
90
src/net/sourceforge/plantuml/cucadiagram/LongCode.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 8770 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cucadiagram;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
|
public class LongCode implements Comparable<LongCode> {
|
||||||
|
|
||||||
|
private final String fullName;
|
||||||
|
private final String separator;
|
||||||
|
|
||||||
|
private LongCode(String fullName, String separator) {
|
||||||
|
if (fullName == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.fullName = fullName;
|
||||||
|
this.separator = separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNamespaceSeparator() {
|
||||||
|
return separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LongCode of(String code, String separator) {
|
||||||
|
if (code == null) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
return new LongCode(code, separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getFullName() {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return fullName + "(" + separator + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return fullName.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
final LongCode other = (LongCode) obj;
|
||||||
|
return this.fullName.equals(other.fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(LongCode other) {
|
||||||
|
return this.fullName.compareTo(other.fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LongCode eventuallyRemoveStartingAndEndingDoubleQuote() {
|
||||||
|
return LongCode.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(fullName), separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
188
src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
Normal file
188
src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 15529 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Link;
|
||||||
|
import net.sourceforge.plantuml.svek.Bibliotekon;
|
||||||
|
import net.sourceforge.plantuml.svek.Line;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Neighborhood {
|
||||||
|
|
||||||
|
private final ILeaf leaf;
|
||||||
|
private final List<Link> sametailLinks;
|
||||||
|
private final List<Link> allButSametails;
|
||||||
|
|
||||||
|
public Neighborhood(ILeaf leaf, List<Link> sametailLinks, List<Link> all) {
|
||||||
|
this.leaf = leaf;
|
||||||
|
this.sametailLinks = sametailLinks;
|
||||||
|
this.allButSametails = new ArrayList<Link>(all);
|
||||||
|
allButSametails.removeAll(sametailLinks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug, double minX, double minY, Bibliotekon bibliotekon, Dimension2D shapeDim) {
|
||||||
|
final Set<Point2D> contactPoints = new HashSet<Point2D>();
|
||||||
|
for (Link link : sametailLinks) {
|
||||||
|
final Line line = bibliotekon.getLine(link);
|
||||||
|
final Point2D contact = line.getStartContactPoint();
|
||||||
|
contactPoints.add(contact);
|
||||||
|
}
|
||||||
|
final Rectangle2D rect = new Rectangle2D.Double(minX, minY, shapeDim.getWidth(), shapeDim.getHeight());
|
||||||
|
final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
|
||||||
|
|
||||||
|
for (Point2D pt : contactPoints) {
|
||||||
|
final Point2D inter = intersection(rect, center, pt);
|
||||||
|
if (inter == null) {
|
||||||
|
// System.err.println("rect=" + rect);
|
||||||
|
// System.err.println("center=" + center);
|
||||||
|
// System.err.println("pt=" + pt);
|
||||||
|
assert false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final double theta = Math.atan2(center.getX() - pt.getX(), -(center.getY() - pt.getY()));
|
||||||
|
final Point2D middle = drawExtends(ug, inter, theta);
|
||||||
|
drawLine(ug, middle, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Link link : allButSametails) {
|
||||||
|
final Line line = bibliotekon.getLine(link);
|
||||||
|
final Point2D contact = link.getEntity1() == leaf ? line.getStartContactPoint() : line.getEndContactPoint();
|
||||||
|
if (contact == null) {
|
||||||
|
assert false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Point2D inter = intersection(rect, center, contact);
|
||||||
|
if (inter == null) {
|
||||||
|
assert false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
drawLine(ug, inter, contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D drawExtends(UGraphic ug, Point2D contact, double theta) {
|
||||||
|
final UPolygon poly = new UPolygon();
|
||||||
|
poly.addPoint(0, 0);
|
||||||
|
poly.addPoint(7, 20);
|
||||||
|
poly.addPoint(-7, 20);
|
||||||
|
poly.rotate(theta);
|
||||||
|
final UTranslate translate = new UTranslate(contact);
|
||||||
|
ug.apply(translate).draw(poly);
|
||||||
|
final Point2D p1 = translate.getTranslated(poly.getPoints().get(1));
|
||||||
|
final Point2D p2 = translate.getTranslated(poly.getPoints().get(2));
|
||||||
|
return new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Point2D intersection(Rectangle2D rect, Point2D pt1, Point2D pt2) {
|
||||||
|
Point2D p;
|
||||||
|
p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
|
||||||
|
new Point2D.Double(rect.getMaxX(), rect.getMinY()), pt1, pt2);
|
||||||
|
if (p != null) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
p = intersection(new Point2D.Double(rect.getMinX(), rect.getMaxY()),
|
||||||
|
new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
|
||||||
|
if (p != null) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
|
||||||
|
new Point2D.Double(rect.getMinX(), rect.getMaxY()), pt1, pt2);
|
||||||
|
if (p != null) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
p = intersection(new Point2D.Double(rect.getMaxX(), rect.getMinY()),
|
||||||
|
new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
|
||||||
|
if (p != null) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static private Point2D intersection(Point2D pt1, Point2D pt2, Point2D pt3, Point2D pt4) {
|
||||||
|
// System.err.println("Checking intersection of " + pt1 + "-" + pt2 + " and " + pt3 + "-" + pt4);
|
||||||
|
return intersection(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), pt3.getX(), pt3.getY(), pt4.getX(),
|
||||||
|
pt4.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final double epsilon = .001;
|
||||||
|
|
||||||
|
static private Point2D intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
|
||||||
|
double y4) {
|
||||||
|
final double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
|
||||||
|
if (d == 0) {
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
final double xi = ((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d;
|
||||||
|
final double yi = ((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d;
|
||||||
|
|
||||||
|
final Point2D.Double p = new Point2D.Double(xi, yi);
|
||||||
|
if (xi + epsilon < Math.min(x1, x2) || xi - epsilon > Math.max(x1, x2)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (xi + epsilon < Math.min(x3, x4) || xi - epsilon > Math.max(x3, x4)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (yi + epsilon < Math.min(y1, y2) || yi - epsilon > Math.max(y1, y2)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (yi + epsilon < Math.min(y3, y4) || yi - epsilon > Math.max(y3, y4)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawLine(UGraphic ug, Point2D pt1, Point2D pt2) {
|
||||||
|
drawLine(ug, pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawLine(UGraphic ug, double x1, double y1, double x2, double y2) {
|
||||||
|
final ULine line = new ULine(x2 - x1, y2 - y1);
|
||||||
|
ug.apply(new UTranslate(x1, y1)).draw(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
97
src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
Normal file
97
src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
|
||||||
|
public class ApolloniusSolver {
|
||||||
|
|
||||||
|
static class Circle {
|
||||||
|
public double[] center;
|
||||||
|
public double radius;
|
||||||
|
|
||||||
|
public Circle(double[] center, double radius) {
|
||||||
|
this.center = center;
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return String.format("Circle[x=%.2f,y=%.2f,r=%.2f]", center[0], center[1], radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
|
||||||
|
* approximately 68 heavy operations (multiplication, division, square-roots).
|
||||||
|
*
|
||||||
|
* @param c1
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param c2
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param c3
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param s1
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c1
|
||||||
|
* @param s2
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c2
|
||||||
|
* @param s3
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c3
|
||||||
|
* @return The circle that is tangent to c1, c2 and c3.
|
||||||
|
*/
|
||||||
|
public static Circle solveApollonius(Circle c1, Circle c2, Circle c3, int s1, int s2, int s3) {
|
||||||
|
double x1 = c1.center[0];
|
||||||
|
double y1 = c1.center[1];
|
||||||
|
double r1 = c1.radius;
|
||||||
|
double x2 = c2.center[0];
|
||||||
|
double y2 = c2.center[1];
|
||||||
|
double r2 = c2.radius;
|
||||||
|
double x3 = c3.center[0];
|
||||||
|
double y3 = c3.center[1];
|
||||||
|
double r3 = c3.radius;
|
||||||
|
|
||||||
|
// Currently optimized for fewest multiplications. Should be optimized for
|
||||||
|
// readability
|
||||||
|
double v11 = 2 * x2 - 2 * x1;
|
||||||
|
double v12 = 2 * y2 - 2 * y1;
|
||||||
|
double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
|
||||||
|
double v14 = 2 * s2 * r2 - 2 * s1 * r1;
|
||||||
|
|
||||||
|
double v21 = 2 * x3 - 2 * x2;
|
||||||
|
double v22 = 2 * y3 - 2 * y2;
|
||||||
|
double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
|
||||||
|
double v24 = 2 * s3 * r3 - 2 * s2 * r2;
|
||||||
|
|
||||||
|
double w12 = v12 / v11;
|
||||||
|
double w13 = v13 / v11;
|
||||||
|
double w14 = v14 / v11;
|
||||||
|
|
||||||
|
double w22 = v22 / v21 - w12;
|
||||||
|
double w23 = v23 / v21 - w13;
|
||||||
|
double w24 = v24 / v21 - w14;
|
||||||
|
|
||||||
|
double P = -w23 / w22;
|
||||||
|
double Q = w24 / w22;
|
||||||
|
double M = -w12 * P - w13;
|
||||||
|
double N = w14 - w12 * Q;
|
||||||
|
|
||||||
|
double a = N * N + Q * Q - 1;
|
||||||
|
double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
|
||||||
|
double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
|
||||||
|
|
||||||
|
// Find a root of a quadratic equation. This requires the circle centers not
|
||||||
|
// to be e.g. colinear
|
||||||
|
double D = b * b - 4 * a * c;
|
||||||
|
double rs = (-b - Math.sqrt(D)) / (2 * a);
|
||||||
|
double xs = M + N * rs;
|
||||||
|
double ys = P + Q * rs;
|
||||||
|
return new Circle(new double[] { xs, ys }, rs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
Circle c1 = new Circle(new double[] { 0, 0 }, 1);
|
||||||
|
Circle c2 = new Circle(new double[] { 4, 0 }, 1);
|
||||||
|
Circle c3 = new Circle(new double[] { 2, 4 }, 2);
|
||||||
|
// Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image)
|
||||||
|
System.out.println(solveApollonius(c1, c2, c3, 1, 1, 1));
|
||||||
|
// Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image)
|
||||||
|
System.out.println(solveApollonius(c1, c2, c3, -1, -1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
Normal file
76
src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
|
||||||
|
public class ApolloniusSolver2 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
|
||||||
|
* approximately 68 heavy operations (multiplication, division, square-roots).
|
||||||
|
*
|
||||||
|
* @param c1
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param c2
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param c3
|
||||||
|
* One of the circles in the problem
|
||||||
|
* @param s1
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c1
|
||||||
|
* @param s2
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c2
|
||||||
|
* @param s3
|
||||||
|
* An indication if the solution should be externally or internally tangent (+1/-1) to c3
|
||||||
|
* @return The circle that is tangent to c1, c2 and c3.
|
||||||
|
*/
|
||||||
|
public static Balloon solveApollonius(Balloon c1, Balloon c2, Balloon c3, int s1, int s2, int s3) {
|
||||||
|
double x1 = c1.getCenter().getX();
|
||||||
|
double y1 = c1.getCenter().getY();
|
||||||
|
double r1 = c1.getRadius();
|
||||||
|
double x2 = c2.getCenter().getX();
|
||||||
|
double y2 = c2.getCenter().getY();
|
||||||
|
double r2 = c2.getRadius();
|
||||||
|
double x3 = c3.getCenter().getX();
|
||||||
|
double y3 = c3.getCenter().getY();
|
||||||
|
double r3 = c3.getRadius();
|
||||||
|
|
||||||
|
// Currently optimized for fewest multiplications. Should be optimized for
|
||||||
|
// readability
|
||||||
|
double v11 = 2 * x2 - 2 * x1;
|
||||||
|
double v12 = 2 * y2 - 2 * y1;
|
||||||
|
double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
|
||||||
|
double v14 = 2 * s2 * r2 - 2 * s1 * r1;
|
||||||
|
|
||||||
|
double v21 = 2 * x3 - 2 * x2;
|
||||||
|
double v22 = 2 * y3 - 2 * y2;
|
||||||
|
double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
|
||||||
|
double v24 = 2 * s3 * r3 - 2 * s2 * r2;
|
||||||
|
|
||||||
|
double w12 = v12 / v11;
|
||||||
|
double w13 = v13 / v11;
|
||||||
|
double w14 = v14 / v11;
|
||||||
|
|
||||||
|
double w22 = v22 / v21 - w12;
|
||||||
|
double w23 = v23 / v21 - w13;
|
||||||
|
double w24 = v24 / v21 - w14;
|
||||||
|
|
||||||
|
double P = -w23 / w22;
|
||||||
|
double Q = w24 / w22;
|
||||||
|
double M = -w12 * P - w13;
|
||||||
|
double N = w14 - w12 * Q;
|
||||||
|
|
||||||
|
double a = N * N + Q * Q - 1;
|
||||||
|
double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
|
||||||
|
double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
|
||||||
|
|
||||||
|
// Find a root of a quadratic equation. This requires the circle centers not
|
||||||
|
// to be e.g. colinear
|
||||||
|
double D = b * b - 4 * a * c;
|
||||||
|
double rs = (-b - Math.sqrt(D)) / (2 * a);
|
||||||
|
double xs = M + N * rs;
|
||||||
|
double ys = P + Q * rs;
|
||||||
|
return new Balloon(new Point2D.Double(xs, ys), rs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
113
src/net/sourceforge/plantuml/cute/Arc.java
Normal file
113
src/net/sourceforge/plantuml/cute/Arc.java
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class Arc {
|
||||||
|
|
||||||
|
private final Segment segment;
|
||||||
|
private final Tension tension;
|
||||||
|
|
||||||
|
public Tension getTension() {
|
||||||
|
return tension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arc(final MyPoint2D a, final MyPoint2D b) {
|
||||||
|
this(a, b, Tension.none());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Arc(final MyPoint2D a, final MyPoint2D b, Tension tension) {
|
||||||
|
this.segment = new Segment(a, b);
|
||||||
|
this.tension = tension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyPoint2D getA() {
|
||||||
|
return (MyPoint2D) segment.getA();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyPoint2D getB() {
|
||||||
|
return (MyPoint2D) segment.getB();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arc withNoTension() {
|
||||||
|
return new Arc(getA(), getB(), Tension.none());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arc withTension(String tensionString) {
|
||||||
|
if (tensionString == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final double newTension = Double.parseDouble(tensionString);
|
||||||
|
return new Arc(getA(), getB(), new Tension(newTension));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arc rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
return new Arc(getA().rotateZoom(rotationZoom), getB().rotateZoom(rotationZoom),
|
||||||
|
tension.rotateZoom(rotationZoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void appendTo(UPath path) {
|
||||||
|
// if (tension.isNone()) {
|
||||||
|
// path.lineTo(getB());
|
||||||
|
// } else {
|
||||||
|
// final double a = segment.getLength() / 2;
|
||||||
|
// final double b = getTension().getValue();
|
||||||
|
// final double radius = (a * a + b * b) / 2 / b;
|
||||||
|
// final int sweep_flag = 1;
|
||||||
|
// path.arcTo(getB(), radius, 0, sweep_flag);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Point2D getTensionPoint() {
|
||||||
|
if (tension.isNone()) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
return segment.getOrthoPoint(-tension.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void appendTo(UPath path) {
|
||||||
|
// if (path.isEmpty()) {
|
||||||
|
// path.moveTo(getA());
|
||||||
|
// }
|
||||||
|
// path.lineTo(getB());
|
||||||
|
// }
|
||||||
|
|
||||||
|
public double getLength() {
|
||||||
|
return segment.getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
123
src/net/sourceforge/plantuml/cute/Balloon.java
Normal file
123
src/net/sourceforge/plantuml/cute/Balloon.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Balloon implements UDrawable {
|
||||||
|
|
||||||
|
private final Point2D center;
|
||||||
|
private final double radius;
|
||||||
|
|
||||||
|
public Balloon(Point2D center, double radius) {
|
||||||
|
if (radius < 0) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.center = center;
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Balloon fromRadiusSegment(Segment centerToContact) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointOnCircle(double a) {
|
||||||
|
return new Point2D.Double(center.getX() + radius * Math.cos(a), center.getY() + radius * Math.sin(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Segment getSegmentCenterToPointOnCircle(double a) {
|
||||||
|
return new Segment(center, getPointOnCircle(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon translate(UTranslate translate) {
|
||||||
|
return new Balloon(translate.getTranslated(center), radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon rotate(RotationZoom rotationZoom) {
|
||||||
|
return new Balloon(rotationZoom.getPoint(center), rotationZoom.applyZoom(radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Balloon(" + center + "," + radius + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getCenter() {
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRadius() {
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
UEllipse circle = new UEllipse(2 * radius, 2 * radius);
|
||||||
|
ug.apply(new UTranslate(center.getX() - circle.getWidth() / 2, center.getY() - circle.getHeight() / 2)).draw(
|
||||||
|
circle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon getInsideTangentBalloon1(double angle, double curvation) {
|
||||||
|
final double f = radius - curvation;
|
||||||
|
final double e = (radius * radius - f * f) / 2 / radius;
|
||||||
|
final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
|
||||||
|
final Point2D p1 = rotation.getPoint(f, e);
|
||||||
|
final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
|
||||||
|
return new Balloon(newCenter, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon getInsideTangentBalloon2(double angle, double curvation) {
|
||||||
|
final double f = radius - curvation;
|
||||||
|
final double e = (radius * radius - f * f) / 2 / radius;
|
||||||
|
final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
|
||||||
|
final Point2D p1 = rotation.getPoint(f, -e);
|
||||||
|
final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
|
||||||
|
return new Balloon(newCenter, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointOnCirclePassingByThisPoint(Point2D passingBy) {
|
||||||
|
final Segment seg = new Segment(center, passingBy);
|
||||||
|
return seg.getFromAtoB(radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointOnCircleOppositeToThisPoint(Point2D passingBy) {
|
||||||
|
final Segment seg = new Segment(center, passingBy);
|
||||||
|
return seg.getFromAtoB(-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
193
src/net/sourceforge/plantuml/cute/BetweenCorners.java
Normal file
193
src/net/sourceforge/plantuml/cute/BetweenCorners.java
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class BetweenCorners {
|
||||||
|
|
||||||
|
private final TriangleCorner corner1;
|
||||||
|
private final TriangleCorner corner2;
|
||||||
|
private final Tension tension;
|
||||||
|
|
||||||
|
private Balloon inside1;
|
||||||
|
private Balloon inside2;
|
||||||
|
private Balloon contact;
|
||||||
|
private Balloon apo;
|
||||||
|
private Point2D apopt1;
|
||||||
|
private Point2D apopt2;
|
||||||
|
|
||||||
|
public BetweenCorners(TriangleCorner corner1, TriangleCorner corner2, Tension tension) {
|
||||||
|
this.corner1 = corner1;
|
||||||
|
this.corner2 = corner2;
|
||||||
|
this.tension = tension;
|
||||||
|
|
||||||
|
if (corner1.hasCurvation()) {
|
||||||
|
inside1 = corner1.getBalloonInside();
|
||||||
|
}
|
||||||
|
if (corner2.hasCurvation()) {
|
||||||
|
inside2 = corner2.getBalloonInside();
|
||||||
|
}
|
||||||
|
if (tension.isNone() == false) {
|
||||||
|
contact = new Balloon(getTensionPoint(), getLength() / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inside1 != null && inside2 != null && contact != null) {
|
||||||
|
apo = ApolloniusSolver2.solveApollonius(inside1, inside2, contact, 1, 1, 1);
|
||||||
|
apopt1 = apo.getPointOnCirclePassingByThisPoint(inside1.getCenter());
|
||||||
|
apopt2 = apo.getPointOnCirclePassingByThisPoint(inside2.getCenter());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointJ() {
|
||||||
|
if (getCorner1().hasCurvation() == false) {
|
||||||
|
return getCorner1().getO();
|
||||||
|
}
|
||||||
|
if (tension.isNone()) {
|
||||||
|
return getCorner1().getOnSegmentA(getCorner1().getCurvation());
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPointK() {
|
||||||
|
if (getCorner1().hasCurvation() == false) {
|
||||||
|
return getCorner1().getO();
|
||||||
|
}
|
||||||
|
if (tension.isNone()) {
|
||||||
|
return getCorner1().getOnSegmentB(getCorner1().getCurvation());
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getBalloonRadius() {
|
||||||
|
return getCorner1().getBalloonInside().getRadius();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initPath(UPath path) {
|
||||||
|
if (apo != null) {
|
||||||
|
path.moveTo(apopt2);
|
||||||
|
} else {
|
||||||
|
path.moveTo(getPointK());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToPath(UPath path, int swepFlag) {
|
||||||
|
if (apo != null) {
|
||||||
|
path.arcTo(apopt1, getCorner1().getBalloonInside().getRadius(), 0, 1);
|
||||||
|
path.arcTo(apopt2, apo.getRadius(), 0, 1);
|
||||||
|
// } else if (getTension().isNone()) {
|
||||||
|
// path.lineTo(getPointJ());
|
||||||
|
// if (getCorner2().hasCurvation()) {
|
||||||
|
// path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // final int sweep_flag = 1;
|
||||||
|
// path.arcTo(getPointJ(), getRadiusFuzzy1(), 0, swepFlag);
|
||||||
|
// if (getCorner2().hasCurvation()) {
|
||||||
|
// path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
path.lineTo(getPointJ());
|
||||||
|
if (getCorner1().hasCurvation()) {
|
||||||
|
path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debugMe(UGraphic ug) {
|
||||||
|
if (getCorner2().hasCurvation() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tension.isNone()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inside1.drawU(ug);
|
||||||
|
inside2.drawU(ug);
|
||||||
|
// getSegment().debugMe(ug);
|
||||||
|
contact.drawU(ug);
|
||||||
|
|
||||||
|
new Balloon(apopt1, 5).drawU(ug);
|
||||||
|
new Balloon(apopt2, 5).drawU(ug);
|
||||||
|
|
||||||
|
// getSegmentCross().debugMe(ug);
|
||||||
|
|
||||||
|
apo.drawU(ug);
|
||||||
|
//
|
||||||
|
// final Point2D newCenter = getSegmentCross().getOrthoPoint(-50);
|
||||||
|
// new Segment(newCenter, getCorner1().getBalloonInside().getCenter()).debugMe(ug);
|
||||||
|
// new Segment(newCenter, getCorner2().getBalloonInside().getCenter()).debugMe(ug);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getRadiusFuzzy1() {
|
||||||
|
final double a = getLength() / 2;
|
||||||
|
final double b = getTension().getValue();
|
||||||
|
final double radius = (a * a + b * b) / 2 / b;
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Segment getSegment() {
|
||||||
|
return new Segment(getCorner1().getO(), getCorner2().getO());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getTensionPoint() {
|
||||||
|
return getSegment().getOrthoPoint(getTension().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Segment getSegmentCross() {
|
||||||
|
return new Segment(getCorner1().getCornerOrBalloonCenter(), getCorner2().getCornerOrBalloonCenter());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tension getTension() {
|
||||||
|
return tension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleCorner getCorner1() {
|
||||||
|
return corner1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleCorner getCorner2() {
|
||||||
|
return corner2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLength() {
|
||||||
|
return getSegment().getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
129
src/net/sourceforge/plantuml/cute/Cheese.java
Normal file
129
src/net/sourceforge/plantuml/cute/Cheese.java
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class Cheese implements CuteShape {
|
||||||
|
|
||||||
|
private final MyDouble radius;
|
||||||
|
private final MyDouble startAngle;
|
||||||
|
private final MyDouble endAngle;
|
||||||
|
private final RotationZoom rotationZoom;
|
||||||
|
|
||||||
|
public Cheese(VarArgs varArgs) {
|
||||||
|
this.radius = varArgs.getAsMyDouble("radius");
|
||||||
|
this.startAngle = varArgs.getAsMyDouble("start").toRadians();
|
||||||
|
this.endAngle = varArgs.getAsMyDouble("end").toRadians();
|
||||||
|
this.rotationZoom = RotationZoom.none();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cheese(MyDouble radius, MyDouble startAngle, MyDouble endAngle, RotationZoom rotation) {
|
||||||
|
this.radius = radius;
|
||||||
|
this.startAngle = startAngle;
|
||||||
|
this.endAngle = endAngle;
|
||||||
|
this.rotationZoom = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final Balloon balloon = new Balloon(new Point2D.Double(), radius.getValue())
|
||||||
|
.rotate(rotationZoom);
|
||||||
|
|
||||||
|
final double angle1 = rotationZoom.applyRotation(startAngle.getValue());
|
||||||
|
final double angle2 = rotationZoom.applyRotation(endAngle.getValue());
|
||||||
|
|
||||||
|
final Point2D ptA = balloon.getPointOnCircle(angle1);
|
||||||
|
final Point2D ptB = balloon.getPointOnCircle(angle2);
|
||||||
|
|
||||||
|
// balloon.drawU(ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
|
||||||
|
final UPath path = new UPath();
|
||||||
|
final Point2D ptA0;
|
||||||
|
if (radius.hasCurvation()) {
|
||||||
|
ptA0 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(radius.getCurvation(0));
|
||||||
|
path.moveTo(ptA0);
|
||||||
|
} else {
|
||||||
|
ptA0 = null;
|
||||||
|
path.moveTo(balloon.getCenter());
|
||||||
|
}
|
||||||
|
final Balloon insideA;
|
||||||
|
if (startAngle.hasCurvation()) {
|
||||||
|
insideA = balloon.getInsideTangentBalloon1(angle1, startAngle.getCurvation(0));
|
||||||
|
final Point2D ptA1 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(
|
||||||
|
radius.getValue() - startAngle.getCurvation(0));
|
||||||
|
final Point2D ptA2 = balloon.getPointOnCirclePassingByThisPoint(insideA.getCenter());
|
||||||
|
path.lineTo(ptA1);
|
||||||
|
path.arcTo(ptA2, insideA.getRadius(), 0, 1);
|
||||||
|
} else {
|
||||||
|
insideA = null;
|
||||||
|
path.lineTo(ptA);
|
||||||
|
}
|
||||||
|
final Balloon insideB;
|
||||||
|
if (endAngle.hasCurvation()) {
|
||||||
|
insideB = balloon.getInsideTangentBalloon2(angle2, endAngle.getCurvation(0));
|
||||||
|
final Point2D ptB1 = balloon.getPointOnCirclePassingByThisPoint(insideB.getCenter());
|
||||||
|
final Point2D ptB2 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(
|
||||||
|
radius.getValue() - endAngle.getCurvation(0));
|
||||||
|
|
||||||
|
path.arcTo(ptB1, balloon.getRadius(), 0, 1);
|
||||||
|
path.arcTo(ptB2, insideB.getRadius(), 0, 1);
|
||||||
|
} else {
|
||||||
|
insideB = null;
|
||||||
|
path.arcTo(ptB, balloon.getRadius(), 0, 1);
|
||||||
|
}
|
||||||
|
if (radius.hasCurvation()) {
|
||||||
|
final Point2D ptB0 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(radius.getCurvation(0));
|
||||||
|
path.lineTo(ptB0);
|
||||||
|
path.arcTo(ptA0, radius.getCurvation(0), 0, 1);
|
||||||
|
} else {
|
||||||
|
path.lineTo(balloon.getCenter());
|
||||||
|
}
|
||||||
|
path.closePath();
|
||||||
|
ug.draw(path);
|
||||||
|
|
||||||
|
// if (startAngle.hasCurvation()) {
|
||||||
|
// insideA.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
|
||||||
|
// }
|
||||||
|
// if (endAngle.hasCurvation()) {
|
||||||
|
// insideB.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public CuteShape rotateZoom(RotationZoom other) {
|
||||||
|
return new Cheese(radius, startAngle, endAngle, rotationZoom.compose(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
src/net/sourceforge/plantuml/cute/Circle.java
Normal file
64
src/net/sourceforge/plantuml/cute/Circle.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Circle implements CuteShape {
|
||||||
|
|
||||||
|
private final double radius;
|
||||||
|
|
||||||
|
public Circle(VarArgs varArgs) {
|
||||||
|
this.radius = varArgs.getAsDouble("radius");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Circle(double radius) {
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
ug = ug.apply(new UTranslate(-radius, -radius));
|
||||||
|
ug.draw(new UEllipse(2 * radius, 2 * radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Circle rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
if (rotationZoom.isNone()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return new Circle(rotationZoom.applyZoom(radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
44
src/net/sourceforge/plantuml/cute/Corner.java
Normal file
44
src/net/sourceforge/plantuml/cute/Corner.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
public class Corner {
|
||||||
|
|
||||||
|
private final double curvation;
|
||||||
|
|
||||||
|
public Corner(double curvation) {
|
||||||
|
this.curvation = curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
src/net/sourceforge/plantuml/cute/Crossing.java
Normal file
66
src/net/sourceforge/plantuml/cute/Crossing.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Crossing {
|
||||||
|
|
||||||
|
private final Balloon balloon;
|
||||||
|
private final InfiniteLine line;
|
||||||
|
|
||||||
|
public Crossing(Balloon balloon, InfiniteLine line) {
|
||||||
|
this.balloon = balloon;
|
||||||
|
this.line = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Point2D> intersection() {
|
||||||
|
final List<Point2D> result = new ArrayList<Point2D>();
|
||||||
|
|
||||||
|
final UTranslate tr = new UTranslate(balloon.getCenter());
|
||||||
|
final UTranslate trInverse = tr.reverse();
|
||||||
|
|
||||||
|
final CrossingSimple simple = new CrossingSimple(balloon.getRadius(), line.translate(trInverse));
|
||||||
|
for (Point2D pt : simple.intersection()) {
|
||||||
|
result.add(tr.getTranslated(pt));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
89
src/net/sourceforge/plantuml/cute/CrossingSimple.java
Normal file
89
src/net/sourceforge/plantuml/cute/CrossingSimple.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CrossingSimple {
|
||||||
|
|
||||||
|
// http://mathworld.wolfram.com/Circle-LineIntersection.html
|
||||||
|
|
||||||
|
private final double radius;
|
||||||
|
private final InfiniteLine line;
|
||||||
|
|
||||||
|
public CrossingSimple(double radius, InfiniteLine line) {
|
||||||
|
this.radius = radius;
|
||||||
|
this.line = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double pow2(double x) {
|
||||||
|
return x * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double sgn(double x) {
|
||||||
|
if (x < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Point2D> intersection() {
|
||||||
|
final List<Point2D> result = new ArrayList<Point2D>();
|
||||||
|
final double delta = pow2(radius * line.getDr()) - pow2(line.getDiscriminant());
|
||||||
|
|
||||||
|
if (delta < 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
|
||||||
|
x = (line.getDiscriminant() * line.getDeltaY() + sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
|
||||||
|
/ pow2(line.getDr());
|
||||||
|
y = (-line.getDiscriminant() * line.getDeltaX() + Math.abs(line.getDeltaY()) * Math.sqrt(delta))
|
||||||
|
/ pow2(line.getDr());
|
||||||
|
result.add(new Point2D.Double(x, y));
|
||||||
|
|
||||||
|
x = (line.getDiscriminant() * line.getDeltaY() - sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
|
||||||
|
/ pow2(line.getDr());
|
||||||
|
y = (-line.getDiscriminant() * line.getDeltaX() - Math.abs(line.getDeltaY()) * Math.sqrt(delta))
|
||||||
|
/ pow2(line.getDr());
|
||||||
|
result.add(new Point2D.Double(x, y));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
178
src/net/sourceforge/plantuml/cute/CutePath.java
Normal file
178
src/net/sourceforge/plantuml/cute/CutePath.java
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class CutePath {
|
||||||
|
|
||||||
|
private final List<Arc> arcs = new ArrayList<Arc>();
|
||||||
|
|
||||||
|
public CutePath(String value) {
|
||||||
|
|
||||||
|
MyPoint2D lastAdded = null;
|
||||||
|
String tension = null;
|
||||||
|
|
||||||
|
final StringTokenizer spl = new StringTokenizer(value, "~:", true);
|
||||||
|
while (spl.hasMoreTokens()) {
|
||||||
|
final String token = spl.nextToken();
|
||||||
|
if (token.equals(":")) {
|
||||||
|
continue;
|
||||||
|
} else if (token.equals("~")) {
|
||||||
|
tension = spl.nextToken();
|
||||||
|
final String next = spl.nextToken();
|
||||||
|
if (next.equals("~") == false) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final StringTokenizer st = new StringTokenizer(token.replaceAll("[()]", ""), ",^");
|
||||||
|
final MyPoint2D current = new MyPoint2D(st);
|
||||||
|
if (lastAdded != null) {
|
||||||
|
add(new Arc(lastAdded, current).withTension(tension));
|
||||||
|
}
|
||||||
|
lastAdded = current;
|
||||||
|
tension = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add(new Arc(lastAdded, arcs.get(0).getA()).withTension(tension));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CutePath() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Arc arc) {
|
||||||
|
if (arcs.size() > 0) {
|
||||||
|
final Arc last = arcs.get(arcs.size() - 1);
|
||||||
|
if (last.getB().equals(arc.getA()) == false) {
|
||||||
|
throw new IllegalArgumentException("last=" + last.getB() + " arc=" + arc.getA());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.arcs.add(arc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final MyPoint2D getMyPoint2D(int i) {
|
||||||
|
return getArc(i).getA();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Arc getArc(int i) {
|
||||||
|
if (i == -1) {
|
||||||
|
return arcs.get(arcs.size() - 1);
|
||||||
|
}
|
||||||
|
if (i == arcs.size()) {
|
||||||
|
return arcs.get(0);
|
||||||
|
}
|
||||||
|
if (i == arcs.size() + 1) {
|
||||||
|
return arcs.get(1);
|
||||||
|
}
|
||||||
|
return arcs.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UPath toUPath() {
|
||||||
|
final TriangleCorner corner0 = new TriangleCorner(getMyPoint2D(0), getMyPoint2D(1), getMyPoint2D(2));
|
||||||
|
final int swepFlag = corner0.determinant() < 0 ? 0 : 1;
|
||||||
|
|
||||||
|
final UPath path = new UPath();
|
||||||
|
final BetweenCorners betweenCornersLast = new BetweenCorners(getCorner(arcs.size() - 1),
|
||||||
|
getCorner(arcs.size()), arcs.get(arcs.size() - 1).getTension());
|
||||||
|
betweenCornersLast.initPath(path);
|
||||||
|
for (int i = 0; i < arcs.size(); i++) {
|
||||||
|
|
||||||
|
// if (i == 0) {
|
||||||
|
// if (getMyPoint2D(i).hasCurvation()) {
|
||||||
|
// path.moveTo(getPointK(i));
|
||||||
|
// } else {
|
||||||
|
// path.moveTo(arcs.get(i).getA());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
|
||||||
|
.getTension());
|
||||||
|
betweenCorners.addToPath(path, swepFlag);
|
||||||
|
|
||||||
|
}
|
||||||
|
path.closePath();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void debugMe(UGraphic ug) {
|
||||||
|
for (int i = 0; i < arcs.size(); i++) {
|
||||||
|
final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
|
||||||
|
.getTension());
|
||||||
|
betweenCorners.debugMe(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D getPointK(final int j) {
|
||||||
|
if (getMyPoint2D(j).hasCurvation()) {
|
||||||
|
return getCorner(j).getOnSegmentB(getMyPoint2D(j).getCurvation(0));
|
||||||
|
}
|
||||||
|
return arcs.get(j - 1).getB();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TriangleCorner getCorner(int i) {
|
||||||
|
return new TriangleCorner(getMyPoint2D(i), getMyPoint2D(i - 1), getMyPoint2D(i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final UPath path = toUPath();
|
||||||
|
ug.draw(path);
|
||||||
|
// debugMe(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CutePath rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
final CutePath result = new CutePath();
|
||||||
|
for (Arc arc : arcs) {
|
||||||
|
result.arcs.add(arc.rotateZoom(rotationZoom));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CutePath withNoTension() {
|
||||||
|
final CutePath result = new CutePath();
|
||||||
|
for (Arc arc : arcs) {
|
||||||
|
result.arcs.add(arc.withNoTension());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
42
src/net/sourceforge/plantuml/cute/CuteShape.java
Normal file
42
src/net/sourceforge/plantuml/cute/CuteShape.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
|
||||||
|
public interface CuteShape extends UDrawable {
|
||||||
|
|
||||||
|
public UDrawable rotateZoom(RotationZoom other);
|
||||||
|
|
||||||
|
}
|
80
src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
Normal file
80
src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CuteShapeFactory {
|
||||||
|
|
||||||
|
private final Map<String, Group> groups;
|
||||||
|
|
||||||
|
public CuteShapeFactory(Map<String, Group> groups) {
|
||||||
|
this.groups = groups;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Positionned createCuteShapePositionned(String data) {
|
||||||
|
final VarArgs varArgs = new VarArgs(data);
|
||||||
|
return new PositionnedImpl(createCuteShape(data), varArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CuteShape createCuteShape(String data) {
|
||||||
|
data = data.toLowerCase().trim();
|
||||||
|
final VarArgs varArgs = new VarArgs(data);
|
||||||
|
if (data.startsWith("circle ")) {
|
||||||
|
return new Circle(varArgs);
|
||||||
|
}
|
||||||
|
if (data.startsWith("cheese ")) {
|
||||||
|
return new Cheese(varArgs);
|
||||||
|
}
|
||||||
|
if (data.startsWith("stick ")) {
|
||||||
|
return new Stick(varArgs);
|
||||||
|
}
|
||||||
|
if (data.startsWith("rectangle ") || data.startsWith("rect ")) {
|
||||||
|
return new Rectangle(varArgs);
|
||||||
|
}
|
||||||
|
if (data.startsWith("triangle ")) {
|
||||||
|
return new Triangle(varArgs);
|
||||||
|
}
|
||||||
|
final String first = data.split(" ")[0];
|
||||||
|
System.err.println("Looking for group " + first + " in " + groups.keySet());
|
||||||
|
final Group group = groups.get(first);
|
||||||
|
if (group == null) {
|
||||||
|
throw new IllegalArgumentException("Cannot find group " + first + " in " + groups.keySet());
|
||||||
|
}
|
||||||
|
System.err.println("Found group " + first + " in " + groups.keySet());
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
124
src/net/sourceforge/plantuml/cute/Group.java
Normal file
124
src/net/sourceforge/plantuml/cute/Group.java
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Group implements Positionned {
|
||||||
|
|
||||||
|
private final String groupName;
|
||||||
|
private final List<Positionned> shapes;
|
||||||
|
private final Group parent;
|
||||||
|
private final Map<String, Group> children;
|
||||||
|
|
||||||
|
// private final List<Group> children = new ArrayList<Group>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Group " + groupName + " (" + shapes.size() + ") ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static Group fromList(List<Positionned> shapes) {
|
||||||
|
// return new Group("Automatic", shapes);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static Group createRoot() {
|
||||||
|
return new Group(null, "ROOT");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Group(Group parent, String groupName) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.shapes = new ArrayList<Positionned>();
|
||||||
|
this.children = new HashMap<String, Group>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Group(Group parent, String groupName, List<Positionned> shapes) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.shapes = shapes;
|
||||||
|
this.children = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group createChild(String childName) {
|
||||||
|
final Group result = new Group(this, childName);
|
||||||
|
this.children.put(childName, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
for (Positionned shape : shapes) {
|
||||||
|
shape.drawU(ug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Positionned shape) {
|
||||||
|
shapes.add(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Positionned rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
if (rotationZoom.isNone()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final List<Positionned> result = new ArrayList<Positionned>();
|
||||||
|
for (Positionned shape : shapes) {
|
||||||
|
result.add(shape.rotateZoom(rotationZoom));
|
||||||
|
}
|
||||||
|
return new Group(parent, groupName + "->" + rotationZoom, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Positionned translate(UTranslate translation) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Group> getChildren() {
|
||||||
|
return Collections.unmodifiableMap(children);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
75
src/net/sourceforge/plantuml/cute/InfiniteLine.java
Normal file
75
src/net/sourceforge/plantuml/cute/InfiniteLine.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class InfiniteLine {
|
||||||
|
|
||||||
|
private final Point2D a;
|
||||||
|
private final Point2D b;
|
||||||
|
|
||||||
|
public InfiniteLine(Point2D a, Point2D b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "{" + a + ";" + b + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDeltaX() {
|
||||||
|
return b.getX() - a.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDeltaY() {
|
||||||
|
return b.getY() - a.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDr() {
|
||||||
|
return a.distance(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDiscriminant() {
|
||||||
|
return a.getX() * b.getY() - b.getX() * a.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InfiniteLine translate(UTranslate translate) {
|
||||||
|
return new InfiniteLine(translate.getTranslated(a), translate.getTranslated(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
89
src/net/sourceforge/plantuml/cute/MyDouble.java
Normal file
89
src/net/sourceforge/plantuml/cute/MyDouble.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
public class MyDouble {
|
||||||
|
|
||||||
|
private static final double NO_CURVE = java.lang.Double.MIN_VALUE;
|
||||||
|
private final double value;
|
||||||
|
private final double curvation;
|
||||||
|
|
||||||
|
public MyDouble(String s) {
|
||||||
|
final StringTokenizer st = new StringTokenizer(s, ",");
|
||||||
|
this.value = java.lang.Double.parseDouble(st.nextToken());
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
this.curvation = java.lang.Double.parseDouble(st.nextToken());
|
||||||
|
} else {
|
||||||
|
this.curvation = NO_CURVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value + "[" + curvation + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
private MyDouble(double value, double curvation) {
|
||||||
|
this.value = value;
|
||||||
|
this.curvation = curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCurvation(double def) {
|
||||||
|
if (curvation == NO_CURVE) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCurvation() {
|
||||||
|
return curvation != NO_CURVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyDouble rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
final double newValue = rotationZoom.applyZoom(value);
|
||||||
|
final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
|
||||||
|
return new MyDouble(newValue, curvation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyDouble toRadians() {
|
||||||
|
return new MyDouble(Math.toRadians(value), curvation);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
119
src/net/sourceforge/plantuml/cute/MyPoint2D.java
Normal file
119
src/net/sourceforge/plantuml/cute/MyPoint2D.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
public class MyPoint2D extends Point2D {
|
||||||
|
|
||||||
|
public static final double NO_CURVE = 0;
|
||||||
|
private final double x;
|
||||||
|
private final double y;
|
||||||
|
private final double curvation;
|
||||||
|
|
||||||
|
public MyPoint2D(StringTokenizer st) {
|
||||||
|
this.x = java.lang.Double.parseDouble(st.nextToken());
|
||||||
|
this.y = java.lang.Double.parseDouble(st.nextToken());
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
this.curvation = java.lang.Double.parseDouble(st.nextToken());
|
||||||
|
} else {
|
||||||
|
this.curvation = NO_CURVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object arg0) {
|
||||||
|
final MyPoint2D other = (MyPoint2D) arg0;
|
||||||
|
return this.x == other.x && this.y == other.y && this.curvation == other.curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MyPoint2D from(double x, double y) {
|
||||||
|
return new MyPoint2D(x, y, NO_CURVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyPoint2D withCurvation(double curvation) {
|
||||||
|
if (curvation == NO_CURVE) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return new MyPoint2D(x, y, curvation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MyPoint2D(Point2D p, double curvation) {
|
||||||
|
this.x = p.getX();
|
||||||
|
this.y = p.getY();
|
||||||
|
this.curvation = curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MyPoint2D(double x, double y, double curvation) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.curvation = curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "(" + x + "," + y + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCurvation(double def) {
|
||||||
|
if (curvation == NO_CURVE) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(double arg0, double arg1) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyPoint2D rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
final Point2D p = rotationZoom.getPoint(x, y);
|
||||||
|
final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
|
||||||
|
return new MyPoint2D(p, curvation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCurvation() {
|
||||||
|
return curvation != NO_CURVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
93
src/net/sourceforge/plantuml/cute/PSystemCute.java
Normal file
93
src/net/sourceforge/plantuml/cute/PSystemCute.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.AbstractPSystem;
|
||||||
|
import net.sourceforge.plantuml.FileFormatOption;
|
||||||
|
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||||
|
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
||||||
|
import net.sourceforge.plantuml.core.ImageData;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||||
|
|
||||||
|
public class PSystemCute extends AbstractPSystem {
|
||||||
|
|
||||||
|
// private final List<Positionned> shapes = new ArrayList<Positionned>();
|
||||||
|
// private final Map<String, Group> groups = new HashMap<String, Group>();
|
||||||
|
private final Group root = Group.createRoot();
|
||||||
|
private Group currentGroup = root;
|
||||||
|
|
||||||
|
public PSystemCute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiagramDescription getDescription() {
|
||||||
|
return new DiagramDescriptionImpl("(Cute)", getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doCommandLine(String line) {
|
||||||
|
line = line.trim();
|
||||||
|
if (line.length()==0 || line.startsWith("'")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (line.startsWith("group ")) {
|
||||||
|
final StringTokenizer st = new StringTokenizer(line);
|
||||||
|
st.nextToken();
|
||||||
|
final String groupName = st.nextToken();
|
||||||
|
currentGroup = currentGroup.createChild(groupName);
|
||||||
|
} else if (line.startsWith("}")) {
|
||||||
|
currentGroup = currentGroup.getParent();
|
||||||
|
} else {
|
||||||
|
final Positionned shape = new CuteShapeFactory(currentGroup.getChildren()).createCuteShapePositionned(line);
|
||||||
|
// if (currentGroup == null) {
|
||||||
|
// shapes.add(shape);
|
||||||
|
// } else {
|
||||||
|
currentGroup.add(shape);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
|
||||||
|
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null, false);
|
||||||
|
builder.addUDrawable(root);
|
||||||
|
return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||||
|
}
|
||||||
|
}
|
59
src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
Normal file
59
src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 3830 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.command.PSystemBasicFactory;
|
||||||
|
import net.sourceforge.plantuml.core.DiagramType;
|
||||||
|
|
||||||
|
public class PSystemCuteFactory extends PSystemBasicFactory<PSystemCute> {
|
||||||
|
|
||||||
|
public PSystemCuteFactory(DiagramType type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PSystemCute init(String startLine) {
|
||||||
|
if (getDiagramType() == DiagramType.CUTE) {
|
||||||
|
return new PSystemCute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PSystemCute executeLine(PSystemCute system, String line) {
|
||||||
|
system.doCommandLine(line);
|
||||||
|
return system;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
44
src/net/sourceforge/plantuml/cute/Positionned.java
Normal file
44
src/net/sourceforge/plantuml/cute/Positionned.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public interface Positionned extends CuteShape {
|
||||||
|
|
||||||
|
public Positionned rotateZoom(RotationZoom rotation);
|
||||||
|
|
||||||
|
public Positionned translate(UTranslate translation);
|
||||||
|
|
||||||
|
}
|
105
src/net/sourceforge/plantuml/cute/PositionnedImpl.java
Normal file
105
src/net/sourceforge/plantuml/cute/PositionnedImpl.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class PositionnedImpl implements Positionned {
|
||||||
|
|
||||||
|
private final CuteShape cuteShape;
|
||||||
|
private final HtmlColor color;
|
||||||
|
private final UTranslate position;
|
||||||
|
private final RotationZoom rotationZoom;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Positionned " + position + " " + cuteShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PositionnedImpl(CuteShape cuteShape, VarArgs args) {
|
||||||
|
this.cuteShape = cuteShape;
|
||||||
|
this.color = args.getAsColor("color");
|
||||||
|
this.position = args.getPosition();
|
||||||
|
this.rotationZoom = RotationZoom.fromVarArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PositionnedImpl(CuteShape cuteShape, HtmlColor color, UTranslate position, RotationZoom rotationZoom) {
|
||||||
|
this.cuteShape = cuteShape;
|
||||||
|
this.color = color;
|
||||||
|
this.position = position;
|
||||||
|
this.rotationZoom = rotationZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PositionnedImpl(Group group, RotationZoom rotation) {
|
||||||
|
this.cuteShape = group;
|
||||||
|
this.color = HtmlColorUtils.BLACK;
|
||||||
|
this.position = new UTranslate();
|
||||||
|
this.rotationZoom = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PositionnedImpl(Group group, UTranslate translation) {
|
||||||
|
this.cuteShape = group;
|
||||||
|
this.color = HtmlColorUtils.BLACK;
|
||||||
|
this.position = translation;
|
||||||
|
this.rotationZoom = RotationZoom.none();
|
||||||
|
}
|
||||||
|
|
||||||
|
private UGraphic applyColor(UGraphic ug) {
|
||||||
|
return ug.apply(new UChangeBackColor(color)).apply(new UChangeColor(color));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
ug = applyColor(ug);
|
||||||
|
ug = ug.apply(position);
|
||||||
|
final UDrawable tmp = rotationZoom.isNone() ? cuteShape : cuteShape.rotateZoom(rotationZoom);
|
||||||
|
// System.err.println("rotationZoom=" + rotationZoom + " tmp=" + tmp);
|
||||||
|
tmp.drawU(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Positionned rotateZoom(RotationZoom other) {
|
||||||
|
return new PositionnedImpl(cuteShape, color, other.getUTranslate(position), rotationZoom.compose(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Positionned translate(UTranslate other) {
|
||||||
|
return new PositionnedImpl(cuteShape, color, position.compose(other), rotationZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
104
src/net/sourceforge/plantuml/cute/Rectangle.java
Normal file
104
src/net/sourceforge/plantuml/cute/Rectangle.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class Rectangle implements CuteShape {
|
||||||
|
|
||||||
|
private final double width;
|
||||||
|
private final double height;
|
||||||
|
private final RotationZoom rotationZoom;
|
||||||
|
private final double curvation;
|
||||||
|
|
||||||
|
public Rectangle(VarArgs varArgs) {
|
||||||
|
final Point2D dim = varArgs.getAsPoint("dimension");
|
||||||
|
this.width = dim.getX();
|
||||||
|
this.height = dim.getY();
|
||||||
|
this.rotationZoom = RotationZoom.none();
|
||||||
|
this.curvation = varArgs.getAsDouble("curve", MyPoint2D.NO_CURVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Rectangle(double width, double height, RotationZoom rotationZoom, double curvation) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.rotationZoom = rotationZoom;
|
||||||
|
this.curvation = curvation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
CutePath cutePath = new CutePath();
|
||||||
|
cutePath.add(new Arc(MyPoint2D.from(0, 0).withCurvation(curvation), MyPoint2D.from(width, 0).withCurvation(
|
||||||
|
curvation)));
|
||||||
|
cutePath.add(new Arc(MyPoint2D.from(width, 0).withCurvation(curvation), MyPoint2D.from(width, height)
|
||||||
|
.withCurvation(curvation)));
|
||||||
|
cutePath.add(new Arc(MyPoint2D.from(width, height).withCurvation(curvation), MyPoint2D.from(0, height)
|
||||||
|
.withCurvation(curvation)));
|
||||||
|
cutePath.add(new Arc(MyPoint2D.from(0, height).withCurvation(curvation), MyPoint2D.from(0, 0).withCurvation(
|
||||||
|
curvation)));
|
||||||
|
cutePath = cutePath.rotateZoom(rotationZoom);
|
||||||
|
cutePath.drawU(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawUOld(UGraphic ug) {
|
||||||
|
final UPath path = new UPath();
|
||||||
|
if (curvation == MyPoint2D.NO_CURVE) {
|
||||||
|
path.moveTo(rotationZoom.getPoint(0, 0));
|
||||||
|
path.lineTo(rotationZoom.getPoint(width, 0));
|
||||||
|
path.lineTo(rotationZoom.getPoint(width, height));
|
||||||
|
path.lineTo(rotationZoom.getPoint(0, height));
|
||||||
|
path.lineTo(rotationZoom.getPoint(0, 0));
|
||||||
|
} else {
|
||||||
|
path.moveTo(rotationZoom.getPoint(width, curvation));
|
||||||
|
path.lineTo(rotationZoom.getPoint(width, height - curvation));
|
||||||
|
path.arcTo(rotationZoom.getPoint(width - curvation, height), curvation, 0, 1);
|
||||||
|
path.lineTo(rotationZoom.getPoint(curvation, height));
|
||||||
|
path.arcTo(rotationZoom.getPoint(0, height - curvation), curvation, 0, 1);
|
||||||
|
path.lineTo(rotationZoom.getPoint(0, curvation));
|
||||||
|
path.arcTo(rotationZoom.getPoint(curvation, 0), curvation, 0, 1);
|
||||||
|
path.lineTo(rotationZoom.getPoint(width - curvation, 0));
|
||||||
|
path.arcTo(rotationZoom.getPoint(width, curvation), curvation, 0, 1);
|
||||||
|
}
|
||||||
|
path.closePath();
|
||||||
|
ug.draw(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rectangle rotateZoom(RotationZoom other) {
|
||||||
|
return new Rectangle(width, height, rotationZoom.compose(other), curvation);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
127
src/net/sourceforge/plantuml/cute/RotationZoom.java
Normal file
127
src/net/sourceforge/plantuml/cute/RotationZoom.java
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class RotationZoom {
|
||||||
|
|
||||||
|
private final double angle;
|
||||||
|
private final double zoom;
|
||||||
|
|
||||||
|
private RotationZoom(double angle, double zoom) {
|
||||||
|
if (zoom < 0) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.angle = angle;
|
||||||
|
this.zoom = zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RotationZoom compose(RotationZoom other) {
|
||||||
|
return new RotationZoom(this.angle + other.angle, this.zoom * other.zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Rotation=" + Math.toDegrees(angle) + " Zoom=" + zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RotationZoom fromVarArgs(VarArgs varArgs) {
|
||||||
|
final double radians = Math.toRadians(varArgs.getAsDouble("rotation", 0));
|
||||||
|
final double scale = varArgs.getAsDouble("scale", 1);
|
||||||
|
return new RotationZoom(radians, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RotationZoom rotationInDegrees(double angle) {
|
||||||
|
return new RotationZoom(Math.toRadians(angle), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RotationZoom rotationInRadians(double angle) {
|
||||||
|
return new RotationZoom(angle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RotationZoom zoom(double zoom) {
|
||||||
|
return new RotationZoom(0, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RotationZoom inverse() {
|
||||||
|
return new RotationZoom(-angle, 1 / zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAngleDegree() {
|
||||||
|
return Math.toDegrees(angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public RotationZoom builtRotationOnYaxis(Point2D toRotate) {
|
||||||
|
final double a = Math.atan2(toRotate.getX(), toRotate.getY());
|
||||||
|
return new RotationZoom(a, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D.Double getPoint(double x, double y) {
|
||||||
|
if (angle == 0) {
|
||||||
|
return new Point2D.Double(x * zoom, y * zoom);
|
||||||
|
}
|
||||||
|
final double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
|
||||||
|
final double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
|
||||||
|
return new Point2D.Double(x1 * zoom, y1 * zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPoint(Point2D p) {
|
||||||
|
return getPoint(p.getX(), p.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public UTranslate getUTranslate(UTranslate translate) {
|
||||||
|
return new UTranslate(getPoint(translate.getDx(), translate.getDy()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RotationZoom none() {
|
||||||
|
return new RotationZoom(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNone() {
|
||||||
|
return angle == 0 && zoom == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double applyZoom(double value) {
|
||||||
|
return value * zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double applyRotation(double alpha) {
|
||||||
|
return angle + alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
108
src/net/sourceforge/plantuml/cute/Segment.java
Normal file
108
src/net/sourceforge/plantuml/cute/Segment.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class Segment {
|
||||||
|
|
||||||
|
private final Point2D a;
|
||||||
|
private final Point2D b;
|
||||||
|
private final double length;
|
||||||
|
|
||||||
|
public Segment(Point2D a, Point2D b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.length = a.distance(b);
|
||||||
|
if (length < 0.0001) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getFromAtoB(double dist) {
|
||||||
|
final double dx = b.getX() - a.getX();
|
||||||
|
final double dy = b.getY() - a.getY();
|
||||||
|
final double coef = dist / length;
|
||||||
|
final double x = dx * coef;
|
||||||
|
final double y = dy * coef;
|
||||||
|
return new Point2D.Double(a.getX() + x, a.getY() + y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getA() {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getB() {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getMiddle() {
|
||||||
|
return new Point2D.Double((a.getX() + b.getX()) / 2, (a.getY() + b.getY()) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D orthoDirection() {
|
||||||
|
final double dx = b.getX() - a.getX();
|
||||||
|
final double dy = b.getY() - a.getY();
|
||||||
|
return new Point2D.Double(-dy / length, dx / length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getOrthoPoint(double value) {
|
||||||
|
final Point2D ortho = orthoDirection();
|
||||||
|
final double dx = -ortho.getX() * value;
|
||||||
|
final double dy = -ortho.getY() * value;
|
||||||
|
return new Point2D.Double((a.getX() + b.getX()) / 2 + dx, (a.getY() + b.getY()) / 2 + dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isLeft(Point2D point) {
|
||||||
|
return ((b.getX() - a.getX()) * (point.getY() - a.getY()) - (b.getY() - a.getY()) * (point.getX() - a.getX())) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debugMe(UGraphic ug) {
|
||||||
|
final double dx = b.getX() - a.getX();
|
||||||
|
final double dy = b.getY() - a.getY();
|
||||||
|
ug = ug.apply(new UTranslate(a));
|
||||||
|
ug.draw(new ULine(dx, dy));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
98
src/net/sourceforge/plantuml/cute/Stick.java
Normal file
98
src/net/sourceforge/plantuml/cute/Stick.java
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
|
||||||
|
public class Stick implements CuteShape {
|
||||||
|
|
||||||
|
private final double width;
|
||||||
|
private final double height;
|
||||||
|
private final RotationZoom rotationZoom;
|
||||||
|
|
||||||
|
public Stick(VarArgs varArgs) {
|
||||||
|
final Point2D dim = varArgs.getAsPoint("dimension");
|
||||||
|
this.width = dim.getX();
|
||||||
|
this.height = dim.getY();
|
||||||
|
this.rotationZoom = RotationZoom.none();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Stick(double width, double height, RotationZoom rotation) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.rotationZoom = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
if (width > height) {
|
||||||
|
drawRotate1(ug);
|
||||||
|
} else {
|
||||||
|
drawRotate2(ug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawRotate1(UGraphic ug) {
|
||||||
|
assert width > height;
|
||||||
|
final UPath path = new UPath();
|
||||||
|
final double small = height / 2;
|
||||||
|
path.moveTo(rotationZoom.getPoint(small, 0));
|
||||||
|
path.lineTo(rotationZoom.getPoint(width - small, 0));
|
||||||
|
path.arcTo(rotationZoom.getPoint(width - small, height), small, 0, 1);
|
||||||
|
path.lineTo(rotationZoom.getPoint(small, height));
|
||||||
|
path.arcTo(rotationZoom.getPoint(small, 0), small, 0, 1);
|
||||||
|
path.closePath();
|
||||||
|
ug.draw(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawRotate2(UGraphic ug) {
|
||||||
|
assert height > width;
|
||||||
|
final UPath path = new UPath();
|
||||||
|
final double small = width / 2;
|
||||||
|
path.moveTo(rotationZoom.getPoint(width, small));
|
||||||
|
path.lineTo(rotationZoom.getPoint(width, height - small));
|
||||||
|
path.arcTo(rotationZoom.getPoint(0, height - small), small, 0, 1);
|
||||||
|
path.lineTo(rotationZoom.getPoint(0, small));
|
||||||
|
path.arcTo(rotationZoom.getPoint(width, small), small, 0, 1);
|
||||||
|
path.closePath();
|
||||||
|
ug.draw(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stick rotateZoom(RotationZoom other) {
|
||||||
|
return new Stick(width, height, this.rotationZoom.compose(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
src/net/sourceforge/plantuml/cute/Tension.java
Normal file
60
src/net/sourceforge/plantuml/cute/Tension.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
public class Tension {
|
||||||
|
|
||||||
|
private final double tension;
|
||||||
|
|
||||||
|
public Tension(double tension) {
|
||||||
|
this.tension = tension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Tension none() {
|
||||||
|
return new Tension(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tension rotateZoom(RotationZoom rotationZoom) {
|
||||||
|
return new Tension(rotationZoom.applyZoom(tension));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNone() {
|
||||||
|
return tension == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getValue() {
|
||||||
|
return tension;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
67
src/net/sourceforge/plantuml/cute/Triangle.java
Normal file
67
src/net/sourceforge/plantuml/cute/Triangle.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class Triangle implements CuteShape {
|
||||||
|
|
||||||
|
private final CutePath cutePath;
|
||||||
|
|
||||||
|
public Triangle(VarArgs varArgs) {
|
||||||
|
this(varArgs.getPointList("points"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Triangle(CutePath cutePath) {
|
||||||
|
this.cutePath = cutePath;
|
||||||
|
// if (points.size() != 3) {
|
||||||
|
// throw new IllegalArgumentException();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Triangle rotateZoom(final RotationZoom angle) {
|
||||||
|
if (angle.isNone()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return new Triangle(cutePath.rotateZoom(angle));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
cutePath.drawU(ug);
|
||||||
|
// ug = ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK));
|
||||||
|
// cutePath.withNoTension().drawU(
|
||||||
|
// ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
141
src/net/sourceforge/plantuml/cute/TriangleCorner.java
Normal file
141
src/net/sourceforge/plantuml/cute/TriangleCorner.java
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class TriangleCorner {
|
||||||
|
|
||||||
|
private final Point2D o;
|
||||||
|
private final Point2D a;
|
||||||
|
private final Point2D b;
|
||||||
|
private final TriangleCornerSimple simple;
|
||||||
|
private final UTranslate translateO;
|
||||||
|
private final UTranslate translateOreverse;
|
||||||
|
|
||||||
|
private final RotationZoom rotation;
|
||||||
|
private final RotationZoom rotationInverse;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Corner " + o + " a=" + a + " b=" + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCurvation() {
|
||||||
|
return ((MyPoint2D) o).hasCurvation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCurvation() {
|
||||||
|
if (hasCurvation() == false) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
return ((MyPoint2D) o).getCurvation(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleCorner(Point2D o, Point2D a, Point2D b) {
|
||||||
|
this.o = o;
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.translateO = new UTranslate(o);
|
||||||
|
this.translateOreverse = translateO.reverse();
|
||||||
|
final Point2D a2 = translateOreverse.getTranslated(a);
|
||||||
|
final Point2D b2 = translateOreverse.getTranslated((b));
|
||||||
|
|
||||||
|
final Point2D a3, b3;
|
||||||
|
if (a2.getX() == 0) {
|
||||||
|
a3 = a2;
|
||||||
|
b3 = b2;
|
||||||
|
this.rotation = RotationZoom.none();
|
||||||
|
this.rotationInverse = RotationZoom.none();
|
||||||
|
} else {
|
||||||
|
this.rotation = RotationZoom.builtRotationOnYaxis(a2);
|
||||||
|
this.rotationInverse = rotation.inverse();
|
||||||
|
a3 = rotation.getPoint(a2);
|
||||||
|
b3 = rotation.getPoint(b2);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.simple = new TriangleCornerSimple(a3, b3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getOnSegmentA(double dist) {
|
||||||
|
final Segment seg = new Segment(o, a);
|
||||||
|
return seg.getFromAtoB(dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getOnSegmentB(double dist) {
|
||||||
|
final Segment seg = new Segment(o, b);
|
||||||
|
return seg.getFromAtoB(dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon getCenterWithFixedRadius(double radius) {
|
||||||
|
final Point2D centerSimple = simple.getCenterWithFixedRadius(radius);
|
||||||
|
return new Balloon(rotationInverse.getPoint(translateO.getTranslated(centerSimple)), radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Balloon getBalloonWithFixedY(double y) {
|
||||||
|
Balloon result = simple.getBalloonWithFixedY(y);
|
||||||
|
result = result.rotate(rotationInverse);
|
||||||
|
result = result.translate(translateO);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getCornerOrBalloonCenter() {
|
||||||
|
if (hasCurvation()) {
|
||||||
|
return getBalloonInside().getCenter();
|
||||||
|
}
|
||||||
|
return getO();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double determinant() {
|
||||||
|
final double ux = a.getX() - o.getX();
|
||||||
|
final double uy = a.getY() - o.getY();
|
||||||
|
final double vx = b.getX() - o.getX();
|
||||||
|
final double vy = b.getY() - o.getY();
|
||||||
|
return ux * vy - uy * vx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getO() {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon getBalloonInside() {
|
||||||
|
if (hasCurvation() == false) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
return getBalloonWithFixedY(getCurvation());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
115
src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
Normal file
115
src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
public class TriangleCornerSimple {
|
||||||
|
|
||||||
|
private final Point2D a;
|
||||||
|
private final Point2D b;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TriangleCornerSimple a=" + a + " " + Math.toDegrees(getAngleA()) + " b=" + b + " "
|
||||||
|
+ Math.toDegrees(getAngleB());
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleCornerSimple(Point2D a, Point2D b) {
|
||||||
|
if (isZero(a.getX()) == false) {
|
||||||
|
throw new IllegalArgumentException("a=" + a);
|
||||||
|
}
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isZero(double v) {
|
||||||
|
return Math.abs(v) < 0.0001;
|
||||||
|
}
|
||||||
|
|
||||||
|
double getAngleA() {
|
||||||
|
return getAngle(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getAngleB() {
|
||||||
|
return getAngle(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getAngle(Point2D pt) {
|
||||||
|
final double dx = pt.getX();
|
||||||
|
final double dy = pt.getY();
|
||||||
|
return Math.atan2(dy, dx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static double solveY(double alpha, double x) {
|
||||||
|
if (alpha < 0 || alpha > Math.PI / 2) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
return x * Math.tan(alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double solveX(double alpha, double y) {
|
||||||
|
if (alpha < -Math.PI / 2 || alpha > Math.PI / 2) {
|
||||||
|
// throw new IllegalArgumentException("y=" + y + " alpha=" + Math.toDegrees(alpha));
|
||||||
|
}
|
||||||
|
final double beta = Math.PI / 2 - alpha;
|
||||||
|
// System.err.println("alpha1=" + Math.toDegrees(alpha));
|
||||||
|
// System.err.println("beta11=" + Math.toDegrees(beta));
|
||||||
|
// System.err.println("XX=" + y * Math.tan(beta));
|
||||||
|
return y * Math.tan(beta);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getCenterWithFixedRadius(double radius) {
|
||||||
|
final double alpha = (getAngleA() + getAngleB()) / 2;
|
||||||
|
final double y = solveY(alpha, radius);
|
||||||
|
return new Point2D.Double(radius, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Balloon getBalloonWithFixedY(double y) {
|
||||||
|
// System.err.println("TriangleCornerSimple::getCenterWithFixedY y=" + y);
|
||||||
|
// System.err.println("a=" + a + " " + Math.toDegrees(getAngleA()));
|
||||||
|
// System.err.println("b=" + b + " " + Math.toDegrees(getAngleB()));
|
||||||
|
final double alpha = (getAngleA() + getAngleB()) / 2;
|
||||||
|
// System.err.println("alpha=" + Math.toDegrees(alpha));
|
||||||
|
final double sign = Math.signum(a.getY());
|
||||||
|
// System.err.println("sgn=" + sign);
|
||||||
|
final double x = solveX(alpha, y);
|
||||||
|
final Balloon result = new Balloon(new Point2D.Double(x * sign, y * sign), Math.abs(x));
|
||||||
|
// System.err.println("result=" + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
130
src/net/sourceforge/plantuml/cute/VarArgs.java
Normal file
130
src/net/sourceforge/plantuml/cute/VarArgs.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 4041 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.cute;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorSet;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class VarArgs {
|
||||||
|
|
||||||
|
private final Map<String, String> args = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public VarArgs(String data) {
|
||||||
|
for (String s : data.split("\\s")) {
|
||||||
|
if (s.contains("=")) {
|
||||||
|
final StringTokenizer st = new StringTokenizer(s, "=");
|
||||||
|
final String key = st.nextToken();
|
||||||
|
final String value = st.nextToken();
|
||||||
|
args.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// System.err.println("arg=" + args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return args.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAsDouble(String k, double def) {
|
||||||
|
if (args.containsKey(k)) {
|
||||||
|
return getAsDouble(k);
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAsDouble(String k) {
|
||||||
|
final String value = args.get(k);
|
||||||
|
if (value == null) {
|
||||||
|
throw new IllegalArgumentException("no key " + k);
|
||||||
|
}
|
||||||
|
return Double.parseDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyDouble getAsMyDouble(String k) {
|
||||||
|
final String value = args.get(k);
|
||||||
|
if (value == null) {
|
||||||
|
throw new IllegalArgumentException("no key " + k);
|
||||||
|
}
|
||||||
|
return new MyDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlColor getAsColor(String k) {
|
||||||
|
final String value = args.get(k);
|
||||||
|
if (value == null) {
|
||||||
|
return HtmlColorUtils.BLACK;
|
||||||
|
}
|
||||||
|
final HtmlColor result = HtmlColorSet.getInstance().getColorIfValid(value);
|
||||||
|
if (result == null) {
|
||||||
|
return HtmlColorUtils.BLACK;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getAsPoint(String k) {
|
||||||
|
final String value = args.get(k);
|
||||||
|
if (value == null) {
|
||||||
|
throw new IllegalArgumentException("no key " + k);
|
||||||
|
}
|
||||||
|
final StringTokenizer st = new StringTokenizer(value.replaceAll("[()]", ""), ",");
|
||||||
|
return new Point2D.Double(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getAsPoint(String k, Point2D def) {
|
||||||
|
if (args.containsKey(k)) {
|
||||||
|
return getAsPoint(k);
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CutePath getPointList(String k) {
|
||||||
|
final String value = args.get(k);
|
||||||
|
if (value == null) {
|
||||||
|
throw new IllegalArgumentException("no key " + k);
|
||||||
|
}
|
||||||
|
return new CutePath(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UTranslate getPosition() {
|
||||||
|
return new UTranslate(getAsPoint("position", new Point2D.Double()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2014, 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 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: 9434 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.descdiagram.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
|
import net.sourceforge.plantuml.command.SingleLineCommand;
|
||||||
|
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
|
||||||
|
|
||||||
|
public class CommandNamespaceSeparator extends SingleLineCommand<DescriptionDiagram> {
|
||||||
|
|
||||||
|
public CommandNamespaceSeparator() {
|
||||||
|
super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeArg(DescriptionDiagram diagram, List<String> arg) {
|
||||||
|
final String s = arg.get(0);
|
||||||
|
if ("none".equalsIgnoreCase(s)) {
|
||||||
|
diagram.setNamespaceSeparator(null);
|
||||||
|
} else {
|
||||||
|
diagram.setNamespaceSeparator(s);
|
||||||
|
}
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user