@Test public void testCalculateConstrainedSize() { Size2D s; RectangleConstraint c1 = RectangleConstraint.NONE; s = c1.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); RectangleConstraint c2 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c2.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); RectangleConstraint c3 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c3.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); RectangleConstraint c4 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE ); s = c4.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.4, EPSILON); RectangleConstraint c5 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c5.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.0, EPSILON); RectangleConstraint c6 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c6.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); RectangleConstraint c7 = RectangleConstraint.NONE; s = c7.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); RectangleConstraint c8 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c8.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); RectangleConstraint c9 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c9.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); }
public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; }
RectangleConstraint { public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; } }
RectangleConstraint { public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; } RectangleConstraint(double w, double h);  RectangleConstraint(Range w, Range h);  RectangleConstraint(Range w, double h);  RectangleConstraint(double w, Range h);  RectangleConstraint(double w, Range widthRange,
                               LengthConstraintType widthConstraintType,
                               double h, Range heightRange,
                               LengthConstraintType heightConstraintType); }
RectangleConstraint { public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; } RectangleConstraint(double w, double h);  RectangleConstraint(Range w, Range h);  RectangleConstraint(Range w, double h);  RectangleConstraint(double w, Range h);  RectangleConstraint(double w, Range widthRange,
                               LengthConstraintType widthConstraintType,
                               double h, Range heightRange,
                               LengthConstraintType heightConstraintType); double getWidth(); Range getWidthRange(); LengthConstraintType getWidthConstraintType(); double getHeight(); Range getHeightRange(); LengthConstraintType getHeightConstraintType(); RectangleConstraint toUnconstrainedWidth(); RectangleConstraint toUnconstrainedHeight(); RectangleConstraint toFixedWidth(double width); RectangleConstraint toFixedHeight(double height); RectangleConstraint toRangeWidth(Range range); RectangleConstraint toRangeHeight(Range range); @Override String toString(); Size2D calculateConstrainedSize(Size2D base); }
RectangleConstraint { public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; } RectangleConstraint(double w, double h);  RectangleConstraint(Range w, Range h);  RectangleConstraint(Range w, double h);  RectangleConstraint(double w, Range h);  RectangleConstraint(double w, Range widthRange,
                               LengthConstraintType widthConstraintType,
                               double h, Range heightRange,
                               LengthConstraintType heightConstraintType); double getWidth(); Range getWidthRange(); LengthConstraintType getWidthConstraintType(); double getHeight(); Range getHeightRange(); LengthConstraintType getHeightConstraintType(); RectangleConstraint toUnconstrainedWidth(); RectangleConstraint toUnconstrainedHeight(); RectangleConstraint toFixedWidth(double width); RectangleConstraint toFixedHeight(double height); RectangleConstraint toRangeWidth(Range range); RectangleConstraint toRangeHeight(Range range); @Override String toString(); Size2D calculateConstrainedSize(Size2D base); static final RectangleConstraint NONE; }