package votorola.s.gwt.wic; // Copyright 2012-2013, 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.dom.client.*; import org.vectomatic.dom.svg.*; import org.vectomatic.dom.svg.utils.OMSVGParser; import votorola.a.web.gwt.*; import votorola.s.gwt.stage.*; import votorola.s.gwt.stage.link.*; import votorola.s.gwt.stage.vote.*; import static votorola.s.gwt.stage.vote.LightableDifference.REL_CANDIDATE; import static votorola.s.gwt.stage.vote.LightableDifference.REL_CO; import static votorola.s.gwt.stage.vote.LightableDifference.REL_TIGHT_CYCLE; import static votorola.s.gwt.stage.vote.LightableDifference.REL_UNKNOWN; import static votorola.s.gwt.stage.vote.LightableDifference.REL_VOTER; /** The GWT entry module for embedding the Crossforum Theatre {@linkplain * votorola.s.gwt.stage.Stage stage} in the Wicket {@linkplain votorola.s.wic.diff.WP_D * difference bridge}. An instance of this class is automatically constructed and * invoked per module definition DIn.gwt.xml. It overlays the * bridge scene with an {@linkplain AnchorLine anchor line} that ties the selected * drafter's link (sLink) at the top left of the bridge to the pin indicator in the vote * track, plus an {@linkplain AlterTie alter tie} that ties the other drafter's link * (tLink) to his/her corresponding node in the track.
  *
  *                                                               --
  *    >>>>>>>>>>>>>>>>>>>>> --- >>>>>>>>>>>>>>>>>>>> --- >>>>>    | vote track
  *            -----                           /\                 --
  *              | alter tie                   /                   |
  *    tLink - - +                            /                    | bridge scene
  *    sLink - - - - - - - - - - - - - - - - +  anchor line        |
  *                                                                |
* *

Acknowledgement: Thomas von der Elbe assisted in troubleshooting the visualization * problems that led to the design of these ties. See the thread Difference lighting and cross-linking on the bridge.

*/ public final class DIn implements EntryPointS { // - E n t r y - P o i n t ------------------------------------------------------------ public final void onModuleLoad() { StageIn.insertStageV(); EntryPointS.U.schedule( DIn.this ); EntryPointS.U.execute(); // because all modules are now loaded Stage.i().addInitializer( new TheatreInitializerC() // auto-removed { public void initComplete( Stage _s, boolean _rPending ) { // HTML view. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - final Document htmlDoc = Document.get(); final Element div = htmlDoc.createDivElement(); // for HTML styling, per WP_D.css div.addClassName( "BridgeOverlay" ); htmlDoc.getBody().appendChild( div ); // SVG view. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - final OMSVGSVGElement svg = OMSVGParser.createDocument().createSVGSVGElement(); div.appendChild( svg.getElement() ); final VoteTrackV trackV = VoteTrackV.i( StageV.i() ); if( trackV == null ) throw new IllegalStateException(); final char rel = DifferenceLight.sceneRel(); final NodeV.Box nodeBox; if( rel == REL_VOTER ) nodeBox = trackV.votersBoardV(); else if( rel == REL_CO ) nodeBox = trackV.peersBoardV(); else if( rel == REL_CANDIDATE || rel == REL_TIGHT_CYCLE ) { nodeBox = trackV.candidateV(); // In tight cycle, candidate is also voter and will also appear in // votersBoardV. We might draw 2nd under-bracket there to show the // cycle. But that would be difficult. And no need; lighting effects // already show the cycle well enough. } else if( rel == REL_UNKNOWN ) nodeBox = null; else throw new IllegalStateException( "rel = " + rel ); svg.appendChild( new AnchorLine( trackV )); if( nodeBox != null ) svg.appendChild( new AlterTie( nodeBox, trackV.track() )); } }); } // - S c h e d u l e r . S c h e d u l e d - C o m m a n d ---------------------------- public void execute() { StageV.i().initEmbeddedDisplay(); } }