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