changeset 3375:87c0a06743b8

FixA: Overview contains names of the the gauges in the headline. flys-client/trunk@5089 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 20 Jul 2012 14:09:53 +0000
parents 27e455487d66
children 653dd9d7f5d5
files flys-client/ChangeLog flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl
diffstat 2 files changed, 122 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jul 20 10:37:29 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jul 20 14:09:53 2012 +0000
@@ -1,3 +1,10 @@
+2012-07-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl: Merged
+	  changes from transformation in flys-artifacts: Render names
+	  to the gauges into the headline. Full names and spread are
+	  displayed as tooltips.
+
 2012-07-20  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/OverviewOutputTab.java:
--- a/flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl	Fri Jul 20 10:37:29 2012 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl	Fri Jul 20 14:09:53 2012 +0000
@@ -21,9 +21,9 @@
     </xsl:if>
   </xsl:template>
 
-  <xsl:variable name="events-min">
+  <xsl:variable name="global-min">
     <xsl:choose>
-      <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
+      <xsl:when test="count(/fixings/events/event) &gt; 0">
         <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from">
           <xsl:sort data-type="number" select="."/>
         </xsl:apply-templates>
@@ -34,9 +34,9 @@
     </xsl:choose>
   </xsl:variable>
 
-  <xsl:variable name="events-max">
+  <xsl:variable name="global-max">
     <xsl:choose>
-      <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
+      <xsl:when test="count(/fixings/events/event) &gt; 0">
         <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to">
           <xsl:sort data-type="number" select="."/>
         </xsl:apply-templates>
@@ -49,48 +49,97 @@
 
   <xsl:template name="percent">
     <xsl:param name="sector"/>
-    <xsl:variable name="rfrom" select="number($events-min)"/>
-    <xsl:variable name="rto" select="number($events-max)"/>
-    <xsl:variable name="rlength" select="$rto - $rfrom"/>
 
-    <xsl:variable name="sfrom" select="number($sector/@from)"/>
-    <xsl:variable name="sto" select="number($sector/@to)"/>
-    <xsl:variable name="slength" select="$sto - $sfrom"/>
-    <xsl:value-of select="100.0 * ($slength div $rlength)"/>
+    <xsl:variable name="start">
+      <xsl:choose>
+        <xsl:when test="number($sector/@from) &lt; $global-min">
+          <xsl:value-of select="$global-min"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="number($sector/@from)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:variable name="end">
+      <xsl:choose>
+        <xsl:when test="number($sector/@to) &gt; $global-max">
+          <xsl:value-of select="$global-max"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="number($sector/@to)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:choose>
+      <xsl:when test="$end &lt; $start">
+        <xsl:value-of select="number(0)"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="100.0 * (($end - $start) div ($global-max - $global-min))"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="emit-gap-gauge">
+    <xsl:param name="gauge"/>
+    <xsl:call-template name="internal-emit-gap">
+      <xsl:with-param name="sector" select="$gauge"/>
+      <xsl:with-param name="preds" select="$gauge/preceding-sibling::gauge"/>
+    </xsl:call-template>
   </xsl:template>
 
   <xsl:template name="emit-gap">
     <xsl:param name="sector"/>
-    <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/>
-    <xsl:variable name="num-preds" select="count($preds)"/>
-    <xsl:variable name="glength">
+    <xsl:call-template name="internal-emit-gap">
+      <xsl:with-param name="sector" select="$sector"/>
+      <xsl:with-param name="preds" select="$sector/preceding-sibling::sector"/>
+    </xsl:call-template>
+  </xsl:template>
+
+  <xsl:template name="internal-emit-gap">
+    <xsl:param name="sector"/>
+    <xsl:param name="preds"/>
+
+    <xsl:variable name="start">
       <xsl:choose>
-        <xsl:when test="$num-preds &lt; 1">
-          <xsl:variable name="rfrom" select="number($events-min)"/>
-          <xsl:value-of select="number($sector/@from) - $rfrom"/>
+        <xsl:when test="number($sector/@from) &lt; $global-min">
+          <xsl:value-of select="$global-min"/>
         </xsl:when>
         <xsl:otherwise>
