1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

version 1.2019.1

This commit is contained in:
Arnaud Roques 2019-02-09 22:56:24 +01:00
parent 10a4c323b9
commit d7535d8027
96 changed files with 652 additions and 3287 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2019.1-SNAPSHOT</version>
<version>1.2019.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -71,9 +71,9 @@ public class AnnotatedWorker {
}
public TextBlockBackcolored addAdd(TextBlock result) {
result = addTitle(result);
result = addFrame(result);
result = addLegend(result);
result = addTitle(result);
result = addCaption(result);
result = addHeaderAndFooter(result);
return (TextBlockBackcolored) result;

View File

@ -108,6 +108,7 @@ public class Option {
if (arg.length == 0) {
OptionFlags.getInstance().setGui(true);
}
initInclude(GraphvizUtils.getenvDefaultConfigFilename());
for (int i = 0; i < arg.length; i++) {
String s = arg[i];
if (s.equalsIgnoreCase("-headless")) {
@ -409,13 +410,21 @@ public class Option {
}
private void initInclude(String filename) throws IOException {
if (filename == null) {
return;
}
if (filename.contains("*")) {
final FileGroup group = new FileGroup(filename, Collections.<String> emptyList(), null);
for (File f : group.getFiles()) {
addInConfig(new FileReader(f));
if (f.exists() && f.canRead()) {
addInConfig(new FileReader(f));
}
}
} else {
addInConfig(new FileReader(filename));
final File f = new File(filename);
if (f.exists() && f.canRead()) {
addInConfig(new FileReader(f));
}
}
}

View File

@ -142,7 +142,7 @@ public class OptionPrint {
System.out.println(" -splash\t\tTo display a splash screen with some progress bar");
System.out.println(" -progress\t\tTo display a textual progress bar in console");
System.out.println(" -pipeimageindex N\tTo generate the Nth image with pipe option");
System.out.println(" -stdlib\t\tTo print standart library info");
System.out.println(" -stdlib\t\tTo print standard library info");
System.out.println(" -extractstdlib\tTo extract PlantUML Standard Library into stdlib folder");
System.out.println(" -filename \"example.puml\"\tTo override %filename% variable");
System.out.println(" -preproc\t\tTo output preprocessor text of diagrams");

View File

@ -432,7 +432,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return legend;
}
public final void setLegend(DisplayPositionned legend) {
public void setLegend(DisplayPositionned legend) {
this.legend = legend;
}

View File

@ -50,16 +50,17 @@ public class WormMutation {
public static WormMutation create(Worm worm, double delta) {
final String signature = worm.getDirectionsCode();
if (signature.length() > 2) {
final String definition = getDefinition(signature);
if (definition == null) {
return createFromLongSignature(signature, delta);
}
return createFromSimpleSignature(signature, delta);
return new WormMutation(definition, delta);
}
private static WormMutation createFromLongSignature(final String signature, final double delta) {
final WormMutation result = new WormMutation();
for (int i = 0; i < signature.length() - 1; i++) {
WormMutation tmp = createFromSimpleSignature(signature.substring(i, i + 2), delta);
WormMutation tmp = new WormMutation(getDefinition(signature.substring(i, i + 2)), delta);
if (i == 0) {
result.translations.add(tmp.translations.get(0));
} else {
@ -96,64 +97,61 @@ public class WormMutation {
return translations.size();
}
private static WormMutation createFromSimpleSignature(final String signature, final double delta) {
final WormMutation result = new WormMutation();
// System.err.println("signature=" + signature);
private static String getDefinition(final String signature) {
if (signature.equals("D") || signature.equals("U")) {
final UTranslate translate = new UTranslate(delta, 0);
result.translations.add(translate);
result.translations.add(translate);
return result;
return "33";
} else if (signature.equals("L") || signature.equals("R")) {
return "55";
} else if (signature.equals("RD")) {
return "123";
} else if (signature.equals("RU")) {
return "543";
} else if (signature.equals("LD")) {
return "187";
} else if (signature.equals("DL")) {
return "345";
} else if (signature.equals("DR")) {
return "765";
} else if (signature.equals("UL")) {
return "321";
} else if (signature.equals("UR")) {
return "781";
// } else if (signature.equals("DLD")) {
// return "3443";
}
if (signature.equals("L") || signature.equals("R")) {
final UTranslate translate = new UTranslate(0, delta);
result.translations.add(translate);
result.translations.add(translate);
return result;
return null;
}
private WormMutation(String definition, double delta) {
if (definition == null) {
throw new IllegalArgumentException();
}
if (signature.equals("RD")) {
result.translations.add(new UTranslate(0, -delta));
result.translations.add(new UTranslate(delta, -delta));
result.translations.add(new UTranslate(delta, 0));
return result;
for (int i = 0; i < definition.length(); i++) {
this.translations.add(translation(Integer.parseInt(definition.substring(i, i + 1)), delta));
}
if (signature.equals("RU")) {
result.translations.add(new UTranslate(0, delta));
result.translations.add(new UTranslate(delta, delta));
result.translations.add(new UTranslate(delta, 0));
return result;
}
private static UTranslate translation(int type, double delta) {
switch (type) {
case 1:
return new UTranslate(0, -delta);
case 2:
return new UTranslate(delta, -delta);
case 3:
return new UTranslate(delta, 0);
case 4:
return new UTranslate(delta, delta);
case 5:
return new UTranslate(0, delta);
case 6:
return new UTranslate(-delta, delta);
case 7:
return new UTranslate(-delta, 0);
case 8:
return new UTranslate(-delta, -delta);
}
if (signature.equals("LD")) {
result.translations.add(new UTranslate(0, -delta));
result.translations.add(new UTranslate(-delta, -delta));
result.translations.add(new UTranslate(-delta, 0));
return result;
}
if (signature.equals("DL")) {
result.translations.add(new UTranslate(delta, 0));
result.translations.add(new UTranslate(delta, delta));
result.translations.add(new UTranslate(0, delta));
return result;
}
if (signature.equals("DR")) {
result.translations.add(new UTranslate(-delta, 0));
result.translations.add(new UTranslate(-delta, delta));
result.translations.add(new UTranslate(0, delta));
return result;
}
if (signature.equals("UL")) {
result.translations.add(new UTranslate(delta, 0));
result.translations.add(new UTranslate(delta, -delta));
result.translations.add(new UTranslate(0, -delta));
return result;
}
if (signature.equals("UR")) {
result.translations.add(new UTranslate(-delta, 0));
result.translations.add(new UTranslate(-delta, -delta));
result.translations.add(new UTranslate(0, -delta));
return result;
}
throw new UnsupportedOperationException(signature);
throw new IllegalArgumentException();
}
static private class MinMax {

View File

@ -42,12 +42,12 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import net.sourceforge.plantuml.AlignmentParam;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.activitydiagram3.PositionedNote;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
@ -133,9 +133,9 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil {
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, skinParam.wrapWidth() , skinParam.getPadding()),
final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false);
final Sheet sheet = new CreoleParser(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, skinParam.wrapWidth(), skinParam.getPadding()),
this, new UStroke(1));
opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(null), withLink);

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
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.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
@ -131,7 +132,8 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
if (lines.size() > 0) {
final boolean tryMerge = line0.get("VMERGE", 0) != null;
final Note note = new Note(p1, p2, lines.toDisplay());
final Display display = diagram.manageVariable(lines.toDisplay());
final Note note = new Note(p1, p2, display);
final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
note.setColors(colors);
// note.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));

View File

@ -261,4 +261,12 @@ public class GroupRoot implements IGroup {
public Set<Stereotag> stereotags() {
throw new UnsupportedOperationException();
}
public void setLegend(DisplayPositionned legend) {
throw new UnsupportedOperationException();
}
public DisplayPositionned getLegend() {
throw new UnsupportedOperationException();
}
}

View File

@ -70,4 +70,8 @@ public interface IGroup extends IEntity {
public char getConcurrentSeparator();
public void setConcurrentSeparator(char separator);
public void setLegend(DisplayPositionned legend);
public DisplayPositionned getLegend();
}

View File

@ -89,7 +89,7 @@ public class GraphvizUtils {
}
private static boolean useVizJs(ISkinParam skinParam) {
if (skinParam!=null && skinParam.isUseVizJs() && VizJsEngine.isOk()) {
if (skinParam != null && skinParam.isUseVizJs() && VizJsEngine.isOk()) {
return true;
}
if (VIZJS.equalsIgnoreCase(getenvGraphvizDot()) && VizJsEngine.isOk()) {
@ -143,6 +143,14 @@ public class GraphvizUtils {
return 4096;
}
public static String getenvDefaultConfigFilename() {
final String env = System.getProperty("PLANTUML_DEFAULT_CONFIG_FILENAME");
if (StringUtils.isNotEmpty(env)) {
return env;
}
return System.getenv("PLANTUML_DEFAULT_CONFIG_FILENAME");
}
public static String getenvLogData() {
final String env = System.getProperty("PLANTUML_LOGDATA");
if (StringUtils.isNotEmpty(env)) {

View File

@ -96,6 +96,11 @@ public class ProcessState {
return name.equals(other.name);
}
@Override
public int hashCode() {
return name.hashCode();
}
public Throwable getCause() {
return cause;
}

View File

@ -52,6 +52,7 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
@ -90,6 +91,7 @@ final class EntityImpl implements ILeaf, IGroup {
private final Bodier bodier;
private final String uid = StringUtils.getUid("cl", UniqueSequence.getValue());
private Display display = Display.empty();
private DisplayPositionned legend = null;
private LeafType leafType;
private Stereotype stereotype;
@ -644,4 +646,15 @@ final class EntityImpl implements ILeaf, IGroup {
public VisibilityModifier getVisibilityModifier() {
return visibility;
}
public void setLegend(DisplayPositionned legend) {
checkGroup();
this.legend = legend;
}
public DisplayPositionned getLegend() {
checkGroup();
return legend;
}
}

View File

@ -50,6 +50,7 @@ public class Dedications {
static {
addNormal("Write your own dedication!", "dedication");
addNormal("linux_china", "linux_china");
addNormal("ARKBAN", "arkban");
addCrypted("0", "pOhci6rKgPXw32AeYXhOpSY0suoauHq5VUSwFqHLHsLYgSO6WaJ7BW5vtHBAoU6ePbcW7d8Flx99MWjPSKQTDm00");
addCrypted("1", "LTxN3hdnhSJ515qcA7IQ841axt4GXfUd3n2wgNirYCdLnyX2360Gv1OEOnJ1-gwFzRW5B3HAqLBkR6Ge0WW_Z000");
}

Binary file not shown.

View File

@ -67,21 +67,26 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "6v8802mEp3EZtv0iGcz-fvJYI4HCdvyvFoLZ70fX42Pji_Rj7u5_xF8MOOgGwCb2hYywcqt8cZ7fvZdB"
+ "UKOHB9z6h9SwR7EpNwh8AC6pcc_-6SNudZjfQ4BQdR1i1_B_wLu53WLaSJR5GnWEsFmBC_QWEUnUABLh"
+ "wMBt2ze2ZMdqOyjAyTtoFPIoRgV0R9HytwmWOV4FnnLLiXJZBf5YgXDROEAE6SdMwKxm3RVRVzHDQj7Q"
+ "ceQ4Zm1Y6obiROzzBIuBEJw5WH74e0umG8G3AOVw8ATuUy41HAyQCUApcCPwgtUUA4321XLQy8-SLESM"
+ "iZpBa0bYS3CGCFaEd03iJKabcEtS1kHfWHP53PRgrdKd8ZFU34y9MJHSHGuOHD0Ag4AGDq47-2vjorkC"
+ "nvWLCVpHFHWVtX3aJHQUI2yM-dhhmK3usLqrazNjJcrg8SGbxtMSjJR0iuQC7EsXzxXaCnxhrrmAmsyj"
+ "G7uBz5BlY1X_Szqi945mBgatd7ME7D-c28Gsbef5xcBAQy8PNNQsfgZlBLYOb_phrg4immXTgRW5y0ij"
+ "ZvDrlb3SDDH_BxaQEdu5rdWqt5k1ijFcOlvxsItDZD83jDc5pT1L4U6USMXLA2P31AuG-ZxW8KdEfDh7"
+ "v57zMBx4F_Od8Rn5uO2LDZFQdrLN98eSLa4Mb3lQn08mtIJQ0M9q9s44r0NTXYhdy0nttRi9UTfcO-hQ"
+ "eOPZDy8OrBVf9FaWOZUNZ9A67bas2ukr7t2Mu1mkajVFFHor2c0zqhlhPcc-mK2yXJdT8js6vML9koMY"
+ "g2D4bjCMh-hYh-wsykUXCtyuvx5ew8tpJvvVXun7yoLzQQb7bBbhqFtj25dUpaXHPjWEr-503MHy2hXU"
+ "DNccaYCGlUaCXqPi967M1w-T1OTm1nVHMATiBqrBaAtdwcEW6Vo8tCcGIZrm9n7hk0jmXl4eij-Ozyge"
+ "k_eyf4Gje60C4vobGjX7I54DsxOWGyRuwHcCJhxoeIqMy6dioSmw53vXebt31ZQc48iMzOEu2S3rtjUe"
+ "bpGcIi3NlFocUioiWvu_iwKLuW1EAGa1g63uy1rdfqgRhMcij-Zzs3HzBHj__MUkCi4f5VkyMu1K1p7v"
+ "BuSWCX7VbTqZy5daOudHHaRWM2lRMBcqz3Z0i22JbXbgcfyPyUbQADVN1ZHhVIZFVvHLdh6dvmK0";
private static final int COLS = 6;
private static final int FREE_LINES = 6;
public static final String DONORS = "6zm80AmEEBmtNeGqQ-xME_ioXj6A6CylpxzGd5Z4qzs0-0MuTthSRwI_YAvqxvjcH5klBSmPH700wedp"
+ "RuQMT_qrVlFrLJB6LIrTOG84tZ4kxHj_ULk8gMBxBHFQ-zkF2tL8QuNW2jnKJiZyTAy2XmAoE9jY_ZbW"
+ "O-FQkxLxdrgxbYvsFw0jq9X6FxQibADsTU1heSR1aN5yGqfcnPWFaQAfZIr0moTkn6gZEi4dKhF_g4Lg"
+ "qffTGxfB0B6C5B7cRT7SlfFjKnWuuQXaXm94E91mI2zo752VIC1HIgD6P1IZiQxYBKz44A632hlmZvmK"
+ "dpraUPIX0uxARY2WyHi40NWcnPJOREDcGCuUrYAdmKATcHizalt5u9GZ3nek8JjK8gW5L078cw0BUbrz"
+ "vX9d6PkYX2TlORpAOe2SPLq0ZYSp-jfBOQ3ytpym4-Hoezfw27FATOnV7HtmKqD6zdxJQfopc8ZvRIx8"
+ "y8K5E5y0lTGQAiRVD-UDXNW8ZIbr8IVEmUDz586mobAmo4rCSStnaovziPgORrrOB1_XrvcXBCC8NAdO"
+ "0_Y8bjC7TRw0hXhgduTSTHsVmjOuBTXRX4ydpRdY_rst93DA5z1Q4pv4LqAKBBrWbIqcHGIk0Fesu259"
+ "RgJgo-HHlYmV4k_xao3Ud70WKfi5x4_A6OrB3bE85rOwLCKCOBfBr0kEserqmwiJqBj0vHGPuQxVquGz"
+ "RDAOEZUuud4_n1ZaYtIyVD5ZCvUCImsTCcrsxDH-n560s_0bUTLz68vL04jHxvR5qdWQ0-uQvZI3T1sH"
+ "zprjIOzB7QLbEMvnLPTuDhU3YuTEBZYJHMFCQ7CSCZiadvEfgLkCvwb1uxT1PEts2gBE0dU3TJYGOHcV"
+ "0zOLamEL7C5H6ivmoCGa2QtMUSLk0t0FechhcEsfQmcndhhw5AWsViJPo81AsWd744UxA-oCXQF8Vjcy"
+ "LqRTrBSX6CS2yiKWmKagb6s4e39iJY53UX_qZCP9FizBkonas_XcuGM6mYT8TDziWrMc48yKwOsw1i3r"
+ "Owl4YnyJ8u2VyVORw5d6EkZvDtfQMHp0ff8GC1MMSlYNOALYtQn9hBVeTLjhRylEdt-l8zCunVisLWgW"
+ "no2B_WiXY9EeSmMte1yNV2P7RI4ZiA-3RLkvDlGumA2WHIsJNBLDC-BJMLQketPuvF6XdFykao2mdqz8"
+ "Ud4AAaUV4gpMtkfAPQ1zyet5IGuM_nHL6hAuYZfgOiGH";
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
@ -94,7 +99,7 @@ public class PSystemDonors extends AbstractPSystem {
}
private UDrawable getGraphicStrings() throws IOException {
final List<TextBlock> cols = getCols(getDonors(), 7, 5);
final List<TextBlock> cols = getCols(getDonors(), COLS, FREE_LINES);
return new UDrawable() {
public void drawU(UGraphic ug) {
final TextBlockBackcolored header = GraphicStrings.createBlackOnWhite(Arrays

View File

@ -311,11 +311,13 @@ public class EpsGraphics {
}
public void epsPolygon(HtmlColorGradient gr, ColorMapper mapper, double... points) {
assert points.length % 2 == 0;
setFillColor(mapper.getMappedColor(gr.getColor1()));
epsPolygon(points);
}
public void epsPolygon(double... points) {
assert points.length % 2 == 0;
checkCloseDone();
double lastX = 0;
double lastY = 0;
@ -761,6 +763,7 @@ public class EpsGraphics {
}
public void epsPolygonShadow(double deltaShadow, double... points) {
assert points.length % 2 == 0;
setStrokeColor(null);
for (double i = 0; i <= deltaShadow; i += 0.5) {
setFillColor(shadowManager.getColor(i, deltaShadow));

View File

@ -109,8 +109,8 @@ public class DiagElement {
}
public final void setShape(String shapeName) {
USymbol shapeFromString = USymbol.getFromString(shapeName);
if (shapeFromString!=null){
final USymbol shapeFromString = USymbol.getFromString(shapeName);
if (shapeFromString != null) {
this.shape = shapeFromString;
}
}

View File

@ -42,7 +42,10 @@ import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
@ -310,4 +313,17 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
}
}
@Override
public void setLegend(DisplayPositionned legend) {
final IGroup currentGroup = this.getCurrentGroup();
if (currentGroup instanceof GroupRoot) {
super.setLegend(legend);
return;
}
currentGroup.setLegend(legend);
}
}

View File

@ -1,84 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class BasicInstantArithmetic implements InstantArithmetic {
private final DayClose dayClose;
BasicInstantArithmetic(DayClose dayClose) {
if (dayClose == null) {
throw new IllegalArgumentException();
}
this.dayClose = dayClose;
}
public Instant add(Instant i1, Duration duration) {
Instant result = i1;
final long min = duration.getMinutes();
if (min < 0) {
throw new IllegalArgumentException();
}
for (long i = 0; i < min; i += 24 * 60 * 60) {
result = result.next(dayClose);
}
return result;
}
public Instant sub(Instant i1, Duration duration) {
Instant result = i1;
final long min = duration.getMinutes();
if (min < 0) {
throw new IllegalArgumentException();
}
for (long i = 0; i < min; i += 24 * 60 * 60) {
result = result.prev(dayClose);
}
return result;
}
public Duration diff(Instant i1, Instant i2) {
if (i2.compareTo(i1) < 0) {
throw new IllegalArgumentException();
}
long minutes = 0;
while (i2.compareTo(i1) > 0) {
minutes += 24 * 60 * 60;
i1 = i1.next(null);
}
return new Duration(minutes);
}
}

View File

@ -1,177 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Day implements Comparable<Day> {
private final int numDay;
private final Month month;
private final int year;
private final WeekDay weekDay;
private Day(int year, Month month, int numDay, WeekDay weekDay) {
this.year = year;
this.month = month;
this.numDay = numDay;
this.weekDay = weekDay;
}
public static boolean isValidDesc(String desc) {
if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
return true;
}
if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
return true;
}
return false;
}
public Day(String desc) {
if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
this.year = Integer.parseInt(desc.substring(0, 4));
this.month = Month.fromNum(Integer.parseInt(desc.substring(5, 7)));
this.numDay = Integer.parseInt(desc.substring(8, 10));
} else if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
this.year = Integer.parseInt(desc.substring(7, 11));
this.month = Month.valueOf(desc.substring(3, 6));
this.numDay = Integer.parseInt(desc.substring(0, 2));
} else {
throw new IllegalArgumentException(desc);
}
final int wd = new GregorianCalendar(year, month.getNum() - 1, numDay).get(Calendar.DAY_OF_WEEK);
this.weekDay = WeekDay.values()[wd - 1];
}
public Day next(DayClose dayClose) {
if (dayClose == null) {
return nextInternal();
}
if (dayClose.isClose(this)) {
throw new IllegalArgumentException();
}
Day result = nextInternal();
while (dayClose.isClose(result)) {
result = result.nextInternal();
}
return result;
}
public Day prev(DayClose dayClose) {
if (dayClose == null) {
return prevInternal();
}
if (dayClose.isClose(this)) {
throw new IllegalArgumentException();
}
Day result = prevInternal();
while (dayClose.isClose(result)) {
result = result.prevInternal();
}
return result;
}
private Day nextInternal() {
if (numDay < month.getNbDays(year)) {
return new Day(year, month, numDay + 1, weekDay.next());
}
final Month next = month.next();
if (next == null) {
return new Day(year + 1, Month.JAN, 1, weekDay.next());
}
return new Day(year, next, 1, weekDay.next());
}
private Day prevInternal() {
if (numDay > 1) {
return new Day(year, month, numDay - 1, weekDay.prev());
}
final Month prev = month.prev();
if (prev == null) {
return new Day(year - 1, Month.DEC, 31, weekDay.prev());
}
return new Day(year, prev, prev.getNbDays(year), weekDay.prev());
}
@Override
public String toString() {
return "" + weekDay + " " + year + "-" + month + "-" + String.format("%02d", numDay);
}
public final int getNumDay() {
return numDay;
}
public final Month getMonth() {
return month;
}
public final int getYear() {
return year;
}
public int compareTo(Day other) {
if (year > other.year) {
return 1;
}
if (year < other.year) {
return -1;
}
final int cmpMonth = month.compareTo(other.month);
if (cmpMonth != 0) {
return cmpMonth;
}
return numDay - other.numDay;
}
@Override
public boolean equals(Object obj) {
final Day this2 = (Day) obj;
return this.numDay == this2.numDay && this.month == this2.month && this.year == this2.year;
}
@Override
public int hashCode() {
return numDay * 420 + year + month.hashCode();
}
public final WeekDay getWeekDay() {
return weekDay;
}
}

View File

@ -1,42 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
interface DayClose {
boolean isClose(Day day);
}

View File

@ -1,44 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class DayCloseNone implements DayClose {
public boolean isClose(Day day) {
return false;
}
}

View File

@ -1,58 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.List;
class DayCloseOr implements DayClose {
private final List<DayClose> all = new ArrayList<DayClose>();
public boolean isClose(Day day) {
for (DayClose dc : all) {
if (dc.isClose(day)) {
return true;
}
}
return false;
}
public void add(DayClose dayClose) {
all.add(dayClose);
}
}

View File

@ -1,53 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class DayCloseWeekDay implements DayClose {
private final WeekDay weekDay;
public DayCloseWeekDay(WeekDay weekDay) {
this.weekDay = weekDay;
}
public boolean isClose(Day day) {
if (day.getWeekDay() == weekDay) {
return true;
}
return false;
}
}

View File

@ -1,46 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
public interface Expression {
Numeric getValue();
String getDescription();
NumericType getNumericType();
}

View File

@ -1,60 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class FormalAddition implements Formal {
private final Expression exp1;
private final Expression exp2;
public FormalAddition(Expression exp1, Expression exp2) {
this.exp1 = exp1;
this.exp2 = exp2;
}
public String getDescription() {
return "add " + exp1 + " " + exp2;
}
public NumericType getNumericType() {
return exp1.getNumericType();
}
public Numeric getValue() {
return exp1.getValue().add(exp2.getValue());
}
}

View File

@ -1,67 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class FormalAdditionInstantDuration implements Formal {
private final Expression exp1;
private final Expression exp2;
private final InstantArithmetic math;
public FormalAdditionInstantDuration(Expression exp1, Expression exp2, InstantArithmetic math) {
this.exp1 = exp1;
this.exp2 = exp2;
this.math = math;
}
public String getDescription() {
return "addID " + exp1 + " " + exp2;
}
public NumericType getNumericType() {
return exp1.getNumericType();
}
public Numeric getValue() {
if (exp2.getNumericType() == NumericType.NUMBER) {
final Duration d = new Duration((NumericNumber) exp2.getValue());
return math.add((Instant) exp1.getValue(), d);
}
return math.add((Instant) exp1.getValue(), (Duration) exp2.getValue());
}
}

View File

@ -1,71 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class FreeVariable implements Expression {
private Expression value;
private final String name;
private final NumericType type;
public FreeVariable(String name, NumericType type) {
this.name = name;
this.type = type;
}
public String getDescription() {
return "$" + name + "=" + (value == null ? "null" : value.getDescription());
}
public NumericType getNumericType() {
return type;
}
public Numeric getValue() {
if (value == null) {
return null;
}
return value.getValue();
}
public void setValue(Expression expression) {
if (expression.getNumericType() != type) {
throw new IllegalArgumentException("Bad type");
}
this.value = expression;
}
}

View File

@ -1,192 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
class IncompleteItem implements Item {
private Map<ItemCaract, Numeric> data = new EnumMap<ItemCaract, Numeric>(ItemCaract.class);
private final InstantArithmetic math;
private final Item parent;
private final String code;
public IncompleteItem(String code, Item parent, InstantArithmetic math) {
this.math = math;
this.code = code;
this.parent = parent;
}
public void setData(ItemCaract caract, Numeric value) {
if (caract.getNumericType() != value.getNumericType()) {
throw new IllegalArgumentException();
}
if (data.containsKey(caract)) {
throw new IllegalStateException();
}
data.put(caract, value);
boolean change = false;
do {
change = false;
change = eventuallyUseBeginComplete() || change;
change = eventuallyUseBeginDuration() || change;
change = eventuallyUseCompleteDuration() || change;
change = eventuallyUseDurationWork() || change;
change = eventuallyUseDurationLoad() || change;
change = eventuallyUseLoadWork() || change;
} while (change);
}
private boolean eventuallyUseDurationWork() {
if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.WORK)
&& data.containsKey(ItemCaract.LOAD) == false) {
final Duration d = (Duration) data.get(ItemCaract.DURATION);
final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK);
data.put(ItemCaract.LOAD, new Load(d.getMinutes() * w.getIntValue()));
return true;
}
return false;
}
private boolean eventuallyUseLoadWork() {
if (data.containsKey(ItemCaract.LOAD) && data.containsKey(ItemCaract.WORK)
&& data.containsKey(ItemCaract.DURATION) == false) {
final Load l = (Load) data.get(ItemCaract.LOAD);
final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK);
data.put(ItemCaract.DURATION, new Duration(l.getMinuteMen() / w.getIntValue()));
return true;
}
return false;
}
private boolean eventuallyUseDurationLoad() {
if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.LOAD)
&& data.containsKey(ItemCaract.WORK) == false) {
final Duration d = (Duration) data.get(ItemCaract.DURATION);
final Load l = (Load) data.get(ItemCaract.LOAD);
data.put(ItemCaract.WORK, new NumericNumber((int) (l.getMinuteMen() / d.getMinutes())));
return true;
}
return false;
}
private boolean eventuallyUseBeginDuration() {
if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.DURATION)
&& data.containsKey(ItemCaract.COMPLETED) == false) {
final Instant i1 = (Instant) data.get(ItemCaract.BEGIN);
final Duration d = (Duration) data.get(ItemCaract.DURATION);
data.put(ItemCaract.COMPLETED, math.add(i1, d));
return true;
}
return false;
}
private boolean eventuallyUseCompleteDuration() {
if (data.containsKey(ItemCaract.COMPLETED) && data.containsKey(ItemCaract.DURATION)
&& data.containsKey(ItemCaract.BEGIN) == false) {
final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED);
final Duration d = (Duration) data.get(ItemCaract.DURATION);
data.put(ItemCaract.BEGIN, math.sub(i2, d));
return true;
}
return false;
}
private boolean eventuallyUseBeginComplete() {
if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.COMPLETED)
&& data.containsKey(ItemCaract.DURATION) == false) {
final Instant i1 = (Instant) data.get(ItemCaract.BEGIN);
final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED);
if (i2.compareTo(i1) <= 0) {
throw new IllegalArgumentException();
}
data.put(ItemCaract.DURATION, math.diff(i1, i2));
return true;
}
return false;
}
public boolean isValid() {
return data.size() == EnumSet.allOf(ItemCaract.class).size();
}
public Instant getBegin() {
return (Instant) data.get(ItemCaract.BEGIN);
}
public Instant getCompleted() {
return (Instant) data.get(ItemCaract.COMPLETED);
}
public Duration getDuration() {
return (Duration) data.get(ItemCaract.DURATION);
}
public Load getLoad() {
return (Load) data.get(ItemCaract.LOAD);
}
public NumericNumber getWork() {
return (NumericNumber) data.get(ItemCaract.WORK);
}
public boolean isLeaf() {
return true;
}
public Item getParent() {
return parent;
}
public List<Item> getChildren() {
return null;
}
public String getCode() {
return code;
}
@Override
public String toString() {
return code + " " + data.toString();
}
}

View File

@ -1,87 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
public class Instant implements Numeric {
private final Day value;
public Instant(Day d) {
this.value = d;
}
public Numeric add(Numeric other) {
throw new UnsupportedOperationException();
}
public NumericType getNumericType() {
return NumericType.INSTANT;
}
public Day getDay() {
return value;
}
public Instant next(DayClose dayClose) {
return new Instant(value.next(dayClose));
}
public Instant prev(DayClose dayClose) {
return new Instant(value.prev(dayClose));
}
@Override
public String toString() {
return "Instant:" + value;
}
public int compareTo(Numeric other) {
final Instant this2 = (Instant) other;
return value.compareTo(this2.value);
}
@Override
public int hashCode() {
return value.hashCode();
}
@Override
public boolean equals(Object obj) {
final Instant other = (Instant) obj;
return value.equals(other.value);
}
}

View File

@ -1,45 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
interface InstantArithmetic {
public Instant add(Instant i1, Duration duration);
public Instant sub(Instant i1, Duration duration);
public Duration diff(Instant i1, Instant i2);
}

View File

@ -1,62 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.List;
public interface Item {
Instant getBegin();
Instant getCompleted();
Duration getDuration();
Load getLoad();
NumericNumber getWork();
boolean isLeaf();
Item getParent();
List<Item> getChildren();
public String getCode();
public boolean isValid();
}

View File

@ -1,73 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
enum ItemCaract {
BEGIN(NumericType.INSTANT), //
COMPLETED(NumericType.INSTANT), //
DURATION(NumericType.DURATION), //
LOAD(NumericType.LOAD), //
WORK(NumericType.NUMBER);
private final NumericType type;
private ItemCaract(NumericType type) {
this.type = type;
}
public NumericType getNumericType() {
return type;
}
public Numeric getData(Item item) {
if (this == BEGIN) {
return item.getBegin();
}
if (this == COMPLETED) {
return item.getCompleted();
}
if (this == DURATION) {
return item.getDuration();
}
if (this == LOAD) {
return item.getLoad();
}
if (this == WORK) {
return item.getWork();
}
throw new UnsupportedOperationException();
}
}

View File

@ -1,60 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.Comparator;
public class ItemComparator implements Comparator<Item> {
public int compare(Item it1, Item it2) {
final int cmp1 = it1.getBegin().compareTo(it2.getBegin());
if (cmp1 != 0) {
return cmp1;
}
if (it1 instanceof Jalon && it2 instanceof Jalon == false) {
return -1;
}
if (it2 instanceof Jalon && it1 instanceof Jalon == false) {
return 1;
}
final int cmp2 = it2.getCompleted().compareTo(it1.getCompleted());
if (cmp2 != 0) {
return cmp2;
}
return it1.getCode().compareTo(it2.getCode());
}
}

View File

@ -1,95 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.List;
public class Jalon implements Item {
private Instant begin;
private final String code;
private final Item parent;
public Jalon(String code, Item parent) {
this.code = code;
this.parent = parent;
}
public Instant getBegin() {
return begin;
}
public Instant getCompleted() {
return begin;
}
public Duration getDuration() {
return new Duration(0);
}
public Load getLoad() {
return new Load(0);
}
public NumericNumber getWork() {
return new NumericNumber(1);
}
public boolean isLeaf() {
return true;
}
public Item getParent() {
return parent;
}
public List<Item> getChildren() {
return null;
}
public String getCode() {
return code;
}
public boolean isValid() {
return begin != null;
}
public void setInstant(Numeric value) {
this.begin = (Instant) value;
}
}

View File

@ -1,80 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class Load implements Numeric {
private final long minuteMen;
public Load(long minuteMen) {
this.minuteMen = minuteMen;
}
public Load(NumericNumber value) {
this(value.getIntValue() * 24L * 60 * 60);
}
public Numeric add(Numeric other) {
return new Load(((Load) other).minuteMen + minuteMen);
}
public NumericType getNumericType() {
return NumericType.LOAD;
}
public int compareTo(Numeric other) {
final Load this2 = (Load) other;
if (this2.minuteMen > minuteMen) {
return -1;
}
if (this2.minuteMen < minuteMen) {
return 1;
}
return 0;
}
public final long getMinuteMen() {
return minuteMen;
}
@Override
public String toString() {
return "LOAD:" + minuteMen / (24 * 60 * 60);
}
}

View File

@ -1,90 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public enum Month {
JAN(31), FEB(28), MAR(31), APR(30), MAY(31), JUN(30), JUL(31), AUG(31), SEP(30), OCT(31), NOV(30), DEC(31);
final private int nbDays;
private Month(int nbDays) {
this.nbDays = nbDays;
}
public final int getNbDays(int year) {
if (this == FEB && year % 4 == 0) {
return 29;
}
return nbDays;
}
public final int getNum() {
return ordinal() + 1;
}
public final int getNumNormal() {
return ordinal();
}
public Month next() {
if (this == DEC) {
return null;
}
final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
return all.get(getNum());
}
public Month prev() {
if (this == JAN) {
return null;
}
final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
return all.get(getNum() - 2);
}
public static Month fromNum(int num) {
if (num < 1 || num > 12) {
throw new IllegalArgumentException();
}
final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
return all.get(num - 1);
}
}

View File

@ -1,43 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
public interface Numeric extends Comparable<Numeric> {
Numeric add(Numeric other);
NumericType getNumericType();
}

View File

@ -1,77 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
class NumericNumber implements Numeric {
private final int value;
public NumericNumber(int v) {
this.value = v;
}
public Numeric add(Numeric other) {
if (other.getNumericType() != getNumericType()) {
throw new IllegalArgumentException();
}
return new NumericNumber(value + ((NumericNumber) other).value);
}
public NumericType getNumericType() {
return NumericType.NUMBER;
}
public int getIntValue() {
return value;
}
@Override
public String toString() {
return "Number:" + value;
}
public int compareTo(Numeric other) {
final NumericNumber this2 = (NumericNumber) other;
if (this2.value > value) {
return -1;
}
if (this2.value < value) {
return 1;
}
return 0;
}
}

View File

@ -1,80 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
enum NumericType {
NUMBER, INSTANT, LOAD, DURATION;
public NumericType add(NumericType other) {
if (this == NUMBER) {
return addNumber(other);
}
if (this == INSTANT) {
return null;
}
if (this == LOAD) {
return addLoad(other);
}
if (this == DURATION) {
return addDuration(other);
}
throw new UnsupportedOperationException();
}
private NumericType addDuration(NumericType other) {
if (other == DURATION) {
return DURATION;
}
return null;
}
private NumericType addLoad(NumericType other) {
if (other == LOAD) {
return LOAD;
}
return null;
}
private NumericType addNumber(NumericType other) {
if (other == NUMBER) {
return NUMBER;
}
return null;
}
}

View File

@ -1,129 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.png.PngIO;
import net.sourceforge.plantuml.project.graphic.GanttDiagramUnused;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
public class PSystemProject extends AbstractPSystem {
private final Project project = new Project();
private final Color background = Color.WHITE;
private final ColorMapper colorMapper = new ColorMapperIdentity();
public int getNbImages() {
return 1;
}
public DiagramDescription getDescription() {
return new DiagramDescription("(Project)");
}
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed)
throws IOException {
final GanttDiagramUnused diagram = new GanttDiagramUnused(project);
final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) {
final BufferedImage im = createImage(diagram);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0), colorMapper,
StringUtils.getAsHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
} else if (fileFormat == FileFormat.EPS) {
final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
diagram.draw(eps, 0, 0);
os.write(eps.getEPSCode().getBytes());
} else if (fileFormat == FileFormat.EPS_TEXT) {
final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
diagram.draw(eps, 0, 0);
os.write(eps.getEPSCode().getBytes());
} else {
throw new UnsupportedOperationException();
}
return ImageDataSimple.ok();
}
private BufferedImage createImage(GanttDiagramUnused diagram) {
EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, background);
Graphics2D g2d = builder.getGraphics2D();
UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
final double height = diagram.getHeight(ug.getStringBounder());
final double width = diagram.getWidth(ug.getStringBounder());
g2d.dispose();
builder = new EmptyImageBuilder(width, height, background);
final BufferedImage im = builder.getBufferedImage();
g2d = builder.getGraphics2D();
ug = new UGraphicG2d(colorMapper, g2d, 1.0);
ug.setBufferedImage(im);
diagram.draw(ug, 0, 0);
g2d.dispose();
return im;
}
public final Project getProject() {
return project;
}
}

View File

@ -1,133 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ParentItem implements Item {
private final String code;
private final Item parent;
private final List<Item> children = new ArrayList<Item>();
public ParentItem(String code, Item parent) {
this.code = code;
this.parent = parent;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(code + " {");
for (final Iterator<Item> it = children.iterator(); it.hasNext();) {
final Item child = it.next();
sb.append(child.getCode());
if (it.hasNext()) {
sb.append(", ");
}
}
sb.append("}");
return sb.toString();
}
public Instant getBegin() {
Instant result = null;
for (Item it : children) {
if (result == null || result.compareTo(it.getBegin()) > 0) {
result = it.getBegin();
}
}
return result;
}
public Instant getCompleted() {
Instant result = null;
for (Item it : children) {
if (result == null || result.compareTo(it.getCompleted()) < 0) {
result = it.getCompleted();
}
}
return result;
}
public Duration getDuration() {
throw new UnsupportedOperationException();
}
public Load getLoad() {
throw new UnsupportedOperationException();
}
public NumericNumber getWork() {
throw new UnsupportedOperationException();
}
public boolean isLeaf() {
return false;
}
public Item getParent() {
return parent;
}
public List<Item> getChildren() {
return Collections.unmodifiableList(children);
}
public String getCode() {
return code;
}
public void addChild(Item child) {
this.children.add(child);
}
public boolean isValid() {
if (children.size() == 0) {
return false;
}
for (Item it : children) {
if (it.isValid() == false) {
return false;
}
}
return true;
}
}

View File

@ -1,283 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.sourceforge.plantuml.StringUtils;
public class Project {
private final Map<String, FreeVariable> variables = new TreeMap<String, FreeVariable>();
private final Map<String, Item> items = new TreeMap<String, Item>();
private final Map<String, Ressource> ressources = new TreeMap<String, Ressource>();
private final DayCloseOr dayClose = new DayCloseOr();
public Project() {
}
public final Instant getStart() {
Instant result = null;
for (Item it : getValidItems()) {
if (result == null || result.compareTo(it.getBegin()) > 0) {
result = it.getBegin();
}
}
return result;
}
public final Instant getEnd() {
Instant result = null;
for (Item it : getValidItems()) {
if (result == null || result.compareTo(it.getCompleted()) < 0) {
result = it.getCompleted();
}
}
return result;
}
public FreeVariable createVariable(String name, NumericType type) {
if (variables.containsKey(name)) {
throw new IllegalArgumentException("Already exist: " + name);
}
final FreeVariable variable = new FreeVariable(name, type);
variables.put(name, variable);
return variable;
}
public Expression getExpression(String desc) {
desc = StringUtils.trin(desc);
final int plus = desc.indexOf('+');
if (plus != -1) {
final Expression exp1 = getExpression(desc.substring(0, plus));
final Expression exp2 = getExpression(desc.substring(plus + 1));
if (exp1.getNumericType() == NumericType.INSTANT
&& (exp2.getNumericType() == NumericType.DURATION || exp2.getNumericType() == NumericType.NUMBER)) {
return new FormalAdditionInstantDuration(exp1, exp2, new BasicInstantArithmetic(dayClose));
}
if (exp2.getNumericType() == NumericType.INSTANT
&& (exp1.getNumericType() == NumericType.DURATION || exp1.getNumericType() == NumericType.NUMBER)) {
return new FormalAdditionInstantDuration(exp2, exp1, new BasicInstantArithmetic(dayClose));
}
return new FormalAddition(exp1, exp2);
}
if (desc.matches("^\\d+$")) {
return new Constant(new NumericNumber(Integer.parseInt(desc)));
}
if (desc.matches("^\\$\\w+$")) {
final String varName = desc.substring(1);
final FreeVariable v = variables.get(varName);
if (v != null) {
return v;
}
throw new IllegalArgumentException("No such variable: " + desc);
}
if (Day.isValidDesc(desc)) {
final Day d = new Day(desc);
return new Constant(new Instant(d));
}
if (desc.matches("^[\\w/]+\\$(begin|completed|work|load|duration)$")) {
final int idx = desc.indexOf('$');
final String varName = desc.substring(0, idx);
final Item item = items.get(varName);
if (item == null) {
throw new IllegalArgumentException("No such variable: " + desc);
}
return new Constant(ItemCaract.valueOf(StringUtils.goUpperCase(desc.substring(idx + 1))).getData(item));
}
if (desc.startsWith("^")) {
final Item item = items.get(desc.substring(1));
if (item == null) {
throw new IllegalArgumentException("No such variable: " + desc);
}
return new Constant(item.getBegin());
}
throw new IllegalArgumentException("cannot parse");
}
public boolean affectation(String destination, Expression expression) {
if (destination.startsWith("^")) {
return affectationJalon(destination, expression);
}
if (destination.startsWith("~")) {
return affectationRessource(destination, expression);
}
final int idx = destination.indexOf('$');
if (idx == -1) {
return affectationVariable(destination, expression);
}
final String itemName = destination.substring(0, idx);
final Item item = getItem(itemName);
if (item instanceof IncompleteItem == false) {
return false;
}
final IncompleteItem incompleteItem = (IncompleteItem) item;
final String suf = destination.substring(idx + 1);
if (suf.equalsIgnoreCase("begin")) {
incompleteItem.setData(ItemCaract.BEGIN, expression.getValue());
} else if (suf.equalsIgnoreCase("completed")) {
incompleteItem.setData(ItemCaract.COMPLETED, expression.getValue());
} else if (suf.equalsIgnoreCase("work")) {
incompleteItem.setData(ItemCaract.WORK, expression.getValue());
} else if (suf.equalsIgnoreCase("duration")) {
if (expression.getNumericType() == NumericType.NUMBER) {
expression = new Constant(new Duration((NumericNumber) expression.getValue()));
}
incompleteItem.setData(ItemCaract.DURATION, expression.getValue());
} else if (suf.equalsIgnoreCase("LOAD")) {
if (expression.getNumericType() == NumericType.NUMBER) {
expression = new Constant(new Load((NumericNumber) expression.getValue()));
}
incompleteItem.setData(ItemCaract.LOAD, expression.getValue());
} else {
return false;
}
return true;
}
private boolean affectationRessource(String res, Expression expression) {
res = res.substring(1);
final int idx = res.indexOf('$');
final String suf = res.substring(idx + 1);
if (suf.equals("capacity")) {
final Ressource ressource = getRessource(res.substring(0, idx));
ressource.setCapacity(((NumericNumber) expression.getValue()).getIntValue());
return true;
}
return false;
}
private Ressource getRessource(String code) {
Ressource result = ressources.get(code);
if (result == null) {
result = new Ressource(code);
ressources.put(code, result);
}
return result;
}
private boolean affectationJalon(String jalon, Expression expression) {
final Jalon it = getItemJalon(jalon.substring(1));
it.setInstant(expression.getValue());
return true;
}
private Jalon getItemJalon(String jalon) {
Jalon result = (Jalon) items.get(jalon);
if (result == null) {
result = new Jalon(jalon, null);
items.put(jalon, result);
}
return result;
}
private Item getItem(String code) {
Item result = items.get(code);
if (result == null) {
final int idx = code.indexOf('/');
if (idx == -1) {
result = new IncompleteItem(code, null, new BasicInstantArithmetic(dayClose));
} else {
final ParentItem parent = getItemParent(code.substring(0, idx));
result = new IncompleteItem(code, parent, new BasicInstantArithmetic(dayClose));
parent.addChild(result);
}
items.put(code, result);
}
return result;
}
private ParentItem getItemParent(String code) {
Item result = items.get(code);
if (result == null) {
final int idx = code.indexOf('/');
if (idx == -1) {
result = new ParentItem(code, null);
items.put(code, result);
} else {
throw new UnsupportedOperationException();
}
}
return (ParentItem) result;
}
private boolean affectationVariable(String destination, Expression expression) {
if (variables.containsKey(destination) == false) {
return false;
}
variables.get(destination).setValue(expression);
return true;
}
public List<Item> getValidItems() {
final List<Item> result = new ArrayList<Item>();
for (Item item : items.values()) {
if (item.isValid()) {
result.add(item);
}
}
Collections.sort(result, new ItemComparator());
return Collections.unmodifiableList(result);
}
public final DayClose getDayClose() {
return dayClose;
}
public void closeWeekDay(WeekDay weekDay) {
dayClose.add(new DayCloseWeekDay(weekDay));
}
// public Item getItem(String code) {
// BasicItem result = items.get(code);
// if (result == null) {
// result = new BasicItem(code);
// items.put(code, result);
// }
// return result;
// }
}

View File

@ -1,62 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public enum WeekDay {
SUN, MON, TUE, WED, THU, FRI, SAT;
public WeekDay next() {
if (this.ordinal() == 6) {
return SUN;
}
final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class));
return all.get(this.ordinal() + 1);
}
public WeekDay prev() {
if (this.ordinal() == 0) {
return SAT;
}
final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class));
return all.get(this.ordinal() - 1);
}
}

View File

@ -1,140 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project.graphic;
import java.util.Map;
import java.util.SortedMap;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.project.Instant;
import net.sourceforge.plantuml.project.Item;
import net.sourceforge.plantuml.project.Jalon;
import net.sourceforge.plantuml.project.Project;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GanttDiagramUnused {
private final Project project;
private final TimeScale timeScale;
private final ItemHeader itemHeader;
public GanttDiagramUnused(Project project) {
this.project = project;
this.timeScale = new TimeScale(project);
this.itemHeader = new ItemHeader(project);
}
public void draw(UGraphic ug, double x, double y) {
final StringBounder stringBounder = ug.getStringBounder();
final double x0start = itemHeader.getWidth(stringBounder);
final double timeScaleHeight = timeScale.getHeight(stringBounder);
final SortedMap<Instant, Double> pos = timeScale.getAbscisse(stringBounder);
for (Item it : project.getValidItems()) {
final Instant start = it.getBegin();
final Instant completed = it.getCompleted();
if (pos.get(start) == null || pos.get(completed) == null) {
Log.println("PB " + it);
continue;
}
final double x1 = pos.get(start) + 3;
final double x2 = pos.get(completed) - 3;
final double yitem = timeScaleHeight + itemHeader.getPosition(stringBounder, it) + 3;
final UShape rect;
if (it instanceof Jalon) {
rect = new UPolygon();
((UPolygon) rect).addPoint(0, 3);
((UPolygon) rect).addPoint(3, 0);
((UPolygon) rect).addPoint(6, 3);
((UPolygon) rect).addPoint(3, 6);
} else {
rect = new URectangle(x2 - x1, 3);
}
ug = ug.apply(new UChangeColor(HtmlColorUtils.GREEN));
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.GRAY));
ug.apply(new UTranslate(x0start + x1, yitem)).draw(rect);
}
drawGrid(ug, x + x0start, y + timeScaleHeight, pos);
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
ug = ug.apply(new UChangeBackColor(null));
timeScale.draw(ug, x + x0start, y);
itemHeader.draw(ug, x, y + timeScaleHeight);
}
private final HtmlColor lightGray = new HtmlColorSetSimple().getColorIfValid("#C8C8C8");
private void drawGrid(UGraphic ug, double x, double y, SortedMap<Instant, Double> pos) {
final ULine line = new ULine(0, itemHeader.getHeight(ug.getStringBounder()));
Instant last = null;
for (Map.Entry<Instant, Double> ent : pos.entrySet()) {
final double xcur = ent.getValue();
if (last == null || last.next(null).equals(ent.getKey())) {
ug = ug.apply(new UChangeColor(lightGray));
} else {
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
}
ug.apply(new UTranslate(x + xcur, y)).draw(line);
last = ent.getKey();
}
}
public double getWidth(StringBounder stringBounder) {
return itemHeader.getWidth(stringBounder) + timeScale.getWidth(stringBounder) + 3;
}
public double getHeight(StringBounder stringBounder) {
return itemHeader.getHeight(stringBounder) + timeScale.getHeight(stringBounder) + 3;
}
}

