List of usage examples for org.jfree.data.time TimeSeries TimeSeries
public TimeSeries(Comparable name, Class timePeriodClass)
From source file:net.sourceforge.openforecast.examples.ExponentialSmoothingChartDemo.java
/** * Use the given forecasting model to produce a TimeSeries object * representing the periods startIndex through endIndex, and containing * the forecast values produced by the model. * @param model the forecasting model to use to generate the forecast * series.//from w w w.j a v a 2 s. c o m * @param initDataSet data set to use to initialize the forecasting model. * @param startIndex the index of the first data point to use from the * set of potential forecast values. * @param endIndex the index of the last data point to use from the set * of potential forecast values. * @param title a title to give to the TimeSeries created. */ private TimeSeries getForecastTimeSeries(ForecastingModel model, DataSet initDataSet, int startIndex, int endIndex, String title) { // Initialize the forecasting model model.init(initDataSet); // Get range of data required for forecast DataSet fcDataSet = getDataSet(fc, startIndex, endIndex); // Obtain forecast values for the forecast data set model.forecast(fcDataSet); // Create a new TimeSeries TimeSeries series = new TimeSeries(title, fc.getTimePeriodClass()); // Iterator through the forecast results, adding to the series Iterator it = fcDataSet.iterator(); while (it.hasNext()) { DataPoint dp = (DataPoint) it.next(); int index = (int) dp.getIndependentValue("t"); series.add(fc.getTimePeriod(index), dp.getDependentValue()); } return series; }
From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java
private JFreeChart createPPMChart() { /*// www. j a v a 2 s .c o m * INIT TIME-SERIES */ final TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries crawlerPPM = new TimeSeries("Crawler PPM", Minute.class); crawlerPPM.setMaximumItemAge(24 * 60); dataset.addSeries(crawlerPPM); this.seriesMap.put(TSERIES_PPM_CRAWLER, crawlerPPM); TimeSeries parserPPM = new TimeSeries("Parser PPM", Minute.class); parserPPM.setMaximumItemAge(24 * 60); dataset.addSeries(parserPPM); this.seriesMap.put(TSERIES_PPM_PARSER, parserPPM); TimeSeries indexerPPM = new TimeSeries("Indexer PPM", Minute.class); indexerPPM.setMaximumItemAge(24 * 60); dataset.addSeries(indexerPPM); this.seriesMap.put(TSERIES_PPM_INDEXER, indexerPPM); /* * INIT CHART */ JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "PPM", dataset, true, false, false); // change axis data format ((DateAxis) chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm")); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java
private XYDataset createDataset(ArrayList<Sensor> sensors) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); for (int i = 0; i < sensors.size(); i++) //for (int i = 0; i < 100; i++) {/* www. j ava2 s . com*/ Sensor current_sensor = sensors.get(i); ArrayList<Measurement> current_measurements = current_sensor.getMeasurements(); final TimeSeries s1 = new TimeSeries("Sensor " + i, Hour.class); for (int j = 0; j < current_measurements.size(); j++) { Measurement current_measurement = current_measurements.get(j); LocalDateTime current_time = current_measurement.getRecord_time(); s1.add(new Hour(current_time.getHour(), current_time.getDayOfMonth(), current_time.getMonthValue(), current_time.getYear()), current_measurement.getErlang()); } dataset.addSeries(s1); } dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:org.openiot.gsn.vsensor.ChartVirtualSensor.java
/** * This method adds the specified stream elements to the timeSeries of the * appropriate plot.//from w w w . jav a 2 s. co m * * @param streamElement */ public synchronized void addData(StreamElement streamElement) { for (int i = 0; i < streamElement.getFieldNames().length; i++) { TimeSeries timeSeries = dataForTheChart.get(streamElement.getFieldNames()[i]); if (timeSeries == null) { dataForTheChart.put(streamElement.getFieldNames()[i], timeSeries = new TimeSeries(streamElement.getFieldNames()[i], org.jfree.data.time.FixedMillisecond.class)); timeSeries.setMaximumItemCount(historySize); dataCollectionForTheChart.addSeries(timeSeries); } try { timeSeries.addOrUpdate(new FixedMillisecond(new Date(streamElement.getTimeStamp())), Double.parseDouble(streamElement.getData()[i].toString())); } catch (SeriesException e) { logger.warn(e.getMessage(), e); } } changed = true; }
From source file:org.tolven.graph.GraphMenuEventHandler.java
private XYDataset createDataset() throws Exception { MenuPath elementPath = new MenuPath(getElement()); MenuStructure dataMS = getAction().getParent(); MenuPath mdPath = new MenuPath(dataMS.getPath(), elementPath); MenuQueryControl ctrl = new MenuQueryControl(); ctrl.setLimit(5000); // TODO: This is a hard coded hard query limit that should be in a property or something ctrl.setMenuStructure(dataMS);//from ww w. j a v a2 s. c o m ctrl.setAccountUser(getAccountUser()); ctrl.setNow(getTolvenNow()); ctrl.setOffset(0); ctrl.setOriginalTargetPath(mdPath); ctrl.setRequestedPath(mdPath); List<MenuData> menuData = getMenuBean().findMenuData(ctrl); Properties menuEventHandlerData = getAction().getMenuEventHandlerDataMap(); String timeColumn = menuEventHandlerData.getProperty("timeColumn"); String valueColumn = menuEventHandlerData.getProperty("valueColumn"); String unitsColumn = menuEventHandlerData.getProperty("unitsColumn"); String datasetColumn = menuEventHandlerData.getProperty("datasetColumn"); String[] datasetUnitsArray = getRequest().getParameter("datasetunits").split(","); List<String> datasetUnits = new ArrayList<String>(); for (String string : datasetUnitsArray) { datasetUnits.add(string); } Map<String, String[]> datasetUnitMap = createDatasetUnitsMap(); Map<String, TimeSeries> timeSeriesMap = new HashMap<String, TimeSeries>(); for (String[] datasetUnitArray : datasetUnitMap.values()) { String dataset = datasetUnitArray[0]; String unit = datasetUnitArray[1]; String datasetUnit = dataset + unit; if (datasetUnits.contains(datasetUnit)) { timeSeriesMap.put(datasetUnit, new TimeSeries(dataset + " (" + unit + ")", Hour.class)); } } for (MenuData md : menuData) { String dataset = md.getStringField(datasetColumn); String units = md.getStringField(unitsColumn); String datasetUnit = dataset + units; TimeSeries currentTimeSeries = timeSeriesMap.get(datasetUnit); if (currentTimeSeries != null) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(md.getDateField(timeColumn)); Hour hour = new Hour(cal.getTime()); currentTimeSeries.addOrUpdate(hour, md.getInternalPQValueField(md.getColumn(valueColumn).getInternal())); } } TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); for (TimeSeries timeSeries : timeSeriesMap.values()) { timeSeriesCollection.addSeries(timeSeries); } timeSeriesCollection.setDomainIsPointsInTime(true); TolvenLogger.info("Done preparing Dataset", GraphMenuEventHandler.class); return timeSeriesCollection; }
From source file:cs.gui.stats.PerformanceStats.java
private ChartPanel createChart(String axisLabel, int type) { int width = (screenSize.width - (screenSize.width / 35)); int height = (int) (screenSize.height - (screenSize.height / (double) 4)); //int width = (screenSize.width - (screenSize.width / 35)) / 2; //int height = (int) (screenSize.height - (screenSize.height / (double) 4)) / 2; lastValue = new double[SUBPLOT_COUNT]; //================= visualise standard chart ========================== CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time")); lastValue[0] = 100D;/* ww w. jav a2 s . c o m*/ TimeSeries timeseries = null; XYPlot xyplot = null; //add new timeseries to modularity row datasets[type] = new TimeSeriesCollection(); NumberAxis numberaxis = new NumberAxis(axisLabel); numberaxis.setAutoRangeIncludesZero(true); //fast StandardXYItemRenderer xyItemRender = new StandardXYItemRenderer(); //original //xyItemRender = new StandardXYItemRenderer(); xyItemRender.setSeriesStroke(0, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(1, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(2, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(3, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); //TODO colours need to be defined statically before the renderer is created! xyplot = new XYPlot(datasets[type], null, numberaxis, xyItemRender); switch (type) { case 0: { xyItemRender.setSeriesPaint(0, Color.BLACK); timeseries = new TimeSeries("Number of existing threads", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); timeseries = new TimeSeries("Number of answered threads", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 1: { xyItemRender.setSeriesPaint(0, Color.YELLOW); timeseries = new TimeSeries("Mean thread answer time (per day)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 2: { xyItemRender.setSeriesPaint(0, Color.GRAY); timeseries = new TimeSeries("Number of thread replies", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 3: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("New thread arrival activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(1, Color.BLUE); timeseries = new TimeSeries("Thread reply activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 4: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("Mean thread aswer time (per month)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; } NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.add(xyplot); ChartPanel chart = null; switch (type) { case 0: { jfreechart1 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart1.getSubtitle(0); //set legend fonts jfreechart1.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart1.setBorderPaint(Color.black); jfreechart1.setBorderVisible(true); jfreechart1.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis1 = combineddomainxyplot.getDomainAxis(); dateAxis1 = (DateAxis) valueAxis1; if (scope1 == 0) { valueAxis1.setAutoRange(true); } else { valueAxis1.setFixedAutoRange(scope1); } chart = new ChartPanel(jfreechart1); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis1, dateAxis1, ddlScope1)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart1.setAntiAlias(false); } break; case 1: { jfreechart2 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart2.getSubtitle(0); //set legend fonts jfreechart2.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart2.setBorderPaint(Color.black); jfreechart2.setBorderVisible(true); jfreechart2.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis2 = combineddomainxyplot.getDomainAxis(); dateAxis2 = (DateAxis) valueAxis2; if (scope2 == 0) { valueAxis2.setAutoRange(true); } else { valueAxis2.setFixedAutoRange(scope2); } chart = new ChartPanel(jfreechart2); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis2, dateAxis2, ddlScope2)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart2.setAntiAlias(false); } break; case 2: { jfreechart3 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart3.getSubtitle(0); //set legend fonts jfreechart3.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart3.setBorderPaint(Color.black); jfreechart3.setBorderVisible(true); jfreechart3.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis3 = combineddomainxyplot.getDomainAxis(); dateAxis3 = (DateAxis) valueAxis3; if (scope3 == 0) { valueAxis3.setAutoRange(true); } else { valueAxis3.setFixedAutoRange(scope3); } chart = new ChartPanel(jfreechart3); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis3, dateAxis3, ddlScope3)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart3.setAntiAlias(false); } break; case 3: { jfreechart4 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart4.getSubtitle(0); //set legend fonts jfreechart4.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart4.setBorderPaint(Color.black); jfreechart4.setBorderVisible(true); jfreechart4.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis4 = combineddomainxyplot.getDomainAxis(); dateAxis4 = (DateAxis) valueAxis4; if (scope4 == 0) { valueAxis4.setAutoRange(true); } else { valueAxis4.setFixedAutoRange(scope4); } chart = new ChartPanel(jfreechart4); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis4, dateAxis4, ddlScope4)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart4.setAntiAlias(false); } break; case 4: { jfreechart5 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart5.getSubtitle(0); //set legend fonts jfreechart5.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart5.setBorderPaint(Color.black); jfreechart5.setBorderVisible(true); jfreechart5.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis5 = combineddomainxyplot.getDomainAxis(); dateAxis5 = (DateAxis) valueAxis5; if (scope5 == 0) { valueAxis5.setAutoRange(true); } else { valueAxis5.setFixedAutoRange(scope5); } chart = new ChartPanel(jfreechart5); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis5, dateAxis5, ddlScope5)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart5.setAntiAlias(false); } break; } return chart; }
From source file:gsn.vsensor.ChartVirtualSensor.java
/** * This method adds the specified stream elements to the timeSeries of the * appropriate plot.//w w w. j a v a 2 s. co m * * @param streamElement */ public synchronized void addData(StreamElement streamElement) { for (int i = 0; i < streamElement.getFieldNames().length; i++) { TimeSeries timeSeries = dataForTheChart.get(streamElement.getFieldNames()[i]); if (timeSeries == null) { dataForTheChart.put(streamElement.getFieldNames()[i], timeSeries = new TimeSeries(streamElement.getFieldNames()[i], org.jfree.data.time.FixedMillisecond.class)); if (isTimeBased) { timeSeries.setMaximumItemAge(historySize); } else { timeSeries.setMaximumItemCount(historySize); } dataCollectionForTheChart.addSeries(timeSeries); } try { timeSeries.addOrUpdate(new FixedMillisecond(new Date(streamElement.getTimeStamp())), Double.parseDouble(streamElement.getData()[i].toString())); } catch (SeriesException e) { logger.warn(e.getMessage(), e); } } changed = true; }
From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java
private JFreeChart createCPUChart() { final TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries series = null;//from w w w . j ava2 s . co m series = new TimeSeries("Total CPU Usage", Minute.class); series.setMaximumItemAge(24 * 60); dataset.addSeries(series); this.seriesMap.put(TSERIES_CPU_TOTAL, series); series = new TimeSeries("User CPU Usage", Minute.class); series.setMaximumItemAge(24 * 60); dataset.addSeries(series); this.seriesMap.put(TSERIES_CPU_USER, series); series = new TimeSeries("System CPU Usage", Minute.class); series.setMaximumItemAge(24 * 60); dataset.addSeries(series); this.seriesMap.put(TSERIES_CPU_SYSTEM, series); // init chart JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "Usage [%]", dataset, true, false, false); // change axis data format ((DateAxis) chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm")); chart.getXYPlot().getRangeAxis().setRange(0, 100); chart.getXYPlot().setNoDataMessage("No data available"); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:cs.stats.gui.StatsCharts.java
private ChartPanel createChart(String axisLabel, int type) { int width = (screenSize.width - (screenSize.width / 35)); int height = (int) (screenSize.height - (screenSize.height / (double) 4)); //int width = (screenSize.width - (screenSize.width / 35)) / 2; //int height = (int) (screenSize.height - (screenSize.height / (double) 4)) / 2; lastValue = new double[SUBPLOT_COUNT]; //================= visualise standard chart ========================== CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time")); lastValue[0] = 100D;//from w w w.j a v a 2 s. com TimeSeries timeseries = null; XYPlot xyplot = null; //add new timeseries to modularity row datasets[type] = new TimeSeriesCollection(); NumberAxis numberaxis = new NumberAxis(axisLabel); numberaxis.setAutoRangeIncludesZero(true); //fast StandardXYItemRenderer xyItemRender = new StandardXYItemRenderer(); //original //xyItemRender = new StandardXYItemRenderer(); xyItemRender.setSeriesStroke(0, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(1, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(2, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(3, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(4, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(5, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(6, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(7, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(8, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(9, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); //TODO colours need to be defined statically before the renderer is created! xyplot = new XYPlot(datasets[type], null, numberaxis, xyItemRender); switch (type) { case 0: { xyItemRender.setSeriesPaint(0, Color.BLACK); timeseries = new TimeSeries("Reply rate 1.0", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(1, Color.BLUE); timeseries = new TimeSeries("Reply rate 0.9", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(2, Color.ORANGE); timeseries = new TimeSeries("Reply rate 0.8", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(3, Color.GREEN); timeseries = new TimeSeries("Reply rate 0.7", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(4, Color.MAGENTA); timeseries = new TimeSeries("Reply rate 0.6", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(5, Color.LIGHT_GRAY); timeseries = new TimeSeries("Reply rate 0.5", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(6, Color.YELLOW); timeseries = new TimeSeries("Reply rate 0.4", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); // xyItemRender.setSeriesPaint(7, Color.PINK); // timeseries = new TimeSeries("Reply rate 0.3", org.jfree.data.time.Hour.class); // datasets[type].addSeries(timeseries); // // xyItemRender.setSeriesPaint(8, Color.RED); // timeseries = new TimeSeries("Reply rate 0.2", org.jfree.data.time.Hour.class); // datasets[type].addSeries(timeseries); // // xyItemRender.setSeriesPaint(9, Color.CYAN); // timeseries = new TimeSeries("Reply rate 0.1", org.jfree.data.time.Hour.class); // datasets[type].addSeries(timeseries); } break; case 1: { xyItemRender.setSeriesPaint(0, Color.BLACK); timeseries = new TimeSeries("0% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(1, Color.BLUE); timeseries = new TimeSeries("1% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(2, Color.ORANGE); timeseries = new TimeSeries("2% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(3, Color.GREEN); timeseries = new TimeSeries("3% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(4, Color.MAGENTA); timeseries = new TimeSeries("3.5% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(5, Color.LIGHT_GRAY); timeseries = new TimeSeries("4% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(6, Color.YELLOW); timeseries = new TimeSeries("4.5% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(7, Color.PINK); timeseries = new TimeSeries("5% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(8, Color.RED); timeseries = new TimeSeries("5.5% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(9, Color.CYAN); timeseries = new TimeSeries("6% of community users removed", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 2: { xyItemRender.setSeriesPaint(0, Color.GRAY); timeseries = new TimeSeries("Average number of thread replies (per hour)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 3: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("New thread arrival activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(1, Color.BLUE); timeseries = new TimeSeries("Thread reply activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 4: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("Mean thread aswer time", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; } NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickUnit(new NumberTickUnit(0.1)); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.add(xyplot); ChartPanel chart = null; switch (type) { case 0: { jfreechart1 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart1.getSubtitle(0); //set legend fonts jfreechart1.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart1.setBorderPaint(Color.black); jfreechart1.setBorderVisible(true); jfreechart1.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis1 = combineddomainxyplot.getDomainAxis(); dateAxis1 = (DateAxis) valueAxis1; dateAxis1.setTickUnit(new DateTickUnit(1, 1)); if (scope1 == 0) { valueAxis1.setAutoRange(true); } else { valueAxis1.setFixedAutoRange(scope1); } chart = new ChartPanel(jfreechart1); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //chart.add(buildPlotDisplayManagementPanel(valueAxis1, dateAxis1, ddlScope1)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart1.setAntiAlias(false); } break; case 1: { jfreechart2 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart2.getSubtitle(0); //set legend fonts jfreechart2.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart2.setBorderPaint(Color.black); jfreechart2.setBorderVisible(true); jfreechart2.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis2 = combineddomainxyplot.getDomainAxis(); dateAxis2 = (DateAxis) valueAxis2; dateAxis2.setTickUnit(new DateTickUnit(1, 1)); if (scope2 == 0) { valueAxis2.setAutoRange(true); } else { valueAxis2.setFixedAutoRange(scope2); } chart = new ChartPanel(jfreechart2); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart2.setAntiAlias(false); } break; case 2: { jfreechart3 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart3.getSubtitle(0); //set legend fonts jfreechart3.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart3.setBorderPaint(Color.black); jfreechart3.setBorderVisible(true); jfreechart3.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis3 = combineddomainxyplot.getDomainAxis(); dateAxis3 = (DateAxis) valueAxis3; if (scope3 == 0) { valueAxis3.setAutoRange(true); } else { valueAxis3.setFixedAutoRange(scope3); } chart = new ChartPanel(jfreechart3); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis3, dateAxis3, ddlScope3)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart3.setAntiAlias(false); } break; case 3: { jfreechart4 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart4.getSubtitle(0); //set legend fonts jfreechart4.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart4.setBorderPaint(Color.black); jfreechart4.setBorderVisible(true); jfreechart4.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis4 = combineddomainxyplot.getDomainAxis(); dateAxis4 = (DateAxis) valueAxis4; if (scope4 == 0) { valueAxis4.setAutoRange(true); } else { valueAxis4.setFixedAutoRange(scope4); } chart = new ChartPanel(jfreechart4); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis4, dateAxis4, ddlScope4)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart4.setAntiAlias(false); } break; case 4: { jfreechart5 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart5.getSubtitle(0); //set legend fonts jfreechart5.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart5.setBorderPaint(Color.black); jfreechart5.setBorderVisible(true); jfreechart5.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis5 = combineddomainxyplot.getDomainAxis(); dateAxis5 = (DateAxis) valueAxis5; if (scope5 == 0) { valueAxis5.setAutoRange(true); } else { valueAxis5.setFixedAutoRange(scope5); } chart = new ChartPanel(jfreechart5); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis5, dateAxis5, ddlScope5)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart5.setAntiAlias(false); } break; } return chart; }
From source file:windows.sensorWindow.java
/** * creates all relevant data and adds it into the corresponding maps * /*from w ww .j a v a2 s . c o m*/ * @param UID * UID of the plotting sensor */ @SuppressWarnings("deprecation") public static void addPlot(Brick newBrick) { // create series TimeSeries newSeries = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries2 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries3 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries4 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries5 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries6 = new TimeSeries("" + 0, Millisecond.class); Measurement m1 = new Measurement(maxValues, maxCycles, newBrick.uid, 0); valuesMap.put(newBrick.uid, m1); if (newBrick.checked3 == true) { Measurement m2 = new Measurement(maxValues, maxCycles, newBrick.uid, 1); values2Map.put(newBrick.uid, m2); } // create entry in state map plot1StateMap.put(newBrick.uid, 0); plot2StateMap.put(newBrick.uid, 0); // create index map entry tmplindex.put(newBrick.uid, 0); // create avrgCtrlEnabled maps if (newBrick.controlAverage == true) avrgCtrl1Enabled.put(newBrick.uid, true); else avrgCtrl1Enabled.put(newBrick.uid, false); if (newBrick.controlAverage2 == true) avrgCtrl2Enabled.put(newBrick.uid, true); else avrgCtrl2Enabled.put(newBrick.uid, false); // create series map entry seriesMap.put(newBrick.uid, newSeries); seriesMap2.put(newBrick.uid, newSeries2); seriesMap3.put(newBrick.uid, newSeries3); seriesMap4.put(newBrick.uid, newSeries4); seriesMap5.put(newBrick.uid, newSeries3); seriesMap6.put(newBrick.uid, newSeries4); // create collection map entry seriesCollectionMap.put(newBrick.uid, new TimeSeriesCollection(newSeries)); seriesCollectionMap2.put(newBrick.uid, new TimeSeriesCollection(newSeries2)); tmplCollection1_1.put(newBrick.uid, new TimeSeriesCollection(newSeries3)); tmplCollection1_2.put(newBrick.uid, new TimeSeriesCollection(newSeries4)); tmplCollection2_1.put(newBrick.uid, new TimeSeriesCollection(newSeries5)); tmplCollection2_2.put(newBrick.uid, new TimeSeriesCollection(newSeries6)); // create plot map entry, special case for current/voltage brick, since // it has 2 parallel measurements and therefore 2 graphs must be treated XYPlot tmpSubPlot; tmpSubPlot = new XYPlot(seriesCollectionMap.get(newBrick.uid), null, null, new StandardXYItemRenderer()); // create the 1st graph if (newBrick.checked2 == true) { // create plot map entry NumberAxis rangeAxis = new NumberAxis( String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier))); rangeAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(0, rangeAxis); rangeAxis.setLabelPaint(Color.BLUE); rangeAxis.setVisible(newBrick.checked2); tmpSubPlot.setDataset(0, seriesCollectionMap.get(newBrick.uid)); // set dot - shape // Shape cross = ShapeUtilities.createDiagonalCross(3, 1); // create and store renderer XYItemRenderer renderer1 = new XYLineAndShapeRenderer(); renderer1 = tmpSubPlot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLUE); renderer1.setSeriesStroke(0, new BasicStroke(3)); // line = dashes: // float dash[] = {5.0f}; // renderer1.setSeriesStroke( 0, new // BasicStroke(3,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, // 10.0f, dash, 0.0f)); // renderer1.setSeriesShape(0, cross); tmpSubPlot.setRenderer(0, renderer1); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // tmpSubPlot.setRenderer(renderer2); // set font rangeAxis.setLabelFont(customFonts.get("axisLabelFont")); rangeAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create template graph // if (newBrick.ctrlTmpl[0] == true) // { tmpSubPlot.setDataset(2, tmplCollection1_1.get(newBrick.uid)); XYItemRenderer renderer3 = new XYLineAndShapeRenderer(); int width = computeTmplPlotWidth(newBrick.tmpl1Width); BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);// , 10.0f, dash, 0.0f); renderer3.setSeriesPaint(0, Color.GREEN); // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) ); renderer3.setSeriesStroke(0, stroke); renderer3.setSeriesVisible(0, newBrick.ctrlTmpl[0]); rendererMap3.put(newBrick.uid, renderer3); tmpSubPlot.setRenderer(2, rendererMap3.get(newBrick.uid)); // } // put everything to the maps rendererMap.put(newBrick.uid, renderer1); plotMap.put(newBrick.uid, tmpSubPlot); axisMap.put(newBrick.uid, rangeAxis); } // create the 2nd graph if (newBrick.checked3 == true) { // set second axis for voltage/ampere brick NumberAxis secondaryAxis = new NumberAxis( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier))); secondaryAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(1, secondaryAxis); secondaryAxis.setLabelPaint(Color.RED); secondaryAxis.setVisible(newBrick.checked3); tmpSubPlot.setDataset(1, seriesCollectionMap2.get(newBrick.uid)); tmpSubPlot.mapDatasetToRangeAxis(1, 1); // set font secondaryAxis.setLabelFont(customFonts.get("axisLabelFont")); secondaryAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create and store renderer XYItemRenderer renderer2 = new StandardXYItemRenderer(); // renderer2 = tmpSubPlot.getRenderer(); renderer2.setSeriesPaint(1, Color.RED); renderer2.setSeriesStroke(0, new BasicStroke(3)); tmpSubPlot.setRenderer(1, renderer2); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // ---------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm5 = new ValueMarker(newBrick.tresholdMin2); markerMapMin2Critical.put(newBrick.uid, vm5); // set critical line markerMapMin2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMin2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMin2Critical.get(newBrick.uid), Layer.BACKGROUND); // create min1 warning map value ValueMarker vm6 = new ValueMarker( newBrick.tresholdMin2 + newBrick.tresholdMin2 * warningPercentage / 100); markerMapMin2Warning.put(newBrick.uid, vm6); // set warning line markerMapMin2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMin2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); // tmpSubPlot.addRangeMarker(markerMapMin2Warning.get(newBrick.uid)); tmpSubPlot.addRangeMarker(1, markerMapMin2Warning.get(newBrick.uid), Layer.BACKGROUND); // create max1 critical map value ValueMarker vm7 = new ValueMarker(newBrick.tresholdMax2); markerMapMax2Critical.put(newBrick.uid, vm7); // set critical line markerMapMax2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMax2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Critical.get(newBrick.uid), Layer.BACKGROUND); // create max1 warning map value ValueMarker vm8 = new ValueMarker( newBrick.tresholdMax2 + newBrick.tresholdMax2 * warningPercentage / 100); markerMapMax2Warning.put(newBrick.uid, vm8); // set warning line markerMapMax2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Warning.get(newBrick.uid), Layer.BACKGROUND); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.orange); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMax.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.orange); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMin.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.red); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add to maps marker2Maxima.put(newBrick.uid, vmMax); marker2Minima.put(newBrick.uid, vmMin); marker2Average.put(newBrick.uid, vmAvg); // add to plot tmpSubPlot.addRangeMarker(1, vmMax, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmMin, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmAvg, Layer.BACKGROUND); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl2high = new ValueMarker(newBrick.getAvg2high()); avrgCtrl2high.setPaint(Color.orange); avrgCtrl2high.setLabel("avrg high"); avrgCtrl2high.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2high.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create lower marker ValueMarker avrgCtrl2low = new ValueMarker(newBrick.getAvg2low()); avrgCtrl2low.setPaint(Color.orange); avrgCtrl2low.setLabel("avrg low"); avrgCtrl2low.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2low.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add both markers avrg2High.put(newBrick.uid, avrgCtrl2high); avrg2Low.put(newBrick.uid, avrgCtrl2low); // add both to plot if (newBrick.controlAverage2) { tmpSubPlot.addRangeMarker(1, avrgCtrl2high, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, avrgCtrl2low, Layer.BACKGROUND); } // ---------------------------------------------------------------------------------- // put everything to the map rendererMap2.put(newBrick.uid, renderer2); plotMap.put(newBrick.uid, tmpSubPlot); axisMap2.put(newBrick.uid, secondaryAxis); } // 1st graph // markers-------------------------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm1 = new ValueMarker(newBrick.tresholdMin1); markerMapMin1Critical.put(newBrick.uid, vm1); // set critical line markerMapMin1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMin1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Critical.get(newBrick.uid)); // create min1 warning map value ValueMarker vm2 = new ValueMarker(newBrick.tresholdMin1 + newBrick.tresholdMin1 * warningPercentage / 100); markerMapMin1Warning.put(newBrick.uid, vm2); // set warning line markerMapMin1Warning.get(newBrick.uid).setPaint(Color.orange); // marker2Map.get(newBrick.uid).setPaint(Color.); // / marker2Map.get(newBrick.uid).setLabel("warning"); markerMapMin1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Warning.get(newBrick.uid)); // create max1 critical map value ValueMarker vm3 = new ValueMarker(newBrick.tresholdMax1); markerMapMax1Critical.put(newBrick.uid, vm3); // set critical line markerMapMax1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMax1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Critical.get(newBrick.uid)); // create max1 warning map value ValueMarker vm4 = new ValueMarker(newBrick.tresholdMax1 + newBrick.tresholdMax1 * warningPercentage / 100); markerMapMax1Warning.put(newBrick.uid, vm4); // set warning line markerMapMax1Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Warning.get(newBrick.uid)); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.cyan); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMax.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.cyan); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMin.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.blue); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add to maps markerMaxima.put(newBrick.uid, vmMax); markerMinima.put(newBrick.uid, vmMin); markerAverage.put(newBrick.uid, vmAvg); // add to plot plotMap.get(newBrick.uid).addRangeMarker(vmMax); plotMap.get(newBrick.uid).addRangeMarker(vmMin); plotMap.get(newBrick.uid).addRangeMarker(vmAvg); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl1high = new ValueMarker(newBrick.getAvg1high()); avrgCtrl1high.setPaint(Color.orange); avrgCtrl1high.setLabel("avrg high"); avrgCtrl1high.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1high.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create lower marker ValueMarker avrgCtrl1low = new ValueMarker(newBrick.getAvg1low()); avrgCtrl1low.setPaint(Color.orange); avrgCtrl1low.setLabel("avrg low"); avrgCtrl1low.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1low.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add both markers avrg1High.put(newBrick.uid, avrgCtrl1high); avrg1Low.put(newBrick.uid, avrgCtrl1low); // add both to plot if (newBrick.controlAverage) { plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1high); plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1low); } // ----------------------------------------------------------------------------------------------------- // set title NumberAxis axisForTitleOnly = new NumberAxis( data.constants.brickIdMap.get(newBrick.deviceIdentifier) + " (" + newBrick.uid + ")"); axisForTitleOnly.setLabelFont(customFonts.get("titleFont")); axisForTitleOnly.setTickLabelsVisible(false); axisForTitleOnly.setTickMarksVisible(false); axisForTitleOnly.setMinorTickMarksVisible(false); axisForTitleOnly.setAxisLineVisible(false); plotMap.get(newBrick.uid).setDomainAxis(1, axisForTitleOnly); // add subplot to the main plot plot.add(plotMap.get(newBrick.uid)); }