Modified code that makes view follow path to not require an origin point

which was a wacky hack in the first place.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1436 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-11 00:05:31 +00:00
parent 4c589d3802
commit 916513f306
+10 -12
View File
@@ -1,5 +1,5 @@
// //
// $Id: MediaPanel.java,v 1.9 2002/05/31 07:33:52 mdb Exp $ // $Id: MediaPanel.java,v 1.10 2002/06/11 00:05:31 mdb Exp $
package com.threerings.media; package com.threerings.media;
@@ -123,14 +123,14 @@ public class MediaPanel extends JComponent
/** /**
* Instructs the view to allow the supplied path to "scroll" it such * Instructs the view to allow the supplied path to "scroll" it such
* that the center point of the view follows the supplied path. The * that the center point of the view follows the supplied path. The
* supplied origin coordinates will be used to report our initial * view will initially report its position as being in the center of
* coordinates to the path and will be updated as the path "moves" us * the view and will update those coordinates as it is scrolled by the
* around. * path.
*/ */
public void setPath (Path path, Point origin) public void setPath (Path path)
{ {
_path = path; Dimension vsize = getViewSize();
_porigin = origin; _porigin.setLocation(vsize.width/2, vsize.height/2);
_pathable = new Pathable() { _pathable = new Pathable() {
// documentation inherited from interface // documentation inherited from interface
public int getX () { public int getX () {
@@ -149,7 +149,7 @@ public class MediaPanel extends JComponent
_dx = x - _porigin.x; _dx = x - _porigin.x;
_dy = y - _porigin.y; _dy = y - _porigin.y;
// and update our origin // update our origin
_porigin.x = x; _porigin.x = x;
_porigin.y = y; _porigin.y = y;
} }
@@ -168,9 +168,8 @@ public class MediaPanel extends JComponent
public void pathCompleted () { public void pathCompleted () {
MediaPanel.this.pathCompleted(); MediaPanel.this.pathCompleted();
} }
protected Point _offset;
}; };
_path = path;
_path.init(_pathable, System.currentTimeMillis()); _path.init(_pathable, System.currentTimeMillis());
} }
@@ -202,7 +201,6 @@ public class MediaPanel extends JComponent
// we're all done; clear out our business // we're all done; clear out our business
_path = null; _path = null;
_pathable = null; _pathable = null;
_porigin = null;
// call our standard callback // call our standard callback
viewFinishedScrolling(); viewFinishedScrolling();
@@ -674,7 +672,7 @@ public class MediaPanel extends JComponent
protected Pathable _pathable; protected Pathable _pathable;
/** The origin of the view as represented to the path. */ /** The origin of the view as represented to the path. */
protected Point _porigin; protected Point _porigin = new Point();
/** Used to correlate tick()s with paint()s. */ /** Used to correlate tick()s with paint()s. */
protected boolean _tickPaintPending = false; protected boolean _tickPaintPending = false;