Turns out people had extended Sprite and added their own Comparable
implementation, so let's not stick a fork in that. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@353 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -37,7 +37,7 @@ import com.samskivert.util.StringUtil;
|
||||
* Something that can be rendered on the media panel.
|
||||
*/
|
||||
public abstract class AbstractMedia
|
||||
implements Shape, Comparable<AbstractMedia>
|
||||
implements Shape
|
||||
{
|
||||
/** A {@link #_renderOrder} value at or above which, indicates that this
|
||||
* media is in the HUD (heads up display) and should not scroll when the
|
||||
@@ -166,8 +166,10 @@ public abstract class AbstractMedia
|
||||
return _bounds.getPathIterator(at, flatness);
|
||||
}
|
||||
|
||||
// from interface Comparable<AbstractMedia>
|
||||
public int compareTo (AbstractMedia other)
|
||||
/**
|
||||
* Compares this media to the specified media by render order.
|
||||
*/
|
||||
public int renderCompareTo (AbstractMedia other)
|
||||
{
|
||||
int result = _renderOrder - other._renderOrder;
|
||||
return (result != 0) ? result : naturalCompareTo(other);
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.awt.Shape;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.samskivert.util.ComparableArrayList;
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
import com.samskivert.util.ObserverList.ObserverOp;
|
||||
import com.samskivert.util.ObserverList;
|
||||
import com.samskivert.util.Tuple;
|
||||
@@ -166,7 +166,7 @@ public abstract class AbstractMediaManager
|
||||
}
|
||||
|
||||
_media.remove(media);
|
||||
_media.insertSorted(media);
|
||||
_media.insertSorted(media, RENDER_ORDER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +195,7 @@ public abstract class AbstractMediaManager
|
||||
}
|
||||
|
||||
media.init(this);
|
||||
int ipos = _media.insertSorted(media);
|
||||
int ipos = _media.insertSorted(media, RENDER_ORDER);
|
||||
|
||||
// if we've started our tick but have not yet painted our media, we need to take care that
|
||||
// this newly added media will be ticked before our upcoming render
|
||||
@@ -270,7 +270,7 @@ public abstract class AbstractMediaManager
|
||||
}
|
||||
|
||||
/** Type safety jockeying. */
|
||||
protected abstract ComparableArrayList<? extends AbstractMedia> createMediaList ();
|
||||
protected abstract SortableArrayList<? extends AbstractMedia> createMediaList ();
|
||||
|
||||
/**
|
||||
* Dispatches all queued media notifications.
|
||||
@@ -284,6 +284,13 @@ public abstract class AbstractMediaManager
|
||||
_notify.clear();
|
||||
}
|
||||
|
||||
/** Used to sort media by render order. */
|
||||
protected static final Comparator<AbstractMedia> RENDER_ORDER = new Comparator<AbstractMedia>() {
|
||||
public int compare (AbstractMedia am1, AbstractMedia am2) {
|
||||
return am1.renderCompareTo(am2);
|
||||
}
|
||||
};
|
||||
|
||||
/** The media host we're working with. */
|
||||
protected MediaHost _host;
|
||||
|
||||
@@ -295,8 +302,8 @@ public abstract class AbstractMediaManager
|
||||
new ArrayList<Tuple<ObserverList,ObserverOp>>();
|
||||
|
||||
/** Our render-order sorted list of media. */
|
||||
@SuppressWarnings("unchecked") protected ComparableArrayList<AbstractMedia> _media =
|
||||
(ComparableArrayList<AbstractMedia>)createMediaList();
|
||||
@SuppressWarnings("unchecked") protected SortableArrayList<AbstractMedia> _media =
|
||||
(SortableArrayList<AbstractMedia>)createMediaList();
|
||||
|
||||
/** The position in our media list that we're ticking (while in the middle of a call to {@link
|
||||
* #tick}) otherwise -1. */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
package com.threerings.media.animation;
|
||||
|
||||
import com.samskivert.util.ComparableArrayList;
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
|
||||
import com.threerings.media.AbstractMedia;
|
||||
import com.threerings.media.AbstractMediaManager;
|
||||
@@ -71,10 +71,10 @@ public class AnimationManager extends AbstractMediaManager
|
||||
}
|
||||
|
||||
@Override // from AbstractMediaManager
|
||||
protected ComparableArrayList<? extends AbstractMedia> createMediaList ()
|
||||
protected SortableArrayList<? extends AbstractMedia> createMediaList ()
|
||||
{
|
||||
return (_anims = new ComparableArrayList<Animation>());
|
||||
return (_anims = new SortableArrayList<Animation>());
|
||||
}
|
||||
|
||||
protected ComparableArrayList<Animation> _anims;
|
||||
protected SortableArrayList<Animation> _anims;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.samskivert.util.Predicate;
|
||||
import com.samskivert.util.ComparableArrayList;
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
|
||||
import com.threerings.media.AbstractMedia;
|
||||
import com.threerings.media.AbstractMediaManager;
|
||||
@@ -248,10 +248,10 @@ public class SpriteManager extends AbstractMediaManager
|
||||
// }
|
||||
|
||||
@Override // from AbstractMediaManager
|
||||
protected ComparableArrayList<? extends AbstractMedia> createMediaList ()
|
||||
protected SortableArrayList<? extends AbstractMedia> createMediaList ()
|
||||
{
|
||||
return (_sprites = new ComparableArrayList<Sprite>());
|
||||
return (_sprites = new SortableArrayList<Sprite>());
|
||||
}
|
||||
|
||||
protected ComparableArrayList<Sprite> _sprites;
|
||||
protected SortableArrayList<Sprite> _sprites;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user