java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag
author František Kučera <franta-hg@frantovo.cz>
Wed Apr 28 00:22:30 2010 +0200 (2010-04-28)
changeset 113 55af119b8c2b
parent 112 b139d35b4faf
child 116 6d9647a51193
permissions -rw-r--r--
SVG…
franta-hg@58
     1
<?xml version="1.0" encoding="UTF-8"?>
franta-hg@58
     2
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
franta-hg@58
     3
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
franta-hg@58
     4
	  xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
franta-hg@58
     5
	  xmlns:fn="http://java.sun.com/jsp/jstl/functions"
franta-hg@58
     6
	  version="2.0">
franta-hg@58
     7
franta-hg@58
     8
    <jsp:directive.attribute name="podnik" type="java.lang.Integer" required="true" description="ID podniku"/>
franta-hg@107
     9
    <jsp:directive.attribute name="hlasuAno" type="java.lang.Integer" required="false" description="počet hlasů pro ano – aby se tu kouřilo"/>
franta-hg@107
    10
    <jsp:directive.attribute name="hlasuNe" type="java.lang.Integer" required="false" description="počet hlasů pro ne – aby se tu nekouřilo"/>
franta-hg@106
    11
    <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;"/>
franta-hg@58
    12
franta-hg@107
    13
    <!-- výchozí hodnota -->
franta-hg@106
    14
    <c:if test="${svgUvnitrXhtml == null}">
franta-hg@106
    15
	<c:set var="svgUvnitrXhtml" value="${true}"/>
franta-hg@106
    16
    </c:if>
franta-hg@106
    17
franta-hg@107
    18
    <!-- hodnoty nejsou uvedeny → načteme si je -->
franta-hg@108
    19
    <c:if test="${hlasuAno == null || hlasuNe == null || (hlasuAno == 0 &amp;&amp; hlasuNe == 0)}">
franta-hg@107
    20
	<jsp:useBean id="hlasovani" class="cz.frantovo.nekurak.web.Hlasovani" scope="request"/>
franta-hg@107
    21
	<jsp:setProperty name="hlasovani" property="podnik" value="${podnik}"/>
franta-hg@107
    22
	<c:set var="hlasuAno" value="${hlasovani.vysledek.hlasuAno}"/>
franta-hg@107
    23
	<c:set var="hlasuNe" value="${hlasovani.vysledek.hlasuNe}"/>
franta-hg@107
    24
    </c:if>
franta-hg@107
    25
franta-hg@106
    26
    <c:choose>
franta-hg@106
    27
	<c:when test="${svgUvnitrXhtml}">
franta-hg@113
    28
	    <svg xmlns="http://www.w3.org/2000/svg"
franta-hg@112
    29
		 xmlns:xlink="http://www.w3.org/1999/xlink"
franta-hg@112
    30
		 width="200" height="200">
franta-hg@106
    31
franta-hg@106
    32
franta-hg@106
    33
		<style type="text/css">
