package votorola.s.gwt.scene.vote; // Copyright 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 org.vectomatic.dom.svg.*; import org.vectomatic.dom.svg.impl.SVGTextElement; import org.vectomatic.dom.svg.utils.*; /** A view of a number that measures a quantity of votes. */ final class FlowVolumeV extends OMSVGTextElement { /** Constructs a FlowVolumeV. */ FlowVolumeV( final VotespaceV votespaceV ) { super( (SVGTextElement)DOMHelper.createElementNS( votespaceV.document().getDocument(), SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_TEXT_TAG ).cast() ); final OMSVGDocument document = votespaceV.document(); addClassNameBaseVal( "FlowVolumeV" ); addClassNameBaseVal( "countingMethod" ); appendChild( newPad( document )); // more click space, when clickable final OMSVGTSpanElement tspanH = document.createSVGTSpanElement(); appendChild( tspanH ); tspanH.appendChild( textNodeH = document.createTextNode( "" )); final OMSVGTSpanElement tspanL = document.createSVGTSpanElement(); appendChild( tspanL ); tspanL.addClassNameBaseVal( "dim" ); tspanL.appendChild( textNodeL = document.createTextNode( "" )); appendChild( newPad( document )); // more click space " } // ------------------------------------------------------------------------------------ /** Sets the quantity of votes that are shown. */ void set( final long value ) { votorola.s.gwt.stage.vote.FlowVolumeV.set( value, textNodeH.getText(), textNodeL.getText() ); } /** Sets a placeholder to display in lieu of a quantity of votes. */ void setPlaceholder( final String placeholder ) { textNodeH.setData( "" ); textNodeL.setData( placeholder ); } //// P r i v a t e /////////////////////////////////////////////////////////////////////// /** Constructs a padding element. Necessary because SVG does not support CSS * padding. */ private OMSVGTSpanElement newPad( final OMSVGDocument document ) { final OMSVGTSpanElement tspan = document.createSVGTSpanElement(); tspan.appendChild( document.createTextNode( "\u00a0" )); // non-breaking space return tspan; } // /** The text node holding the higher order digits. // */ // private OMText textNodeH() { return textNodeH; } private final OMText textNodeH; // /** The text node holding the lower order digits. // */ // private OMText textNodeL() { return textNodeL; } private final OMText textNodeL; }