View File

@ -1,116 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project.graphic;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.project.Item;
import net.sourceforge.plantuml.project.Project;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class ItemHeader {
private final UFont font = UFont.serif(9);
private final Project project;
private final FontConfiguration fontConfig = FontConfiguration.blackBlueTrue(font);
public ItemHeader(Project project) {
this.project = project;
}
public void draw(UGraphic ug, double x, double y) {
final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
ug.apply(new UTranslate(x, y)).draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder)));
for (Item it : project.getValidItems()) {
final TextBlock b = Display.create("" + it.getCode()).create(fontConfig, HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
final Dimension2D dim = b.calculateDimension(stringBounder);
b.drawU(ug.apply(new UTranslate(x, y)));
y += dim.getHeight();
ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0));
}
}
public double getWidth(StringBounder stringBounder) {
double width = 0;
for (Item it : project.getValidItems()) {
final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
width = Math.max(width, dim.getWidth());
}
return width;
}
public double getHeight(StringBounder stringBounder) {
double height = 0;
for (Item it : project.getValidItems()) {
final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
height += dim.getHeight();
}
return height;
}
public double getPosition(StringBounder stringBounder, Item item) {
double pos = 0;
for (Item it : project.getValidItems()) {
if (it == item) {
return pos;
}
final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
pos += dim.getHeight();
}
throw new IllegalArgumentException();
}
}

