1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-13 21:52:27 +00:00
This commit is contained in:
Arnaud Roques 2022-11-29 19:57:22 +01:00
parent 8a5e7a48ca
commit 4ea37512c7
8 changed files with 332 additions and 5 deletions

View File

@ -42,7 +42,9 @@ import java.util.TreeMap;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors;
@ -51,12 +53,14 @@ public class Blotter implements UDrawable {
private final XDimension2D dim;
private final HColor defaultBackcolor;
private final double round;
private HColor last;
private final SortedMap<Double, HColor> changes = new TreeMap<>();
public Blotter(XDimension2D dim, HColor defaultBackcolor) {
public Blotter(XDimension2D dim, HColor defaultBackcolor, double round) {
if (defaultBackcolor == null)
defaultBackcolor = HColors.transparent();
this.round = round;
this.dim = dim;
this.defaultBackcolor = defaultBackcolor;
this.last = defaultBackcolor;
@ -71,16 +75,54 @@ public class Blotter implements UDrawable {
public void drawU(UGraphic ug) {
HColor current = defaultBackcolor;
double y = 0;
int i = 0;
for (Entry<Double, HColor> ent : changes.entrySet()) {
if (current.isTransparent() == false) {
final URectangle rect = new URectangle(dim.getWidth(), ent.getKey() - y);
final UShape rect = getRectangleBackground(i, ent.getKey() - y);
ug.apply(current).apply(current.bg()).apply(UTranslate.dy(y)).draw(rect);
}
y = ent.getKey();
current = ent.getValue();
i++;
}
}
private UShape getRectangleBackground(int i, double height) {
final double width = dim.getWidth();
if (round == 0)
return new URectangle(width, height);
if (changes.size() == 1)
return new URectangle(width, height).rounded(round);
if (i == 0) {
final UPath result = new UPath();
result.moveTo(round / 2, 0);
result.lineTo(width - round / 2, 0);
result.arcTo(round / 2, round / 2, 0, 0, 1, width, round / 2);
result.lineTo(width, height);
result.lineTo(0, height);
result.lineTo(0, round / 2);
result.arcTo(round / 2, round / 2, 0, 0, 1, round / 2, 0);
result.closePath();
return result;
}
if (i == changes.size() - 1) {
final UPath result = new UPath();
result.moveTo(0, 0);
result.lineTo(width, 0);
result.lineTo(width, height - round / 2);
result.arcTo(round / 2, round / 2, 0, 0, 1, width - round / 2, height);
result.lineTo(round / 2, height);
result.arcTo(round / 2, round / 2, 0, 0, 1, 0, height - round / 2);
result.lineTo(0, 0);
result.closePath();
return result;
}
return new URectangle(width, height);
}
public void closeChanges() {
changes.put(dim.getHeight(), defaultBackcolor);
}

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -199,9 +200,11 @@ public class GroupingTile extends AbstractTile {
}
private void drawBackground(UGraphic ug, Area area) {
final HColor back = start.getUsedStyles()[0].value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
final Style style = start.getUsedStyles()[0];
final HColor back = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
final double round = style.value(PName.RoundCorner).asDouble();
final XDimension2D dimensionToUse = area.getDimensionToUse();
final Blotter blotter = new Blotter(dimensionToUse, back);
final Blotter blotter = new Blotter(dimensionToUse, back, round);
for (Tile tile : tiles)
if (tile instanceof ElseTile) {

View File

@ -112,8 +112,12 @@ import net.sourceforge.plantuml.tim.stdlib.JsonKeyExists;
import net.sourceforge.plantuml.tim.stdlib.Lighten;
import net.sourceforge.plantuml.tim.stdlib.LoadJson;
import net.sourceforge.plantuml.tim.stdlib.LogicalAnd;
import net.sourceforge.plantuml.tim.stdlib.LogicalNand;
import net.sourceforge.plantuml.tim.stdlib.LogicalNor;
import net.sourceforge.plantuml.tim.stdlib.LogicalNot;
import net.sourceforge.plantuml.tim.stdlib.LogicalNxor;
import net.sourceforge.plantuml.tim.stdlib.LogicalOr;
import net.sourceforge.plantuml.tim.stdlib.LogicalXor;
import net.sourceforge.plantuml.tim.stdlib.Lower;
import net.sourceforge.plantuml.tim.stdlib.Newline;
import net.sourceforge.plantuml.tim.stdlib.Now;
@ -197,6 +201,10 @@ public class TContext {
functionsSet.addFunction(new Now());
functionsSet.addFunction(new LogicalAnd());
functionsSet.addFunction(new LogicalOr());
functionsSet.addFunction(new LogicalXor());
functionsSet.addFunction(new LogicalNand());
functionsSet.addFunction(new LogicalNor());
functionsSet.addFunction(new LogicalNxor());
// %standard_exists_function
// %str_replace
// !exit

View File

@ -0,0 +1,68 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.tim.stdlib;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TFunctionSignature;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.expression.TValue;
public class LogicalNand extends SimpleReturnFunction {
public TFunctionSignature getSignature() {
return new TFunctionSignature("%nand", 2);
}
public boolean canCover(int nbArg, Set<String> namedArgument) {
return nbArg >= 2;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
for (TValue v : values)
if (v.toBoolean() == false)
return TValue.fromBoolean(!false);
return TValue.fromBoolean(!true);
}
}

View File

@ -0,0 +1,68 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.tim.stdlib;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TFunctionSignature;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.expression.TValue;
public class LogicalNor extends SimpleReturnFunction {
public TFunctionSignature getSignature() {
return new TFunctionSignature("%nor", 2);
}
public boolean canCover(int nbArg, Set<String> namedArgument) {
return nbArg >= 2;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
for (TValue v : values)
if (v.toBoolean() == true)
return TValue.fromBoolean(!true);
return TValue.fromBoolean(!false);
}
}

View File

@ -0,0 +1,69 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.tim.stdlib;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TFunctionSignature;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.expression.TValue;
public class LogicalNxor extends SimpleReturnFunction {
public TFunctionSignature getSignature() {
return new TFunctionSignature("%nxor", 2);
}
public boolean canCover(int nbArg, Set<String> namedArgument) {
return nbArg >= 2;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
int cpt = 0;
for (TValue v : values)
if (v.toBoolean() == true)
cpt++;
return TValue.fromBoolean(!(cpt == 1));
}
}

View File

@ -0,0 +1,69 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.tim.stdlib;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TFunctionSignature;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.expression.TValue;
public class LogicalXor extends SimpleReturnFunction {
public TFunctionSignature getSignature() {
return new TFunctionSignature("%xor", 2);
}
public boolean canCover(int nbArg, Set<String> namedArgument) {
return nbArg >= 2;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
int cpt = 0;
for (TValue v : values)
if (v.toBoolean() == true)
cpt++;
return TValue.fromBoolean(cpt == 1);
}
}

View File

@ -81,7 +81,7 @@ public class Version {
}
public static int beta() {
final int beta = 4;
final int beta = 5;
return beta;
}