001package 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. 002 003import org.vectomatic.dom.svg.*; 004import org.vectomatic.dom.svg.impl.SVGTextElement; 005import org.vectomatic.dom.svg.utils.*; 006 007 008/** A view of a number that measures a quantity of votes. 009 */ 010final class FlowVolumeV extends OMSVGTextElement 011{ 012 013 014 /** Constructs a FlowVolumeV. 015 */ 016 FlowVolumeV( final VotespaceV votespaceV ) 017 { 018 super( (SVGTextElement)DOMHelper.createElementNS( votespaceV.document().getDocument(), 019 SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_TEXT_TAG ).cast() ); 020 021 final OMSVGDocument document = votespaceV.document(); 022 addClassNameBaseVal( "FlowVolumeV" ); 023 addClassNameBaseVal( "countingMethod" ); 024 appendChild( newPad( document )); // more click space, when clickable 025 026 final OMSVGTSpanElement tspanH = document.createSVGTSpanElement(); 027 appendChild( tspanH ); 028 tspanH.appendChild( textNodeH = document.createTextNode( "" )); 029 030 final OMSVGTSpanElement tspanL = document.createSVGTSpanElement(); 031 appendChild( tspanL ); 032 tspanL.addClassNameBaseVal( "dim" ); 033 tspanL.appendChild( textNodeL = document.createTextNode( "" )); 034 035 appendChild( newPad( document )); // more click space " 036 } 037 038 039 040 // ------------------------------------------------------------------------------------ 041 042 043 /** Sets the quantity of votes that are shown. 044 */ 045 void set( final long value ) 046 { 047 votorola.s.gwt.stage.vote.FlowVolumeV.set( value, textNodeH.getText(), textNodeL.getText() ); 048 } 049 050 051 052 /** Sets a placeholder to display in lieu of a quantity of votes. 053 */ 054 void setPlaceholder( final String placeholder ) 055 { 056 textNodeH.setData( "" ); 057 textNodeL.setData( placeholder ); 058 } 059 060 061 062//// P r i v a t e /////////////////////////////////////////////////////////////////////// 063 064 065 /** Constructs a padding element. Necessary because SVG does not support CSS 066 * padding. 067 */ 068 private OMSVGTSpanElement newPad( final OMSVGDocument document ) 069 { 070 final OMSVGTSpanElement tspan = document.createSVGTSpanElement(); 071 tspan.appendChild( document.createTextNode( "\u00a0" )); // non-breaking space 072 return tspan; 073 } 074 075 076 // /** The text node holding the higher order digits. 077 // */ 078 // private OMText textNodeH() { return textNodeH; } 079 080 081 private final OMText textNodeH; 082 083 084 085 // /** The text node holding the lower order digits. 086 // */ 087 // private OMText textNodeL() { return textNodeL; } 088 089 090 private final OMText textNodeL; 091 092 093 094}