diff options
author | Christopher Hoskin <mans0954@debian.org> | 2017-09-08 19:57:06 +0100 |
---|---|---|
committer | Christopher Hoskin <mans0954@debian.org> | 2017-09-08 19:57:06 +0100 |
commit | 277c886dbbaa9ac62798e87272c7ead5795033f8 (patch) | |
tree | 309f666741dddb2f914ab224d98b6ca32d8e228a /src/net/sourceforge/plantuml/real | |
parent | f9dab4abce6df0e9b5121895cc6e94823c2dece3 (diff) |
New upstream version 1.2017.15
Diffstat (limited to 'src/net/sourceforge/plantuml/real')
-rw-r--r-- | src/net/sourceforge/plantuml/real/AbstractReal.java | 135 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/PositiveForce.java | 185 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/Real.java | 111 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealDelta.java | 131 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealImpl.java | 137 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealLine.java | 364 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealMax.java | 197 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealMiddle.java | 159 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealMiddle2.java | 145 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealMin.java | 177 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealMoveable.java | 143 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealOrigin.java | 81 | ||||
-rw-r--r-- | src/net/sourceforge/plantuml/real/RealUtils.java | 135 |
13 files changed, 1058 insertions, 1042 deletions
diff --git a/src/net/sourceforge/plantuml/real/AbstractReal.java b/src/net/sourceforge/plantuml/real/AbstractReal.java index fcb473f..a7fa9ba 100644 --- a/src/net/sourceforge/plantuml/real/AbstractReal.java +++ b/src/net/sourceforge/plantuml/real/AbstractReal.java @@ -1,67 +1,68 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-
-abstract class AbstractReal implements Real {
-
- private final RealLine line;
-
- AbstractReal(RealLine line) {
- this.line = line;
- this.line.register2(this);
- }
-
- final RealLine getLine() {
- return line;
- }
-
- abstract double getCurrentValueInternal();
-
- final public double getCurrentValue() {
- final double result = getCurrentValueInternal();
- line.register(result);
- return result;
- }
-
- public Real getMaxAbsolute() {
- return line.asMaxAbsolute();
- }
-
- public Real getMinAbsolute() {
- return line.asMinAbsolute();
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + + +abstract class AbstractReal implements Real { + + private final RealLine line; + + AbstractReal(RealLine line) { + this.line = line; + this.line.register2(this); + } + + final RealLine getLine() { + return line; + } + + abstract double getCurrentValueInternal(); + + final public double getCurrentValue() { + final double result = getCurrentValueInternal(); + line.register(result); + return result; + } + + public Real getMaxAbsolute() { + return line.asMaxAbsolute(); + } + + public Real getMinAbsolute() { + return line.asMinAbsolute(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/PositiveForce.java b/src/net/sourceforge/plantuml/real/PositiveForce.java index ce14e3d..800231d 100644 --- a/src/net/sourceforge/plantuml/real/PositiveForce.java +++ b/src/net/sourceforge/plantuml/real/PositiveForce.java @@ -1,92 +1,93 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-class PositiveForce {
-
- private final Real fixedPoint;
- private final RealMoveable movingPoint;
- private final double minimunDistance;
- private final boolean trace = false;
- private final Throwable creationPoint;
-
- public PositiveForce(Real fixedPoint, RealMoveable movingPoint, double minimunDistance) {
- if (fixedPoint == movingPoint) {
- throw new IllegalArgumentException();
- }
- this.fixedPoint = fixedPoint;
- this.movingPoint = movingPoint;
- this.minimunDistance = minimunDistance;
- this.creationPoint = new Throwable();
- this.creationPoint.fillInStackTrace();
- }
-
- @Override
- public String toString() {
- return "PositiveForce fixed=" + fixedPoint + " moving=" + movingPoint + " min=" + minimunDistance;
- }
-
- public boolean apply() {
- if (trace) {
- System.err.println("apply " + this);
- }
- final double movingPointValue = movingPoint.getCurrentValue();
- final double fixedPointValue;
- try {
- fixedPointValue = fixedPoint.getCurrentValue();
- } catch (IllegalStateException e) {
- System.err.println("Pb with force " + this);
- System.err.println("This force has been created here:");
- creationPoint.printStackTrace();
- System.err.println("The fixed point has been created here: " + fixedPoint);
- fixedPoint.printCreationStackTrace();
- throw e;
- }
- final double distance = movingPointValue - fixedPointValue;
- final double diff = distance - minimunDistance;
- if (diff >= 0) {
- if (trace) {
- System.err.println("Not using ");
- }
- return false;
- }
- if (trace) {
- System.err.println("moving " + (-diff) + " " + movingPoint);
- }
- movingPoint.move(-diff);
- return true;
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +class PositiveForce { + + private final Real fixedPoint; + private final RealMoveable movingPoint; + private final double minimunDistance; + private final boolean trace = false; + private final Throwable creationPoint; + + public PositiveForce(Real fixedPoint, RealMoveable movingPoint, double minimunDistance) { + if (fixedPoint == movingPoint) { + throw new IllegalArgumentException(); + } + this.fixedPoint = fixedPoint; + this.movingPoint = movingPoint; + this.minimunDistance = minimunDistance; + this.creationPoint = new Throwable(); + this.creationPoint.fillInStackTrace(); + } + + @Override + public String toString() { + return "PositiveForce fixed=" + fixedPoint + " moving=" + movingPoint + " min=" + minimunDistance; + } + + public boolean apply() { + if (trace) { + System.err.println("apply " + this); + } + final double movingPointValue = movingPoint.getCurrentValue(); + final double fixedPointValue; + try { + fixedPointValue = fixedPoint.getCurrentValue(); + } catch (IllegalStateException e) { + System.err.println("Pb with force " + this); + System.err.println("This force has been created here:"); + creationPoint.printStackTrace(); + System.err.println("The fixed point has been created here: " + fixedPoint); + fixedPoint.printCreationStackTrace(); + throw e; + } + final double distance = movingPointValue - fixedPointValue; + final double diff = distance - minimunDistance; + if (diff >= 0) { + if (trace) { + System.err.println("Not using "); + } + return false; + } + if (trace) { + System.err.println("moving " + (-diff) + " " + movingPoint); + } + movingPoint.move(-diff); + return true; + } + +} diff --git a/src/net/sourceforge/plantuml/real/Real.java b/src/net/sourceforge/plantuml/real/Real.java index 5ceecf4..ec4e494 100644 --- a/src/net/sourceforge/plantuml/real/Real.java +++ b/src/net/sourceforge/plantuml/real/Real.java @@ -1,55 +1,56 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-public interface Real {
-
- public void printCreationStackTrace();
-
- public String getName();
-
- public double getCurrentValue();
-
- public Real addFixed(double delta);
-
- public Real addAtLeast(double delta);
-
- public void ensureBiggerThan(Real other);
-
-// public Real getMaxAbsolute();
-//
-// public Real getMinAbsolute();
-//
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +public interface Real { + + public void printCreationStackTrace(); + + public String getName(); + + public double getCurrentValue(); + + public Real addFixed(double delta); + + public Real addAtLeast(double delta); + + public void ensureBiggerThan(Real other); + +// public Real getMaxAbsolute(); +// +// public Real getMinAbsolute(); +// +} diff --git a/src/net/sourceforge/plantuml/real/RealDelta.java b/src/net/sourceforge/plantuml/real/RealDelta.java index 8e35848..cfff052 100644 --- a/src/net/sourceforge/plantuml/real/RealDelta.java +++ b/src/net/sourceforge/plantuml/real/RealDelta.java @@ -1,65 +1,66 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-class RealDelta extends RealMoveable {
-
- private final Real delegated;
- private final double diff;
-
- RealDelta(Real delegated, double diff) {
- super(((AbstractReal) delegated).getLine(), "[Delegated {" + delegated.getName() + "} d=" + diff + "]");
- this.delegated = delegated;
- this.diff = diff;
- }
-
- @Override
- double getCurrentValueInternal() {
- return delegated.getCurrentValue() + diff;
- }
-
- public Real addAtLeast(double delta) {
- return new RealDelta(delegated.addAtLeast(delta), diff);
- }
-
- public void ensureBiggerThan(Real other) {
- delegated.ensureBiggerThan(new RealDelta(other, -diff));
- }
-
- void move(double delta) {
- ((RealMoveable) delegated).move(delta);
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +class RealDelta extends RealMoveable { + + private final Real delegated; + private final double diff; + + RealDelta(Real delegated, double diff) { + super(((AbstractReal) delegated).getLine(), "[Delegated {" + delegated.getName() + "} d=" + diff + "]"); + this.delegated = delegated; + this.diff = diff; + } + + @Override + double getCurrentValueInternal() { + return delegated.getCurrentValue() + diff; + } + + public Real addAtLeast(double delta) { + return new RealDelta(delegated.addAtLeast(delta), diff); + } + + public void ensureBiggerThan(Real other) { + delegated.ensureBiggerThan(new RealDelta(other, -diff)); + } + + void move(double delta) { + ((RealMoveable) delegated).move(delta); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealImpl.java b/src/net/sourceforge/plantuml/real/RealImpl.java index 8b8d7d6..2bbc8e4 100644 --- a/src/net/sourceforge/plantuml/real/RealImpl.java +++ b/src/net/sourceforge/plantuml/real/RealImpl.java @@ -1,68 +1,69 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-class RealImpl extends RealMoveable implements RealOrigin {
-
- private double currentValue;
-
- public RealImpl(String name, RealLine line, double currentValue) {
- super(line, name);
- this.currentValue = currentValue;
- }
-
- void move(double delta) {
- this.currentValue += delta;
- }
-
- @Override
- double getCurrentValueInternal() {
- return currentValue;
- }
-
- public Real addAtLeast(double delta) {
- final RealImpl result = new RealImpl(getName() + ".addAtLeast" + delta, getLine(), this.currentValue + delta);
- getLine().addForce(new PositiveForce(this, result, delta));
- return result;
- }
-
- public void ensureBiggerThan(Real other) {
- getLine().addForce(new PositiveForce(other, this, 0));
- }
-
- public void compileNow() {
- getLine().compile();
- }
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +class RealImpl extends RealMoveable implements RealOrigin { + + private double currentValue; + + public RealImpl(String name, RealLine line, double currentValue) { + super(line, name); + this.currentValue = currentValue; + } + + void move(double delta) { + this.currentValue += delta; + } + + @Override + double getCurrentValueInternal() { + return currentValue; + } + + public Real addAtLeast(double delta) { + final RealImpl result = new RealImpl(getName() + ".addAtLeast" + delta, getLine(), this.currentValue + delta); + getLine().addForce(new PositiveForce(this, result, delta)); + return result; + } + + public void ensureBiggerThan(Real other) { + getLine().addForce(new PositiveForce(other, this, 0)); + } + + public void compileNow() { + getLine().compile(); + } +} diff --git a/src/net/sourceforge/plantuml/real/RealLine.java b/src/net/sourceforge/plantuml/real/RealLine.java index 6c7a92d..8d794cd 100644 --- a/src/net/sourceforge/plantuml/real/RealLine.java +++ b/src/net/sourceforge/plantuml/real/RealLine.java @@ -1,180 +1,184 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-class RealLine {
-
- private final List<PositiveForce> forces = new ArrayList<PositiveForce>();
-
- private double min;
- private double max;
- private Set<AbstractReal> all = new HashSet<AbstractReal>();
-
- void register(double v) {
- // System.err.println("RealLine::register " + v);
- // min = Math.min(min, v);
- // max = Math.max(max, v);
- }
-
- void register2(AbstractReal abstractReal) {
- all.add(abstractReal);
- }
-
- public double getAbsoluteMin() {
- return min;
- }
-
- public double getAbsoluteMax() {
- return max;
- }
-
- public void addForce(PositiveForce force) {
- this.forces.add(force);
- }
-
- static private int CPT;
-
- public void compile() {
- int cpt = 0;
- final Map<PositiveForce, Integer> counter = new HashMap<PositiveForce, Integer>();
- do {
- boolean done = true;
- for (PositiveForce f : forces) {
- // System.err.println("force=" + f);
- final boolean change = f.apply();
- if (change) {
- incCounter(counter, f);
- // System.err.println("changed! " + f);
- done = false;
- }
- }
- if (done) {
- // System.err.println("cpt=" + cpt + " size=" + forces.size());
- CPT += cpt;
- // System.err.println("CPT=" + CPT);
- min = 0;
- max = 0;
- for (AbstractReal real : all) {
- final double v = real.getCurrentValue();
- // System.err.println("RealLine::compile v=" + v);
- if (v > max) {
- max = v;
- }
- if (v < min) {
- min = v;
- }
- }
- // System.err.println("RealLine::compile min=" + min + " max=" + max);
- return;
- }
- cpt++;
- if (cpt > 99999) {
- printCounter(counter);
- throw new IllegalStateException("Inifinite Loop?");
- }
- } while (true);
-
- }
-
- private void printCounter(Map<PositiveForce, Integer> counter) {
- for (Map.Entry<PositiveForce, Integer> ent : counter.entrySet()) {
- System.err.println("count=" + ent.getValue() + " for " + ent.getKey());
- }
- }
-
- private static void incCounter(Map<PositiveForce, Integer> counter, PositiveForce f) {
- final Integer v = counter.get(f);
- counter.put(f, v == null ? 1 : v + 1);
- }
-
- Real asMaxAbsolute() {
- return new MaxAbsolute();
- }
-
- Real asMinAbsolute() {
- return new MinAbsolute();
- }
-
- class MaxAbsolute extends AbstractAbsolute {
- public double getCurrentValue() {
- return max;
- }
- }
-
- class MinAbsolute extends AbstractAbsolute {
- public double getCurrentValue() {
- return min;
- }
- }
-
- abstract class AbstractAbsolute implements Real {
-
- public void printCreationStackTrace() {
- }
-
- public String getName() {
- return getClass().getName();
- }
-
- public Real addFixed(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public Real addAtLeast(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public void ensureBiggerThan(Real other) {
- throw new UnsupportedOperationException();
- }
-
- public Real getMaxAbsolute() {
- return asMaxAbsolute();
- }
-
- public Real getMinAbsolute() {
- return asMinAbsolute();
- }
-
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +class RealLine { + + private final List<PositiveForce> forces = new ArrayList<PositiveForce>(); + + private double min; + private double max; + private Set<AbstractReal> all = new HashSet<AbstractReal>(); + + void register(double v) { + // System.err.println("RealLine::register " + v); + // min = Math.min(min, v); + // max = Math.max(max, v); + } + + void register2(AbstractReal abstractReal) { + all.add(abstractReal); + } + + public double getAbsoluteMin() { + return min; + } + + public double getAbsoluteMax() { + return max; + } + + public void addForce(PositiveForce force) { + this.forces.add(force); + } + + static private int CPT; + + public void compile() { + int cpt = 0; + final Map<PositiveForce, Integer> counter = new HashMap<PositiveForce, Integer>(); + do { + boolean done = true; + for (PositiveForce f : forces) { + // System.err.println("force=" + f); + final boolean change = f.apply(); + if (change) { + incCounter(counter, f); + // System.err.println("changed! " + f); + done = false; + } + } + if (done) { + // System.err.println("cpt=" + cpt + " size=" + forces.size()); + CPT += cpt; + // System.err.println("CPT=" + CPT); + min = 0; + max = 0; + for (AbstractReal real : all) { + final double v = real.getCurrentValue(); + // System.err.println("RealLine::compile v=" + v); + if (v > max) { + max = v; + } + if (v < min) { + min = v; + } + } + // System.err.println("RealLine::compile min=" + min + " max=" + max); + return; + } + cpt++; + if (cpt > 99999) { + printCounter(counter); + throw new IllegalStateException("Inifinite Loop?"); + } + } while (true); + + } + + private void printCounter(Map<PositiveForce, Integer> counter) { + for (PositiveForce f : forces) { + System.err.println("force=" + f); + } + for (Map.Entry<PositiveForce, Integer> ent : counter.entrySet()) { + System.err.println("count=" + ent.getValue() + " for " + ent.getKey()); + } + } + + private static void incCounter(Map<PositiveForce, Integer> counter, PositiveForce f) { + final Integer v = counter.get(f); + counter.put(f, v == null ? 1 : v + 1); + } + + Real asMaxAbsolute() { + return new MaxAbsolute(); + } + + Real asMinAbsolute() { + return new MinAbsolute(); + } + + class MaxAbsolute extends AbstractAbsolute { + public double getCurrentValue() { + return max; + } + } + + class MinAbsolute extends AbstractAbsolute { + public double getCurrentValue() { + return min; + } + } + + abstract class AbstractAbsolute implements Real { + + public void printCreationStackTrace() { + } + + public String getName() { + return getClass().getName(); + } + + public Real addFixed(double delta) { + throw new UnsupportedOperationException(); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + throw new UnsupportedOperationException(); + } + + public Real getMaxAbsolute() { + return asMaxAbsolute(); + } + + public Real getMinAbsolute() { + return asMinAbsolute(); + } + + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMax.java b/src/net/sourceforge/plantuml/real/RealMax.java index 61db463..7016032 100644 --- a/src/net/sourceforge/plantuml/real/RealMax.java +++ b/src/net/sourceforge/plantuml/real/RealMax.java @@ -1,98 +1,99 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-class RealMax extends AbstractReal implements Real {
-
- private final List<Real> all = new ArrayList<Real>();
- private final Throwable creationPoint;
-
- RealMax(Collection<Real> reals) {
- super(line(reals));
- this.all.addAll(reals);
- this.creationPoint = new Throwable();
- this.creationPoint.fillInStackTrace();
- }
-
- static RealLine line(Collection<Real> reals) {
- return ((AbstractReal) reals.iterator().next()).getLine();
- }
-
- public String getName() {
- return "max " + all;
- }
-
- @Override
- double getCurrentValueInternal() {
- double result = all.get(0).getCurrentValue();
- for (int i = 1; i < all.size(); i++) {
- Throwable t = new Throwable();
- t.fillInStackTrace();
- final int stackLength = t.getStackTrace().length;
- if (stackLength > 1000) {
- System.err.println("The faulty RealMax " + getName());
- System.err.println("has been created here:");
- printCreationStackTrace();
- throw new IllegalStateException("Infinite recursion?");
- }
- final double v = all.get(i).getCurrentValue();
- if (v > result) {
- result = v;
- }
- }
- return result;
- }
-
- public Real addFixed(double delta) {
- return new RealDelta(this, delta);
- }
-
- public Real addAtLeast(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public void ensureBiggerThan(Real other) {
- throw new UnsupportedOperationException();
- }
-
- public void printCreationStackTrace() {
- creationPoint.printStackTrace();
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +class RealMax extends AbstractReal implements Real { + + private final List<Real> all = new ArrayList<Real>(); + private final Throwable creationPoint; + + RealMax(Collection<Real> reals) { + super(line(reals)); + this.all.addAll(reals); + this.creationPoint = new Throwable(); + this.creationPoint.fillInStackTrace(); + } + + static RealLine line(Collection<Real> reals) { + return ((AbstractReal) reals.iterator().next()).getLine(); + } + + public String getName() { + return "max " + all; + } + + @Override + double getCurrentValueInternal() { + double result = all.get(0).getCurrentValue(); + for (int i = 1; i < all.size(); i++) { + Throwable t = new Throwable(); + t.fillInStackTrace(); + final int stackLength = t.getStackTrace().length; + if (stackLength > 1000) { + System.err.println("The faulty RealMax " + getName()); + System.err.println("has been created here:"); + printCreationStackTrace(); + throw new IllegalStateException("Infinite recursion?"); + } + final double v = all.get(i).getCurrentValue(); + if (v > result) { + result = v; + } + } + return result; + } + + public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + throw new UnsupportedOperationException(); + } + + public void printCreationStackTrace() { + creationPoint.printStackTrace(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMiddle.java b/src/net/sourceforge/plantuml/real/RealMiddle.java index 1fda4c2..0ede5a9 100644 --- a/src/net/sourceforge/plantuml/real/RealMiddle.java +++ b/src/net/sourceforge/plantuml/real/RealMiddle.java @@ -1,79 +1,80 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-class RealMiddle extends AbstractReal implements Real {
-
- private final RealMoveable p1;
- private final RealMoveable p2;
- private final double delta;
-
- private RealMiddle(RealMoveable p1, RealMoveable p2, double delta) {
- super(p1.getLine());
- this.p1 = p1;
- this.p2 = p2;
- this.delta = delta;
- }
-
- RealMiddle(RealMoveable p1, RealMoveable p2) {
- this(p1, p2, 0);
- }
-
- @Override
- double getCurrentValueInternal() {
- return (p1.getCurrentValue() + p2.getCurrentValue()) / 2 + delta;
- }
-
- public Real addFixed(double diff) {
- return new RealMiddle(p1, p2, delta + diff);
- }
-
- public Real addAtLeast(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public void ensureBiggerThan(Real other) {
- throw new UnsupportedOperationException();
- }
-
- public String getName() {
- return "[Middle " + p1.getName() + " and " + p2.getName() + "]";
- }
-
- public void printCreationStackTrace() {
- throw new UnsupportedOperationException();
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +class RealMiddle extends AbstractReal implements Real { + + private final RealMoveable p1; + private final RealMoveable p2; + private final double delta; + + private RealMiddle(RealMoveable p1, RealMoveable p2, double delta) { + super(p1.getLine()); + this.p1 = p1; + this.p2 = p2; + this.delta = delta; + } + + RealMiddle(RealMoveable p1, RealMoveable p2) { + this(p1, p2, 0); + } + + @Override + double getCurrentValueInternal() { + return (p1.getCurrentValue() + p2.getCurrentValue()) / 2 + delta; + } + + public Real addFixed(double diff) { + return new RealMiddle(p1, p2, delta + diff); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + throw new UnsupportedOperationException(); + } + + public String getName() { + return "[Middle " + p1.getName() + " and " + p2.getName() + "]"; + } + + public void printCreationStackTrace() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMiddle2.java b/src/net/sourceforge/plantuml/real/RealMiddle2.java index 17ba400..4eef4f1 100644 --- a/src/net/sourceforge/plantuml/real/RealMiddle2.java +++ b/src/net/sourceforge/plantuml/real/RealMiddle2.java @@ -1,72 +1,73 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-class RealMiddle2 extends RealMoveable {
-
- private final RealMoveable p1;
- private final RealMoveable p2;
-
- RealMiddle2(RealMoveable p1, RealMoveable p2) {
- super(p1.getLine(), "middle");
- assert p1.getLine() == p2.getLine();
- this.p1 = p1;
- this.p2 = p2;
- }
-
- @Override
- double getCurrentValueInternal() {
- return (p1.getCurrentValue() + p2.getCurrentValue()) / 2;
- }
-
- // public Real addFixed(double diff) {
- // return new RealMiddle2(p1, p2, delta + diff);
- // }
-
- public Real addAtLeast(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public void ensureBiggerThan(Real other) {
- getLine().addForce(new PositiveForce(other, this, 0));
- }
-
- @Override
- void move(double delta) {
- p1.move(delta / 2);
- p2.move(delta / 2);
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +class RealMiddle2 extends RealMoveable { + + private final RealMoveable p1; + private final RealMoveable p2; + + RealMiddle2(RealMoveable p1, RealMoveable p2) { + super(p1.getLine(), "middle"); + assert p1.getLine() == p2.getLine(); + this.p1 = p1; + this.p2 = p2; + } + + @Override + double getCurrentValueInternal() { + return (p1.getCurrentValue() + p2.getCurrentValue()) / 2; + } + + // public Real addFixed(double diff) { + // return new RealMiddle2(p1, p2, delta + diff); + // } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + getLine().addForce(new PositiveForce(other, this, 0)); + } + + @Override + void move(double delta) { + p1.move(delta / 2); + p2.move(delta / 2); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMin.java b/src/net/sourceforge/plantuml/real/RealMin.java index 8ca6ffa..2d59baf 100644 --- a/src/net/sourceforge/plantuml/real/RealMin.java +++ b/src/net/sourceforge/plantuml/real/RealMin.java @@ -1,88 +1,89 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-class RealMin extends AbstractReal implements Real {
-
- private final List<Real> all = new ArrayList<Real>();
-
- RealMin(Collection<Real> reals) {
- super(RealMax.line(reals));
- this.all.addAll(reals);
- }
-
- public String getName() {
- return "min " + all;
- }
-
- @Override
- double getCurrentValueInternal() {
- double result = all.get(0).getCurrentValue();
- for (int i = 1; i < all.size(); i++) {
- final double v = all.get(i).getCurrentValue();
- if (v < result) {
- result = v;
- }
- }
- return result;
- }
-
- public Real addFixed(double delta) {
- return new RealDelta(this, delta);
- }
-
- public Real addAtLeast(double delta) {
- throw new UnsupportedOperationException();
- }
-
- public void ensureBiggerThan(Real other) {
- for (Real r : all) {
- r.ensureBiggerThan(other);
- }
- }
-
- public int size() {
- return all.size();
- }
-
- public void printCreationStackTrace() {
- throw new UnsupportedOperationException();
- }
-
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +class RealMin extends AbstractReal implements Real { + + private final List<Real> all = new ArrayList<Real>(); + + RealMin(Collection<Real> reals) { + super(RealMax.line(reals)); + this.all.addAll(reals); + } + + public String getName() { + return "min " + all; + } + + @Override + double getCurrentValueInternal() { + double result = all.get(0).getCurrentValue(); + for (int i = 1; i < all.size(); i++) { + final double v = all.get(i).getCurrentValue(); + if (v < result) { + result = v; + } + } + return result; + } + + public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + public Real addAtLeast(double delta) { + throw new UnsupportedOperationException(); + } + + public void ensureBiggerThan(Real other) { + for (Real r : all) { + r.ensureBiggerThan(other); + } + } + + public int size() { + return all.size(); + } + + public void printCreationStackTrace() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/real/RealMoveable.java b/src/net/sourceforge/plantuml/real/RealMoveable.java index 918ef03..331363f 100644 --- a/src/net/sourceforge/plantuml/real/RealMoveable.java +++ b/src/net/sourceforge/plantuml/real/RealMoveable.java @@ -1,71 +1,72 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-abstract class RealMoveable extends AbstractReal implements Real {
-
- public static final AtomicInteger CPT = new AtomicInteger();
- private final int cpt = CPT.getAndIncrement();
- private final String name;
- private final Throwable creationPoint;
-
- RealMoveable(RealLine line, String name) {
- super(line);
- this.name = name;
- this.creationPoint = new Throwable();
- this.creationPoint.fillInStackTrace();
- }
-
- abstract void move(double delta);
-
- final public void printCreationStackTrace() {
- creationPoint.printStackTrace();
- }
-
- final public Real addFixed(double delta) {
- return new RealDelta(this, delta);
- }
-
- @Override
- public final String toString() {
- return "#" + cpt + "_" + name;
- }
-
- final public String getName() {
- return name;
- }
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +import java.util.concurrent.atomic.AtomicInteger; + +abstract class RealMoveable extends AbstractReal implements Real { + + public static final AtomicInteger CPT = new AtomicInteger(); + private final int cpt = CPT.getAndIncrement(); + private final String name; + private final Throwable creationPoint; + + RealMoveable(RealLine line, String name) { + super(line); + this.name = name; + this.creationPoint = new Throwable(); + this.creationPoint.fillInStackTrace(); + } + + abstract void move(double delta); + + final public void printCreationStackTrace() { + creationPoint.printStackTrace(); + } + + final public Real addFixed(double delta) { + return new RealDelta(this, delta); + } + + @Override + public final String toString() { + return "#" + cpt + "_" + name; + } + + final public String getName() { + return name; + } +} diff --git a/src/net/sourceforge/plantuml/real/RealOrigin.java b/src/net/sourceforge/plantuml/real/RealOrigin.java index dea8165..e46a6cd 100644 --- a/src/net/sourceforge/plantuml/real/RealOrigin.java +++ b/src/net/sourceforge/plantuml/real/RealOrigin.java @@ -1,40 +1,41 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-public interface RealOrigin extends Real {
-
- public void compileNow();
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +public interface RealOrigin extends Real { + + public void compileNow(); +} diff --git a/src/net/sourceforge/plantuml/real/RealUtils.java b/src/net/sourceforge/plantuml/real/RealUtils.java index d447804..75f0893 100644 --- a/src/net/sourceforge/plantuml/real/RealUtils.java +++ b/src/net/sourceforge/plantuml/real/RealUtils.java @@ -1,67 +1,68 @@ -/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * 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.real;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class RealUtils {
-
- public static RealOrigin createOrigin() {
- final RealLine line = new RealLine();
- final RealImpl result = new RealImpl("O", line, 0);
- return result;
- }
-
- public static Real middle(Real r1, Real r2) {
- return new RealMiddle2((RealMoveable) r1, (RealMoveable) r2);
- }
-
- public static Real max(Real... reals) {
- return new RealMax(Arrays.asList(reals));
- }
-
- public static Real max(Collection<Real> reals) {
- return new RealMax(reals);
- }
-
- public static Real min(Real... reals) {
- return new RealMin(Arrays.asList(reals));
- }
-
- public static Real min(Collection<Real> reals) {
- return new RealMin(reals);
- }
-}
+/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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 + * + * 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.real; + +import java.util.Arrays; +import java.util.Collection; + +public class RealUtils { + + public static RealOrigin createOrigin() { + final RealLine line = new RealLine(); + final RealImpl result = new RealImpl("O", line, 0); + return result; + } + + public static Real middle(Real r1, Real r2) { + return new RealMiddle2((RealMoveable) r1, (RealMoveable) r2); + } + + public static Real max(Real... reals) { + return new RealMax(Arrays.asList(reals)); + } + + public static Real max(Collection<Real> reals) { + return new RealMax(reals); + } + + public static Real min(Real... reals) { + return new RealMin(Arrays.asList(reals)); + } + + public static Real min(Collection<Real> reals) { + return new RealMin(reals); + } +} |