franta-hg@106
    34
		    rect.ne {
franta-hg@106
    35
			fill:  url(#ne_prechod);
franta-hg@106
    36
			stroke: black;
franta-hg@106
    37
		    }
franta-hg@106
    38
		    rect.ano {
franta-hg@106
    39
			fill: url(#ano_prechod);
franta-hg@106
    40
			stroke: black;
franta-hg@106
    41
		    }
franta-hg@106
    42
franta-hg@106
    43
		    a:hover rect.ano, a:hover rect.ne {
franta-hg@106
    44
			fill: url(#zvyrazneny_prechod);
franta-hg@106
    45
		    }
franta-hg@106
    46
franta-hg@106
    47
		    a:hover text {
franta-hg@106
    48
			fill: green;
franta-hg@106
    49
		    }
franta-hg@106
    50
franta-hg@106
    51
		    line.ramecek {
franta-hg@106
    52
			stroke: black;
franta-hg@106
    53
			stroke-width: 2;
franta-hg@106
    54
		    }
franta-hg@106
    55
franta-hg@106
    56
franta-hg@106
    57
		    rect.pozadi {
franta-hg@106
    58
			fill: url(#pozadi_prechod);
franta-hg@106
    59
		    }
franta-hg@106
    60
franta-hg@106
    61
		    text {
franta-hg@106
    62
			font-size: 12px;
franta-hg@106
    63
			font-family: Sans;
franta-hg@106
    64
		    }
franta-hg@106
    65
franta-hg@106
    66
		</style>
franta-hg@106
    67
franta-hg@106
    68
		<!-- pozadí – přechod -->
franta-hg@106
    69
		<defs>
franta-hg@106
    70
		    <linearGradient id="pozadi_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@107
    71
			<stop offset="20%" style="stop-color:rgb(245,245,255); stop-opacity:0.5"/>
franta-hg@106
    72
			<stop offset="100%" style="stop-color:silver; stop-opacity:0.8"/>
franta-hg@106
    73
		    </linearGradient>
franta-hg@106
    74
		</defs>
franta-hg@106
    75
franta-hg@106
    76
		<!-- nekuřácký graf – přechod -->
franta-hg@106
    77
		<defs>
franta-hg@106
    78
		    <linearGradient id="ne_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    79
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    80
			<stop offset="100%" style="stop-color:blue; stop-opacity:1"/>
franta-hg@106
    81
		    </linearGradient>
franta-hg@106
    82
		</defs>
franta-hg@106
    83
franta-hg@106
    84
		<!-- zvýrazněný graf – přechod -->
franta-hg@106
    85
		<defs>
franta-hg@106
    86
		    <linearGradient id="zvyrazneny_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    87
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    88
			<stop offset="100%" style="stop-color:green; stop-opacity:1"/>
franta-hg@106
    89
		    </linearGradient>
franta-hg@106
    90
		</defs>
franta-hg@106
    91
franta-hg@106
    92
		<!-- kuřácký graf – přechod -->
franta-hg@106
    93
		<defs>
franta-hg@106
    94
		    <linearGradient id="ano_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    95
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    96
			<stop offset="100%" style="stop-color:red; stop-opacity:1"/>
franta-hg@106
    97
		    </linearGradient>
franta-hg@106
    98
		</defs>
franta-hg@106
    99
franta-hg@106
   100
		<!-- pozadí a linka -->
franta-hg@106
   101
		<rect x="0" y="0" width="200" height="200" class="pozadi"/>
franta-hg@106
   102
		<line x1="10" y1="180" x2="190" y2="180" class="ramecek"/>
franta-hg@106
   103
franta-hg@107
   104
		<!-- nadpis grafu -->
franta-hg@111
   105
		<text x="60" y="20"><fmt:message key="hlasovani.graf.nadpis"/>:</text>
franta-hg@106
   106
franta-hg@107
   107
		<!-- žádné hlasy -->
franta-hg@107
   108
		<c:if test="${hlasuAno == 0 &amp;&amp; hlasuNe == 0}">
franta-hg@111
   109
		    <text x="30" y="100"><fmt:message key="hlasovani.graf.zadneHlasy"/></text>
franta-hg@107
   110
		</c:if>
franta-hg@107
   111
franta-hg@107
   112
		<!-- vypočteme si výšky sloupců grafu -->
franta-hg@107
   113
		<c:set var="hlasuNeVyska" value="${150*hlasuNe/(hlasuAno+hlasuNe)}"/>
franta-hg@107
   114
		<c:set var="hlasuAnoVyska" value="${150*hlasuAno/(hlasuAno+hlasuNe)}"/>
franta-hg@107
   115
franta-hg@106
   116
		<!-- nekuřáci -->
franta-hg@111
   117
		<fmt:message key="hlasovani.graf.popisSloupce" var="hlasuNeLokalizace">
franta-hg@111
   118
		    <fmt:param value="${hlasuNe}"/>
franta-hg@111
   119
		</fmt:message>
franta-hg@111
   120
		<a xlink:href="javascript:hlasovani.hlasuj(${podnik}, false);" xlink:title="${hlasuNeLokalizace}">
franta-hg@112
   121
		    <text x="30" y="195" class="ne"><fmt:message key="hlasovani.graf.nekourit"/></text>
franta-hg@107
   122
		    <rect x="30" y="${180 - hlasuNeVyska}" width="50" height="${hlasuNeVyska}" class="ne"/>
franta-hg@106
   123
		</a>
franta-hg@106
   124
franta-hg@106
   125
		<!-- kuřáci -->
franta-hg@111
   126
		<fmt:message key="hlasovani.graf.popisSloupce" var="hlasuAnoLokalizace">
franta-hg@111
   127
		    <fmt:param value="${hlasuAno}"/>
franta-hg@111
   128
		</fmt:message>
franta-hg@111
   129
		<a xlink:href="javascript:hlasovani.hlasuj(${podnik}, true);" xlink:title="${hlasuAnoLokalizace}">
franta-hg@112
   130
		    <text x="130" y="195" class="ano"><fmt:message key="hlasovani.graf.kourit"/></text>
franta-hg@107
   131
		    <rect x="120" y="${180 - hlasuAnoVyska}" width="50" height="${hlasuAnoVyska}" class="ano"/>
franta-hg@106
   132
		</a>
franta-hg@106
   133
	    </svg>
franta-hg@106
   134
	</c:when>
franta-hg@106
   135
	<c:otherwise>
franta-hg@106
   136
	    <object data="hlasovani-svg.jsp?podnik=${podnik}&amp;amp;hlasuAno=${hlasuAno}&amp;amp;hlasuNe=${hlasuNe}" type="image/svg+xml"/>
franta-hg@106
   137
	</c:otherwise>
franta-hg@106
   138
    </c:choose>
franta-hg@58
   139
franta-hg@58
   140
</jsp:root>