java/nekurak.net-web/web/WEB-INF/tags/nekurak/hlasovani.tag
author František Kučera <franta-hg@frantovo.cz>
Tue Apr 27 13:14:23 2010 +0200 (2010-04-27)
changeset 106 6209f3d550c5
parent 58 e019dbc42723
child 107 e8371105fcc8
permissions -rw-r--r--
Hlasování: základ SVG grafu, výpočet. TODO: validita SVG vloženého do 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@106
     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@106
    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@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@106
    13
    <c:if test="${svgUvnitrXhtml == null}">
franta-hg@106
    14
	<c:set var="svgUvnitrXhtml" value="${true}"/>
franta-hg@106
    15
    </c:if>
franta-hg@106
    16
franta-hg@106
    17
    <c:choose>
franta-hg@106
    18
	<c:when test="${svgUvnitrXhtml}">
franta-hg@106
    19
	    <svg width="200" height="200"
franta-hg@106
    20
		 xmlns="http://www.w3.org/2000/svg"
franta-hg@106
    21
		 xmlns:xlink="http://www.w3.org/1999/xlink">
franta-hg@106
    22
franta-hg@106
    23
franta-hg@106
    24
		<style type="text/css">
franta-hg@106
    25
		    rect.ne {
franta-hg@106
    26
			fill:  url(#ne_prechod);
franta-hg@106
    27
			stroke: black;
franta-hg@106
    28
		    }
franta-hg@106
    29
		    rect.ano {
franta-hg@106
    30
			fill: url(#ano_prechod);
franta-hg@106
    31
			stroke: black;
franta-hg@106
    32
		    }
franta-hg@106
    33
franta-hg@106
    34
		    a:hover rect.ano, a:hover rect.ne {
franta-hg@106
    35
			fill: url(#zvyrazneny_prechod);
franta-hg@106
    36
		    }
franta-hg@106
    37
franta-hg@106
    38
		    a:hover text {
franta-hg@106
    39
			fill: green;
franta-hg@106
    40
		    }
franta-hg@106
    41
franta-hg@106
    42
		    line.ramecek {
franta-hg@106
    43
			stroke: black;
franta-hg@106
    44
			stroke-width: 2;
franta-hg@106
    45
		    }
franta-hg@106
    46
franta-hg@106
    47
franta-hg@106
    48
		    rect.pozadi {
franta-hg@106
    49
			fill: url(#pozadi_prechod);
franta-hg@106
    50
		    }
franta-hg@106
    51
franta-hg@106
    52
		    text {
franta-hg@106
    53
			font-size: 12px;
franta-hg@106
    54
			font-family: Sans;
franta-hg@106
    55
		    }
franta-hg@106
    56
franta-hg@106
    57
		</style>
franta-hg@106
    58
franta-hg@106
    59
		<!-- pozadí – přechod -->
franta-hg@106
    60
		<defs>
franta-hg@106
    61
		    <linearGradient id="pozadi_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    62
			<stop offset="0%" style="stop-color:white; stop-opacity:0.5"/>
franta-hg@106
    63
			<stop offset="100%" style="stop-color:silver; stop-opacity:0.8"/>
franta-hg@106
    64
		    </linearGradient>
franta-hg@106
    65
		</defs>
franta-hg@106
    66
franta-hg@106
    67
		<!-- nekuřácký graf – přechod -->
franta-hg@106
    68
		<defs>
franta-hg@106
    69
		    <linearGradient id="ne_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    70
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    71
			<stop offset="100%" style="stop-color:blue; stop-opacity:1"/>
franta-hg@106
    72
		    </linearGradient>
franta-hg@106
    73
		</defs>
franta-hg@106
    74
franta-hg@106
    75
		<!-- zvýrazněný graf – přechod -->
franta-hg@106
    76
		<defs>
franta-hg@106
    77
		    <linearGradient id="zvyrazneny_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    78
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    79
			<stop offset="100%" style="stop-color:green; stop-opacity:1"/>
franta-hg@106
    80
		    </linearGradient>
franta-hg@106
    81
		</defs>
franta-hg@106
    82
franta-hg@106
    83
		<!-- kuřácký graf – přechod -->
franta-hg@106
    84
		<defs>
franta-hg@106
    85
		    <linearGradient id="ano_prechod" x1="0%" y1="0%" x2="100%" y2="100%">
franta-hg@106
    86
			<stop offset="0%" style="stop-color:white; stop-opacity:1"/>
franta-hg@106
    87
			<stop offset="100%" style="stop-color:red; stop-opacity:1"/>
franta-hg@106
    88
		    </linearGradient>
franta-hg@106
    89
		</defs>
franta-hg@106
    90
franta-hg@106
    91
		<!-- pozadí a linka -->
franta-hg@106
    92
		<rect x="0" y="0" width="200" height="200" class="pozadi"/>
franta-hg@106
    93
		<line x1="10" y1="180" x2="190" y2="180" class="ramecek"/>
franta-hg@106
    94
franta-hg@106
    95
		<!-- Nadpis grafu -->
franta-hg@106
    96
		<text x="60" y="20">Mělo by se tu:</text>
franta-hg@106
    97
franta-hg@106
    98
		<!-- nekuřáci -->
franta-hg@106
    99
		<a xlink:href="javascript:alert('To čumíš, co? :-)')" xlink:title="Hlasů: ${hlasuNe}">
franta-hg@106
   100
		    <text x="30" y="195" class="ne">nekouřit</text>
franta-hg@106
   101
		    <rect x="30" y="${180 - (150*hlasuNe/(hlasuAno+hlasuNe))}" width="50" height="${150*hlasuNe/(hlasuAno+hlasuNe)}" class="ne"/>
franta-hg@106
   102
		</a>
franta-hg@106
   103
franta-hg@106
   104
		<!-- kuřáci -->
franta-hg@106
   105
		<a xlink:href="javascript:alert('To čumíš, co? :-)')" xlink:title="Hlasů: ${hlasuAno}">
franta-hg@106
   106
		    <text x="130" y="195" class="ano">kouřit</text>
franta-hg@106
   107
		    <rect x="120" y="${180 - (150*hlasuAno/(hlasuAno+hlasuNe))}" width="50" height="${150*hlasuAno/(hlasuAno+hlasuNe)}" class="ano"/>
franta-hg@106
   108
		</a>
franta-hg@106
   109
	    </svg>
franta-hg@106
   110
	</c:when>
franta-hg@106
   111
	<c:otherwise>
franta-hg@106
   112
	    <object data="hlasovani-svg.jsp?podnik=${podnik}&amp;amp;hlasuAno=${hlasuAno}&amp;amp;hlasuNe=${hlasuNe}" type="image/svg+xml"/>
franta-hg@106
   113
	</c:otherwise>
franta-hg@106
   114
    </c:choose>
franta-hg@58
   115
franta-hg@58
   116
</jsp:root>