1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-06 18:30:52 +00:00
plantuml/src/net/sourceforge/plantuml/posimo/MargedBlock.java

92 lines
2.7 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2023-02-22 18:43:48 +00:00
* (C) Copyright 2009-2024, Arnaud Roques
2010-11-15 20:35:36 +00:00
*
2023-02-22 18:43:48 +00:00
* Project Info: https://plantuml.com
2010-11-15 20:35:36 +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:
*
2023-02-22 18:43:48 +00:00
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
2017-03-15 19:13:31 +00:00
*
2010-11-15 20:35:36 +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
2010-11-15 20:35:36 +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.posimo;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.Positionable;
2023-02-22 18:43:48 +00:00
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.geom.XPoint2D;
2010-11-15 20:35:36 +00:00
public class MargedBlock {
private final Block block;
private final IEntityImageBlock imageBlock;
2010-11-25 21:12:39 +00:00
private final double marginDecorator;
2022-09-12 20:08:34 +00:00
private final XDimension2D imageDimension;
2010-11-15 20:35:36 +00:00
static private int uid = 1;
2023-02-22 18:43:48 +00:00
public MargedBlock(StringBounder stringBounder, IEntityImageBlock imageBlock, double marginDecorator,
Cluster parent) {
2010-11-15 20:35:36 +00:00
this.imageBlock = imageBlock;
this.marginDecorator = marginDecorator;
this.imageDimension = imageBlock.getDimension(stringBounder);
2023-02-22 18:43:48 +00:00
this.block = new Block(uid++, imageDimension.getWidth() + 2 * marginDecorator,
imageDimension.getHeight() + 2 * marginDecorator, parent);
2010-11-15 20:35:36 +00:00
}
public Block getBlock() {
return block;
}
2010-11-25 21:12:39 +00:00
public double getMarginDecorator() {
2010-11-15 20:35:36 +00:00
return marginDecorator;
}
2011-09-08 10:42:27 +00:00
2010-11-15 20:35:36 +00:00
public IEntityImageBlock getImageBlock() {
return imageBlock;
}
public Positionable getImagePosition() {
return new Positionable() {
2022-09-12 20:08:34 +00:00
public XDimension2D getSize() {
2010-11-15 20:35:36 +00:00
return imageDimension;
}
2022-09-12 20:08:34 +00:00
public XPoint2D getPosition() {
final XPoint2D pos = block.getPosition();
return new XPoint2D(pos.getX() + marginDecorator, pos.getY() + marginDecorator);
2011-09-08 10:42:27 +00:00
}
public void moveSvek(double deltaX, double deltaY) {
throw new UnsupportedOperationException();
2010-11-15 20:35:36 +00:00
}
};
}
}