List of usage examples for org.jfree.data.time TimeSeries add
public void add(RegularTimePeriod period, Number value)
From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java
public void updateChart(List<TribeStatsElement> pElems) { chart = null;//from ww w. j a v a 2 s. c o m startPointer = null; endPointer = null; int idx = jViewSelectionBox.getSelectedIndex(); if (idx == 0) { TimeSeriesCollection pointsDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries pointSeries = new TimeSeries("Punkte (" + elem.getTribe().getName() + ")"); // TimeSeries pointSeries2 = new TimeSeries("Punkte2 (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Long[] points = elem.getPoints(); for (int i = 0; i < timestamps.length; i++) { pointSeries.add(new Second(new Date(timestamps[i])), points[i]); } pointsDataset.addSeries(pointSeries); } addDataset("Punkte", pointsDataset); } else if (idx == 1) { TimeSeriesCollection rankDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries rankSeries = new TimeSeries("Rang (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Integer[] ranks = elem.getRanks(); for (int i = 0; i < timestamps.length; i++) { rankSeries.add(new Second(new Date(timestamps[i])), ranks[i]); } rankDataset.addSeries(rankSeries); } addDataset("Rang", rankDataset); } else if (idx == 2) { TimeSeriesCollection villageDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries villageSeries = new TimeSeries("Drfer (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Short[] villages = elem.getVillages(); for (int i = 0; i < timestamps.length; i++) { villageSeries.add(new Second(new Date(timestamps[i])), villages[i]); } villageDataset.addSeries(villageSeries); } addDataset("Drfer", villageDataset); } else if (idx == 3) { TimeSeriesCollection killsOffDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries bashOffSeries = new TimeSeries("Kills (Off) (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Long[] bashOff = elem.getBashOffPoints(); for (int i = 0; i < timestamps.length; i++) { bashOffSeries.add(new Second(new Date(timestamps[i])), bashOff[i]); } killsOffDataset.addSeries(bashOffSeries); } addDataset("Kills (Off)", killsOffDataset); } else if (idx == 4) { TimeSeriesCollection rankOffDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries rankOffSeries = new TimeSeries("Rang (Off) (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Short[] rankOff = elem.getBashOffRank(); for (int i = 0; i < timestamps.length; i++) { rankOffSeries.add(new Second(new Date(timestamps[i])), rankOff[i]); } rankOffDataset.addSeries(rankOffSeries); } addDataset("Rang (Off)", rankOffDataset); } else if (idx == 5) { TimeSeriesCollection killsDefDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries bashDefSeries = new TimeSeries("Kills (Def) (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Long[] bashDef = elem.getBashDefPoints(); for (int i = 0; i < timestamps.length; i++) { bashDefSeries.add(new Second(new Date(timestamps[i])), bashDef[i]); } killsDefDataset.addSeries(bashDefSeries); } addDataset("Kills (Def)", killsDefDataset); } else if (idx == 6) { TimeSeriesCollection rankDefDataset = new TimeSeriesCollection(); for (TribeStatsElement elem : pElems) { TimeSeries rankDefSeries = new TimeSeries("Rang (Def) (" + elem.getTribe().getName() + ")"); Long[] timestamps = elem.getTimestamps(); Short[] rankDef = elem.getBashDefRank(); for (int i = 0; i < timestamps.length; i++) { rankDefSeries.add(new Second(new Date(timestamps[i])), rankDef[i]); } rankDefDataset.addSeries(rankDefSeries); } addDataset("Rang (Def)", rankDefDataset); } jChartPanel.removeAll(); theChartPanel = new ChartPanel(chart); theChartPanel.setDisplayToolTips(true); theChartPanel.setMouseWheelEnabled(true); jChartPanel.add(theChartPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jChartPanel.updateUI(); } }); }
From source file:fmiquerytest.Coordinates.java
static String drawTempRainChart(List<stepWeather> stepDataBase, Map routeWeather) { //First, fetch the real data List<Double> times = new ArrayList<>(); List<Double> temps = new ArrayList<>(); List<Double> rains = new ArrayList<>(); List<Double> lights = new ArrayList<>(); for (int i = 0; i < stepDataBase.size(); ++i) { stepWeather step = stepDataBase.get(i); stepWeather nextstep = step;//from w ww . j ava 2 s . co m if (i < stepDataBase.size() - 1) { nextstep = stepDataBase.get(i + 1); } times.add(step.timeAsDouble); temps.add(getParameterAverage(routeWeather, step, nextstep, "Temperature")); rains.add(getParameterAverage(routeWeather, step, nextstep, "Precipitation1h")); lights.add(Math.pow(Math.abs(step.timeAsDouble % 24 - ((step.sunRise + step.sunSet) / 2)) / ((step.sunSet - step.sunRise) / 2), 5)); } double zeroPoint = times.get(0); // Make first dataset final TimeSeriesCollection dataset = new TimeSeriesCollection(); final TimeSeries s1 = new TimeSeries("Temperature C", Minute.class); // Make second dataset final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); final TimeSeries s2 = new TimeSeries("Rain (mm)", Minute.class); // Make third dataset //final TimeSeriesCollection dataset3 = new TimeSeriesCollection(); final TimeSeries s3 = new TimeSeries("Darkness", Minute.class); // Show data per minute RegularTimePeriod start = new Minute(new Date(FmiQueryTest.startTimeMillis)); for (int i = 0; i < times.size() - 1; ++i) { double time = times.get(i); double nexttime = times.get(i + 1); int firstMinute = intValue((time - zeroPoint) * 60); int currentMinute = firstMinute; int lastMinute = intValue((nexttime - zeroPoint) * 60); while (currentMinute < lastMinute) { s1.add(start, temps.get(i) + ((double) currentMinute - firstMinute) / (lastMinute - firstMinute) * (temps.get(i + 1) - temps.get(i))); s2.add(start, (rains.get(i) + rains.get(i + 1)) / 2); //+((double)currentMinute-firstMinute)/(lastMinute-firstMinute)*(rains.get(i+1)-rains.get(i))); s3.add(start, lights.get(i) + ((double) currentMinute - firstMinute) / (lastMinute - firstMinute) * (lights.get(i + 1) - lights.get(i))); ++currentMinute; start = start.next(); } } dataset.addSeries(s1); dataset2.addSeries(s3); dataset2.addSeries(s2); // Initialize chart final JFreeChart chart = ChartFactory.createTimeSeriesChart("Temperature and rain", "Time", "Temperature C", dataset, true, // legend? true, // tooltips? false // URLs? ); final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); // configure the range axis to display first dataset... final ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis(); rangeAxis.setRange(-30, 30); final TickUnits units = new TickUnits(); units.add(new NumberTickUnit(10.0)); units.add(new NumberTickUnit(1.0)); units.add(new NumberTickUnit(0.1)); rangeAxis.setStandardTickUnits(units); //rangeAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 16)); // add the secondary dataset/renderer/axis plot.setRangeAxis(rangeAxis); final XYItemRenderer renderer2 = new XYAreaRenderer(); final ValueAxis axis2 = new NumberAxis("Rain (mm) "); axis2.setRange(0, 2); axis2.setStandardTickUnits(units); //axis2.setTickLabelFont(new Font("SansSerif", Font.BOLD, 16)); renderer2.setSeriesPaint(0, new Color(0, 0, 255, 128)); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setRangeAxis(1, axis2); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer3 = new XYAreaRenderer(); renderer3.setSeriesPaint(0, new Color(0, 0, 0, 64)); //plot.setDataset(1, dataset2); plot.setRenderer(1, renderer3); plot.setRangeAxis(1, axis2); plot.mapDatasetToRangeAxis(1, 1); chart.setBackgroundPaint(Color.white); //plot.setBackgroundPaint(Color.lightGray); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); // final TextTitle subtitle = new TextTitle("An area chart demonstration. We use this " // + "subtitle as an example of what happens when you get a really long title or " // + "subtitle."); // subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); // subtitle.setPosition(RectangleEdge.TOP); //// subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05)); // subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM); // chart.addSubtitle(subtitle); // Produce chart // ChartFrame frame = new ChartFrame("Tamperature and rain", chart); // frame.pack(); // RefineryUtilities.centerFrameOnScreen(frame); // frame.setVisible(true); ByteArrayOutputStream bas = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(bas, chart, 600, 400); } catch (IOException ex) { Logger.getLogger(WeatherTools.class.getName()).log(Level.SEVERE, null, ex); } byte[] byteArray = bas.toByteArray(); String baseCode = Base64.encode(byteArray); return "<img width=\"480\" alt=\"Temperature and rain\" src=\"data:image/png;base64," + baseCode.trim() + "\" />"; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getDailyLoginsDataSet() { List<ServerWideStatsRecord> totalLogins = getDailyTotalLogins(); List<ServerWideStatsRecord> uniqueLogins = getDailyUniqueLogins(); if (totalLogins == null || uniqueLogins == null) { return null; }// ww w . ja v a 2s.c om TimeSeries s1 = new TimeSeries(msgs.getString("legend_logins"), Day.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_unique_logins"), Day.class); for (ServerWideStatsRecord login : totalLogins) { Day day = new Day((Date) login.get(0)); s1.add(day, (Long) login.get(1)); } for (ServerWideStatsRecord login : uniqueLogins) { Day day = new Day((Date) login.get(0)); s2.add(day, (Long) login.get(1)); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); TimeSeries mavS1 = MovingAverage.createMovingAverage(s1, "7 day login moving average", 7, 7); dataset.addSeries(mavS1); TimeSeries mavS2 = MovingAverage.createMovingAverage(s2, "7 day unique login moving average", 7, 7); dataset.addSeries(mavS2); return dataset; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getWeeklyLoginsDataSet() { List<ServerWideStatsRecord> totalLogins = getWeeklyTotalLogins(); List<ServerWideStatsRecord> uniqueLogins = getWeeklyUniqueLogins(); if (totalLogins == null || uniqueLogins == null) { return null; }/* ww w.j ava2 s . c o m*/ TimeSeries s1 = new TimeSeries(msgs.getString("legend_logins"), Week.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_unique_logins"), Week.class); for (ServerWideStatsRecord login : totalLogins) { Week week = new Week((Date) login.get(0)); s1.add(week, (Long) login.get(1)); } for (ServerWideStatsRecord login : uniqueLogins) { Week week = new Week((Date) login.get(0)); s2.add(week, (Long) login.get(1)); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getMonthlyLoginsDataSet() { List<ServerWideStatsRecord> totalLogins = getMonthlyTotalLogins(); List<ServerWideStatsRecord> uniqueLogins = getMonthlyUniqueLogins(); if (totalLogins == null || uniqueLogins == null) { return null; }// w ww. jav a 2 s .c o m TimeSeries s1 = new TimeSeries(msgs.getString("legend_logins"), Month.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_unique_logins"), Month.class); for (ServerWideStatsRecord login : totalLogins) { Month month = new Month((Date) login.get(0)); s1.add(month, (Long) login.get(1)); } for (ServerWideStatsRecord login : uniqueLogins) { Month month = new Month((Date) login.get(0)); s2.add(month, (Long) login.get(1)); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Creates a test dataset.//from w w w .j a v a2s .co m * * @return the dataset. */ public static XYDataset createDummyDataset() { final TimeSeries s1 = new TimeSeries("Channel 0 23.4kHz", Second.class); s1.add(new Second(new Date(1110400770000L)), 178); s1.add(new Second(new Date(1110401020000L)), 182); s1.add(new Second(new Date(1110401270000L)), 172); s1.add(new Second(new Date(1110401520000L)), 173); s1.add(new Second(new Date(1110401770000L)), 164); s1.add(new Second(new Date(1110402080000L)), 148); s1.add(new Second(new Date(1110402330000L)), 159); s1.add(new Second(new Date(1110402580000L)), 162); s1.add(new Second(new Date(1110402830000L)), 171); s1.add(new Second(new Date(1110403080000L)), 175); s1.add(new Second(new Date(1110403330000L)), 175); s1.add(new Second(new Date(1110403580000L)), 169); s1.add(new Second(new Date(1110403830000L)), 176); s1.add(new Second(new Date(1110404080000L)), 181); s1.add(new Second(new Date(1110404330000L)), 184); s1.add(new Second(new Date(1110404580000L)), 169); s1.add(new Second(new Date(1110404830000L)), 165); s1.add(new Second(new Date(1110405080000L)), 163); s1.add(new Second(new Date(1110405330000L)), 149); s1.add(new Second(new Date(1110405580000L)), 150); s1.add(new Second(new Date(1110405830000L)), 163); s1.add(new Second(new Date(1110406080000L)), 164); s1.add(new Second(new Date(1110406330000L)), 161); s1.add(new Second(new Date(1110406580000L)), 169); s1.add(new Second(new Date(1110406830000L)), 170); s1.add(new Second(new Date(1110407080000L)), 167); s1.add(new Second(new Date(1110407330000L)), 167); s1.add(new Second(new Date(1110407580000L)), 187); s1.add(new Second(new Date(1110407830000L)), 195); s1.add(new Second(new Date(1110408080000L)), 207); s1.add(new Second(new Date(1110408330000L)), 200); s1.add(new Second(new Date(1110408580000L)), 185); s1.add(new Second(new Date(1110408830000L)), 179); s1.add(new Second(new Date(1110409080000L)), 172); s1.add(new Second(new Date(1110409330000L)), 196); s1.add(new Second(new Date(1110409580000L)), 233); s1.add(new Second(new Date(1110409830000L)), 218); s1.add(new Second(new Date(1110410080000L)), 217); s1.add(new Second(new Date(1110410330000L)), 198); s1.add(new Second(new Date(1110410580000L)), 196); s1.add(new Second(new Date(1110410830000L)), 183); s1.add(new Second(new Date(1110411080000L)), 170); s1.add(new Second(new Date(1110411330000L)), 155); s1.add(new Second(new Date(1110411580000L)), 167); s1.add(new Second(new Date(1110411830000L)), 166); s1.add(new Second(new Date(1110412080000L)), 184); s1.add(new Second(new Date(1110412330000L)), 199); s1.add(new Second(new Date(1110412580000L)), 194); s1.add(new Second(new Date(1110412830000L)), 185); s1.add(new Second(new Date(1110413080000L)), 181); s1.add(new Second(new Date(1110413330000L)), 171); s1.add(new Second(new Date(1110413580000L)), 163); s1.add(new Second(new Date(1110413830000L)), 169); s1.add(new Second(new Date(1110414080000L)), 162); s1.add(new Second(new Date(1110414330000L)), 173); s1.add(new Second(new Date(1110414580000L)), 160); s1.add(new Second(new Date(1110414830000L)), 147); s1.add(new Second(new Date(1110415080000L)), 151); s1.add(new Second(new Date(1110415330000L)), 179); s1.add(new Second(new Date(1110415580000L)), 192); s1.add(new Second(new Date(1110415830000L)), 180); s1.add(new Second(new Date(1110416080000L)), 159); s1.add(new Second(new Date(1110416330000L)), 164); s1.add(new Second(new Date(1110416580000L)), 178); s1.add(new Second(new Date(1110416830000L)), 163); s1.add(new Second(new Date(1110417080000L)), 157); s1.add(new Second(new Date(1110417330000L)), 152); s1.add(new Second(new Date(1110417580000L)), 148); s1.add(new Second(new Date(1110417830000L)), 162); s1.add(new Second(new Date(1110418080000L)), 176); s1.add(new Second(new Date(1110418330000L)), 168); s1.add(new Second(new Date(1110418580000L)), 167); s1.add(new Second(new Date(1110418830000L)), 170); s1.add(new Second(new Date(1110419080000L)), 161); s1.add(new Second(new Date(1110419330000L)), 150); s1.add(new Second(new Date(1110419580000L)), 157); s1.add(new Second(new Date(1110419830000L)), 164); s1.add(new Second(new Date(1110420080000L)), 156); s1.add(new Second(new Date(1110420330000L)), 155); s1.add(new Second(new Date(1110420580000L)), 150); s1.add(new Second(new Date(1110420830000L)), 160); s1.add(new Second(new Date(1110421080000L)), 168); s1.add(new Second(new Date(1110421330000L)), 160); s1.add(new Second(new Date(1110421580000L)), 162); s1.add(new Second(new Date(1110421830000L)), 152); s1.add(new Second(new Date(1110422080000L)), 148); s1.add(new Second(new Date(1110422330000L)), 141); s1.add(new Second(new Date(1110422580000L)), 140); s1.add(new Second(new Date(1110422830000L)), 145); s1.add(new Second(new Date(1110423080000L)), 152); s1.add(new Second(new Date(1110423330000L)), 152); s1.add(new Second(new Date(1110423580000L)), 143); s1.add(new Second(new Date(1110423830000L)), 164); s1.add(new Second(new Date(1110424080000L)), 177); s1.add(new Second(new Date(1110424330000L)), 161); s1.add(new Second(new Date(1110424580000L)), 166); s1.add(new Second(new Date(1110424830000L)), 177); s1.add(new Second(new Date(1110425080000L)), 177); s1.add(new Second(new Date(1110425330000L)), 183); s1.add(new Second(new Date(1110425580000L)), 196); s1.add(new Second(new Date(1110425830000L)), 198); s1.add(new Second(new Date(1110426080000L)), 197); s1.add(new Second(new Date(1110426330000L)), 189); s1.add(new Second(new Date(1110426580000L)), 201); s1.add(new Second(new Date(1110426830000L)), 193); s1.add(new Second(new Date(1110427080000L)), 200); s1.add(new Second(new Date(1110427330000L)), 210); s1.add(new Second(new Date(1110427580000L)), 214); s1.add(new Second(new Date(1110427830000L)), 204); s1.add(new Second(new Date(1110428080000L)), 196); s1.add(new Second(new Date(1110428330000L)), 199); s1.add(new Second(new Date(1110428580000L)), 202); s1.add(new Second(new Date(1110428830000L)), 215); s1.add(new Second(new Date(1110429080000L)), 220); s1.add(new Second(new Date(1110429330000L)), 236); s1.add(new Second(new Date(1110429580000L)), 238); s1.add(new Second(new Date(1110429830000L)), 246); s1.add(new Second(new Date(1110430080000L)), 240); s1.add(new Second(new Date(1110430330000L)), 242); s1.add(new Second(new Date(1110430580000L)), 232); s1.add(new Second(new Date(1110430830000L)), 233); s1.add(new Second(new Date(1110431080000L)), 233); s1.add(new Second(new Date(1110431330000L)), 227); s1.add(new Second(new Date(1110431580000L)), 199); s1.add(new Second(new Date(1110431830000L)), 218); s1.add(new Second(new Date(1110432080000L)), 212); s1.add(new Second(new Date(1110432330000L)), 220); s1.add(new Second(new Date(1110432580000L)), 205); s1.add(new Second(new Date(1110432830000L)), 188); s1.add(new Second(new Date(1110433080000L)), 185); s1.add(new Second(new Date(1110433330000L)), 172); s1.add(new Second(new Date(1110433580000L)), 168); s1.add(new Second(new Date(1110433830000L)), 173); s1.add(new Second(new Date(1110434080000L)), 175); s1.add(new Second(new Date(1110434330000L)), 160); s1.add(new Second(new Date(1110434580000L)), 138); s1.add(new Second(new Date(1110434830000L)), 112); s1.add(new Second(new Date(1110435080000L)), 89); s1.add(new Second(new Date(1110435330000L)), 72); s1.add(new Second(new Date(1110435580000L)), 54); s1.add(new Second(new Date(1110435830000L)), 44); s1.add(new Second(new Date(1110436080000L)), 51); s1.add(new Second(new Date(1110436330000L)), 77); s1.add(new Second(new Date(1110436580000L)), 105); s1.add(new Second(new Date(1110436830000L)), 126); s1.add(new Second(new Date(1110437080000L)), 136); s1.add(new Second(new Date(1110437330000L)), 142); s1.add(new Second(new Date(1110437580000L)), 152); s1.add(new Second(new Date(1110437830000L)), 153); s1.add(new Second(new Date(1110438080000L)), 141); s1.add(new Second(new Date(1110438330000L)), 127); s1.add(new Second(new Date(1110438580000L)), 17); s1.add(new Second(new Date(1110438830000L)), 18); s1.add(new Second(new Date(1110439080000L)), 18); s1.add(new Second(new Date(1110439330000L)), 18); s1.add(new Second(new Date(1110439580000L)), 18); s1.add(new Second(new Date(1110439830000L)), 18); s1.add(new Second(new Date(1110440080000L)), 19); s1.add(new Second(new Date(1110440330000L)), 18); s1.add(new Second(new Date(1110440580000L)), 18); s1.add(new Second(new Date(1110440830000L)), 40); s1.add(new Second(new Date(1110441080000L)), 108); s1.add(new Second(new Date(1110441330000L)), 157); s1.add(new Second(new Date(1110441580000L)), 153); s1.add(new Second(new Date(1110441830000L)), 124); s1.add(new Second(new Date(1110442080000L)), 173); s1.add(new Second(new Date(1110442330000L)), 171); s1.add(new Second(new Date(1110442580000L)), 168); s1.add(new Second(new Date(1110442830000L)), 168); s1.add(new Second(new Date(1110443080000L)), 169); s1.add(new Second(new Date(1110443330000L)), 167); s1.add(new Second(new Date(1110443580000L)), 168); s1.add(new Second(new Date(1110443830000L)), 171); s1.add(new Second(new Date(1110444080000L)), 172); s1.add(new Second(new Date(1110444330000L)), 172); s1.add(new Second(new Date(1110444580000L)), 170); s1.add(new Second(new Date(1110444830000L)), 173); s1.add(new Second(new Date(1110445080000L)), 173); s1.add(new Second(new Date(1110445330000L)), 174); s1.add(new Second(new Date(1110445580000L)), 172); s1.add(new Second(new Date(1110445830000L)), 173); s1.add(new Second(new Date(1110446080000L)), 172); s1.add(new Second(new Date(1110446330000L)), 172); s1.add(new Second(new Date(1110446580000L)), 171); s1.add(new Second(new Date(1110446830000L)), 171); s1.add(new Second(new Date(1110447080000L)), 171); s1.add(new Second(new Date(1110447330000L)), 172); s1.add(new Second(new Date(1110447580000L)), 174); s1.add(new Second(new Date(1110447830000L)), 173); s1.add(new Second(new Date(1110448080000L)), 173); s1.add(new Second(new Date(1110448330000L)), 171); s1.add(new Second(new Date(1110448580000L)), 170); s1.add(new Second(new Date(1110448830000L)), 172); s1.add(new Second(new Date(1110449080000L)), 172); s1.add(new Second(new Date(1110449330000L)), 172); s1.add(new Second(new Date(1110449580000L)), 170); s1.add(new Second(new Date(1110449830000L)), 167); s1.add(new Second(new Date(1110450080000L)), 165); s1.add(new Second(new Date(1110450330000L)), 166); s1.add(new Second(new Date(1110450580000L)), 165); s1.add(new Second(new Date(1110450830000L)), 163); s1.add(new Second(new Date(1110451080000L)), 163); s1.add(new Second(new Date(1110451330000L)), 160); s1.add(new Second(new Date(1110451580000L)), 160); s1.add(new Second(new Date(1110451830000L)), 160); s1.add(new Second(new Date(1110452080000L)), 160); s1.add(new Second(new Date(1110452330000L)), 159); s1.add(new Second(new Date(1110452580000L)), 159); s1.add(new Second(new Date(1110452830000L)), 158); s1.add(new Second(new Date(1110453080000L)), 158); s1.add(new Second(new Date(1110453330000L)), 159); s1.add(new Second(new Date(1110453580000L)), 159); s1.add(new Second(new Date(1110453830000L)), 158); s1.add(new Second(new Date(1110454080000L)), 154); s1.add(new Second(new Date(1110454330000L)), 151); s1.add(new Second(new Date(1110454580000L)), 151); s1.add(new Second(new Date(1110454830000L)), 102); s1.add(new Second(new Date(1110455080000L)), 90); s1.add(new Second(new Date(1110455330000L)), 95); s1.add(new Second(new Date(1110455580000L)), 102); s1.add(new Second(new Date(1110455830000L)), 107); s1.add(new Second(new Date(1110456080000L)), 113); s1.add(new Second(new Date(1110456330000L)), 119); s1.add(new Second(new Date(1110456580000L)), 123); s1.add(new Second(new Date(1110456830000L)), 127); s1.add(new Second(new Date(1110457080000L)), 131); s1.add(new Second(new Date(1110457330000L)), 134); s1.add(new Second(new Date(1110457580000L)), 137); s1.add(new Second(new Date(1110457830000L)), 138); s1.add(new Second(new Date(1110458080000L)), 140); s1.add(new Second(new Date(1110458330000L)), 142); s1.add(new Second(new Date(1110458580000L)), 142); s1.add(new Second(new Date(1110458830000L)), 141); s1.add(new Second(new Date(1110459080000L)), 144); s1.add(new Second(new Date(1110459330000L)), 145); s1.add(new Second(new Date(1110459580000L)), 146); s1.add(new Second(new Date(1110459830000L)), 149); s1.add(new Second(new Date(1110460080000L)), 149); s1.add(new Second(new Date(1110460330000L)), 149); s1.add(new Second(new Date(1110460580000L)), 150); s1.add(new Second(new Date(1110460830000L)), 152); s1.add(new Second(new Date(1110461080000L)), 151); s1.add(new Second(new Date(1110461330000L)), 151); s1.add(new Second(new Date(1110461580000L)), 151); s1.add(new Second(new Date(1110461830000L)), 151); s1.add(new Second(new Date(1110462080000L)), 151); s1.add(new Second(new Date(1110462330000L)), 153); s1.add(new Second(new Date(1110462580000L)), 152); s1.add(new Second(new Date(1110462830000L)), 152); s1.add(new Second(new Date(1110463080000L)), 152); s1.add(new Second(new Date(1110463330000L)), 151); s1.add(new Second(new Date(1110463580000L)), 152); s1.add(new Second(new Date(1110463830000L)), 152); s1.add(new Second(new Date(1110464080000L)), 152); s1.add(new Second(new Date(1110464330000L)), 151); s1.add(new Second(new Date(1110464580000L)), 150); s1.add(new Second(new Date(1110464830000L)), 148); s1.add(new Second(new Date(1110465080000L)), 147); s1.add(new Second(new Date(1110465330000L)), 145); s1.add(new Second(new Date(1110465580000L)), 145); s1.add(new Second(new Date(1110465830000L)), 145); s1.add(new Second(new Date(1110466080000L)), 146); s1.add(new Second(new Date(1110466330000L)), 147); s1.add(new Second(new Date(1110466580000L)), 147); s1.add(new Second(new Date(1110466830000L)), 145); s1.add(new Second(new Date(1110467080000L)), 143); s1.add(new Second(new Date(1110467330000L)), 142); s1.add(new Second(new Date(1110467580000L)), 141); s1.add(new Second(new Date(1110467830000L)), 143); s1.add(new Second(new Date(1110468080000L)), 144); s1.add(new Second(new Date(1110468330000L)), 143); s1.add(new Second(new Date(1110468580000L)), 143); s1.add(new Second(new Date(1110468830000L)), 141); s1.add(new Second(new Date(1110469080000L)), 140); s1.add(new Second(new Date(1110469330000L)), 140); s1.add(new Second(new Date(1110469580000L)), 141); s1.add(new Second(new Date(1110469830000L)), 143); s1.add(new Second(new Date(1110470080000L)), 146); s1.add(new Second(new Date(1110470330000L)), 150); s1.add(new Second(new Date(1110470580000L)), 153); s1.add(new Second(new Date(1110470830000L)), 155); s1.add(new Second(new Date(1110471080000L)), 157); s1.add(new Second(new Date(1110471330000L)), 156); s1.add(new Second(new Date(1110471580000L)), 154); s1.add(new Second(new Date(1110471830000L)), 155); s1.add(new Second(new Date(1110472080000L)), 153); s1.add(new Second(new Date(1110472330000L)), 150); s1.add(new Second(new Date(1110472580000L)), 145); s1.add(new Second(new Date(1110472830000L)), 144); s1.add(new Second(new Date(1110473080000L)), 148); s1.add(new Second(new Date(1110473330000L)), 152); s1.add(new Second(new Date(1110473580000L)), 154); s1.add(new Second(new Date(1110473830000L)), 157); s1.add(new Second(new Date(1110474080000L)), 160); s1.add(new Second(new Date(1110474330000L)), 159); s1.add(new Second(new Date(1110474580000L)), 161); s1.add(new Second(new Date(1110474830000L)), 156); s1.add(new Second(new Date(1110475080000L)), 142); s1.add(new Second(new Date(1110475330000L)), 140); s1.add(new Second(new Date(1110475580000L)), 136); s1.add(new Second(new Date(1110475830000L)), 127); s1.add(new Second(new Date(1110476080000L)), 113); s1.add(new Second(new Date(1110476330000L)), 105); s1.add(new Second(new Date(1110476580000L)), 107); s1.add(new Second(new Date(1110476830000L)), 103); s1.add(new Second(new Date(1110477080000L)), 97); s1.add(new Second(new Date(1110477330000L)), 102); s1.add(new Second(new Date(1110477580000L)), 111); s1.add(new Second(new Date(1110477830000L)), 127); s1.add(new Second(new Date(1110478080000L)), 149); s1.add(new Second(new Date(1110478330000L)), 166); s1.add(new Second(new Date(1110478580000L)), 181); s1.add(new Second(new Date(1110478830000L)), 189); s1.add(new Second(new Date(1110479080000L)), 203); s1.add(new Second(new Date(1110479330000L)), 224); s1.add(new Second(new Date(1110479580000L)), 234); s1.add(new Second(new Date(1110479830000L)), 237); s1.add(new Second(new Date(1110480080000L)), 229); s1.add(new Second(new Date(1110480330000L)), 228); s1.add(new Second(new Date(1110480580000L)), 222); s1.add(new Second(new Date(1110480830000L)), 205); s1.add(new Second(new Date(1110481080000L)), 222); s1.add(new Second(new Date(1110481330000L)), 226); s1.add(new Second(new Date(1110481580000L)), 222); s1.add(new Second(new Date(1110481830000L)), 229); s1.add(new Second(new Date(1110482080000L)), 247); s1.add(new Second(new Date(1110482330000L)), 240); s1.add(new Second(new Date(1110482580000L)), 251); s1.add(new Second(new Date(1110482830000L)), 240); s1.add(new Second(new Date(1110483080000L)), 242); s1.add(new Second(new Date(1110483330000L)), 241); s1.add(new Second(new Date(1110483580000L)), 250); s1.add(new Second(new Date(1110483830000L)), 255); s1.add(new Second(new Date(1110484080000L)), 255); s1.add(new Second(new Date(1110484330000L)), 255); s1.add(new Second(new Date(1110484580000L)), 255); s1.add(new Second(new Date(1110484830000L)), 255); s1.add(new Second(new Date(1110485080000L)), 255); s1.add(new Second(new Date(1110485330000L)), 254); s1.add(new Second(new Date(1110485580000L)), 253); s1.add(new Second(new Date(1110485830000L)), 254); s1.add(new Second(new Date(1110486080000L)), 59); // We may as well use the default TimeZone final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.setDomainIsPointsInTime(true); return (dataset); }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getDailySiteUserDataSet() { List<ServerWideStatsRecord> siteCreatedDeletedList = getSiteCreatedDeletedStats("daily"); TimeSeriesCollection dataset = new TimeSeriesCollection(); if (siteCreatedDeletedList != null) { TimeSeries s1 = new TimeSeries(msgs.getString("legend_site_created"), Day.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_site_deleted"), Day.class); for (ServerWideStatsRecord login : siteCreatedDeletedList) { Day day = new Day((Date) login.get(0)); s1.add(day, (Long) login.get(1)); s2.add(day, (Long) login.get(2)); }//w ww . j av a2s. com dataset.addSeries(s1); dataset.addSeries(s2); } List<ServerWideStatsRecord> newUserList = getNewUserStats("daily"); if (newUserList != null) { TimeSeries s3 = new TimeSeries(msgs.getString("legend_new_user"), Day.class); for (ServerWideStatsRecord login : newUserList) { Day day = new Day((Date) login.get(0)); s3.add(day, (Long) login.get(1)); } dataset.addSeries(s3); } return dataset; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getWeeklySiteUserDataSet() { List<ServerWideStatsRecord> siteCreatedDeletedList = getSiteCreatedDeletedStats("weekly"); TimeSeriesCollection dataset = new TimeSeriesCollection(); if (siteCreatedDeletedList != null) { TimeSeries s1 = new TimeSeries(msgs.getString("legend_site_created"), Week.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_site_deleted"), Week.class); for (ServerWideStatsRecord login : siteCreatedDeletedList) { Week week = new Week((Date) login.get(0)); s1.add(week, (Long) login.get(1)); s2.add(week, (Long) login.get(2)); }/*from ww w. j av a 2s.c o m*/ dataset.addSeries(s1); dataset.addSeries(s2); } List<ServerWideStatsRecord> newUserList = getNewUserStats("weekly"); if (newUserList != null) { TimeSeries s3 = new TimeSeries(msgs.getString("legend_new_user"), Week.class); for (ServerWideStatsRecord login : newUserList) { Week week = new Week((Date) login.get(0)); s3.add(week, (Long) login.get(1)); } dataset.addSeries(s3); } return dataset; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private IntervalXYDataset getMonthlySiteUserDataSet() { List<ServerWideStatsRecord> siteCreatedDeletedList = getSiteCreatedDeletedStats("monthly"); TimeSeriesCollection dataset = new TimeSeriesCollection(); if (siteCreatedDeletedList != null) { TimeSeries s1 = new TimeSeries(msgs.getString("legend_site_created"), Month.class); TimeSeries s2 = new TimeSeries(msgs.getString("legend_site_deleted"), Month.class); for (ServerWideStatsRecord login : siteCreatedDeletedList) { Month month = new Month((Date) login.get(0)); s1.add(month, (Long) login.get(1)); s2.add(month, (Long) login.get(2)); }//from w ww . j av a2s.c om dataset.addSeries(s1); dataset.addSeries(s2); } List<ServerWideStatsRecord> newUserList = getNewUserStats("monthly"); if (newUserList != null) { TimeSeries s3 = new TimeSeries(msgs.getString("legend_new_user"), Month.class); for (ServerWideStatsRecord login : newUserList) { Month month = new Month((Date) login.get(0)); s3.add(month, (Long) login.get(1)); } dataset.addSeries(s3); } return dataset; }
From source file:skyc.ViewContent.java
private void b2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b2ActionPerformed // TODO add your handling code here: Statement stmt = null;/*from w ww.j av a2 s . c om*/ Connection currentCon = null; boolean rs = false; ResultSet rs2; String color; int Orderby = jComboBox2.getSelectedIndex(); if (Orderby == 0) color = "r"; else if (Orderby == 1) color = "b"; else color = "g"; TimeSeries series = new TimeSeries("", Day.class); currentCon = ConnectionManager.getConnection(); try { stmt = currentCon.createStatement(); } catch (SQLException ex) { Logger.getLogger(ViewContent.class.getName()).log(Level.SEVERE, null, ex); } String SelectQuery = "Select * from pics WHERE location = '" + location + "' AND date >= '" + fromstring + "' AND date <= '" + tostring + "' ORDER BY '" + color + "'"; try { rs2 = stmt.executeQuery(SelectQuery); int i = 10; while (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); series.add(new Day(new Date("2015/04/" + i)), Integer.parseInt(b)); i++; // p1.setBackground(new Color(Integer.parseInt(r),Integer.parseInt(g),Integer.parseInt(b)) ); } } catch (SQLException e2) { System.out.println("SQL error is: " + e2); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart("Change of sky color", // Title "Day", // X-Axis label "Ratio", // Y-Axis label dataset, // Dataset true, // Show legend true, //tooltips false //url ); saveChart(chart); gr h = new gr(); h.setVisible(true); }