@Test public void ifFitsAlignRight() { assertEquals(5, Scrolling.getDelta(new Interval(0, 100), new Interval(95, 105))); }
static int getDelta(Interval vis, Interval target) { if (vis.getLength() < target.getLength()) { return target.getLowerBound() - vis.getLowerBound(); } if (target.getLowerBound() < vis.getLowerBound() || target.getUpperBound() > vis.getUpperBound()) { return target.getUpperBound() - vis.getUpperBound(); } return 0; }
Scrolling { static int getDelta(Interval vis, Interval target) { if (vis.getLength() < target.getLength()) { return target.getLowerBound() - vis.getLowerBound(); } if (target.getLowerBound() < vis.getLowerBound() || target.getUpperBound() > vis.getUpperBound()) { return target.getUpperBound() - vis.getUpperBound(); } return 0; } }
Scrolling { static int getDelta(Interval vis, Interval target) { if (vis.getLength() < target.getLength()) { return target.getLowerBound() - vis.getLowerBound(); } if (target.getLowerBound() < vis.getLowerBound() || target.getUpperBound() > vis.getUpperBound()) { return target.getUpperBound() - vis.getUpperBound(); } return 0; }  }
Scrolling { static int getDelta(Interval vis, Interval target) { if (vis.getLength() < target.getLength()) { return target.getLowerBound() - vis.getLowerBound(); } if (target.getLowerBound() < vis.getLowerBound() || target.getUpperBound() > vis.getUpperBound()) { return target.getUpperBound() - vis.getUpperBound(); } return 0; }  static void scrollTo(Rectangle rect, Element element); }
Scrolling { static int getDelta(Interval vis, Interval target) { if (vis.getLength() < target.getLength()) { return target.getLowerBound() - vis.getLowerBound(); } if (target.getLowerBound() < vis.getLowerBound() || target.getUpperBound() > vis.getUpperBound()) { return target.getUpperBound() - vis.getUpperBound(); } return 0; }  static void scrollTo(Rectangle rect, Element element);  }