package votorola.s.gwt.scene; // Copyright 2010-2011, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import com.google.gwt.user.client.ui.*; import votorola.s.gwt.scene.axial.*; import votorola.s.gwt.scene.feed.*; import votorola.s.gwt.scene.dum.*; import votorola.s.gwt.scene.geo.*; import votorola.s.gwt.scene.vote.*; import votorola.g.hold.*; /** A scene for Crossforum Theatre, a spatial context in which people, places and events * are situated. */ public interface Scene { // - S c e n e ------------------------------------------------------------------------ /** Tests whether the specified bite is within the current scope of this scene. * * @see Scoping */ public boolean inScope( BiteJS bite ); // ==================================================================================== /** Short names designating particular scene types, suitable for use in a ({@linkplain * Scenes#cCompositionSwitch() composition switch}). Each name begins with a single ASCII * uppercase letter which may be followed by zero or more ASCII lowercase letters * and digits. * * @see votorola.s.gwt.scene.feed.Feed.SwitchMnemonic */ public static enum SwitchMnemonic { /** Designating a {@linkplain DummyScene DummyScene}. */ Dum { public Hold emplace() { final Spool spool = new Spool1(); final DummyScene scene = new DummyScene(); setModel( scene, spool ); addView( new DummySceneV(scene), spool ); return new SpoolHold( spool ); } }, /** Designating a {@linkplain Geomap geomap}. */ G { public Hold emplace() { final Spool spool = new Spool1(); final Geomap scene = new Geomap( spool ); Scenes.i().setScene( scene ); spool.add( new Hold() { public void release() { Scenes.i().clearMap(); }}); addView( scene, spool ); return new SpoolHold( spool ); } }, /** Designating a {@linkplain TriaxialPollMap TriaxialPollMap}. */ T { public Hold emplace() { final Spool spool = new Spool1(); final TriaxialPollMap scene = new TriaxialPollMap(); setModel( scene, spool ); addView( new TriaxialPollMapV(scene), spool ); return new SpoolHold( spool ); } }, /** Designating a {@linkplain Votespace votespace social scene}. */ V { public Hold emplace() { final Spool spool = new Spool1(); final Votespace scene = new Votespace(); setModel( scene, spool ); addView( new VotespaceV(scene), spool ); return new SpoolHold( spool ); } }; // -------------------------------------------------------------------------------- private static void addView( final Widget sceneV, final Spool spool ) { ScenesV.i().setScene( sceneV ); // to center spool.add( new Hold() { public void release() { sceneV.removeFromParent(); }}); } /** Constructs and emplaces the designated scene model, views and controllers. * * @return a hold the release of which undoes the emplacement. */ public abstract Hold emplace(); private static void setModel( final Scene scene, final Spool spool ) { spool.add( (Hold)scene ); Scenes.i().setScene( scene ); spool.add( new Hold() { public void release() { Scenes.i().clearMap(); }}); } } }