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