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