SharedUtils { public static int realignToGridRoundToNearest(boolean logRealign, double val) { boolean roundUp; if (Math.abs(val % SharedConstants.DEFAULT_GRID_SIZE) < SharedConstants.DEFAULT_GRID_SIZE / 2) { roundUp = val < 0; } else { roundUp = val >= 0; } return realignTo(logRealign, val, roundUp, SharedConstants.DEFAULT_GRID_SIZE); }  static int realignToGrid(double d); static Rectangle realignToGrid(Rectangle rectangle, boolean realignHeightAndWidth); static int realignToGridRoundToNearest(boolean logRealign, double val); static int realignToGrid(boolean logRealign, double val, boolean roundUp); static int realignTo(boolean logRealign, double val, boolean roundUp, int gridSize); static String listToString(String sep, Collection<?> list); static String mapToString(Map<?, ?> map); static String mapToString(String mapSep, String listSep, Map<?, ?> map); static List<T> mergeLists(List<T> listA, List<T> listB, List<T> listC); static Double[][] cloneArray(Double[][] src); static String[] cloneArray(String[] src); static int[] cloneArray(int[] src); static String[] splitAtLineEndChar(String text);  }
@Test public void testRealignToGridRoundToNearest() { assertEquals(10, SharedUtils.realignToGridRoundToNearest(false, 5.0)); assertEquals(10, SharedUtils.realignToGridRoundToNearest(false, 9.0)); assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, 4.0)); assertEquals(-10, SharedUtils.realignToGridRoundToNearest(false, -5.0)); assertEquals(-10, SharedUtils.realignToGridRoundToNearest(false, -9.0)); assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, -3.0)); assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, 0)); }