diff --git a/src/java/com/threerings/cast/CompositedMaskedImage.java b/src/java/com/threerings/cast/CompositedMaskedImage.java index b2851fa6..3df352c4 100644 --- a/src/java/com/threerings/cast/CompositedMaskedImage.java +++ b/src/java/com/threerings/cast/CompositedMaskedImage.java @@ -66,20 +66,18 @@ public class CompositedMaskedImage extends CompositedMultiFrameImage // documentation inherited from interface public void paintFrame (Graphics2D g, int index, int x, int y) { - _images[index].paint(g, x + _images[index].getX(), - y + _images[index].getY()); + _images[index].paint(g, x + getX(index), y + getY(index)); } // documentation inherited from interface public boolean hitTest (int index, int x, int y) { - return _images[index].hitTest(x + _images[index].getX(), - y + _images[index].getY()); + return _images[index].hitTest(x + getX(index), y + getY(index)); } // documentation inherited from interface TrimmedMultiFrameImage public void getTrimmedBounds (int index, Rectangle bounds) { - bounds.setBounds(_images[index].getX(), _images[index].getY(), - _images[index].getWidth(), _images[index].getHeight()); + bounds.setBounds(getX(index), getY(index), _images[index].getWidth(), + _images[index].getHeight()); } // documentation inherited @@ -129,4 +127,18 @@ public class CompositedMaskedImage extends CompositedMultiFrameImage } } } + + /** + * @return the x offset into the source image for the image at index + */ + protected int getX (int index) { + return ((VolatileMirage)_images[index]).getX(); + } + + /** + * @return the y offset into the source image for the image at index + */ + protected int getY (int index) { + return ((VolatileMirage)_images[index]).getY(); + } }; diff --git a/src/java/com/threerings/cast/CompositedMirage.java b/src/java/com/threerings/cast/CompositedMirage.java index c2e75f6d..100fd50e 100644 --- a/src/java/com/threerings/cast/CompositedMirage.java +++ b/src/java/com/threerings/cast/CompositedMirage.java @@ -6,16 +6,16 @@ import com.threerings.cast.CompositedActionFrames.ComponentFrames; import com.threerings.media.image.Mirage; public interface CompositedMirage - extends Mirage, Comparator + extends Mirage { /** * Returns the x offset into our image. */ - public int getX (); + public int getXOrigin (); /** * Returns the y offset into our image. */ - public int getY (); + public int getYOrigin (); } diff --git a/src/java/com/threerings/cast/CompositedMultiFrameImage.java b/src/java/com/threerings/cast/CompositedMultiFrameImage.java index 84008aed..c080f38e 100644 --- a/src/java/com/threerings/cast/CompositedMultiFrameImage.java +++ b/src/java/com/threerings/cast/CompositedMultiFrameImage.java @@ -27,6 +27,7 @@ import java.awt.Rectangle; import java.awt.Transparency; import java.awt.image.BufferedImage; import java.util.Arrays; +import java.util.Comparator; import com.threerings.cast.CompositedActionFrames.ComponentFrames; import com.threerings.cast.bundle.BundledComponentRepository.TileSetFrameImage; @@ -75,12 +76,12 @@ public class CompositedMultiFrameImage public int getXOrigin (int index) { - return _images[index].getX(); + return _images[index].getXOrigin(); } public int getYOrigin (int index) { - return _images[index].getY(); + return _images[index].getYOrigin(); } // documentation inherited from interface @@ -137,22 +138,15 @@ public class CompositedMultiFrameImage this.y = y; } - public int getX () + public int getXOrigin () { return x; } - public int getY () + public int getYOrigin () { return y; } - - // documentation inherited from interface - public int compare (ComponentFrames cf1, ComponentFrames cf2) - { - return (cf1.ccomp.componentClass.getRenderPriority(_action, _orient) - - cf2.ccomp.componentClass.getRenderPriority(_action, _orient)); - } public long getEstimatedMemoryUsage () { @@ -214,7 +208,7 @@ public class CompositedMultiFrameImage * Used to create our mirage using the source action frame images. */ protected class CompositedVolatileMirage extends VolatileMirage - implements CompositedMirage + implements CompositedMirage, Comparator { public CompositedVolatileMirage (int index) { diff --git a/src/java/com/threerings/cast/CompositedShadowImage.java b/src/java/com/threerings/cast/CompositedShadowImage.java index ea85e8fc..f7d34942 100644 --- a/src/java/com/threerings/cast/CompositedShadowImage.java +++ b/src/java/com/threerings/cast/CompositedShadowImage.java @@ -65,26 +65,44 @@ public class CompositedShadowImage extends CompositedMultiFrameImage public int getYOrigin (int index) { return _sources[0].frames.getYOrigin(_orient, index); } + + @Override // documentation inherited + protected CompositedMirage createCompositedMirage (int index) { + // Always use a CompositedVolatileMirage for ShadowImage since we need to draw into it. + return new CompositedVolatileMirage(index); + } // documentation inherited from interface public void paintFrame (Graphics2D g, int index, int x, int y) { Composite ocomp = g.getComposite(); g.setComposite(_shadowAlpha); - _images[index].paint(g, x + _images[index].getX(), - y + _images[index].getY()); + _images[index].paint(g, x + getX(index), y + getY(index)); g.setComposite(ocomp); } // documentation inherited from interface public boolean hitTest (int index, int x, int y) { - return _images[index].hitTest(x + _images[index].getX(), - y + _images[index].getY()); + return _images[index].hitTest(x + getX(index), y + getY(index)); } // documentation inherited from interface TrimmedMultiFrameImage public void getTrimmedBounds (int index, Rectangle bounds) { - bounds.setBounds(_images[index].getX(), _images[index].getY(), - _images[index].getWidth(), _images[index].getHeight()); + bounds.setBounds(getX(index), getY(index), _images[index].getWidth(), + _images[index].getHeight()); + } + + /** + * @return the x offset into the source image for the image at index + */ + protected int getX (int index) { + return ((VolatileMirage)_images[index]).getX(); + } + + /** + * @return the y offset into the source image for the image at index + */ + protected int getY (int index) { + return ((VolatileMirage)_images[index]).getY(); } /** The alpha value at which we render our shadow. */