plantuml/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java

100 lines
3.3 KiB
Java
Raw Normal View History

2011-08-08 17:48:29 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2022-03-07 19:33:46 +00:00
* (C) Copyright 2009-2023, 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
*
*
*/
2013-12-10 19:36:50 +00:00
package net.sourceforge.plantuml.svek.image;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
2022-05-04 17:52:00 +00:00
import net.sourceforge.plantuml.awt.geom.Dimension2D;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.cucadiagram.Display;
2015-06-07 10:23:10 +00:00
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.graphic.StringBounder;
2015-09-28 20:42:17 +00:00
import net.sourceforge.plantuml.graphic.color.Colors;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.skin.Area;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.rose.Rose;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.svek.IEntityImage;
2017-04-05 17:37:42 +00:00
import net.sourceforge.plantuml.svek.Margins;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.svek.ShapeType;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.ugraphic.UGraphic;
2020-03-18 10:50:02 +00:00
import net.sourceforge.plantuml.ugraphic.color.HColor;
2011-08-08 17:48:29 +00:00
2015-06-07 10:23:10 +00:00
public class EntityImageNoteLink extends AbstractTextBlock implements IEntityImage {
2011-08-08 17:48:29 +00:00
private final Component comp;
2019-07-14 20:09:26 +00:00
public EntityImageNoteLink(Display note, Colors colors, ISkinParam skinParam, StyleBuilder styleBuilder) {
2011-08-08 17:48:29 +00:00
final Rose skin = new Rose();
2021-06-27 16:50:40 +00:00
comp = skin.createComponentNote(
2022-02-16 18:59:44 +00:00
new Style[] { ComponentType.NOTE.getStyleSignature().getMergedStyle(styleBuilder) }, ComponentType.NOTE,
colors.mute(skinParam), note);
2011-08-08 17:48:29 +00:00
}
2013-12-10 19:36:50 +00:00
public Dimension2D calculateDimension(StringBounder stringBounder) {
2011-08-08 17:48:29 +00:00
final double height = comp.getPreferredHeight(stringBounder);
final double width = comp.getPreferredWidth(stringBounder);
return new Dimension2DDouble(width, height);
}
2013-12-10 19:36:50 +00:00
public void drawU(UGraphic ug) {
comp.drawU(ug, new Area(calculateDimension(ug.getStringBounder())), new SimpleContext2D(false));
2011-08-08 17:48:29 +00:00
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
2020-03-18 10:50:02 +00:00
public HColor getBackcolor() {
2011-08-08 17:48:29 +00:00
return null;
}
2013-12-10 19:36:50 +00:00
2017-04-05 17:37:42 +00:00
public Margins getShield(StringBounder stringBounder) {
return Margins.NONE;
2011-09-07 20:41:58 +00:00
}
2013-12-10 19:36:50 +00:00
public boolean isHidden() {
return false;
}
2019-07-14 20:09:26 +00:00
2018-12-22 11:11:40 +00:00
public double getOverscanX(StringBounder stringBounder) {
return 0;
}
2011-08-08 17:48:29 +00:00
}