Sweet Mary, mother of Jesus! Another fucking refactor. It turns out that
the way I was doing inheritance between the display and editable scene implementations was not copacetic. The new method (which is for every editable scene impl to delegate to a display scene impl so that regardless of how far along you are on the inheritance chain, there are only ever two actual objects, the display impl and the editable impl) is somewhat cleaner, but makes it clear that no method can work as nicely as it would were we to have mutliple inheritance. The basic problem is that the editable versions of the scenes have to be able to manipulate the instance variables in the display versions of the scenes because they have to keep them up to date so that they are displaying the right thing. As the editable versions are in different packages, they don't have access to the display instance variables, so the display versions simply have to make available enough "editable" functionality to allow the editable versions to get their job done. It's more coupling that I'd like, but at least it's only between the display and editable versions across the inheritance hierarchy rather than down the hierarchy. Blah. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@745 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,30 +1,19 @@
|
||||
//
|
||||
// $Id: EditableSceneImpl.java,v 1.4 2001/12/05 03:38:09 mdb Exp $
|
||||
// $Id: EditableSceneImpl.java,v 1.5 2001/12/05 08:45:06 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.tools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.whirled.client.DisplaySceneImpl;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
|
||||
/**
|
||||
* A basic implementation of the {@link EditableScene} interface.
|
||||
*/
|
||||
public class EditableSceneImpl
|
||||
extends DisplaySceneImpl
|
||||
implements EditableScene
|
||||
public class EditableSceneImpl implements EditableScene
|
||||
{
|
||||
/**
|
||||
* Creates an instance that will obtain data from the supplied scene
|
||||
* model and update it when changes are made.
|
||||
*/
|
||||
public EditableSceneImpl (EditableSceneModel model)
|
||||
{
|
||||
super(model.sceneModel, null);
|
||||
_emodel = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance that will create and use a blank scene model.
|
||||
*/
|
||||
@@ -33,6 +22,52 @@ public class EditableSceneImpl
|
||||
this(EditableSceneModel.blankSceneModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance that will obtain data from the supplied scene
|
||||
* model and update it when changes are made.
|
||||
*/
|
||||
public EditableSceneImpl (EditableSceneModel model)
|
||||
{
|
||||
this(model, new DisplaySceneImpl(model.sceneModel, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance that will obtain data from the supplied scene
|
||||
* model and update it when changes are made. It will delegate to the
|
||||
* supplied display scene instead of creating its own delegate.
|
||||
*/
|
||||
public EditableSceneImpl (
|
||||
EditableSceneModel model, DisplaySceneImpl delegate)
|
||||
{
|
||||
_model = model.sceneModel;
|
||||
_emodel = model;
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public int getId ()
|
||||
{
|
||||
return _delegate.getId();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public int getVersion ()
|
||||
{
|
||||
return _delegate.getVersion();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public int[] getNeighborIds ()
|
||||
{
|
||||
return _delegate.getNeighborIds();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public PlaceConfig getPlaceConfig ()
|
||||
{
|
||||
return _delegate.getPlaceConfig();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void setId (int sceneId)
|
||||
{
|
||||
@@ -89,6 +124,12 @@ public class EditableSceneImpl
|
||||
return _emodel;
|
||||
}
|
||||
|
||||
/** A reference to our scene model. */
|
||||
protected SceneModel _model;
|
||||
|
||||
/** A reference to our editable scene model. */
|
||||
protected EditableSceneModel _emodel;
|
||||
|
||||
/** Our display scene delegate. */
|
||||
protected DisplaySceneImpl _delegate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user