2011-08-08 17:48:29 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2019-01-16 18:34:41 +00:00
|
|
|
* (C) Copyright 2009-2020, Arnaud Roques
|
2011-08-08 17:48:29 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2011-08-08 17:48:29 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* 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
|
|
|
|
*
|
2011-08-08 17:48:29 +00:00
|
|
|
* 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
|
2013-12-10 19:36:50 +00:00
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
2011-08-08 17:48:29 +00:00
|
|
|
* 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.svek;
|
|
|
|
|
|
|
|
import java.awt.geom.Dimension2D;
|
|
|
|
|
|
|
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.URectangle;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
2020-03-18 10:50:02 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
public final class RoundedContainer {
|
|
|
|
|
|
|
|
private final Dimension2D dim;
|
|
|
|
private final double titleHeight;
|
2013-12-10 19:36:50 +00:00
|
|
|
private final double attributeHeight;
|
2020-03-18 10:50:02 +00:00
|
|
|
private final HColor borderColor;
|
|
|
|
private final HColor backColor;
|
|
|
|
private final HColor imgBackcolor;
|
2015-04-07 18:18:37 +00:00
|
|
|
private final UStroke stroke;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2020-03-18 10:50:02 +00:00
|
|
|
public RoundedContainer(Dimension2D dim, double titleHeight, double attributeHeight, HColor borderColor,
|
|
|
|
HColor backColor, HColor imgBackcolor, UStroke stroke) {
|
2018-10-21 19:44:14 +00:00
|
|
|
if (dim.getWidth() == 0) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2011-08-08 17:48:29 +00:00
|
|
|
this.dim = dim;
|
|
|
|
this.imgBackcolor = imgBackcolor;
|
|
|
|
this.titleHeight = titleHeight;
|
|
|
|
this.borderColor = borderColor;
|
|
|
|
this.backColor = backColor;
|
2013-12-10 19:36:50 +00:00
|
|
|
this.attributeHeight = attributeHeight;
|
2015-04-07 18:18:37 +00:00
|
|
|
this.stroke = stroke;
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public void drawU(UGraphic ug, boolean shadowing) {
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2020-04-19 16:04:39 +00:00
|
|
|
ug = ug.apply(backColor.bg()).apply(borderColor);
|
2020-03-18 10:50:02 +00:00
|
|
|
final URectangle rect = new URectangle(dim.getWidth(), dim.getHeight()).rounded(IEntityImage.CORNER);
|
2013-12-10 19:36:50 +00:00
|
|
|
if (shadowing) {
|
|
|
|
rect.setDeltaShadow(3.0);
|
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
ug.apply(stroke).draw(rect);
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final double yLine = titleHeight + attributeHeight;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2020-04-19 16:04:39 +00:00
|
|
|
ug = ug.apply(imgBackcolor.bg());
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
final double thickness = stroke.getThickness();
|
|
|
|
|
2020-03-18 10:50:02 +00:00
|
|
|
final URectangle inner = new URectangle(dim.getWidth() - 4 * thickness,
|
|
|
|
dim.getHeight() - titleHeight - 4 * thickness - attributeHeight).rounded(IEntityImage.CORNER);
|
2020-04-19 16:04:39 +00:00
|
|
|
ug.apply(imgBackcolor).apply(new UTranslate(2 * thickness, yLine + 2 * thickness))
|
2015-04-07 18:18:37 +00:00
|
|
|
.draw(inner);
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
if (titleHeight > 0) {
|
2020-03-18 10:50:02 +00:00
|
|
|
ug.apply(stroke).apply(UTranslate.dy(yLine)).draw(ULine.hline(dim.getWidth()));
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (attributeHeight > 0) {
|
2020-03-18 10:50:02 +00:00
|
|
|
ug.apply(stroke).apply(UTranslate.dy(yLine - attributeHeight)).draw(ULine.hline(dim.getWidth()));
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|