@@ -183,20 +183,24 @@ private <V extends MetricSpace<V>> Expression<V> offset(UIElement page, ExtendGi
183183 return Expression .signedDistance (end (direction ), page .end (direction ), direction );
184184 }
185185
186+ @ Deprecated
186187 private boolean hasSuccessor (Direction direction , UIElement possibleSuccessor ) {
187188 return signedDistanceToSuccessor (direction , possibleSuccessor ).isGreaterOrEqualTo (scalar (0 ));
188189 }
189190
191+ @ Deprecated
190192 private Scalar signedDistanceToSuccessor (Direction direction , UIElement successor ) {
191193 return direction .signedDistance (direction .end (rectangle ), direction .begin (successor .rectangle ));
192194 }
193195
194196 // todo: used only in PageValidator - no tolerance yet
197+ @ Deprecated
195198 public boolean hasRightElement (UIElement rightElement ) {
196199 return hasSuccessor (RIGHT , rightElement );
197200 }
198201
199202 // todo: used only in PageValidator - no tolerance yet
203+ @ Deprecated
200204 public boolean hasBelowElement (UIElement bottomElement ) {
201205 return hasSuccessor (DOWN , bottomElement );
202206 }
@@ -264,6 +268,10 @@ public <V extends MetricSpace<V>> Expression<V> end(ExtendGiving<V> direction) {
264268 return ElementPropertyExpression .end (direction , this );
265269 }
266270
271+ public <V extends MetricSpace <V >> Expression <V > begin (ExtendGiving <V > direction ) {
272+ return ElementPropertyExpression .begin (direction , this );
273+ }
274+
267275 public void validateSameSize (UIElement element , Context context ) {
268276 validateSameExtend (ORIGIN_CORNER , element , context );
269277 }
@@ -328,7 +336,7 @@ public void validateIsAbove(UIElement element, Condition<Scalar> condition, Cont
328336 }
329337
330338 public void validateSuccessor (Direction direction , UIElement toBeValidatedSuccessor , Condition <Scalar > condition , Context context ) {
331- ConstantExpression <Scalar > signedDistance = new ConstantExpression <>( signedDistanceToSuccessor (direction , toBeValidatedSuccessor ) );
339+ Expression <Scalar > signedDistance = Expression . signedDistance ( end (direction ) , toBeValidatedSuccessor . begin ( direction ), direction );
332340 if (!condition .isSatisfiedOn (signedDistance , context , direction )) {
333341 context .add (String .format ("%s element aligned not properly. Expected margin should be %s. Actual margin is %s" ,
334342 direction .afterName (),
0 commit comments