View File

@ -1,159 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project.graphic;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.util.Collections;
import java.util.SortedMap;
import java.util.TreeMap;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.project.Day;
import net.sourceforge.plantuml.project.Instant;
import net.sourceforge.plantuml.project.Month;
import net.sourceforge.plantuml.project.Project;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class TimeScale {
private final UFont font = UFont.serif(9);
private final Project project;
private final FontConfiguration fontConfig = FontConfiguration.blackBlueTrue(font);
public TimeScale(Project project) {
this.project = project;
}
public void draw(UGraphic ug, final double x, double y) {
final StringBounder stringBounder = ug.getStringBounder();
final double monthHeight = getMonthHeight(stringBounder);
final double caseWidth = getCaseWidth(stringBounder);
final double caseHeight = getCaseHeight(stringBounder);
final int nb = getNbCase();
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, monthHeight));
final Instant end = project.getEnd();
Month printed = null;
double curx = x;
for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
final Day d = cur.getDay();
if (printed == null || d.getMonth() != printed) {
ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight));
printed = d.getMonth();
final TextBlock b = Display.create(printed.name()).create(fontConfig, HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
final Dimension2D dim = b.calculateDimension(stringBounder);
b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2))));
}
curx += caseWidth;
}
curx = x;
y += monthHeight;
ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, caseHeight));
for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
final Day d = cur.getDay();
final TextBlock b = Display.create("" + d.getNumDay()).create(fontConfig, HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
final Dimension2D dim = b.calculateDimension(stringBounder);
b.drawU(ug.apply(new UTranslate((curx + (caseWidth - dim.getWidth()) / 2), (y + (caseHeight - dim
.getHeight()) / 2))));
curx += caseWidth;
ug.apply(new UTranslate(curx, y)).draw(new ULine(0, caseHeight));
}
}
public SortedMap<Instant, Double> getAbscisse(StringBounder stringBounder) {
final SortedMap<Instant, Double> pos = new TreeMap<Instant, Double>();
final double caseWidth = getCaseWidth(stringBounder);
final Instant end = project.getEnd();
double x = 0;
for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
pos.put(cur, x);
x += caseWidth;
}
return Collections.unmodifiableSortedMap(pos);
}
private int getNbCase() {
int result = 0;
final Instant end = project.getEnd();
for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
result++;
}
return result;
}
private double getCaseWidth(StringBounder stringBounder) {
final Dimension2D dim00 = stringBounder.calculateDimension(font, "00");
return dim00.getWidth() + 3;
}
private double getCaseHeight(StringBounder stringBounder) {
final Dimension2D dim00 = stringBounder.calculateDimension(font, "00");
return dim00.getHeight() + 3;
}
private double getMonthHeight(StringBounder stringBounder) {
final Dimension2D dimZZ = stringBounder.calculateDimension(font, "ZZ");
return dimZZ.getHeight() + 3;
}
public double getWidth(StringBounder stringBounder) {
return getCaseWidth(stringBounder) * getNbCase();
}
public double getHeight(StringBounder stringBounder) {
return getCaseHeight(stringBounder) + getMonthHeight(stringBounder);
}
}

