diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java index 1496a04a6..44faa44b0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -60,18 +60,18 @@ public class RectanglePacker { private int maxWidth = -1; private int maxHeight = -1; - static class RectHComparator implements Comparator { - public int compare(Object o1, Object o2) { - Rect r1 = (Rect) o1; - Rect r2 = (Rect) o2; + static class RectHComparator implements Comparator<Rect> { + @Override + public int compare(Rect r1, Rect r2) { return r2.h() - r1.h(); } + @Override public boolean equals(Object obj) { return this == obj; } } - private static final Comparator rectHComparator = new RectHComparator(); + private static final Comparator<Rect> rectHComparator = new RectHComparator(); public RectanglePacker(BackingStoreManager manager, int initialWidth, @@ -203,13 +203,13 @@ public class RectanglePacker { } nextLevelSet = new LevelSet(newWidth, newHeight); - + // Make copies of all existing rectangles - List/*<Rect>*/ newRects = new ArrayList/*<Rect>*/(); - for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { - Level level = (Level) i1.next(); - for (Iterator i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = (Rect) i2.next(); + List<Rect> newRects = new ArrayList<Rect>(); + for (Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { + Level level = i1.next(); + for (Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { + Rect cur = i2.next(); Rect newRect = new Rect(0, 0, cur.w(), cur.h(), null); cur.setNextLocation(newRect); // Hook up the reverse mapping too for easier replacement @@ -222,8 +222,8 @@ public class RectanglePacker { Collections.sort(newRects, rectHComparator); // Try putting all of these rectangles into the new level set done = true; - for (Iterator iter = newRects.iterator(); iter.hasNext(); ) { - if (!nextLevelSet.add((Rect) iter.next())) { + for (Iterator<Rect> iter = newRects.iterator(); iter.hasNext(); ) { + if (!nextLevelSet.add(iter.next())) { done = false; break; } @@ -271,10 +271,10 @@ public class RectanglePacker { Object newBackingStore = manager.allocateBackingStore(nextLevelSet.w(), nextLevelSet.h()); manager.beginMovement(backingStore, newBackingStore); - for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { - Level level = (Level) i1.next(); - for (Iterator i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = (Rect) i2.next(); + for (Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { + Level level = i1.next(); + for (Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { + Rect cur = i2.next(); manager.move(backingStore, cur, newBackingStore, cur.getNextLocation()); } |