java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag
changeset 106 6209f3d550c5
parent 58 e019dbc42723
child 107 e8371105fcc8
     1.1 --- a/java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag	Tue Mar 09 20:26:30 2010 +0100
     1.2 +++ b/java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag	Tue Apr 27 13:14:23 2010 +0200
     1.3 @@ -6,7 +6,111 @@
     1.4  	  version="2.0">
     1.5  
     1.6      <jsp:directive.attribute name="podnik" type="java.lang.Integer" required="true" description="ID podniku"/>
     1.7 +    <jsp:directive.attribute name="hlasuAno" type="java.lang.Integer" required="true" description="počet hlasů pro ano – aby se tu kouřilo"/>
     1.8 +    <jsp:directive.attribute name="hlasuNe" type="java.lang.Integer" required="true" description="počet hlasů pro ne – aby se tu nekouřilo"/>
     1.9 +    <jsp:directive.attribute name="svgUvnitrXhtml" type="java.lang.Boolean" required="false" description="true = SVG vložené přímo do XHTML (XML) | false = SVG jako externí obrázek – &lt;img src='…'/&gt;"/>
    1.10  
    1.11 -    <p>TODO: tady bude graf a hlasování.</p>
    1.12 +    <c:if test="${svgUvnitrXhtml == null}">
    1.13 +	<c:set var="svgUvnitrXhtml" value="${true}"/>
    1.14 +    </c:if>
    1.15 +
    1.16 +    <c:choose>
    1.17 +	<c:when test="${svgUvnitrXhtml}">
    1.18 +	    <svg width="200" height="200"
    1.19 +		 xmlns="http://www.w3.org/2000/svg"
    1.20 +		 xmlns:xlink="http://www.w3.org/1999/xlink">
    1.21 +
    1.22 +
    1.23 +		<style type="text/css">
    1.24 +		    rect.ne {
    1.25 +			fill:  url(#ne_prechod);
    1.26 +			stroke: black;
    1.27 +		    }
    1.28 +		    rect.ano {
    1.29 +			fill: url(#ano_prechod);
    1.30 +			stroke: black;
    1.31 +		    }
    1.32 +
    1.33 +		    a:hover rect.ano, a:hover rect.ne {
    1.34 +			fill: url(#zvyrazneny_prechod);
    1.35 +		    }
    1.36 +
    1.37 +		    a:hover text {
    1.38 +			fill: green;
    1.39 +		    }
    1.40 +
    1.41 +		    line.ramecek {
    1.42 +			stroke: black;
    1.43 +			stroke-width: 2;
    1.44 +		    }
    1.45 +
    1.46 +
    1.47 +		    rect.pozadi {
    1.48 +			fill: url(#pozadi_prechod);
    1.49 +		    }
    1.50 +
    1.51 +		    text {
    1.52 +			font-size: 12px;
    1.53 +			font-family: Sans;
    1.54 +		    }
    1.55 +
    1.56 +		</style>
    1.57 +
    1.58 +		<!-- pozadí – přechod -->
    1.59 +		<defs>
    1.60 +		    <linearGradient id="pozadi_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
    1.61 +			<stop offset="0%" style="stop-color:white; stop-opacity:0.5"/>
    1.62 +			<stop offset="100%" style="stop-color:silver; stop-opacity:0.8"/>
    1.63 +		    </linearGradient>
    1.64 +		</defs>
    1.65 +
    1.66 +		<!-- nekuřácký graf – přechod -->
    1.67 +		<defs>
    1.68 +		    <linearGradient id="ne_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
    1.69 +			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
    1.70 +			<stop offset="100%" style="stop-color:blue; stop-opacity:1"/>
    1.71 +		    </linearGradient>
    1.72 +		</defs>
    1.73 +
    1.74 +		<!-- zvýrazněný graf – přechod -->
    1.75 +		<defs>
    1.76 +		    <linearGradient id="zvyrazneny_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
    1.77 +			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
    1.78 +			<stop offset="100%" style="stop-color:green; stop-opacity:1"/>
    1.79 +		    </linearGradient>
    1.80 +		</defs>
    1.81 +
    1.82 +		<!-- kuřácký graf – přechod -->
    1.83 +		<defs>
    1.84 +		    <linearGradient id="ano_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
    1.85 +			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
    1.86 +			<stop offset="100%" style="stop-color:red; stop-opacity:1"/>
    1.87 +		    </linearGradient>
    1.88 +		</defs>
    1.89 +
    1.90 +		<!-- pozadí a linka -->
    1.91 +		<rect x="0" y="0" width="200" height="200" class="pozadi"/>
    1.92 +		<line x1="10" y1="180" x2="190" y2="180" class="ramecek"/>
    1.93 +
    1.94 +		<!-- Nadpis grafu -->
    1.95 +		<text x="60" y="20">Mělo by se tu:</text>
    1.96 +
    1.97 +		<!-- nekuřáci -->
    1.98 +		<a xlink:href="javascript:alert('To čumíš, co? :-)')" xlink:title="Hlasů: ${hlasuNe}">
    1.99 +		    <text x="30" y="195" class="ne">nekouřit</text>
   1.100 +		    <rect x="30" y="${180 - (150*hlasuNe/(hlasuAno+hlasuNe))}" width="50" height="${150*hlasuNe/(hlasuAno+hlasuNe)}" class="ne"/>
   1.101 +		</a>
   1.102 +
   1.103 +		<!-- kuřáci -->
   1.104 +		<a xlink:href="javascript:alert('To čumíš, co? :-)')" xlink:title="Hlasů: ${hlasuAno}">
   1.105 +		    <text x="130" y="195" class="ano">kouřit</text>
   1.106 +		    <rect x="120" y="${180 - (150*hlasuAno/(hlasuAno+hlasuNe))}" width="50" height="${150*hlasuAno/(hlasuAno+hlasuNe)}" class="ano"/>
   1.107 +		</a>
   1.108 +	    </svg>
   1.109 +	</c:when>
   1.110 +	<c:otherwise>
   1.111 +	    <object data="hlasovani-svg.jsp?podnik=${podnik}&amp;amp;hlasuAno=${hlasuAno}&amp;amp;hlasuNe=${hlasuNe}" type="image/svg+xml"/>
   1.112 +	</c:otherwise>
   1.113 +    </c:choose>
   1.114  
   1.115  </jsp:root>
   1.116 \ No newline at end of file