1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-07 19:00:53 +00:00
plantuml/src/net/sourceforge/plantuml/creole/SheetBlock2.java

115 lines
3.6 KiB
Java
Raw Normal View History

2015-04-07 18:26:58 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2022-03-07 19:33:46 +00:00
* (C) Copyright 2009-2023, Arnaud Roques
2015-04-07 18:26:58 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2015-04-07 18:26:58 +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
*
2015-04-07 18:26:58 +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
* 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.creole;
2015-06-07 10:23:10 +00:00
import java.awt.geom.Rectangle2D;
2019-03-29 22:14:07 +00:00
import java.util.List;
2021-05-09 21:14:40 +00:00
import java.util.Objects;
2015-04-07 18:26:58 +00:00
2022-05-31 16:31:10 +00:00
import net.sourceforge.plantuml.awt.geom.Dimension2D;
2020-03-18 10:50:02 +00:00
import net.sourceforge.plantuml.creole.atom.Atom;
2015-06-07 10:23:10 +00:00
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
2017-04-05 17:37:42 +00:00
import net.sourceforge.plantuml.graphic.InnerStrategy;
2015-04-07 18:26:58 +00:00
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
2022-05-31 16:31:10 +00:00
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
2015-04-07 18:26:58 +00:00
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
import net.sourceforge.plantuml.ugraphic.UStroke;
2022-05-31 16:31:10 +00:00
final public class SheetBlock2 extends AbstractTextBlock implements TextBlock, Atom, WithPorts {
2015-04-07 18:26:58 +00:00
2019-03-29 22:14:07 +00:00
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
throw new UnsupportedOperationException(getClass().toString());
}
2020-04-19 16:04:39 +00:00
2015-04-07 18:26:58 +00:00
private final SheetBlock1 block;
private final UStroke defaultStroke;
private final Stencil stencil;
public SheetBlock2 enlargeMe(final double delta1, final double delta2) {
2020-04-19 16:04:39 +00:00
final Stencil newStencil = new Stencil() {
public double getStartingX(StringBounder stringBounder, double y) {
return stencil.getStartingX(stringBounder, y) - delta1;
2020-04-19 16:04:39 +00:00
}
public double getEndingX(StringBounder stringBounder, double y) {
return stencil.getEndingX(stringBounder, y) + delta2;
2020-04-19 16:04:39 +00:00
}
};
return new SheetBlock2(block, newStencil, defaultStroke);
}
2015-04-07 18:26:58 +00:00
public SheetBlock2(SheetBlock1 block, Stencil stencil, UStroke defaultStroke) {
this.block = block;
2021-05-09 21:14:40 +00:00
this.stencil = Objects.requireNonNull(stencil);
2015-04-07 18:26:58 +00:00
this.defaultStroke = defaultStroke;
}
2020-04-19 16:04:39 +00:00
2016-12-14 21:01:03 +00:00
@Override
public String toString() {
return block.toString();
}
2015-04-07 18:26:58 +00:00
public Dimension2D calculateDimension(StringBounder stringBounder) {
return block.calculateDimension(stringBounder);
}
public void drawU(UGraphic ug) {
2022-05-31 16:31:10 +00:00
if (stencil != null)
2016-12-01 20:29:25 +00:00
ug = UGraphicStencil.create(ug, stencil, defaultStroke);
2022-05-31 16:31:10 +00:00
2015-04-07 18:26:58 +00:00
block.drawU(ug);
}
public double getStartingAltitude(StringBounder stringBounder) {
return 0;
}
2020-04-19 16:04:39 +00:00
2015-06-07 10:23:10 +00:00
@Override
2017-04-05 17:37:42 +00:00
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return block.getInnerPosition(member, stringBounder, strategy);
2015-06-07 10:23:10 +00:00
}
2020-04-19 16:04:39 +00:00
2022-05-31 16:31:10 +00:00
@Override
public Ports getPorts(StringBounder stringBounder) {
return new Ports();
}
2015-04-07 18:26:58 +00:00
}