java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag
author František Kučera <franta-hg@frantovo.cz>
Wed Jan 12 16:15:37 2011 +0100 (2011-01-12)
changeset 164 e146e2e3b80b
parent 145 0efefbf5f8b6
permissions -rw-r--r--
Spokojenost: soulad kuřáckosti podniku s výsledky hlasování.
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@164
     9
	<jsp:directive.attribute name="hlasuAno" type="java.lang.Integer" required="true" description="počet hlasů pro ano – aby se tu kouřilo"/>
franta-hg@164
    10
	<jsp:directive.attribute name="hlasuNe" type="java.lang.Integer" required="true" 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
	<c:choose>
franta-hg@145
    19
		<c:when test="${svgUvnitrXhtml}">
franta-hg@145
    20
			<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
franta-hg@145
    21
					 xmlns:xlink="http://www.w3.org/1999/xlink"
franta-hg@145
    22
					 version="1.1" baseProfile="full"
franta-hg@145
    23
					 width="200" height="200">
franta-hg@106
    24
franta-hg@106
    25
franta-hg@145
    26
				<svg:style type="text/css">
franta-hg@145
    27
			rect.ne {
franta-hg@116
    28
			fill:  url(#ne_prechod_${podnik});
franta-hg@106
    29
			stroke: black;
franta-hg@145
    30
			}
franta-hg@145
    31
			rect.ano {
franta-hg@116
    32
			fill: url(#ano_prechod_${podnik});
franta-hg@106
    33
			stroke: black;
franta-hg@145
    34
			}
franta-hg@106
    35
franta-hg@145
    36
			a:hover rect.ano, a:hover rect.ne {
franta-hg@116
    37
			fill: url(#zvyrazneny_prechod_${podnik});
franta-hg@145
    38
			}
franta-hg@106
    39
franta-hg@145
    40
			a:hover text {
franta-hg@106
    41
			fill: green;
franta-hg@145
    42
			}
franta-hg@106
    43
franta-hg@145
    44
			line.ramecek {
franta-hg@106
    45
			stroke: black;
franta-hg@106
    46
			stroke-width: 2;
franta-hg@145
    47
			}
franta-hg@106
    48
franta-hg@106
    49
franta-hg@145
    50
			rect.pozadi {
franta-hg@116
    51
			fill: url(#pozadi_prechod_${podnik});
franta-hg@145
    52
			}
franta-hg@106
    53
franta-hg@145
    54
			text {
franta-hg@106
    55
			font-size: 12px;
franta-hg@106
    56
			font-family: Sans;
franta-hg@145
    57
			}
franta-hg@106
    58
franta-hg@145
    59
				</svg:style>
franta-hg@106
    60
franta-hg@145
    61
				<!-- pozadí – přechod -->
franta-hg@145
    62
				<svg:defs>
franta-hg@145
    63
					<svg:linearGradient id="pozadi_prechod_${podnik}" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@145
    64
						<svg:stop offset="20%" style="stop-color:rgb(245,245,255); stop-opacity:0.5"/>
franta-hg@145
    65
						<svg:stop offset="100%" style="stop-color:silver; stop-opacity:0.8"/>
franta-hg@145
    66
					</svg:linearGradient>
franta-hg@145
    67
				</svg:defs>
franta-hg@106
    68
franta-hg@145
    69
				<!-- nekuřácký graf – přechod -->
franta-hg@145
    70
				<svg:defs>
franta-hg@145
    71
					<svg:linearGradient id="ne_prechod_${podnik}" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@145
    72
						<svg:stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@145
    73
						<svg:stop offset="100%" style="stop-color:blue; stop-opacity:1"/>
franta-hg@145
    74
					</svg:linearGradient>
franta-hg@145
    75
				</svg:defs>
franta-hg@106
    76
franta-hg@145
    77
				<!-- zvýrazněný graf – přechod -->
franta-hg@145
    78
				<svg:defs>
franta-hg@145
    79
					<svg:linearGradient id="zvyrazneny_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:green; stop-opacity:1"/>
franta-hg@145
    82
					</svg:linearGradient>
franta-hg@145
    83
				</svg:defs>
franta-hg@106
    84
franta-hg@145
    85
				<!-- kuřácký graf – přechod -->
franta-hg@145
    86
				<svg:defs>
franta-hg@145
    87
					<svg:linearGradient id="ano_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:red; stop-opacity:1"/>
franta-hg@145
    90
					</svg:linearGradient>
franta-hg@145
    91
				</svg:defs>
franta-hg@106
    92
franta-hg@145
    93
				<!-- pozadí a linka -->
franta-hg@145
    94
				<svg:rect x="0" y="0" width="200" height="200" class="pozadi"/>
franta-hg@145
    95
				<svg:line x1="10" y1="180" x2="190" y2="180" class="ramecek"/>
franta-hg@106
    96
franta-hg@145
    97
				<!-- nadpis grafu -->
franta-hg@145
    98
				<svg:text x="60" y="20"><fmt:message key="hlasovani.graf.nadpis"/>:</svg:text>
franta-hg@106
    99
franta-hg@145
   100
				<!-- žádné hlasy -->
franta-hg@145
   101
				<c:if test="${hlasuAno == 0 &amp;&amp; hlasuNe == 0}">
franta-hg@145
   102
					<svg:text x="30" y="100"><fmt:message key="hlasovani.graf.zadneHlasy"/></svg:text>
franta-hg@145
   103
				</c:if>
franta-hg@107
   104
franta-hg@145
   105
				<!-- vypočteme si výšky sloupců grafu -->
franta-hg@145
   106
				<c:set var="hlasuNeVyska" value="${150*hlasuNe/(hlasuAno+hlasuNe)}"/>
franta-hg@145
   107
				<c:set var="hlasuAnoVyska" value="${150*hlasuAno/(hlasuAno+hlasuNe)}"/>
franta-hg@107
   108
franta-hg@145
   109
				<!-- nekuřáci -->
franta-hg@145
   110
				<fmt:message key="hlasovani.graf.popisSloupce" var="hlasuNeLokalizace">
franta-hg@145
   111
					<fmt:param value="${hlasuNe}"/>
franta-hg@145
   112
				</fmt:message>
franta-hg@145
   113
				<svg:a xlink:href="javascript:hlasovani.hlasuj(${podnik}, false);" xlink:title="${hlasuNeLokalizace}">
franta-hg@145
   114
					<svg:text x="30" y="195" class="ne"><fmt:message key="hlasovani.graf.nekourit"/></svg:text>
franta-hg@145
   115
					<svg:rect x="30" y="${180 - hlasuNeVyska}" width="50" height="${hlasuNeVyska}" class="ne"/>
franta-hg@145
   116
				</svg:a>
franta-hg@106
   117
franta-hg@145
   118
				<!-- kuřáci -->
franta-hg@145
   119
				<fmt:message key="hlasovani.graf.popisSloupce" var="hlasuAnoLokalizace">
franta-hg@145
   120
					<fmt:param value="${hlasuAno}"/>
franta-hg@145
   121
				</fmt:message>
franta-hg@145
   122
				<svg:a xlink:href="javascript:hlasovani.hlasuj(${podnik}, true);" xlink:title="${hlasuAnoLokalizace}">
franta-hg@145
   123
					<svg:text x="130" y="195" class="ano"><fmt:message key="hlasovani.graf.kourit"/></svg:text>
franta-hg@145
   124
					<svg:rect x="120" y="${180 - hlasuAnoVyska}" width="50" height="${hlasuAnoVyska}" class="ano"/>
franta-hg@145
   125
				</svg:a>
franta-hg@145
   126
			</svg:svg>
franta-hg@145
   127
		</c:when>
franta-hg@145
   128
		<c:otherwise>
franta-hg@145
   129
			<object data="hlasovani-svg.jsp?podnik=${podnik}&amp;amp;hlasuAno=${hlasuAno}&amp;amp;hlasuNe=${hlasuNe}" type="image/svg+xml"/>
franta-hg@145
   130
		</c:otherwise>
franta-hg@145
   131
	</c:choose>
franta-hg@58
   132
franta-hg@58
   133
</jsp:root>