From 916513f306b9985482e5952fb1e8dff23234cbe8 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 11 Jun 2002 00:05:31 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/MediaPanel.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/java/com/threerings/media/MediaPanel.java b/src/java/com/threerings/media/MediaPanel.java index 2292b06cc..90f42425c 100644 --- a/src/java/com/threerings/media/MediaPanel.java +++ b/src/java/com/threerings/media/MediaPanel.java @@ -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; @@ -123,14 +123,14 @@ public class MediaPanel extends JComponent /** * Instructs the view to allow the supplied path to "scroll" it such * that the center point of the view follows the supplied path. The - * supplied origin coordinates will be used to report our initial - * coordinates to the path and will be updated as the path "moves" us - * around. + * view will initially report its position as being in the center of + * the view and will update those coordinates as it is scrolled by the + * path. */ - public void setPath (Path path, Point origin) + public void setPath (Path path) { - _path = path; - _porigin = origin; + Dimension vsize = getViewSize(); + _porigin.setLocation(vsize.width/2, vsize.height/2); _pathable = new Pathable() { // documentation inherited from interface public int getX () { @@ -149,7 +149,7 @@ public class MediaPanel extends JComponent _dx = x - _porigin.x; _dy = y - _porigin.y; - // and update our origin + // update our origin _porigin.x = x; _porigin.y = y; } @@ -168,9 +168,8 @@ public class MediaPanel extends JComponent public void pathCompleted () { MediaPanel.this.pathCompleted(); } - - protected Point _offset; }; + _path = path; _path.init(_pathable, System.currentTimeMillis()); } @@ -202,7 +201,6 @@ public class MediaPanel extends JComponent // we're all done; clear out our business _path = null; _pathable = null; - _porigin = null; // call our standard callback viewFinishedScrolling(); @@ -674,7 +672,7 @@ public class MediaPanel extends JComponent protected Pathable _pathable; /** 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. */ protected boolean _tickPaintPending = false;