View File

@ -44,7 +44,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class ComplementDate implements ComplementPattern {
public IRegex toRegex(String suffix) {
return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix));
return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix), toRegexD(suffix));
}
private IRegex toRegexA(String suffix) {
@ -74,6 +74,12 @@ public class ComplementDate implements ComplementPattern {
new RegexLeaf("CYEAR" + suffix, "([\\d]{4})"));
}
private IRegex toRegexD(String suffix) {
return new RegexConcat( //
new RegexLeaf("DCOUNT" + suffix, "([\\d]+)"), //
new RegexLeaf("[%s]+days?[%s]+after[%s]+start"));
}
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
if (arg.get("ADAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultA(arg, suffix));
@ -84,9 +90,17 @@ public class ComplementDate implements ComplementPattern {
if (arg.get("CDAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultC(arg, suffix));
}
if (arg.get("DCOUNT" + suffix, 0) != null) {
return Failable.<Complement> ok(resultD(system, arg, suffix));
}
throw new IllegalStateException();
}
private Complement resultD(GanttDiagram system, RegexResult arg, String suffix) {
final int day = Integer.parseInt(arg.get("DCOUNT" + suffix, 0));
return system.getStartingDate(day);
}
private Complement resultA(RegexResult arg, String suffix) {
final int day = Integer.parseInt(arg.get("ADAY" + suffix, 0));
final String month = arg.get("AMONTH" + suffix, 0);

View File

@ -44,20 +44,20 @@ public class ComplementSeveralDays implements ComplementPattern {
public IRegex toRegex(String suffix) {
return new RegexConcat( //
new RegexLeaf("COMPLEMENT" + suffix, "(\\d+)[%s]+(days?|weeks?)"), //
new RegexLeaf("LOAD" + suffix, "([%s]+at[%s]+(\\d+)%)?"));
new RegexLeaf("COMPLEMENT" + suffix, "(\\d+)[%s]+(days?|weeks?)")); //
// new RegexLeaf("LOAD" + suffix, "([%s]+at[%s]+(\\d+)%)?"));
}
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
final String number = arg.get("COMPLEMENT" + suffix, 0);
final boolean inWeeks = arg.get("COMPLEMENT" + suffix, 1).startsWith("w");
final int factor = inWeeks ? system.daysInWeek() : 1;
final String load = arg.get("LOAD" + suffix, 1);
// final String load = arg.get("LOAD" + suffix, 1);
final int days = Integer.parseInt(number) * factor;
if (load == null) {
return Failable.<Complement> ok(LoadInDays.inDay(days));
}
return Failable.<Complement> ok(LoadInDays.inDayWithLoad(days, Integer.parseInt(load)));
// if (load == null) {
return Failable.<Complement> ok(LoadInDays.inDay(days));
// }
// return Failable.<Complement> ok(LoadInDays.inDayWithLoad(days, Integer.parseInt(load)));
}
}

View File

@ -35,6 +35,8 @@
*/
package net.sourceforge.plantuml.project3;
import java.util.Date;
public class DayAsDate implements Complement, Comparable<DayAsDate>, Subject {
private final int year;
@ -49,6 +51,14 @@ public class DayAsDate implements Complement, Comparable<DayAsDate>, Subject {
return new DayAsDate(year, Month.values()[month - 1], dayOfMonth);
}
public static DayAsDate today() {
final Date now = new Date();
final int year = now.getYear() + 1900;
final int month = now.getMonth() + 1;
final int dayOfMonth = now.getDate();
return create(year, month, dayOfMonth);
}
private DayAsDate(int year, Month month, int dayOfMonth) {
this.year = year;
this.dayOfMonth = dayOfMonth;
@ -126,4 +136,5 @@ public class DayAsDate implements Complement, Comparable<DayAsDate>, Subject {
public int compareTo(DayAsDate other) {
return this.internalNumber() - other.internalNumber();
}
}

View File

@ -39,19 +39,20 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -124,7 +125,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
throws IOException {
final double margin = 10;
sortTasks();
// OsortTasks();
final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
@ -136,19 +137,19 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
}
private void sortTasks() {
final TaskCodeSimpleOrder order = getCanonicalOrder(1);
final List<Task> list = new ArrayList<Task>(tasks.values());
Collections.sort(list, new Comparator<Task>() {
public int compare(Task task1, Task task2) {
return order.compare(task1.getCode(), task2.getCode());
}
});
tasks.clear();
for (Task task : list) {
tasks.put(task.getCode(), task);
}
}
// private void sortTasks() {
// final TaskCodeSimpleOrder order = getCanonicalOrder(1);
// final List<Task> list = new ArrayList<Task>(tasks.values());
// Collections.sort(list, new Comparator<Task>() {
// public int compare(Task task1, Task task2) {
// return order.compare(task1.getCode(), task2.getCode());
// }
// });
// tasks.clear();
// for (Task task : list) {
// tasks.put(task.getCode(), task);
// }
// }
private UDrawable getUDrawable() {
return new UDrawable() {
@ -510,24 +511,6 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
tasks.put(separator.getCode(), separator);
}
private TaskCodeSimpleOrder getCanonicalOrder(int hierarchyHeader) {
final List<TaskCode> codes = new ArrayList<TaskCode>();
for (TaskCode code : tasks.keySet()) {
if (code.getHierarchySize() >= hierarchyHeader) {
codes.add(code.truncateHierarchy(hierarchyHeader));
}
}
return new TaskCodeSimpleOrder(codes, hierarchyHeader);
}
private int getMaxHierarchySize() {
int max = Integer.MIN_VALUE;
for (TaskCode code : tasks.keySet()) {
max = Math.max(max, code.getHierarchySize());
}
return max;
}
public void addContraint(GanttConstraint constraint) {
constraints.add(constraint);
}
@ -547,6 +530,13 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
return this.calendar.getStartingDate();
}
public DayAsDate getStartingDate(int nday) {
if (this.calendar == null) {
return null;
}
return ((GCalendarSimple) this.calendar).toDayAsDate(new InstantDay(nday));
}
public int daysInWeek() {
return 7 - closedDayOfWeek.size();
}
@ -561,9 +551,18 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
private final Map<String, Resource> resources = new LinkedHashMap<String, Resource>();
public void affectResource(Task result, String resourceName) {
Resource resource = getResource(resourceName);
result.addResource(resource);
public void affectResource(Task result, String description) {
final Pattern p = Pattern.compile("([^:]+)(:(\\d+))?");
final Matcher m = p.matcher(description);
if (m.find() == false) {
throw new IllegalArgumentException();
}
final Resource resource = getResource(m.group(1));
int percentage = 100;
if (m.group(3) != null) {
percentage = Integer.parseInt(m.group(3));
}
result.addResource(resource, percentage);
}
public Resource getResource(String resourceName) {
@ -637,4 +636,18 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
nameDays.put(day, name);
}
public void setTodayColors(ComplementColors colors) {
if (today == null) {
this.today = DayAsDate.today();
}
colorDay(today, colors.getCenter());
}
private DayAsDate today;
public CommandExecutionResult setToday(DayAsDate date) {
this.today = date;
return CommandExecutionResult.ok();
}
}

View File

@ -51,7 +51,7 @@ public class GanttDiagramFactory extends UmlDiagramFactory {
private List<SubjectPattern> subjects() {
return Arrays.<SubjectPattern> asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(),
new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource());
new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday());
}
public GanttDiagramFactory(DiagramType type) {

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml.project3;
public interface Load extends Value, Complement, LoadPlanable {
public interface Load extends Value, Complement {
int getFullLoad();

View File

@ -49,10 +49,10 @@ public class LoadInDays implements Load {
return new LoadInDays(days, 100);
}
public static Complement inDayWithLoad(int days, int loadPerDay) {
final int tmp = (int) Math.ceil(days * 100.0 / loadPerDay);
return new LoadInDays(tmp, loadPerDay);
}
// public static Complement inDayWithLoad(int days, int loadPerDay) {
// final int tmp = (int) Math.ceil(days * 100.0 / loadPerDay);
// return new LoadInDays(tmp, loadPerDay);
// }
public int getFullLoad() {
return days * loadPerDay;

View File

@ -49,4 +49,12 @@ public class PlanUtils {
};
}
public static LoadPlanable multiply(final LoadPlanable p1, final LoadPlanable p2) {
return new LoadPlanable() {
public int getLoadAt(Instant instant) {
return p1.getLoadAt(instant) * p2.getLoadAt(instant) / 100;
}
};
}
}

View File

@ -38,16 +38,16 @@ package net.sourceforge.plantuml.project3;
import java.util.Set;
import java.util.TreeSet;
public class Resource implements Subject, LoadPlanable {
public class Resource implements Subject /* , LoadPlanable */{
private final String name;
private ResourceDraw draw;
private final LoadPlanable loadPlanable;
// private final LoadPlanable loadPlanable;
private Set<Instant> closed = new TreeSet<Instant>();
public Resource(String name, LoadPlanable loadPlanable) {
this.name = name;
this.loadPlanable = loadPlanable;
// this.loadPlanable = loadPlanable;
}
@Override
@ -78,13 +78,17 @@ public class Resource implements Subject, LoadPlanable {
this.draw = draw;
}
public int getLoadAt(Instant instant) {
if (this.closed.contains(instant)) {
return 0;
}
return loadPlanable.getLoadAt(instant);
public boolean isClosedAt(Instant instant) {
return this.closed.contains(instant);
}
// public int getLoadAt(Instant instant) {
// if (this.closed.contains(instant)) {
// return 0;
// }
// return loadPlanable.getLoadAt(instant);
// }
public void addCloseDay(Instant instant) {
this.closed.add(instant);
}

View File

@ -38,16 +38,16 @@ package net.sourceforge.plantuml.project3;
import java.util.LinkedHashSet;
import java.util.Set;
public class Resources implements LoadPlanable {
public class Resources /*implements LoadPlanable*/ {
private final Set<Resource> all = new LinkedHashSet<Resource>();
public int getLoadAt(Instant instant) {
int result = 0;
for (Resource res : all) {
result += res.getLoadAt(instant);
}
return result;
}
// public int getLoadAt(Instant instant) {
// int result = 0;
// for (Resource res : all) {
// result += res.getLoadAt(instant);
// }
// return result;
// }
}

View File

@ -33,26 +33,29 @@
*
*
*/
package net.sourceforge.plantuml.project;
package net.sourceforge.plantuml.project3;
class Constant implements Expression {
import java.util.Arrays;
import java.util.Collection;
private final Numeric value;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
public Constant(Numeric value) {
this.value = value;
public class SubjectToday implements SubjectPattern {
public Collection<VerbPattern> getVerbs() {
return Arrays.<VerbPattern> asList(new VerbIsColoredForToday(), new VerbIsForToday());
}
public String getDescription() {
return "Constant:" + value;
public IRegex toRegex() {
return new RegexConcat( //
new RegexLeaf("today") //
);
}
public NumericType getNumericType() {
return value.getNumericType();
public Subject getSubject(GanttDiagram project, RegexResult arg) {
return new Today();
}
public Numeric getValue() {
return value;
}
}

View File

@ -57,6 +57,6 @@ public interface Task extends Subject, Moment {
public void setColors(ComplementColors colors);
public void addResource(Resource resource);
public void addResource(Resource resource, int percentage);
}

View File

@ -35,58 +35,32 @@
*/
package net.sourceforge.plantuml.project3;
import java.util.Arrays;
import java.util.List;
import net.sourceforge.plantuml.cucadiagram.Display;
public class TaskCode {
private final List<String> hierarchy;
private final String code;
public TaskCode(String code) {
this.hierarchy = Arrays.asList(code.split("/"));
}
public boolean startsWith(TaskCode other) {
if (other.hierarchy.size() > this.hierarchy.size()) {
return false;
}
assert other.hierarchy.size() <= this.hierarchy.size();
final List<String> sub = this.hierarchy.subList(0, other.hierarchy.size());
return sub.equals(other.hierarchy);
}
private TaskCode(List<String> hierarchy) {
this.hierarchy = hierarchy;
}
public TaskCode truncateHierarchy(int size) {
return new TaskCode(this.hierarchy.subList(0, size));
this.code = code;
}
@Override
public int hashCode() {
return hierarchy.hashCode();
return code.hashCode();
}
@Override
public boolean equals(Object arg) {
final TaskCode other = (TaskCode) arg;
return this.hierarchy.equals(other.hierarchy);
return this.code.equals(other.code);
}
@Override
public String toString() {
return hierarchy.toString();
return code.toString();
}
public String getSimpleDisplay() {
return hierarchy.get(hierarchy.size() - 1);
}
public int getHierarchySize() {
return hierarchy.size();
return code;
}
}

View File

@ -1,71 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* 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.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project3;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
public class TaskCodeSimpleOrder implements Comparator<TaskCode> {
private final List<TaskCode> order;
private final int hierarchySize;
public TaskCodeSimpleOrder(Collection<TaskCode> order, int hierarchySize) {
this.order = new ArrayList<TaskCode>(order);
this.hierarchySize = hierarchySize;
for (TaskCode code : order) {
if (code.getHierarchySize() != hierarchySize) {
throw new IllegalArgumentException();
}
}
}
public int compare(TaskCode code1, TaskCode code2) {
if (code1.getHierarchySize() < hierarchySize) {
throw new IllegalArgumentException();
}
if (code2.getHierarchySize() < hierarchySize) {
throw new IllegalArgumentException();
}
code1 = code1.truncateHierarchy(hierarchySize);
code2 = code2.truncateHierarchy(hierarchySize);
final int idx1 = order.indexOf(code1);
final int idx2 = order.indexOf(code2);
return idx1 - idx2;
}
}

View File

@ -40,6 +40,8 @@ import net.sourceforge.plantuml.SpriteContainerEmpty;
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.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
@ -53,6 +55,8 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TaskDrawRegular implements TaskDraw {
// private static final HtmlColor defaultColor = HtmlColorUtils.COL_84BE84;
private static final HtmlColor defaultColor = new HtmlColorSetSimple().getColorIfValid("GreenYellow");
private final TaskImpl task;
private final TimeScale timeScale;
private final double y;
@ -87,22 +91,23 @@ public class TaskDrawRegular implements TaskDraw {
ug2.draw(shapeFull);
} else {
final double fullHeight = ((URectangle) shapeFull).getHeight();
ug2.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UChangeColor(HtmlColorUtils.WHITE))
.draw(shapeFull);
drawInside(ug1, fullHeight);
ug2.apply(new UChangeBackColor(null)).draw(shapeFull);
// ug2.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UChangeColor(HtmlColorUtils.WHITE))
// .draw(shapeFull);
// drawInside(ug1, fullHeight);
// ug2.apply(new UChangeBackColor(null)).draw(shapeFull);
ug2.draw(shapeFull);
}
}
private void drawInside(UGraphic ug, double fullHeight) {
for (Instant i = task.getStart(); i.compareTo(task.getEnd()) <= 0; i = i.increment()) {
final int load = task.getLoadAt(i);
final URectangle shapeLoad = getShapeInside(load, i);
final double diffHeight = fullHeight - shapeLoad.getHeight();
final double start = timeScale.getStartingPosition(i);
ug.apply(new UChangeColor(null)).apply(new UTranslate(start, diffHeight + margin)).draw(shapeLoad);
}
}
// private void drawInside(UGraphic ug, double fullHeight) {
// for (Instant i = task.getStart(); i.compareTo(task.getEnd()) <= 0; i = i.increment()) {
// // final int load = task.getLoadAt(i);
// final URectangle shapeLoad = getShapeInside(i);
// final double diffHeight = fullHeight - shapeLoad.getHeight();
// final double start = timeScale.getStartingPosition(i);
// ug.apply(new UChangeColor(null)).apply(new UTranslate(start, diffHeight + margin)).draw(shapeLoad);
// }
// }
private UGraphic applyColors(UGraphic ug) {
if (colors != null && colors.isOk()) {
@ -111,16 +116,26 @@ public class TaskDrawRegular implements TaskDraw {
if (isDiamond()) {
return ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK));
}
return ug.apply(new UChangeColor(HtmlColorUtils.BLUE)).apply(new UChangeBackColor(HtmlColorUtils.COL_84BE84));
return ug.apply(new UChangeColor(HtmlColorUtils.BLUE)).apply(new UChangeBackColor(defaultColor));
}
private URectangle getShapeInside(int load, Instant instant) {
private URectangle getShapeInside(Instant instant) {
final double start = timeScale.getStartingPosition(instant);
final double end = timeScale.getEndingPosition(instant);
final double height = (getHeight() - 2 * margin) * load / 100.0;
final double height = getHeight() - 2 * margin;
return new URectangle(end - start, height);
}
// private URectangle getShapeInside(int load, Instant instant) {
// final double start = timeScale.getStartingPosition(instant);
// final double end = timeScale.getEndingPosition(instant);
// if (load > 100) {
// load = 100;
// }
// final double height = (getHeight() - 2 * margin) * load / 100.0;
// return new URectangle(end - start, height);
// }
private UShape getShape(int load) {
if (isDiamond()) {
return getDiamond();

View File

@ -36,14 +36,14 @@
package net.sourceforge.plantuml.project3;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.LinkedHashMap;
import java.util.Map;
public class TaskImpl implements Task, LoadPlanable {
private final TaskCode code;
private final Solver3 solver;
private final Set<Resource> resources = new LinkedHashSet<Resource>();
private final Map<Resource, Integer> resources2 = new LinkedHashMap<Resource, Integer>();
private final LoadPlanable defaultPlan;
public TaskImpl(TaskCode code, LoadPlanable defaultPlan) {
@ -55,39 +55,46 @@ public class TaskImpl implements Task, LoadPlanable {
}
public int getLoadAt(Instant instant) {
LoadPlanable plan1 = defaultPlan;
if (resources.size() > 0) {
plan1 = PlanUtils.minOf(plan1, getRessourcePlan());
LoadPlanable result = defaultPlan;
if (resources2.size() > 0) {
result = PlanUtils.multiply(defaultPlan, getRessourcePlan());
}
return PlanUtils.minOf(getLoad(), plan1).getLoadAt(instant);
return result.getLoadAt(instant);
// return PlanUtils.minOf(getLoad(), plan1).getLoadAt(instant);
}
public int loadForResource(Resource res, Instant i) {
if (resources.contains(res) && i.compareTo(getStart()) >= 0 && i.compareTo(getEnd()) <= 0) {
if (res.getLoadAt(i) == 0) {
public int loadForResource(Resource res, Instant instant) {
if (resources2.keySet().contains(res) && instant.compareTo(getStart()) >= 0 && instant.compareTo(getEnd()) <= 0) {
if (res.isClosedAt(instant)) {
return 0;
}
int size = 0;
for (Resource r : resources) {
if (r.getLoadAt(i) > 0) {
size++;
}
}
return getLoadAt(i) / size;
// int size = 0;
return resources2.get(res);
// for (Resource r : resources) {
// if (r.getLoadAt(i) > 0) {
// size++;
// }
// }
// return getLoadAt(instant) / size;
}
return 0;
}
private LoadPlanable getRessourcePlan() {
if (resources.size() == 0) {
if (resources2.size() == 0) {
throw new IllegalStateException();
}
return new LoadPlanable() {
public int getLoadAt(Instant instant) {
int result = 0;
for (Resource res : resources) {
result += res.getLoadAt(instant);
for (Map.Entry<Resource, Integer> ent : resources2.entrySet()) {
final Resource res = ent.getKey();
if (res.isClosedAt(instant)) {
continue;
}
final int percentage = ent.getValue();
result += percentage;
}
return result;
}
@ -95,12 +102,17 @@ public class TaskImpl implements Task, LoadPlanable {
}
public String getPrettyDisplay() {
if (resources.size() > 0) {
if (resources2.size() > 0) {
final StringBuilder result = new StringBuilder(code.getSimpleDisplay());
result.append(" ");
for (Iterator<Resource> it = resources.iterator(); it.hasNext();) {
for (Iterator<Map.Entry<Resource, Integer>> it = resources2.entrySet().iterator(); it.hasNext();) {
final Map.Entry<Resource, Integer> ent = it.next();
result.append("{");
result.append(it.next().getName());
result.append(ent.getKey().getName());
final int percentage = ent.getValue();
if (percentage != 100) {
result.append(":" + percentage + "%");
}
result.append("}");
if (it.hasNext()) {
result.append(" ");
@ -168,8 +180,8 @@ public class TaskImpl implements Task, LoadPlanable {
this.colors = colors;
}
public void addResource(Resource resource) {
this.resources.add(resource);
public void addResource(Resource resource, int percentage) {
this.resources2.put(resource, percentage);
}
}

View File

@ -84,7 +84,7 @@ public class TaskSeparator implements Task {
return comment;
}
public void addResource(Resource resource) {
public void addResource(Resource resource, int percentage) {
throw new UnsupportedOperationException();
}

View File

@ -33,8 +33,8 @@
*
*
*/
package net.sourceforge.plantuml.project;
package net.sourceforge.plantuml.project3;
interface Formal extends Expression {
public class Today implements Subject {
}

View File

@ -33,26 +33,35 @@
*
*
*/
package net.sourceforge.plantuml.project.command;
package net.sourceforge.plantuml.project3;
import java.util.List;
import java.util.Arrays;
import java.util.Collection;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.project.PSystemProject;
import net.sourceforge.plantuml.project.WeekDay;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandCloseWeekDay extends SingleLineCommand<PSystemProject> {
public class VerbIsColoredForToday implements VerbPattern {
public CommandCloseWeekDay() {
super("(?i)^\\s*close\\s+(\\w{3,}day)\\s*$");
public Collection<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> asList(new ComplementInColors());
}
@Override
protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) {
final WeekDay weekDay = WeekDay.valueOf(StringUtils.goUpperCase(arg.get(0).substring(0, 3)));
diagram.getProject().closeWeekDay(weekDay);
return CommandExecutionResult.ok();
public IRegex toRegex() {
return new RegexLeaf("is[%s]+colou?red");
}
public Verb getVerb(final GanttDiagram project, RegexResult arg) {
return new Verb() {
public CommandExecutionResult execute(Subject subject, Complement complement) {
final Today task = (Today) subject;
final ComplementColors colors = (ComplementColors) complement;
project.setTodayColors(colors);
return CommandExecutionResult.ok();
}
};
}
}

View File

@ -33,29 +33,33 @@
*
*
*/
package net.sourceforge.plantuml.project.command;
package net.sourceforge.plantuml.project3;
import java.util.List;
import java.util.Arrays;
import java.util.Collection;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.project.Expression;
import net.sourceforge.plantuml.project.PSystemProject;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandAffectation extends SingleLineCommand<PSystemProject> {
public class VerbIsForToday implements VerbPattern {
public CommandAffectation() {
super("(?i)^\\s*([~\\^]?[\\w$/]+)\\s*:=\\s*(.+)$");
public Collection<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> asList(new ComplementInColors(), new ComplementDate());
}
@Override
protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) {
final Expression exp = diagram.getProject().getExpression(StringUtils.trin(arg.get(1)));
final boolean ok = diagram.getProject().affectation(StringUtils.trin(arg.get(0)), exp);
if (ok) {
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot execute");
public IRegex toRegex() {
return new RegexLeaf("is");
}
public Verb getVerb(final GanttDiagram project, RegexResult arg) {
return new Verb() {
public CommandExecutionResult execute(Subject subject, Complement complement) {
final Today task = (Today) subject;
final DayAsDate date = (DayAsDate) complement;
return project.setToday(date);
}
};
}
}

View File

@ -154,7 +154,7 @@ public class PSystemSalt extends AbstractPSystem implements WithSprite {
} else if (s.startsWith("skinparam ")) {
// System.err.println("skipping " + s);
} else if (s.startsWith("scale ")) {
final Double scale = Double.parseDouble(s.substring("scale ".length()));
final double scale = Double.parseDouble(s.substring("scale ".length()));
this.setScale(new ScaleSimple(scale));
// System.err.println("skipping " + s);
} else if (s.startsWith("sprite $")) {

View File

@ -201,4 +201,18 @@ public abstract class AbstractMessage implements EventWithDeactivate {
public double getPosYendLevel() {
return posYendLevel;
}
private String anchor;
public void setAnchor(String anchor) {
this.anchor = anchor;
if (anchor != null && anchor.startsWith("{")) {
throw new IllegalArgumentException(anchor);
}
}
public String getAnchor() {
return anchor;
}
}

View File

@ -33,28 +33,35 @@
*
*
*/
package net.sourceforge.plantuml.project;
package net.sourceforge.plantuml.sequencediagram;
public class Ressource {
public class LinkAnchor {
private final String code;
private final String anchor1;
private final String anchor2;
private final String message;
private int capacity = 1;
public Ressource(String code) {
this.code = code;
public LinkAnchor(String anchor1, String anchor2, String message) {
this.anchor1 = anchor1;
this.anchor2 = anchor2;
this.message = message;
}
public DayClose getDayClose() {
return new DayCloseNone();
@Override
public String toString() {
return anchor1 + "<->" + anchor2 + " " + message;
}
public final int getCapacity() {
return capacity;
public final String getAnchor1() {
return anchor1;
}
public final void setCapacity(int capacity) {
this.capacity = capacity;
public final String getAnchor2() {
return anchor2;
}
public final String getMessage() {
return message;
}
}

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -525,4 +526,15 @@ public class SequenceDiagram extends UmlDiagram {
public Display manageVariable(Display labels) {
return labels.replace("%autonumber%", autoNumber.getCurrentMessageNumber(false));
}
private final List<LinkAnchor> linkAnchors = new ArrayList<LinkAnchor>();
public CommandExecutionResult linkAnchor(String anchor1, String anchor2, String message) {
this.linkAnchors.add(new LinkAnchor(anchor1, anchor2, message));
return CommandExecutionResult.ok();
}
public List<LinkAnchor> getLinkAnchors() {
return Collections.unmodifiableList(linkAnchors);
}
}

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandFootboxOld;
import net.sourceforge.plantuml.sequencediagram.command.CommandGrouping;
import net.sourceforge.plantuml.sequencediagram.command.CommandHSpace;
import net.sourceforge.plantuml.sequencediagram.command.CommandIgnoreNewpage;
import net.sourceforge.plantuml.sequencediagram.command.CommandLinkAnchor;
import net.sourceforge.plantuml.sequencediagram.command.CommandNewpage;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA2;
@ -138,6 +139,7 @@ public class SequenceDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandDelay());
cmds.add(new CommandFootboxOld());
cmds.add(new CommandUrl());
cmds.add(new CommandLinkAnchor());
return cmds;
}

View File

@ -76,6 +76,7 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
return new RegexConcat(
new RegexLeaf("^"), //
new RegexLeaf("PARALLEL", "(&%s*)?"), //
new RegexLeaf("ANCHOR", "(\\{([\\p{L}0-9_]+)\\}[%s]+)?"), //
new RegexOr("PART1", //
new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("PART1LONG", "[%g]([^%g]+)[%g]"), //
@ -234,6 +235,8 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
if (parallel) {
msg.goParallel();
}
final String anchor = arg.get("ANCHOR", 1);
msg.setAnchor(anchor);
final String error = diagram.addMessage(msg);
if (error != null) {

View File

@ -35,27 +35,43 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
import java.util.List;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandBoxStart extends SingleLineCommand<SequenceDiagram> {
public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
public CommandBoxStart() {
super("(?i)^box(?:[%s]+[%g]([^%g]+)[%g])?(?:[%s]+(#\\w+))?$");
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("box"), //
new RegexOptional(new RegexOr( //
new RegexLeaf("NAME1", "[%s]+[%g]([^%g]+)[%g]"), //
new RegexLeaf("NAME2", "[%s]+([^#]+)"))), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("COLOR", "(#\\w+)?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg2) {
if (diagram.isBoxPending()) {
return CommandExecutionResult.error("Box cannot be nested");
}
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(1));
final String title = arg.get(0) == null ? "" : arg.get(0);
final String argTitle = arg2.getLazzy("NAME", 0);
final String argColor = arg2.get("COLOR", 0);
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor);
final String title = argTitle == null ? "" : argTitle;
diagram.boxStart(Display.getWithNewlines(title), color);
return CommandExecutionResult.ok();
}

View File

@ -33,50 +33,38 @@
*
*
*/
package net.sourceforge.plantuml.project;
package net.sourceforge.plantuml.sequencediagram.command;
class Duration implements Numeric {
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.sequencediagram.SequenceDiagram;
private final long minutes;
public class CommandLinkAnchor extends SingleLineCommand2<SequenceDiagram> {
public Duration(long minutes) {
this.minutes = minutes;
public CommandLinkAnchor() {
super(getRegexConcat());
}
public Duration(NumericNumber value) {
this(value.getIntValue() * 24L * 60 * 60);
}
public Numeric add(Numeric other) {
return new Duration(((Duration) other).minutes + minutes);
}
public static Duration of(long days) {
return new Duration(days * 24 * 60 * 60);
}
public NumericType getNumericType() {
return NumericType.DURATION;
}
public long getMinutes() {
return minutes;
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("ANCHOR1", "\\{([\\p{L}0-9_]+)\\}"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("LINK", "\\<-\\>"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("ANCHOR2", "\\{([\\p{L}0-9_]+)\\}"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?$"));
}
@Override
public String toString() {
return "DURATION:" + minutes / (24 * 60 * 60);
}
public int compareTo(Numeric other) {
final Duration this2 = (Duration) other;
if (this2.minutes > minutes) {
return -1;
}
if (this2.minutes < minutes) {
return 1;
}
return 0;
protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
final String anchor1 = arg.get("ANCHOR1", 0);
final String anchor2 = arg.get("ANCHOR2", 0);
final String message = arg.get("MESSAGE", 0);
return diagram.linkAnchor(anchor1, anchor2, message);
}
}

View File

@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.real.Real;
@ -51,6 +52,8 @@ import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.Skin;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -164,10 +167,20 @@ public class CommunicationTile implements TileWithUpdateStairs, TileWithCallback
}
}
comp.drawU(ug, area, (Context2D) ug);
if (message.getAnchor() != null) {
drawAnchor(ug);
}
// ug.draw(new ULine(x2 - x1, 0));
}
private void drawAnchor(UGraphic ug) {
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
ug.draw(new UEllipse(10, 10));
}
public double getPreferredHeight(StringBounder stringBounder) {
final Component comp = getComponent(stringBounder);
final Dimension2D dim = comp.getPreferredDimension(stringBounder);

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.real.RealUtils;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.LinkAnchor;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.ugraphic.LimitFinder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -55,10 +56,12 @@ public class MainTile implements Tile, Bordered {
private final List<Tile> tiles = new ArrayList<Tile>();
private final LivingSpaces livingSpaces;
private final List<LinkAnchor> linkAnchors;
public MainTile(SequenceDiagram diagram, Englobers englobers, TileArguments tileArguments) {
this.livingSpaces = tileArguments.getLivingSpaces();
this.linkAnchors = diagram.getLinkAnchors();
final List<Real> min2 = new ArrayList<Real>();
final List<Real> max2 = new ArrayList<Real>();
@ -112,10 +115,26 @@ public class MainTile implements Tile, Bordered {
for (YPositionedTile tile : positionedTiles) {
tile.drawU(ug);
}
for (LinkAnchor linkAnchor : linkAnchors) {
System.err.println("linkAnchor=" + linkAnchor);
final YPositionedTile tile1 = getFromAnchor(positionedTiles, linkAnchor.getAnchor1());
final YPositionedTile tile2 = getFromAnchor(positionedTiles, linkAnchor.getAnchor2());
System.err.println("tile1=" + tile1);
System.err.println("tile2=" + tile2);
}
// System.err.println("MainTile::drawUInternal finalY=" + y);
return y;
}
private YPositionedTile getFromAnchor(List<YPositionedTile> positionedTiles, String anchor) {
for (YPositionedTile tile : positionedTiles) {
if (tile.matchAnchor(anchor)) {
return tile;
}
}
return null;
}
public double getPreferredHeight(StringBounder stringBounder) {
final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(limitFinder, false);

View File

@ -36,6 +36,8 @@
package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -57,4 +59,15 @@ public class YPositionedTile implements UDrawable {
ug.apply(new UTranslate(0, y)).draw(tile);
}
public boolean matchAnchor(String anchor) {
final Event event = tile.getEvent();
if (event instanceof AbstractMessage) {
final AbstractMessage msg = (AbstractMessage) event;
if (anchor.equals(msg.getAnchor())) {
return true;
}
}
return false;
}
}

View File

@ -54,10 +54,9 @@ final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent {
private final int cornersize = 10;
private final SymbolContext symbolContext;
public ComponentRoseNoteHexagonal(SymbolContext symbolContext, FontConfiguration font, Display strings,
ISkinSimple spriteContainer, HorizontalAlignment alignment) {
super(LineBreakStrategy.NONE, strings, font, alignment, 12, 12, 4, spriteContainer, false, null, null);
super(spriteContainer.wrapWidth(), strings, font, alignment, 12, 12, 4, spriteContainer, false, null, null);
this.symbolContext = symbolContext;
}

View File

@ -45,7 +45,9 @@ class HumanDuration {
@Override
public String toString() {
long time = duration / 1000;
long time = duration;
// final long ms = time % 1000L;
time = time / 1000;
final long sec = time % 60;
time = time / 60;
final long min = time % 60;

View File

@ -45,13 +45,10 @@ import net.sourceforge.plantuml.PSystemError;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.directdot.PSystemDot;
import net.sourceforge.plantuml.ditaa.PSystemDitaa;
import net.sourceforge.plantuml.eggs.PSystemWelcome;
import net.sourceforge.plantuml.jcckit.PSystemJcckit;
import net.sourceforge.plantuml.math.PSystemMath;
import net.sourceforge.plantuml.salt.PSystemSalt;
import net.sourceforge.plantuml.stats.api.Stats;
import net.sourceforge.plantuml.sudoku.PSystemSudoku;
public class StatsUtilsIncrement {
@ -122,7 +119,7 @@ public class StatsUtilsIncrement {
if (type == PSystemSalt.class) {
return "Salt";
}
if (type == PSystemSudoku.class) {
if (type.getSimpleName().equals("PSystemSudoku")) {
return "Sudoku";
}
if (type == PSystemDot.class) {
@ -131,10 +128,10 @@ public class StatsUtilsIncrement {
if (type == PSystemWelcome.class) {
return "Welcome";
}
if (type == PSystemDitaa.class) {
if (type.getSimpleName().equals("PSystemDitaa")) {
return "Ditaa";
}
if (type == PSystemJcckit.class) {
if (type.getSimpleName().equals("PSystemJcckit")) {
return "Jcckit";
}
if (type == PSystemMath.class) {

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml.suggest;
import net.sourceforge.plantuml.StringUtils;
public class SuggestEngineResult {
private final SuggestEngineStatus status;

View File

@ -67,9 +67,6 @@ public class ClusterDecoration {
this.maxX = maxX;
this.maxY = maxY;
this.defaultStroke = stroke;
// if (stateBack instanceof HtmlColorTransparent) {
// throw new UnsupportedOperationException();
// }
}
private static USymbol guess(USymbol symbol, PackageStyle style) {
@ -96,138 +93,6 @@ public class ClusterDecoration {
.withCorner(roundCorner, 0);
symbol.asBig(title, titleAlignment, stereo, maxX - minX, maxY - minY, symbolContext).drawU(
ug.apply(new UTranslate(minX, minY)));
// return;
// }
// if (style == PackageStyle.NODE) {
// drawWithTitleNode(ug, biColor, shadowing);
// } else if (style == PackageStyle.CARD) {
// drawWithTitleCard(ug, biColor, shadowing);
// } else if (style == PackageStyle.DATABASE) {
// drawWithTitleDatabase(ug, biColor, shadowing);
// } else if (style == PackageStyle.CLOUD) {
// drawWithTitleCloud(ug, biColor, shadowing);
// } else if (style == PackageStyle.FRAME) {
// drawWithTitleFrame(ug, biColor, shadowing);
// } else if (style == PackageStyle.RECT) {
// drawWithTitleRect(ug, biColor, shadowing);
// } else {
// throw new UnsupportedOperationException();
// // drawWithTitleFolder(ug, biColor, shadowing);
// }
}
// // Cloud
// private void drawWithTitleCloud(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double width = maxX - minX;
// final double height = maxY - minY;
// ug = biColor.applyColors(ug);
// ug = ug.apply(defaultStroke);
// PackageStyle.CLOUD.drawU(ug.apply(new UTranslate(minX, minY)), new Dimension2DDouble(width, height), dimTitle,
// shadowing);
// ug = ug.apply(new UStroke());
// title.drawU(ug.apply(new UTranslate(minX + (width - dimTitle.getWidth()) / 2, minY + 10)));
//
// }
//
// // Database
// private void drawWithTitleDatabase(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double width = maxX - minX;
// final double height = maxY - minY;
// ug = ug.apply(defaultStroke);
// ug = biColor.applyColors(ug);
// PackageStyle.DATABASE.drawU(ug.apply(new UTranslate(minX, minY - 10)),
// new Dimension2DDouble(width, height + 10), dimTitle, shadowing);
// ug = ug.apply(new UStroke());
// title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY + 10)));
//
// }
//
// // Corner
// private void drawWithTitleFrame(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double width = maxX - minX;
// final double height = maxY - minY;
// ug = biColor.applyColors(ug);
// ug = ug.apply(defaultStroke);
// PackageStyle.FRAME.drawU(ug.apply(new UTranslate(minX, minY)), new Dimension2DDouble(width, height), dimTitle,
// shadowing);
// ug = ug.apply(new UStroke());
// title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY)));
//
// }
//
// // Card
// private void drawWithTitleCard(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final double width = maxX - minX;
// final double height = maxY - minY;
// final SymbolContext ctx = biColor.withStroke(defaultStroke).withShadow(shadowing);
// USymbol.CARD.asBig(title, TextBlockUtils.empty(0, 0), width + 10, height, ctx).drawU(
// ug.apply(new UTranslate(minX, minY)));
// }
//
// // Node
// private void drawWithTitleNode(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final double width = maxX - minX;
// final double height = maxY - minY;
// final SymbolContext ctx = biColor.withStroke(defaultStroke).withShadow(shadowing);
// USymbol.NODE.asBig(title, TextBlockUtils.empty(0, 0), width + 10, height, ctx).drawU(
// ug.apply(new UTranslate(minX, minY)));
// }
//
// // Folder
// private UPolygon getSpecificFrontierForFolder(StringBounder stringBounder) {
// final double width = maxX - minX;
// final double height = maxY - minY;
// final Dimension2D dimTitle = title.calculateDimension(stringBounder);
// final double wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
// final double htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
// final UPolygon shape = new UPolygon();
// shape.addPoint(0, 0);
// shape.addPoint(wtitle, 0);
// shape.addPoint(wtitle + marginTitleX3, htitle);
// shape.addPoint(width, htitle);
// shape.addPoint(width, height);
// shape.addPoint(0, height);
// shape.addPoint(0, 0);
// return shape;
// }
//
// private void drawWithTitleFolder(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
// final double htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
// final UPolygon shape = getSpecificFrontierForFolder(ug.getStringBounder());
// if (shadowing) {
// shape.setDeltaShadow(3.0);
// }
//
// ug = biColor.applyColors(ug);
// ug = ug.apply(defaultStroke);
// ug.apply(new UTranslate(minX, minY)).draw(shape);
// ug.apply(new UTranslate(minX, minY + htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
// ug = ug.apply(new UStroke());
// title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY + marginTitleY1)));
// }
//
// // Rect
// private void drawWithTitleRect(UGraphic ug, SymbolContext biColor, boolean shadowing) {
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double width = maxX - minX;
// final double height = maxY - minY;
// final URectangle shape = new URectangle(width, height);
// if (shadowing) {
// shape.setDeltaShadow(3.0);
// }
//
// ug = biColor.applyColors(ug);
// ug = ug.apply(defaultStroke);
//
// ug.apply(new UTranslate(minX, minY)).draw(shape);
// ug = ug.apply(new UStroke());
// final double deltax = width - dimTitle.getWidth();
// title.drawU(ug.apply(new UTranslate(minX + deltax / 2, minY + 5)));
// }
}

View File

@ -57,9 +57,11 @@ import net.sourceforge.plantuml.SkinParamSameClassWidth;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.GroupType;
@ -417,8 +419,8 @@ public final class GeneralImageBuilder {
if (leaf.getLeafType() == LeafType.EMPTY_PACKAGE) {
if (leaf.getUSymbol() != null) {
// final HtmlColor black = HtmlColorUtils.BLACK;
final HtmlColor black = SkinParamUtils.getColor(skinParam, leaf.getStereotype(),
leaf.getUSymbol().getColorParamBorder());
final HtmlColor black = SkinParamUtils.getColor(skinParam, leaf.getStereotype(), leaf.getUSymbol()
.getColorParamBorder());
return new EntityImageDescription(leaf, new SkinParamForecolored(skinParam, black), portionShower,
links);
}
@ -548,8 +550,23 @@ public final class GeneralImageBuilder {
return label.create(fontConfiguration, HorizontalAlignment.CENTER, skinParam);
}
private TextBlock addLegend(TextBlock original, DisplayPositionned legend) {
if (legend == null || legend.isNull()) {
return original;
}
final TextBlock text = EntityImageLegend.create(legend.getDisplay(), dotData.getSkinParam());
return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment());
}
private TextBlock getStereoBlock(IGroup g) {
final DisplayPositionned legend = g.getLegend();
return addLegend(getStereoBlockWithoutLegend(g), legend);
}
private TextBlock getStereoBlockWithoutLegend(IGroup g) {
final Stereotype stereotype = g.getStereotype();
final DisplayPositionned legend = g.getLegend();
if (stereotype == null) {
return TextBlockUtils.empty(0, 0);
}

View File

@ -701,7 +701,7 @@ public class Line implements Moveable, Hideable {
}
todraw.setComment(link.getEntity1().getCode().getFullName() + "-" + link.getEntity2().getCode().getFullName());
drawRainbow(ug.apply(new UTranslate(x, y)), color, todraw, link.getSupplementaryColors());
drawRainbow(ug.apply(new UTranslate(x, y)), color, todraw, link.getSupplementaryColors(), stroke);
ug = ug.apply(new UStroke()).apply(new UChangeColor(color));
@ -733,12 +733,12 @@ public class Line implements Moveable, Hideable {
}
}
private void drawRainbow(UGraphic ug, HtmlColor color, DotPath todraw, List<Colors> supplementaryColors) {
private void drawRainbow(UGraphic ug, HtmlColor color, DotPath todraw, List<Colors> supplementaryColors, UStroke stroke) {
ug.draw(todraw);
final LinkType linkType = link.getType();
if (this.extremity2 != null) {
UGraphic ug2 = ug.apply(new UStroke()).apply(new UChangeColor(color));
UGraphic ug2 = ug.apply(new UChangeColor(color)).apply(stroke.onlyThickness());
if (linkType.getDecor1().isFill()) {
ug2 = ug2.apply(new UChangeBackColor(color));
} else {
@ -748,7 +748,7 @@ public class Line implements Moveable, Hideable {
this.extremity2.drawU(ug2);
}
if (this.extremity1 != null) {
UGraphic ug2 = ug.apply(new UStroke()).apply(new UChangeColor(color));
UGraphic ug2 = ug.apply(new UChangeColor(color)).apply(stroke.onlyThickness());
if (linkType.getDecor2().isFill()) {
ug2 = ug2.apply(new UChangeBackColor(color));
} else {

View File

@ -41,14 +41,13 @@ import java.awt.geom.Point2D;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class ExtremityCircleLine extends Extremity {
private final Point2D contact;
private final double angle;
private final double radius = 4;
private final double lineHeight = 4;
@Override
public Point2D somePoint() {
@ -61,11 +60,14 @@ class ExtremityCircleLine extends Extremity {
}
public void drawU(UGraphic ug) {
final double thickness = ug.getParam().getStroke().getThickness();
final double radius = 4 + thickness - 1;
final double lineHeight = 4 + thickness - 1;
final int xWing = 4;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D middle = new Point2D.Double(0, 0);
Point2D base = new Point2D.Double(-xWing-radius-3, 0);
Point2D circleBase = new Point2D.Double(-xWing-radius-3, 0);
Point2D base = new Point2D.Double(-xWing - radius - 3, 0);
Point2D circleBase = new Point2D.Double(-xWing - radius - 3, 0);
Point2D lineTop = new Point2D.Double(-xWing, -lineHeight);
Point2D lineBottom = new Point2D.Double(-xWing, lineHeight);
@ -76,8 +78,11 @@ class ExtremityCircleLine extends Extremity {
rotate.transform(circleBase, circleBase);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
ug.apply(new UTranslate(contact.getX()+circleBase.getX()-radius, contact.getY()+circleBase.getY()-radius)).draw(new UEllipse(2*radius, 2*radius));
drawLine(ug, contact.getX(), contact.getY(), lineTop, lineBottom);
final UStroke stroke = new UStroke(thickness);
ug.apply(
new UTranslate(contact.getX() + circleBase.getX() - radius, contact.getY() + circleBase.getY() - radius))
.apply(stroke).draw(new UEllipse(2 * radius, 2 * radius));
drawLine(ug.apply(stroke), contact.getX(), contact.getY(), lineTop, lineBottom);
}
static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
@ -74,9 +75,11 @@ public class EntityImageBranch extends AbstractEntityImage {
diams.addPoint(0, SIZE);
diams.addPoint(SIZE, 0);
ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.activityBorder)))
.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), getStereo(),
ColorParam.activityBackground))).apply(new UStroke(1.5)).draw(diams);
final HtmlColor border = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.activityDiamondBorder,
ColorParam.activityBorder);
final HtmlColor back = SkinParamUtils.getColor(getSkinParam(), getStereo(),
ColorParam.activityDiamondBackground, ColorParam.activityBackground);
ug.apply(new UChangeColor(border)).apply(new UChangeBackColor(back)).apply(new UStroke(1.5)).draw(diams);
}
public ShapeType getShapeType() {

View File

@ -408,6 +408,7 @@ public class SvgGraphics {
}
public void svgPolygon(double deltaShadow, double... points) {
assert points.length % 2 == 0;
manageShadow(deltaShadow);
if (hidden == false) {
final Element elt = (Element) document.createElement("polygon");
@ -789,6 +790,7 @@ public class SvgGraphics {
}
private void addFilter(Element filter, String name, String... data) {
assert data.length % 2 == 0;
final Element elt = (Element) document.createElement(name);
for (int i = 0; i < data.length; i += 2) {
elt.setAttribute(data[i], data[i + 1]);

View File

@ -382,6 +382,7 @@ public class TikzGraphics {
public void polygon(double[] points) {
assert points.length % 2 == 0;
final StringBuilder sb = new StringBuilder();
appendShadeOrDraw(sb);
sb.append("line width=" + thickness + "pt]");
@ -395,6 +396,7 @@ public class TikzGraphics {
}
private void round(double r, double[] points) {
assert points.length % 2 == 0;
final StringBuilder sb = new StringBuilder();
appendShadeOrDraw(sb);
sb.append("line width=" + thickness + "pt]");

View File

@ -50,6 +50,7 @@ public class ShadowManager {
}
public double[] getShadowDeltaPoints(double deltaShadow, double diff, double[] points) {
assert points.length % 2 == 0;
double cx = 0;
double cy = 0;
for (int i = 0; i < points.length; i += 2) {

View File

@ -97,37 +97,57 @@ public class UImage implements UShape {
if (newColor == null) {
return this;
}
int darker = -1;
int darkerRgb = -1;
for (int i = 0; i < image.getWidth(); i++) {
for (int j = 0; j < image.getHeight(); j++) {
final int color = image.getRGB(i, j);
if (isTransparent(color)) {
// System.err.println("i="+i+" j="+j+" "+Integer.toHexString(color)+" "+isTransparent(color));
final int rgb = getRgb(color);
final int a = getA(color);
if (a != mask_a__) {
continue;
}
final int grey = ColorChangerMonochrome.getGrayScale(color);
if (darker == -1 || grey < ColorChangerMonochrome.getGrayScale(darker)) {
darker = color;
// if (isTransparent(color)) {
// continue;
// }
final int grey = ColorChangerMonochrome.getGrayScale(rgb);
if (darkerRgb == -1 || grey < ColorChangerMonochrome.getGrayScale(darkerRgb)) {
darkerRgb = rgb;
}
}
}
final BufferedImage copy = deepCopy(image);
for (int i = 0; i < image.getWidth(); i++) {
for (int j = 0; j < image.getHeight(); j++) {
if (copy.getRGB(i, j) == darker) {
copy.setRGB(i, j, newColor.getRGB());
final int color = copy.getRGB(i, j);
final int rgb = getRgb(color);
final int a = getA(color);
if (a!=0 && rgb == darkerRgb) {
copy.setRGB(i, j, newColor.getRGB() + a);
}
}
}
return new UImage(copy, formula);
}
private boolean isTransparent(int color) {
if (color == 0) {
return true;
}
return false;
private static final int mask_a__ = 0xFF000000;
private static final int mask_rgb = 0x00FFFFFF;
private int getRgb(int color) {
return color & mask_rgb;
}
private int getA(int color) {
return color & mask_a__;
}
// private boolean isTransparent(int argb) {
// if ((argb & mask) == mask) {
// return false;
// }
// return true;
// }
// From https://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage
private static BufferedImage deepCopy(BufferedImage bi) {
final ColorModel cm = bi.getColorModel();

View File

@ -48,6 +48,7 @@ public class UMotif {
private final List<Point2D> points = new ArrayList<Point2D>();
public UMotif(int... data) {
assert data.length % 2 == 0;
for (int i = 0; i < data.length; i += 2) {
points.add(new Point2D.Double(data[i], data[i + 1]));
}

View File

@ -60,6 +60,10 @@ public class UStroke implements UChange {
this(1.0);
}
public UStroke onlyThickness() {
return new UStroke(thickness);
}
private UStroke applyThickness(UStroke thickness) {
if (thickness == null) {
return this;

View File

@ -58,6 +58,7 @@ public class DriverPolygonSvg implements UDriver<SvgGraphics> {
final UPolygon shape = (UPolygon) ushape;
final double points[] = shape.getPointArray(x, y);
assert points.length % 2 == 0;
final UClip clip = clipContainer.getClip();
if (clip != null) {
for (int j = 0; j < points.length; j += 2) {

View File

@ -43,7 +43,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000;
public static int version() {
return 1201900;
return 1201901;
}
public static int versionPatched() {
@ -88,7 +88,7 @@ public class Version {
}
public static long compileTime() {
return 1547394402485L;
return 1549726324013L;
}
public static String compileTimeString() {