001package 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. 002 003import com.google.gwt.user.client.ui.*; 004import votorola.s.gwt.scene.axial.*; 005import votorola.s.gwt.scene.feed.*; 006import votorola.s.gwt.scene.dum.*; 007import votorola.s.gwt.scene.geo.*; 008import votorola.s.gwt.scene.vote.*; 009import votorola.g.hold.*; 010 011 012/** A scene for Crossforum Theatre, a spatial context in which people, places and events 013 * are situated. 014 */ 015public interface Scene 016{ 017 018 019 // - S c e n e ------------------------------------------------------------------------ 020 021 022 /** Tests whether the specified bite is within the current scope of this scene. 023 * 024 * @see Scoping 025 */ 026 public boolean inScope( BiteJS bite ); 027 028 029 030 // ==================================================================================== 031 032 033 /** Short names designating particular scene types, suitable for use in a ({@linkplain 034 * Scenes#cCompositionSwitch() composition switch}). Each name begins with a single ASCII 035 * uppercase letter which may be followed by zero or more ASCII lowercase letters 036 * and digits. 037 * 038 * @see votorola.s.gwt.scene.feed.Feed.SwitchMnemonic 039 */ 040 public static enum SwitchMnemonic 041 { 042 043 044 /** Designating a {@linkplain DummyScene DummyScene}. 045 */ 046 Dum 047 { 048 public Hold emplace() 049 { 050 final Spool spool = new Spool1(); 051 final DummyScene scene = new DummyScene(); 052 setModel( scene, spool ); 053 054 addView( new DummySceneV(scene), spool ); 055 return new SpoolHold( spool ); 056 } 057 }, 058 059 060 061 /** Designating a {@linkplain Geomap geomap}. 062 */ 063 G 064 { 065 public Hold emplace() 066 { 067 final Spool spool = new Spool1(); 068 final Geomap scene = new Geomap( spool ); 069 Scenes.i().setScene( scene ); 070 spool.add( new Hold() { public void release() { Scenes.i().clearMap(); }}); 071 072 addView( scene, spool ); 073 return new SpoolHold( spool ); 074 } 075 }, 076 077 078 079 /** Designating a {@linkplain TriaxialPollMap TriaxialPollMap}. 080 */ 081 T 082 { 083 public Hold emplace() 084 { 085 final Spool spool = new Spool1(); 086 final TriaxialPollMap scene = new TriaxialPollMap(); 087 setModel( scene, spool ); 088 089 addView( new TriaxialPollMapV(scene), spool ); 090 return new SpoolHold( spool ); 091 } 092 }, 093 094 095 096 /** Designating a {@linkplain Votespace votespace social scene}. 097 */ 098 V 099 { 100 public Hold emplace() 101 { 102 final Spool spool = new Spool1(); 103 final Votespace scene = new Votespace(); 104 setModel( scene, spool ); 105 106 addView( new VotespaceV(scene), spool ); 107 return new SpoolHold( spool ); 108 } 109 }; 110 111 112 113 // -------------------------------------------------------------------------------- 114 115 116 private static void addView( final Widget sceneV, final Spool spool ) 117 { 118 ScenesV.i().setScene( sceneV ); // to center 119 spool.add( new Hold() { public void release() { sceneV.removeFromParent(); }}); 120 } 121 122 123 124 /** Constructs and emplaces the designated scene model, views and controllers. 125 * 126 * @return a hold the release of which undoes the emplacement. 127 */ 128 public abstract Hold emplace(); 129 130 131 132 private static void setModel( final Scene scene, final Spool spool ) 133 { 134 spool.add( (Hold)scene ); 135 Scenes.i().setScene( scene ); 136 spool.add( new Hold() { public void release() { Scenes.i().clearMap(); }}); 137 } 138 139 } 140 141 142}