List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { displayPopupMenu(e.getX(), e.getY()); return;/*from www . ja v a 2 s .c o m*/ } repaint(); int smallX = Math.min(startX, endX); int smallY = Math.min(startY, endY); int bigX = Math.max(startX, endX); int bigY = Math.max(startY, endY); XYPlot plot = this.getChart().getXYPlot(); Rectangle2D plotArea = this.getScreenDataArea(); double chartSmallX = plot.getDomainAxis().java2DToValue(smallX, plotArea, plot.getDomainAxisEdge()); double chartBigX = plot.getDomainAxis().java2DToValue(bigX, plotArea, plot.getDomainAxisEdge()); double chartSmallY = plot.getRangeAxis().java2DToValue(smallY, plotArea, plot.getRangeAxisEdge()); double chartBigY = plot.getRangeAxis().java2DToValue(bigY, plotArea, plot.getRangeAxisEdge()); double minXValue = Math.min(chartSmallX, chartBigX); double maxXValue = Math.max(chartSmallX, chartBigX); double minYValue = Math.min(chartSmallY, chartBigY); double maxYValue = Math.max(chartSmallY, chartBigY); //testLog.append("Scanning: (" + smallX + ", " + smallY + "), (" + bigX + ", " + bigY + ")\n"); //testLog.append("Scanning: X = [" + Math.min(chartSmallX, chartBigX) + ", " + Math.max(chartSmallX, chartBigX) + "]\n"); //testLog.append("Scanning: Y = [" + Math.min(chartSmallY, chartBigY) + ", " + Math.max(chartSmallY, chartBigY) + "]\n"); Set<XYItemEntity> foundItem = new HashSet<XYItemEntity>(); XYDataset dataset = this.getChart().getXYPlot().getDataset(); EntityCollection collection = this.getChartRenderingInfo().getEntityCollection(); for (Object obj : collection.getEntities()) { if (obj instanceof XYItemEntity) { XYItemEntity entity = (XYItemEntity) obj; int series = entity.getSeriesIndex(); int idx = entity.getItem(); if (dataset.getX(series, idx).doubleValue() >= minXValue && dataset.getX(series, idx).doubleValue() <= maxXValue && dataset.getY(series, idx).doubleValue() >= minYValue && dataset.getY(series, idx).doubleValue() <= maxYValue) { foundItem.add(entity); } } } // for (int x = smallX; x <= bigX; ++x) // { // for (int y = smallY; y <= bigY; ++y) // { // ChartEntity entity = this.getEntityForPoint(x, y); // if (entity instanceof XYItemEntity) // { // foundItem.add((XYItemEntity)entity); // } // } // } selectedItems = foundItem; // outlierRegion.clear(); // for (XYItemEntity entity : foundItem) // { // //testLog.append(entity.toString() + "\n"); // //testLog.append("Series = " + entity.getSeriesIndex() + ", "); // //testLog.append("X = " + entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()) + ", "); // //testLog.append("Y = " + entity.getDataset().getY(entity.getSeriesIndex(), entity.getItem()) + "\n"); // outlierRegion.add(entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()).doubleValue()); // } // // Collections.sort(outlierRegion); // if (!outlierRegion.isEmpty()) // { // testLog.setText(""); // testLog.append("Outlier time selected = ["); // for (int i = 0; i < outlierRegion.size(); ++i) // { // testLog.append(outlierRegion.get(i).toString()); // if (i < outlierRegion.size() - 1) // { // testLog.append(" "); // } // } // testLog.append("]\n"); // } }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL,/*from w w w . j a v a2 s .c om*/ // !legendPanelOn, false, // no legend true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:ws.moor.bt.gui.charts.BlockDownload.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Downloaded Blocks", "Time", "Blocks", dataset, true, false, false);//ww w . j a v a 2s.com chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:com.seagate.kinetic.monitor.view.KineticSpecifiedNodeView.java
private void createStatChart() { TimeSeriesCollection putOpsTsc = new TimeSeriesCollection(putOpsTs); TimeSeriesCollection putTrgTsc = new TimeSeriesCollection(putTrgTs); TimeSeriesCollection getOpsTsc = new TimeSeriesCollection(getOpsTs); TimeSeriesCollection getTrgTsc = new TimeSeriesCollection(getTrgTs); TimeSeriesCollection deleteOpsTsc = new TimeSeriesCollection(deleteOpsTs); TimeSeriesCollection deleteTrgTsc = new TimeSeriesCollection(deleteTrgTs); statChart = ChartFactory.createTimeSeriesChart("", "Time", "put kvop/s", putOpsTsc, true, true, false); XYPlot xyplot = (XYPlot) statChart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setDomainPannable(true);// w w w .ja va 2 s. com xyplot.setRangePannable(true); ValueAxis yAxis = xyplot.getDomainAxis(); yAxis.setAutoRange(true); yAxis.setFixedAutoRange(60000.0); NumberAxis numberaxis1 = new NumberAxis("get kvop/s"); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, getOpsTsc); xyplot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer standardxyitemrenderer1 = new StandardXYItemRenderer(); xyplot.setRenderer(1, standardxyitemrenderer1); NumberAxis numberaxis2 = new NumberAxis("delete kvop/s"); numberaxis2.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(2, numberaxis2); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(2, deleteOpsTsc); xyplot.mapDatasetToRangeAxis(2, 2); StandardXYItemRenderer standardxyitemrenderer2 = new StandardXYItemRenderer(); xyplot.setRenderer(2, standardxyitemrenderer2); NumberAxis numberaxis3 = new NumberAxis("put MB/s"); xyplot.setRangeAxis(3, numberaxis3); xyplot.setDataset(3, putTrgTsc); xyplot.mapDatasetToRangeAxis(3, 3); StandardXYItemRenderer standardxyitemrenderer3 = new StandardXYItemRenderer(); xyplot.setRenderer(3, standardxyitemrenderer3); NumberAxis numberaxis4 = new NumberAxis("get MB/s"); numberaxis4.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(4, numberaxis4); xyplot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(4, getTrgTsc); xyplot.mapDatasetToRangeAxis(4, 4); StandardXYItemRenderer standardxyitemrenderer4 = new StandardXYItemRenderer(); xyplot.setRenderer(4, standardxyitemrenderer4); NumberAxis numberaxis5 = new NumberAxis("delete MB/s"); xyplot.setRangeAxis(5, numberaxis5); xyplot.setDataset(5, deleteTrgTsc); xyplot.mapDatasetToRangeAxis(5, 5); StandardXYItemRenderer standardxyitemrenderer5 = new StandardXYItemRenderer(); xyplot.setRenderer(5, standardxyitemrenderer5); ChartUtilities.applyCurrentTheme(statChart); xyplot.getRenderer().setSeriesPaint(0, Color.black); standardxyitemrenderer1.setSeriesPaint(0, Color.red); numberaxis1.setLabelPaint(Color.red); numberaxis1.setTickLabelPaint(Color.red); standardxyitemrenderer2.setSeriesPaint(0, Color.green); numberaxis2.setLabelPaint(Color.green); numberaxis2.setTickLabelPaint(Color.green); standardxyitemrenderer3.setSeriesPaint(0, Color.orange); numberaxis3.setLabelPaint(Color.orange); numberaxis3.setTickLabelPaint(Color.orange); standardxyitemrenderer4.setSeriesPaint(0, Color.blue); numberaxis4.setLabelPaint(Color.blue); numberaxis4.setTickLabelPaint(Color.blue); standardxyitemrenderer5.setSeriesPaint(0, Color.cyan); numberaxis5.setLabelPaint(Color.cyan); numberaxis5.setTickLabelPaint(Color.cyan); final JPanel main = new JPanel(new BorderLayout()); final JPanel optionsPanel = new JPanel(); String[] options = { SYSTEM_TOTAL_IOPS_AND_THROUGHPUT_STATISTICS }; this.orientationComboBox = new JComboBox<String>(options); this.orientationComboBox.setSize(600, 50); this.orientationComboBox.addActionListener(this); optionsPanel.add(this.orientationComboBox); chartPanel = new ChartPanel(statChart); chartPanel.setMouseWheelEnabled(false); chartPanel.setPreferredSize(new Dimension(900, 450)); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); main.add(optionsPanel, BorderLayout.NORTH); main.add(this.chartPanel); setContentPane(main); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java
private PortHeatMapPlotPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes, EnumSet<IB_Depth> includedDepths) { super(new BorderLayout()); // creates the main chart panel, which creates the PortHeatMapDataSet // (so all the data has been initialized here, available for all subsequent actions) overallDimension = new java.awt.Dimension(900, 500); heatPanel = (ChartPanel) createHeatPanel(history, includedNodes, includedDepths); heatPanel.setPreferredSize(overallDimension); // add the vertical and horizontal crosshairs CrosshairOverlay overlay = new CrosshairOverlay(); TimeXhair = new Crosshair(0); TimeXhair.setPaint(TimeSliceColor); // vertical slice (single timestamp) for dataset1, SingleTimeChart plot 1, slider 2, etc PortXhair = new Crosshair(0); PortXhair.setPaint(PortSliceColor); // horizontal slice (single port) for dataset2, SinglePortChart, slider 1 overlay.addDomainCrosshair(TimeXhair); overlay.addRangeCrosshair(PortXhair); heatPanel.addOverlay(overlay);/*from www . ja v a 2 s . c o m*/ TimeXhair.setLabelVisible(true); TimeXhair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); TimeXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100)); PortXhair.setLabelVisible(true); PortXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100)); add(heatPanel); JPanel PortSliderPanel = new JPanel(new BorderLayout()); // all ports, single timestamp (right vertical plot) - uses TimeXhair and slider 2 from the horizontal panel (TimeSliderPanel) XYSeriesCollection dataset1 = new XYSeriesCollection(); SingleTimeChart = ChartFactory.createXYLineChart("Vertical Cross-section (all ports single timestamp)", PortAxisLabel, UtilizationAxisLabel, dataset1, PlotOrientation.HORIZONTAL, false, false, false); XYPlot plot1 = (XYPlot) SingleTimeChart.getPlot(); plot1.getDomainAxis().setLowerMargin(0.0); plot1.getDomainAxis().setUpperMargin(0.0); plot1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot1.getRenderer().setSeriesPaint(0, TimeSliceColor); // this is the right ChartPanel SingleTimeChartPanel = new ChartPanel(SingleTimeChart); SingleTimeChartPanel.setMinimumDrawWidth(0); SingleTimeChartPanel.setMinimumDrawHeight(0); SingleTimeChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getWidth() / 3))); ((XYPlot) SingleTimeChart.getPlot()).getRangeAxis().setRange(new Range(0, 1)); ((XYPlot) SingleTimeChart.getPlot()).getDomainAxis().setRange(new Range(0, 1)); // this slider panel holds the slider and the Single Time Snapshot of all ports, on the right or EAST (for use with plot2) PortSlider = new JSlider(0, 1, 0); PortSlider.addChangeListener(this); PortSlider.setOrientation(JSlider.VERTICAL); PortSliderPanel.add(SingleTimeChartPanel); PortSliderPanel.add(PortSlider, BorderLayout.WEST); TimeSliderPanel = new JPanel(new BorderLayout()); // single port, all timestamps (lower horizontal plot) - uses PortXhair and slider 1 from the vertical panel (PortSliderPanel) XYSeriesCollection dataset2 = new XYSeriesCollection(); SinglePortChart = ChartFactory.createXYLineChart("Horizontal Cross-section (single port over time)", TimeAxisLabel, UtilizationAxisLabel, dataset2, PlotOrientation.VERTICAL, false, false, false); XYPlot plot2 = (XYPlot) SinglePortChart.getPlot(); plot2.getDomainAxis().setLowerMargin(0.0); plot2.getDomainAxis().setUpperMargin(0.0); plot2.getRenderer().setSeriesPaint(0, PortSliceColor); ChartPanel SinglePortChartPanel = new ChartPanel(SinglePortChart); SinglePortChartPanel.setMinimumDrawWidth(0); SinglePortChartPanel.setMinimumDrawHeight(0); SinglePortChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getHeight() / 3))); ((XYPlot) SinglePortChart.getPlot()).getRangeAxis().setRange(new Range(0, 1)); ((XYPlot) SinglePortChart.getPlot()).getDomainAxis().setRange(new Range(0, 1)); DepthPanel = new HeatMapDepthPanel(null); DepthPanel.setPreferredSize( new Dimension((int) (overallDimension.getWidth() / 4), (int) (overallDimension.getHeight() / 3))); TimeSliderPanel.add(DepthPanel, BorderLayout.EAST); // this slider panel holds the slider and the Single Port for all times, in the BOTTOM (for use with plot1) TimeSlider = new JSlider(0, 1, 0); TimeSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 200)); TimeSlider.addChangeListener(this); TimeSliderPanel.add(SinglePortChartPanel); TimeSliderPanel.add(TimeSlider, BorderLayout.NORTH); add(PortSliderPanel, BorderLayout.EAST); add(TimeSliderPanel, BorderLayout.SOUTH); heatChart.setNotify(true); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo2.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);/*from w ww. j a v a 2 s.co m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // setXSummary(dataset); //X is time renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:org.jax.maanova.plot.MaanovaChartPanel.java
/** * Convert the given point in java2d coordinates to chart coordinates. * @param java2DPoint the point to convert * @return the converted point/*from w ww . j av a 2 s . c o m*/ * @throws ClassCastException the plot isn't an XYPlot */ public Point2D toChartPoint(Point2D java2DPoint) throws ClassCastException { XYPlot plot = this.getChart().getXYPlot(); Rectangle2D dataArea = this.chartRenderingInfo.getPlotInfo().getDataArea(); double graphX = plot.getDomainAxis().java2DToValue(java2DPoint.getX(), dataArea, plot.getDomainAxisEdge()); double graphY = plot.getRangeAxis().java2DToValue(java2DPoint.getY(), dataArea, plot.getRangeAxisEdge()); return new Point2D.Double(graphX, graphY); }
From source file:org.jax.maanova.plot.MaanovaChartPanel.java
/** * Convert the given rectangle in java2d coordinates to chart coordinates. * @param java2DRectangle the rectangle to convert * @return the converted rectangle/*from www . ja v a 2 s .c om*/ * @throws ClassCastException the plot isn't an XYPlot */ public Rectangle2D toChartRectangle(Rectangle2D java2DRectangle) throws ClassCastException { XYPlot plot = this.getChart().getXYPlot(); Rectangle2D dataArea = this.chartRenderingInfo.getPlotInfo().getDataArea(); double x1 = plot.getDomainAxis().java2DToValue(java2DRectangle.getMinX(), dataArea, plot.getDomainAxisEdge()); double y1 = plot.getRangeAxis().java2DToValue(java2DRectangle.getMinY(), dataArea, plot.getRangeAxisEdge()); double x2 = plot.getDomainAxis().java2DToValue(java2DRectangle.getMaxX(), dataArea, plot.getDomainAxisEdge()); double y2 = plot.getRangeAxis().java2DToValue(java2DRectangle.getMaxY(), dataArea, plot.getRangeAxisEdge()); return toNonNegativeWidthHeightRectangle(new Rectangle2D.Double(x1, y1, x2 - x1, y2 - y1)); }
From source file:com.fr3ts0n.ecu.gui.application.ObdDataPlotter.java
/** * Creates a chart.// w w w.ja v a 2s . co m * * @param dataset a dataset. * @return A chart. */ private JFreeChart createChart(XYDataset dataset) { chart = ChartFactory.createTimeSeriesChart("OBD Data Graph", // title "Time", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setTickLabelFont(legendFont); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); chart.getLegend().setItemFont(legendFont); return chart; }
From source file:it.marcoberri.mbmeteo.action.chart.GetMinAndMax.java
/** * Processes requests for both HTTP/* ww w . j a v a 2s . c om*/ * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("start : " + this.getClass().getName()); final HashMap<String, String> params = getParams(request.getParameterMap()); final Integer dimy = Default.toInteger(params.get("dimy"), 600); final Integer dimx = Default.toInteger(params.get("dimx"), 800); final String from = Default.toString(params.get("from") + " 00:00:00", "1970-01-01 00:00:00"); final String to = Default.toString(params.get("to") + " 23:59:00", "2030-01-01 23:59:00"); final String field = Default.toString(params.get("field"), "outdoorTemperature"); final String period = Default.toString(params.get("period"), "day"); request.getSession().setAttribute("from", params.get("from")); request.getSession().setAttribute("to", params.get("to")); final String cacheKey = getCacheKey(params); if (cacheReadEnable) { final Query q = ds.find(Cache.class); q.filter("cacheKey", cacheKey).filter("servletName", this.getClass().getName()); final Cache c = (Cache) q.get(); if (c == null) { log.info("cacheKey:" + cacheKey + " on servletName: " + this.getClass().getName() + " not found"); } if (c != null) { final GridFSDBFile imageForOutput = MongoConnectionHelper.getGridFS() .findOne(new ObjectId(c.getGridId())); if (imageForOutput != null) { ds.save(c); try { response.setHeader("Content-Length", "" + imageForOutput.getLength()); response.setHeader("Content-Disposition", "inline; filename=\"" + imageForOutput.getFilename() + "\""); final OutputStream out = response.getOutputStream(); final InputStream in = imageForOutput.getInputStream(); final byte[] content = new byte[(int) imageForOutput.getLength()]; in.read(content); out.write(content); in.close(); out.close(); return; } catch (Exception e) { log.error(e); } } else { log.error("file not in db"); } } } final String formatIn = getFormatIn(period); final String formatOut = getFormatOut(period); final Query q = ds.createQuery(MapReduceMinMax.class).disableValidation(); final Date dFrom = DateTimeUtil.getDate("yyyy-MM-dd hh:mm:ss", from); final Date dTo = DateTimeUtil.getDate("yyyy-MM-dd hh:mm:ss", to); final List<Date> datesIn = getRangeDate(dFrom, dTo); final HashSet<String> datesInString = new HashSet<String>(); for (Date d : datesIn) { datesInString.add(DateTimeUtil.dateFormat(formatIn, d)); } if (datesIn != null && !datesIn.isEmpty()) { q.filter("_id in", datesInString); } q.order("_id"); final List<MapReduceMinMax> mapReduceResult = q.asList(); final TimeSeries serieMin = new TimeSeries("Min"); final TimeSeries serieMax = new TimeSeries("Max"); for (MapReduceMinMax m : mapReduceResult) { try { final Date tmpDate = DateTimeUtil.getDate(formatIn, m.getId().toString()); if (tmpDate == null) { continue; } final Millisecond t = new Millisecond(tmpDate); ChartEnumMinMaxHelper chartEnum = ChartEnumMinMaxHelper.getByFieldAndType(field, "min"); Method method = m.getClass().getMethod(chartEnum.getMethod()); Number n = (Number) method.invoke(m); serieMin.add(t, n); chartEnum = ChartEnumMinMaxHelper.getByFieldAndType(field, "max"); method = m.getClass().getMethod(chartEnum.getMethod()); n = (Number) method.invoke(m); serieMax.add(t, n); } catch (IllegalAccessException ex) { log.error(ex); } catch (IllegalArgumentException ex) { log.error(ex); } catch (InvocationTargetException ex) { log.error(ex); } catch (NoSuchMethodException ex) { log.error(ex); } catch (SecurityException ex) { log.error(ex); } } final ChartEnumMinMaxHelper chartData = ChartEnumMinMaxHelper.getByFieldAndType(field, "min"); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(serieMin); dataset.addSeries(serieMax); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Max/Min", "", chartData.getUm(), dataset, true, false, false); final XYPlot plot = (XYPlot) chart.getPlot(); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(formatOut)); axis.setVerticalTickLabels(true); if (field.toUpperCase().indexOf("PRESSURE") != -1) { plot.getRangeAxis().setRange(chartPressureMin, chartPressureMax); } final File f = File.createTempFile("mbmeteo", ".jpg"); ChartUtilities.saveChartAsJPEG(f, chart, dimx, dimy); try { if (cacheWriteEnable) { final GridFSInputFile gfsFile = MongoConnectionHelper.getGridFS().createFile(f); gfsFile.setFilename(f.getName()); gfsFile.save(); final Cache c = new Cache(); c.setServletName(this.getClass().getName()); c.setCacheKey(cacheKey); c.setGridId(gfsFile.getId().toString()); ds.save(c); } response.setContentType("image/jpeg"); response.setHeader("Content-Length", "" + f.length()); response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\""); final OutputStream out = response.getOutputStream(); final FileInputStream in = new FileInputStream(f.toString()); final int size = in.available(); final byte[] content = new byte[size]; in.read(content); out.write(content); in.close(); out.close(); } catch (Exception e) { log.error(e); } finally { f.delete(); } }