diff options
author | Harvey Harrison <[email protected]> | 2013-09-14 23:43:56 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-09-14 23:43:56 -0700 |
commit | 9decf6f1e287309fce76d0f75f7ef1bcd5eff7b3 (patch) | |
tree | 4a1b256cf5bbdd4cfb63238459e4bcf5e9ac4962 | |
parent | 0bfd29012c5cec92eb7f0b277bff52e0a6b6db2c (diff) |
j3dutils: use core mapping for transparent geometry
Preserve the old interface for backwards compatibility purposes.
Signed-off-by: Harvey Harrison <[email protected]>
3 files changed, 13 insertions, 49 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/SimpleDistanceComparator.java b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/SimpleDistanceComparator.java index efc1b52..8af44fc 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/SimpleDistanceComparator.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/SimpleDistanceComparator.java @@ -41,13 +41,15 @@ package com.sun.j3d.utils.scenegraph.transparency; import java.util.Comparator; +import javax.media.j3d.TransparencySortGeom; + /** * Sample TransparencySortComparator which has the same functionality as * the fixed default function in Java 3D. * * @since Java 3D 1.4 */ -public class SimpleDistanceComparator implements Comparator { +public class SimpleDistanceComparator implements Comparator<TransparencySortGeom> { /** Creates a new instance of SimpleDistanceComparator */ public SimpleDistanceComparator() { @@ -63,15 +65,12 @@ public class SimpleDistanceComparator implements Comparator { * closer to the viewer. Object1 < Object2 if it is to be considered closer * and rendered after. * - * @param o1 TransparencySortGeom object 1 - * @param o2 TransparencySortGeom object 2 + * @param t1 TransparencySortGeom object 1 + * @param t2 TransparencySortGeom object 2 * */ @Override - public int compare(Object o1, Object o2) { - TransparencySortGeom t1 = (TransparencySortGeom)o1; - TransparencySortGeom t2 = (TransparencySortGeom)o2; - + public int compare(TransparencySortGeom t1, TransparencySortGeom t2) { double f = t1.getDistanceSquared()-t2.getDistanceSquared(); if (f<0) return -1; diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java index 0bedbd1..b50d5ea 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java @@ -40,8 +40,9 @@ package com.sun.j3d.utils.scenegraph.transparency; import java.util.Comparator; -import java.util.WeakHashMap; +import javax.media.j3d.TransparencySortGeom; +import javax.media.j3d.TransparencySortMap; import javax.media.j3d.View; /** @@ -58,9 +59,6 @@ import javax.media.j3d.View; */ public class TransparencySortController { - // Issue 478 - use a WeakHashMap to avoid holding a reference to a View unnecessarily. - private static WeakHashMap<View,Comparator> comparators = new WeakHashMap<View,Comparator>(); - /** * Set the comparator for the specified view. * @@ -72,8 +70,8 @@ public class TransparencySortController { * @param view the view to which the comparator applies * @param comparator the comparator to call */ - public static void setComparator(View view, Comparator comparator) { - comparators.put(view, comparator); + public static void setComparator(View view, Comparator<TransparencySortGeom> comparator) { + TransparencySortMap.setComparator(view, comparator); } /** @@ -82,7 +80,7 @@ public class TransparencySortController { * @return the comparator for the specified view, or null if there * is no comparator for the view or the view is unknown. */ - public static Comparator getComparator(View view) { - return comparators.get(view); + public static Comparator<TransparencySortGeom> getComparator(View view) { + return TransparencySortMap.getComparator(view); } } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java index ff05913..d2b431d 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java @@ -38,9 +38,6 @@ */ package com.sun.j3d.utils.scenegraph.transparency; -import javax.media.j3d.Geometry; -import javax.media.j3d.Shape3D; -import javax.media.j3d.Transform3D; /** * @@ -52,34 +49,4 @@ import javax.media.j3d.Transform3D; * * @since Java 3D 1.4 */ -public interface TransparencySortGeom { - - /** - * Returns the Geometry for this object. - * - * @return geometry for this object - */ - public Geometry getGeometry(); - - /** - * Returns the distance squared of this object to the viewer. - * - * @return distancesquared to viewer - */ - public double getDistanceSquared(); - - /** - * Returns the LocalToVWorld transform for this object - * - * @param localToVW variable in which transform will be returned - */ - public void getLocalToVWorld(Transform3D localToVW); - - /** - * Returns the Shape3D being rendered using this geometry. - * - * @return the Shape3D being rendered using this geometry - */ - public Shape3D getShape3D(); - -} +public interface TransparencySortGeom extends javax.media.j3d.TransparencySortGeom {} |