summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java')
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
new file mode 100644
index 0000000..62c74da
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
@@ -0,0 +1,144 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileGeometry extends Dimension2D {
+
+ private final double width;
+ private final double height;
+ private final double left;
+ private final double inY;
+ private final double outY;
+
+ public FtileGeometry(Dimension2D dim, double left, double inY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY);
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY) {
+ this(width, height, left, inY, Double.MIN_NORMAL);
+ }
+
+ @Override
+ public String toString() {
+ return "[" + width + "x" + height + " left=" + left + "]";
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY, double outY) {
+ this.left = left;
+ this.inY = inY;
+ this.outY = outY;
+ this.width = width;
+ this.height = height;
+ }
+
+ public FtileGeometry(Dimension2D dim, double left, double inY, double outY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY, outY);
+ }
+
+ public boolean hasPointOut() {
+ return outY != Double.MIN_NORMAL;
+ }
+
+ public Point2D getPointIn() {
+ return new Point2D.Double(left, inY);
+ }
+
+ public Point2D getPointOut() {
+ if (outY == Double.MIN_NORMAL) {
+ throw new UnsupportedOperationException();
+ }
+ return new Point2D.Double(left, outY);
+ }
+
+ public FtileGeometry withoutPointOut() {
+ return new FtileGeometry(width, height, left, inY);
+ }
+
+ public FtileGeometry translate(UTranslate translate) {
+ final double dx = translate.getDx();
+ final double dy = translate.getDy();
+ if (this.outY == Double.MIN_NORMAL) {
+ return new FtileGeometry(width, height, left + dx, inY + dy);
+ }
+ return new FtileGeometry(width, height, left + dx, inY + dy, outY + dy);
+ }
+
+ public final double getInY() {
+ return inY;
+ }
+
+ public final double getLeft() {
+ return left;
+ }
+
+ public double getOutY() {
+ return outY;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public FtileGeometry addDim(double deltaWidth, double deltaHeight) {
+ return new FtileGeometry(width + deltaWidth, height + deltaHeight, left, inY, outY + deltaHeight);
+ }
+
+ public FtileGeometry addMarginX(double marginx) {
+ return new FtileGeometry(width + 2 * marginx, height, left + marginx, inY, outY);
+ }
+
+ public FtileGeometry fixedHeight(double fixedHeight) {
+ return new FtileGeometry(width, fixedHeight, left, inY, outY);
+ }
+
+ public FtileGeometry appendBottom(FtileGeometry other) {
+ return new FtileGeometryMerger(this, other).getResult();
+ }
+
+}