mirror of
https://github.com/octoleo/plantuml.git
synced 2024-10-31 19:22:31 +00:00
This commit is contained in:
parent
fae0dfdf02
commit
8a5e7a48ca
@ -135,7 +135,7 @@ public class TextSkin extends Rose {
|
||||
if (type == ComponentType.DIVIDER)
|
||||
return new ComponentTextDivider(type, stringsToDisplay, fileFormat);
|
||||
|
||||
if (type == ComponentType.GROUPING_HEADER)
|
||||
if (type == ComponentType.GROUPING_HEADER_LEGACY || type == ComponentType.GROUPING_HEADER_TEOZ)
|
||||
return new ComponentTextGroupingHeader(type, stringsToDisplay, fileFormat);
|
||||
|
||||
if (type == ComponentType.GROUPING_SPACE)
|
||||
|
@ -78,9 +78,9 @@ final public class GroupingLeaf extends Grouping implements EventWithDeactivate
|
||||
|
||||
@Override
|
||||
public final HColor getBackColorGeneral() {
|
||||
if (backColorGeneral == null) {
|
||||
if (backColorGeneral == null)
|
||||
return start.getBackColorGeneral();
|
||||
}
|
||||
|
||||
return backColorGeneral;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ public class GroupingStart extends Grouping {
|
||||
|
||||
public Style[] getUsedStyles() {
|
||||
final Style[] result = super.getUsedStyles();
|
||||
if (result[0] != null) {
|
||||
if (result[0] != null)
|
||||
result[0] = result[0].eventuallyOverride(PName.BackGroundColor, backColorGeneral);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -77,9 +77,9 @@ public class GroupingStart extends Grouping {
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
if (parent == null) {
|
||||
if (parent == null)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return parent.getLevel() + 1;
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ class DrawableSetInitializer {
|
||||
final Display strings = start.getTitle().equals("group") ? Display.create(start.getComment())
|
||||
: Display.create(start.getTitle(), start.getComment());
|
||||
final Component header = drawableSet.getSkin().createComponent(start.getUsedStyles(),
|
||||
ComponentType.GROUPING_HEADER, null, skinParam, strings);
|
||||
ComponentType.GROUPING_HEADER_LEGACY, null, skinParam, strings);
|
||||
final ParticipantBox veryfirst = drawableSet.getVeryfirst();
|
||||
final InGroupableList inGroupableList = new InGroupableList(veryfirst, start, freeY2.getFreeY(range));
|
||||
inGroupableStack.addList(inGroupableList);
|
||||
|
@ -0,0 +1,97 @@
|
||||
/* ========================================================================
|
||||
* 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.sequencediagram.teoz;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
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.URectangle;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class Blotter implements UDrawable {
|
||||
|
||||
private final XDimension2D dim;
|
||||
private final HColor defaultBackcolor;
|
||||
private HColor last;
|
||||
private final SortedMap<Double, HColor> changes = new TreeMap<>();
|
||||
|
||||
public Blotter(XDimension2D dim, HColor defaultBackcolor) {
|
||||
if (defaultBackcolor == null)
|
||||
defaultBackcolor = HColors.transparent();
|
||||
this.dim = dim;
|
||||
this.defaultBackcolor = defaultBackcolor;
|
||||
this.last = defaultBackcolor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" + dim + " " + defaultBackcolor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawU(UGraphic ug) {
|
||||
HColor current = defaultBackcolor;
|
||||
double y = 0;
|
||||
for (Entry<Double, HColor> ent : changes.entrySet()) {
|
||||
if (current.isTransparent() == false) {
|
||||
final URectangle rect = new URectangle(dim.getWidth(), ent.getKey() - y);
|
||||
ug.apply(current).apply(current.bg()).apply(UTranslate.dy(y)).draw(rect);
|
||||
}
|
||||
y = ent.getKey();
|
||||
current = ent.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeChanges() {
|
||||
changes.put(dim.getHeight(), defaultBackcolor);
|
||||
}
|
||||
|
||||
public void addChange(double ypos, HColor color) {
|
||||
if (color == null)
|
||||
color = HColors.transparent();
|
||||
if (color.equals(last))
|
||||
return;
|
||||
changes.put(ypos, color);
|
||||
last = color;
|
||||
}
|
||||
|
||||
}
|
@ -50,6 +50,7 @@ import net.sourceforge.plantuml.skin.Context2D;
|
||||
import net.sourceforge.plantuml.skin.rose.Rose;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
|
||||
public class ElseTile extends AbstractTile {
|
||||
|
||||
@ -82,6 +83,10 @@ public class ElseTile extends AbstractTile {
|
||||
return yGauge;
|
||||
}
|
||||
|
||||
public final HColor getBackColorGeneral() {
|
||||
return anElse.getBackColorGeneral();
|
||||
}
|
||||
|
||||
public Component getComponent(StringBounder stringBounder) {
|
||||
// final Display display = Display.create(anElse.getTitle());
|
||||
final ISkinParam tmp = new SkinParamBackcolored(skinParam, anElse.getBackColorElement(),
|
||||
|
@ -57,8 +57,10 @@ import net.sourceforge.plantuml.skin.Component;
|
||||
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.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
|
||||
public class GroupingTile extends AbstractTile {
|
||||
|
||||
@ -156,7 +158,7 @@ public class GroupingTile extends AbstractTile {
|
||||
}
|
||||
|
||||
private Component getComponent(StringBounder stringBounder) {
|
||||
final Component comp = skin.createComponent(start.getUsedStyles(), ComponentType.GROUPING_HEADER, null,
|
||||
final Component comp = skin.createComponent(start.getUsedStyles(), ComponentType.GROUPING_HEADER_TEOZ, null,
|
||||
skinParam, display);
|
||||
return comp;
|
||||
}
|
||||
@ -168,14 +170,19 @@ public class GroupingTile extends AbstractTile {
|
||||
public void drawU(UGraphic ug) {
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
|
||||
final Area area = Area.create(max.getCurrentValue() - min.getCurrentValue(), getTotalHeight(stringBounder));
|
||||
|
||||
final Component comp = getComponent(stringBounder);
|
||||
final XDimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
|
||||
final Area area = Area.create(max.getCurrentValue() - min.getCurrentValue(), getTotalHeight(stringBounder));
|
||||
|
||||
if (YGauge.USE_ME) {
|
||||
comp.drawU(ug.apply(new UTranslate(min.getCurrentValue(), getYGauge().getMin().getCurrentValue())), area,
|
||||
(Context2D) ug);
|
||||
} else {
|
||||
if (((Context2D) ug).isBackground()) {
|
||||
drawBackground(ug, area);
|
||||
return;
|
||||
}
|
||||
comp.drawU(ug.apply(UTranslate.dx(min.getCurrentValue())), area, (Context2D) ug);
|
||||
drawAllElses(ug);
|
||||
}
|
||||
@ -191,6 +198,36 @@ 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 XDimension2D dimensionToUse = area.getDimensionToUse();
|
||||
final Blotter blotter = new Blotter(dimensionToUse, back);
|
||||
|
||||
for (Tile tile : tiles)
|
||||
if (tile instanceof ElseTile) {
|
||||
final ElseTile elseTile = (ElseTile) tile;
|
||||
final double ypos = elseTile.getTimeHook().getValue() - getTimeHook().getValue() + MARGINY_MAGIC / 2;
|
||||
blotter.addChange(ypos, elseTile.getBackColorGeneral());
|
||||
}
|
||||
|
||||
blotter.closeChanges();
|
||||
blotter.drawU(ug.apply(UTranslate.dx(min.getCurrentValue())));
|
||||
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
|
||||
final XDimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
|
||||
double h = dim1.getHeight() + MARGINY_MAGIC / 2;
|
||||
for (Tile tile : tiles) {
|
||||
if (YGauge.USE_ME)
|
||||
((UDrawable) tile).drawU(ug);
|
||||
else
|
||||
((UDrawable) tile).drawU(ug.apply(UTranslate.dy(h)));
|
||||
final double preferredHeight = tile.getPreferredHeight();
|
||||
h += preferredHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private double getTotalHeight(StringBounder stringBounder) {
|
||||
final XDimension2D dimIfEmpty = getPreferredDimensionIfEmpty(stringBounder);
|
||||
return bodyHeight + dimIfEmpty.getHeight() + MARGINY_MAGIC / 2;
|
||||
@ -198,7 +235,6 @@ public class GroupingTile extends AbstractTile {
|
||||
|
||||
private void drawAllElses(UGraphic ug) {
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
final double totalHeight = getTotalHeight(stringBounder);
|
||||
|
||||
final List<Double> ys = new ArrayList<>();
|
||||
for (Tile tile : tiles) {
|
||||
@ -213,6 +249,7 @@ public class GroupingTile extends AbstractTile {
|
||||
ys.add(ypos);
|
||||
}
|
||||
}
|
||||
final double totalHeight = getTotalHeight(stringBounder);
|
||||
ys.add(totalHeight);
|
||||
int i = 0;
|
||||
for (Tile tile : tiles) {
|
||||
|
@ -56,7 +56,7 @@ public enum ComponentType implements Styleable {
|
||||
DELAY_LINE, PARTICIPANT_LINE, CONTINUE_LINE,
|
||||
|
||||
//
|
||||
GROUPING_ELSE_LEGACY, GROUPING_ELSE_TEOZ, GROUPING_HEADER, GROUPING_SPACE,
|
||||
GROUPING_ELSE_LEGACY, GROUPING_ELSE_TEOZ, GROUPING_HEADER_LEGACY, GROUPING_HEADER_TEOZ, GROUPING_SPACE,
|
||||
//
|
||||
NEWPAGE, NOTE, NOTE_HEXAGONAL, NOTE_BOX, DIVIDER, REFERENCE, ENGLOBER,
|
||||
|
||||
|
@ -67,7 +67,8 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
|
||||
this.teoz = teoz;
|
||||
this.roundCorner = style.value(PName.RoundCorner).asInt();
|
||||
this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet());
|
||||
this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
this.backgroundColor = teoz ? HColors.transparent()
|
||||
: style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,6 +56,7 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColors;
|
||||
|
||||
public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
|
||||
|
||||
@ -69,11 +70,12 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
|
||||
private final SymbolContext symbolContextCorner;
|
||||
private final double roundCorner;
|
||||
|
||||
public ComponentRoseGroupingHeader(Style style, Style styleHeader, Display strings, ISkinSimple spriteContainer) {
|
||||
public ComponentRoseGroupingHeader(boolean teoz, Style style, Style styleHeader, Display strings,
|
||||
ISkinSimple spriteContainer) {
|
||||
super(styleHeader, LineBreakStrategy.NONE, 15, 30, 1, spriteContainer, strings.get(0));
|
||||
|
||||
this.roundCorner = style.value(PName.RoundCorner).asInt();
|
||||
this.background = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
this.background = teoz ? HColors.transparent() : style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
this.symbolContext = style.getSymbolContext(getIHtmlColorSet());
|
||||
this.symbolContextCorner = styleHeader.getSymbolContext(getIHtmlColorSet());
|
||||
|
||||
|
@ -208,8 +208,11 @@ public class Rose {
|
||||
if (type == ComponentType.NOTE_BOX)
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
if (type == ComponentType.GROUPING_HEADER)
|
||||
return new ComponentRoseGroupingHeader(styles[0], styles[1], stringsToDisplay, param);
|
||||
if (type == ComponentType.GROUPING_HEADER_LEGACY)
|
||||
return new ComponentRoseGroupingHeader(false, styles[0], styles[1], stringsToDisplay, param);
|
||||
|
||||
if (type == ComponentType.GROUPING_HEADER_TEOZ)
|
||||
return new ComponentRoseGroupingHeader(true, styles[0], styles[1], stringsToDisplay, param);
|
||||
|
||||
if (type == ComponentType.GROUPING_ELSE_LEGACY)
|
||||
return new ComponentRoseGroupingElse(false, styles[0], stringsToDisplay.get(0), param);
|
||||
|
@ -81,7 +81,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static int beta() {
|
||||
final int beta = 3;
|
||||
final int beta = 4;
|
||||
return beta;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user