# HG changeset patch # User František Kučera # Date 1235866104 -3600 # Node ID be6383d38a3a7266fbb874358be260c6ec21f8ea # Parent 9bb0a26fd6161b6d0fa5ddac51a807738c9615e2 Zobrazujeme graf – zatím s pokusnými daty. Pozor na chybu: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment V konsoli se vypíše: X11 connection rejected because of wrong authentication. Je potřeba přidat tuto volbu: -Djava.awt.headless=true (ve webovém rozhraní GlassFishe a restartovat ho) diff -r 9bb0a26fd616 -r be6383d38a3a java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/grafy/CasovyGrafUtoku.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/grafy/CasovyGrafUtoku.java Sun Mar 01 01:08:24 2009 +0100 @@ -0,0 +1,59 @@ +package cz.frantovo.hrisniciSpameri.grafy; + +import de.laures.cewolf.DatasetProduceException; +import de.laures.cewolf.DatasetProducer; +import de.laures.cewolf.links.CategoryItemLinkGenerator; +import de.laures.cewolf.tooltips.CategoryToolTipGenerator; +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.time.Day; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYDataset; + +/** + * + * @author fiki + */ +public class CasovyGrafUtoku implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable { + + private static final long serialVersionUID = -9133218147909088777L; + + public XYDataset produceDataset(Map params) throws DatasetProduceException { + + System.setProperty("java.awt.headless", "true"); + + TimeSeries timeseries = new TimeSeries("fond", org.jfree.data.time.Day.class); + TimeSeriesCollection dataset = new TimeSeriesCollection(); + + + Calendar datum = Calendar.getInstance(); + for (int i = 0; i < 11; i++) { + datum.add(Calendar.DAY_OF_YEAR, -1); + double nahodneCislo = 100 - 10 * i - 20 * Math.random(); + timeseries.add(new Day(datum.getTime()), nahodneCislo); + } + + dataset.addSeries(timeseries); + return dataset; + } + + public boolean hasExpired(Map params, Date since) { + return (System.currentTimeMillis() - since.getTime()) > 5000; + } + + public String getProducerId() { + return this.getClass().getSimpleName(); + } + + public String generateToolTip(CategoryDataset data, int series, int item) { + return ""; + } + + public String generateLink(Object dataset, int series, Object category) { + return ""; + } +} diff -r 9bb0a26fd616 -r be6383d38a3a java/HrisniciSpameri/web/graf.jspx --- a/java/HrisniciSpameri/web/graf.jspx Sun Mar 01 00:10:46 2009 +0100 +++ b/java/HrisniciSpameri/web/graf.jspx Sun Mar 01 01:08:24 2009 +0100 @@ -1,14 +1,33 @@ -

Graf

+ + + + + + + + + + + + + + + + + + + + + + +