-          <xsl:variable name="bend" select="number($preds[last()]/@to)"/>
-          <xsl:value-of select="number($sector/@from) - $bend"/>
+          <xsl:value-of select="$sector/@from"/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
-    <xsl:choose>
-      <xsl:when test="number($glength) &lt; 0.05 "/>
-      <xsl:otherwise>
-        <div>
-          <xsl:attribute name="style">
-            <xsl:text>width:</xsl:text>
-              <xsl:variable name="rfrom" select="number($events-min)"/>
-              <xsl:variable name="rto" select="number($events-max)"/>
-              <xsl:variable name="rlength" select="$rto - $rfrom"/>
-              <xsl:value-of select="100.0 * ($glength div $rlength)"/>
-            <xsl:text>%;float:left</xsl:text>
-          </xsl:attribute>
-          <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
-        </div>
-      </xsl:otherwise>
-    </xsl:choose>
+
+    <xsl:if test="$start &lt; $global-max">
+      <xsl:variable name="num-preds" select="count($preds)"/>
+      <xsl:variable name="prev-end">
+        <xsl:choose>
+          <xsl:when test="count($preds) &lt; 1">
+            <xsl:value-of select="$global-min"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="number($preds[last()]/@to)"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
+      <xsl:if test="$prev-end &lt; $global-max">
+        <xsl:variable name="gap-len" select="$start - $prev-end"/>
+        <xsl:if test="$gap-len &gt; 0.005">
+          <div>
+            <xsl:attribute name="style">
+              <xsl:text>width:</xsl:text>
+                <xsl:value-of select="100.0 * ($gap-len div ($global-max - $global-min))"/>
+              <xsl:text>%;float:left</xsl:text>
+            </xsl:attribute>
+            <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
+          </div>
+        </xsl:if>
+      </xsl:if>
+    </xsl:if>
   </xsl:template>
 
   <xsl:template match="sector" mode="sectors">
@@ -147,6 +196,35 @@
     </tr>
   </xsl:template>
 
+  <xsl:template match="gauge" mode="gauges">
+    <xsl:call-template name="emit-gap-gauge">
+      <xsl:with-param name="gauge" select="."/>
+    </xsl:call-template>
+    <div>
+      <xsl:attribute name="style">
+        <xsl:text>overflow:hidden;background:</xsl:text>
+        <xsl:choose>
+          <xsl:when test="(count(preceding::*) mod  2) = 0">#ada96e</xsl:when>
+          <xsl:otherwise>gray</xsl:otherwise>
+        </xsl:choose>
+        <xsl:text>;width:</xsl:text>
+        <xsl:call-template name="percent">
+          <xsl:with-param name="sector" select="."/>
+        </xsl:call-template>
+        <xsl:text>%</xsl:text>
+        <xsl:text>;float:left</xsl:text>
+      </xsl:attribute>
+      <xsl:attribute name="title">
+        <xsl:value-of select="@name"/>
+        <xsl:text>: km </xsl:text>
+        <xsl:value-of select="@from"/>
+        <xsl:text> - </xsl:text>
+        <xsl:value-of select="@to"/>
+      </xsl:attribute>
+      <nobr><xsl:value-of select="@name"/></nobr>
+    </div>
+  </xsl:template>
+
   <xsl:template match="events">
     <table width="97%" border="1" cellspacing="0" cellpadding="0"
            style="font-size: 10pt;font-family:Arial;Verdana,sans-serif">
@@ -161,7 +239,7 @@
         <xsl:if test="$render-checkboxes">
           <th>&#160;</th>
         </xsl:if>
-        <th>km <xsl:value-of select="$events-min"/> - <xsl:value-of select="$events-max"/></th>
+        <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th>
         <th>Ereignis</th>
       </tr>
       <xsl:apply-templates/>
@@ -210,5 +288,6 @@
 
   <xsl:template match="text()"/>
   <xsl:template match="text()" mode="sectors"/>
+  <xsl:template match="text()" mode="gauges"/>
 
 </xsl:stylesheet>

http://dive4elements.wald.intevation.org