From 8f276c0a3855eb06dd86c6f7f34f0e36fb8fc782 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 13 Nov 2002 23:59:11 +0000 Subject: [PATCH] Have AbstractMedia implement Shape so that it can be treated generically by code that operates on shapes. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1945 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/AbstractMedia.java | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/AbstractMedia.java b/src/java/com/threerings/media/AbstractMedia.java index 4f0d28e04..f4b5c1686 100644 --- a/src/java/com/threerings/media/AbstractMedia.java +++ b/src/java/com/threerings/media/AbstractMedia.java @@ -1,10 +1,17 @@ // -// $Id: AbstractMedia.java,v 1.2 2002/11/05 20:50:42 mdb Exp $ +// $Id: AbstractMedia.java,v 1.3 2002/11/13 23:59:11 mdb Exp $ package com.threerings.media; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.Shape; + +import java.awt.geom.AffineTransform; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + import java.util.ArrayList; import com.samskivert.util.ObserverList; @@ -14,6 +21,7 @@ import com.samskivert.util.StringUtil; * Something that can be rendered on the media panel. */ public abstract class AbstractMedia + implements Shape { /** * Instantiate an abstract media object. @@ -78,6 +86,61 @@ public abstract class AbstractMedia return _bounds; } + // documentation inherited from interface Shape + public Rectangle2D getBounds2D () + { + return new Rectangle2D.Float(_bounds.x, _bounds.y, + _bounds.width, _bounds.height); + } + + // documentation inherited from interface Shape + public boolean contains (double x, double y) + { + return _bounds.contains(x, y); + } + + // documentation inherited from interface Shape + public boolean contains (Point2D p) + { + return _bounds.contains(p); + } + + // documentation inherited from interface Shape + public boolean intersects (double x, double y, double w, double h) + { + return _bounds.intersects(x, y, w, h); + } + + // documentation inherited from interface Shape + public boolean intersects (Rectangle2D r) + { + return _bounds.intersects(r); + } + + // documentation inherited from interface Shape + public boolean contains (double x, double y, double w, double h) + { + return _bounds.contains(x, y, w, h); + } + + // documentation inherited from interface Shape + public boolean contains (Rectangle2D r) + { + return _bounds.contains(r); + } + + // documentation inherited from interface Shape + public PathIterator getPathIterator (AffineTransform at) + { + return _bounds.getPathIterator(at); + } + + // documentation inherited from interface Shape + public PathIterator getPathIterator (AffineTransform at, double flatness) + { + return _bounds.getPathIterator(at, flatness); + } + /** * Sets the render order associated with this media. Media * can be rendered in two layers; those with negative render order and