From 6799dd9e9763a2e86fa6e886b5336548fd40a528 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sun, 27 Jan 2013 09:58:04 -0800 Subject: j3dcore: annotate addMaps in TextureBin Signed-off-by: Harvey Harrison --- src/classes/share/javax/media/j3d/RenderBin.java | 8 ++-- src/classes/share/javax/media/j3d/TextureBin.java | 49 +++++++++++------------ 2 files changed, 27 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/classes/share/javax/media/j3d/RenderBin.java b/src/classes/share/javax/media/j3d/RenderBin.java index a156ecf..379e851 100644 --- a/src/classes/share/javax/media/j3d/RenderBin.java +++ b/src/classes/share/javax/media/j3d/RenderBin.java @@ -4743,10 +4743,8 @@ private void processOrderedGroupInserted(J3dMessage m) { ColoringAttributesRetained coloringAttributes; TransparencyAttributesRetained transparencyAttributes; int i; - ArrayList list; TextureUnitStateRetained texUnitState[]; RenderingAttributesRetained renderingAttributes; - HashMap addmap = null; if (ra.app == null) { polygonAttributes = null; @@ -4770,6 +4768,7 @@ private void processOrderedGroupInserted(J3dMessage m) { // Get the renderMoleculelist for this xform HashMap rmap = null; + HashMap> addmap = null; if (ra.isOpaque()) { rmap = textureBin.opaqueRenderMoleculeMap; addmap = textureBin.addOpaqueRMs; @@ -4797,9 +4796,10 @@ private void processOrderedGroupInserted(J3dMessage m) { currentBin = currentBin.next; } // Check the "to-be-added" list of renderMolecules for a match - if ((list = (ArrayList)addmap.get(ra.geometryAtom.source.localToVworld[0])) != null) { + ArrayList list = addmap.get(ra.geometryAtom.source.localToVworld[0]); + if (list != null) { for (i = 0; i < list.size(); i++) { - currentBin = (RenderMolecule)list.get(i); + currentBin = list.get(i); if (currentBin.equals(ra, polygonAttributes, lineAttributes, pointAttributes, material, diff --git a/src/classes/share/javax/media/j3d/TextureBin.java b/src/classes/share/javax/media/j3d/TextureBin.java index 7ab84a2..2cc8592 100644 --- a/src/classes/share/javax/media/j3d/TextureBin.java +++ b/src/classes/share/javax/media/j3d/TextureBin.java @@ -113,13 +113,12 @@ class TextureBin extends Object implements ObjectUpdate { static final int SOLE_USER_DIRTY_TUS = 0x10; - /** - * The hashMap of RenderMolecules in this TextureBin - * this is used in rendering, the key used is localToVworld - */ - HashMap addOpaqueRMs = new HashMap(); - HashMap addTransparentRMs = new HashMap(); - +/** + * The hashMap of RenderMolecules in this TextureBin this is used in rendering, + * the key used is localToVworld + */ +HashMap> addOpaqueRMs = new HashMap>(); +HashMap> addTransparentRMs = new HashMap>(); // A hashmap based on localToVworld for fast // insertion of new renderMolecules @@ -829,19 +828,18 @@ HashMap transparentRenderMoleculeMap = new HashMa * with the same localToVworld and attributes in * findRenderMolecule(). */ - RenderMolecule addAll(HashMap renderMoleculeMap, HashMap addRMs, - RenderMolecule startList, - boolean opaqueList) { +RenderMolecule addAll(HashMap renderMoleculeMap, + HashMap> addRMs, + RenderMolecule startList, boolean opaqueList) { int i; - RenderMolecule r; - Collection c = addRMs.values(); - Iterator listIterator = c.iterator(); + Collection> c = addRMs.values(); + Iterator> listIterator = c.iterator(); RenderMolecule renderMoleculeList, head; while (listIterator.hasNext()) { boolean changed = false; - ArrayList curList = (ArrayList)listIterator.next(); - r = (RenderMolecule)curList.get(0); + ArrayList curList = listIterator.next(); + RenderMolecule r = curList.get(0); // If this is a opaque one , but has been switched to a transparentList or // vice-versa (dur to changeLists function called before this), then // do nothing! @@ -887,7 +885,7 @@ HashMap transparentRenderMoleculeMap = new HashMa } } for (i = 1; i < curList.size(); i++) { - r = (RenderMolecule)curList.get(i); + r = curList.get(i); // If this is a opaque one , but has been switched to a transparentList or // vice-versa (dur to changeLists function called before this), then // do nothing! @@ -978,19 +976,18 @@ HashMap transparentRenderMoleculeMap = new HashMa * Adds the given RenderMolecule to this TextureBin */ void addRenderMolecule(RenderMolecule r, RenderBin rb) { - RenderMolecule rm; - ArrayList list; - HashMap map; r.textureBin = this; + HashMap> map; if (r.isOpaqueOrInOG) map = addOpaqueRMs; else map = addTransparentRMs; - if ((list = (ArrayList)map.get(r.localToVworld)) == null) { - list = new ArrayList(); - map.put(r.localToVworld, list); + ArrayList list = map.get(r.localToVworld); + if (list == null) { + list = new ArrayList(); + map.put(r.localToVworld, list); } list.add(r); @@ -1004,11 +1001,10 @@ HashMap transparentRenderMoleculeMap = new HashMa * Removes the given RenderMolecule from this TextureBin */ void removeRenderMolecule(RenderMolecule r) { - ArrayList list; int index; boolean found = false; - RenderMolecule renderMoleculeList, rmlist; - HashMap addMap; + RenderMolecule rmlist; + HashMap> addMap; HashMap allMap; r.textureBin = null; @@ -1024,7 +1020,8 @@ HashMap transparentRenderMoleculeMap = new HashMa } // If the renderMolecule being remove is contained in addRMs, then // remove the renderMolecule from the addList - if ((list = (ArrayList) addMap.get(r.localToVworld)) != null) { + ArrayList list = addMap.get(r.localToVworld); + if (list != null) { if ((index = list.indexOf(r)) != -1) { list.remove(index); // If this was the last element for this localToVworld, then remove -- cgit v1.2.3