Daniel Quathamer
10 months ago
8 changed files with 246 additions and 10 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/freemarker-2.3.25.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/postgresql-42.2.19.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/superx5.0.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/saxon-he-10.5.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib_ext/servlet-api.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/jersey-core-1.11.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/fop-2.2.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/spring-jdbc-3.0.3.RELEASE.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/kettle-core-6.0.0.0-353.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-core-2.16.0.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-1.2-api-2.16.0.jar"/> |
||||
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-api-2.16.0.jar"/> |
||||
<classpathentry kind="output" path="superx/WEB-INF/classes"/> |
||||
</classpath> |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>rpta</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
package de.superx.rpta; |
||||
|
||||
public class SvgProducer { |
||||
|
||||
public static void main(String[] args) { |
||||
// TODO Auto-generated method stub
|
||||
System.out.println(SimpleBarChart("40|110",100,120,50,"#cccccc","steelblue",true)); |
||||
|
||||
} |
||||
/* erzeugt Datenbalken aus "_graph"-Columns, mit Maxvalue Def. |
||||
* Beispielaufruf aus JR: |
||||
* <imageExpression>net.sf.jasperreports.renderers.SimpleDataRenderer.getInstance(de.superx.rpta.SvgProducer.SimpleBarChart($F{männlich},100,149,30,"#cccccc","steelblue",false).getBytes("UTF-8"))</imageExpression> |
||||
* |
||||
*/ |
||||
public static String SimpleBarChart(String barValueStr, double totalValue, double totalWidth, double height,String bgColor, String fgColor,boolean alignLeft) |
||||
{ |
||||
double barValue=0; |
||||
int delim=barValueStr.indexOf("|"); |
||||
if(delim!=0) |
||||
{ |
||||
barValue=Double.valueOf(barValueStr.substring(0, delim)); |
||||
totalValue=Double.valueOf(barValueStr.substring(delim+1)); |
||||
} |
||||
else |
||||
barValue=Double.valueOf(barValueStr); |
||||
|
||||
if(Double.valueOf(totalValue)==null) |
||||
totalValue=100; //percent is default
|
||||
String ret = generateSvg(totalValue, totalWidth, height, bgColor, fgColor, alignLeft, barValue); |
||||
return ret; |
||||
} |
||||
/* erzeugt Datenbalken aus "_graph"-Columns, zum maxValue 100 |
||||
* Beispielaufruf aus JR: |
||||
* <imageExpression>net.sf.jasperreports.renderers.SimpleDataRenderer.getInstance(de.superx.rpta.SvgProducer.SimpleBarChart($F{ Anteil Benutzer an Gesamtzahl (in %) },100,199,30,"#cccccc","steelblue",true).getBytes("UTF-8"))</imageExpression> * |
||||
*/ |
||||
public static String SimpleBarChart(double barValue, double totalValue, double totalWidth, double height,String bgColor, String fgColor,boolean alignLeft) |
||||
{ |
||||
|
||||
if(Double.valueOf(totalValue)==null) |
||||
totalValue=100; //percent is default
|
||||
String ret = generateSvg(totalValue, totalWidth, height, bgColor, fgColor, alignLeft, barValue); |
||||
return ret; |
||||
} |
||||
/* erzeugt svg-Code für Datenbalken aus "_graph"-Columns |
||||
* |
||||
*/ |
||||
private static String generateSvg(double totalValue, double totalWidth, double height, String bgColor, |
||||
String fgColor, boolean alignLeft, double barValue) { |
||||
//Compute width:
|
||||
double barWidth=totalWidth*(barValue/totalValue); |
||||
double x=0; |
||||
if(!alignLeft) |
||||
x=totalWidth-barWidth; //rechtsbündig
|
||||
String ret="<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"px\" height=\""+height+"px\">"; |
||||
//background:
|
||||
ret+="<g><rect x=\"0\" y=\"0\" width=\""+totalWidth+"px\" height=\""+height+"px\" fill=\""+bgColor+"\"><title>"+totalValue+"</title></rect>"; |
||||
|
||||
//foreground:
|
||||
ret+="<rect class=\"chartBar\" width=\""+barWidth+"\" height=\""+(height-1) +"\" x=\""+x+"\" y=\"0\" rx=\"5\" ry=\"5\" fill=\""+fgColor+"\"><title>"+barValue+"</title></rect>"; |
||||
ret+="</g></svg>"; |
||||
return ret; |
||||
} |
||||
|
||||
} |
Binary file not shown.
Loading…
Reference in new issue