List of usage examples for org.jfree.chart.annotations XYDataImageAnnotation XYDataImageAnnotation
public XYDataImageAnnotation(Image image, double x, double y, double w, double h, boolean includeInDataBounds)
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapWorker.java
protected Void doInBackground() throws Exception { // this is a SwingWorker thread from its pool, give it a recognizable name Thread.currentThread().setName("PortHeatMapWorker"); JFreeChart Chart = PlotPanel.getHeatChart(); logger.info("Worker Building HeatMapPlot"); MessageManager.getInstance()/*from ww w .j a va2 s . c om*/ .postMessage(new SmtMessage(SmtMessageType.SMT_MSG_INFO, "Worker Building HeatMapPlot")); PortHeatMapDataSet pHeatMap = null; if (UseService) { SMT_UpdateService updateService = SMT_UpdateService.getInstance(); History = updateService.getCollection(); if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else if (History != null) { if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else { // FIXME - eliminate this, for test purposes only if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedNodes); else pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedDepths); } // logger.fine("Finished creating dataset"); // logger.fine("Max X: " + pHeatMap.getMaximumXValue()); // logger.fine("Max Y: " + pHeatMap.getMaximumYValue()); // logger.fine("Max Z: " + pHeatMap.getMaximumZValue()); // // if any of these "maximum" values are illegal, stop here and return null if (!pHeatMap.isValid()) { logger.severe("Invalid HeatMap, check OMS Collection or Depth filter (empty or null)"); MessageManager.getInstance().postMessage(new SmtMessage(SmtMessageType.SMT_MSG_SEVERE, "Invalid HeatMap, check OMS Collection or Depth filter (empty or null)")); PlotPanel.setHeatMapDataSet(null); return null; } PlotPanel.setHeatMapDataSet(pHeatMap); Range fixedXRange = new Range(0, pHeatMap.getMaximumXValue()); // time # Range fixedYRange = new Range(0, pHeatMap.getMaximumYValue()); // port # Range fixedZRange = new Range(0, pHeatMap.getMaximumZValue()); // % Util // there are 3 valid paint scales, 0, 1, & 2 LookupPaintScale paintScale = PaintScaleFactory.getLookupPaintScale(1, 0, fixedZRange.getUpperBound(), fixedZRange.getUpperBound()); ValueAxis paintAxis = PaintScaleFactory.getPaintScaleAxis(0, fixedZRange.getUpperBound(), PortHeatMapPlotPanel.UtilizationAxisLabel); BufferedImage image = HeatMapUtilities.createHeatMapImage(pHeatMap, paintScale); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, fixedXRange.getLowerBound(), fixedYRange.getLowerBound(), fixedXRange.getUpperBound(), fixedYRange.getUpperBound(), true); XYPlot plot = (XYPlot) Chart.getPlot(); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); // finally, show the heatmap PaintScaleLegend psLegend = new PaintScaleLegend(paintScale, paintAxis); psLegend.setMargin(new RectangleInsets(3, 40, 3, 10)); psLegend.setPosition(RectangleEdge.TOP); // location (within NORTH) of // heatmap legend psLegend.setAxisOffset(4.0); psLegend.setFrame(new BlockBorder(Color.GRAY)); Chart.addSubtitle(psLegend); // fix the sliders ranges, and set them for the middle if ((pHeatMap != null) && (PlotPanel != null)) { PlotPanel.getTimeSlider().setMinimum((int) fixedXRange.getLowerBound()); PlotPanel.getTimeSlider().setMaximum((int) fixedXRange.getUpperBound()); PlotPanel.getTimeSlider().setValue((int) fixedXRange.getCentralValue()); PlotPanel.getPortSlider().setMinimum((int) fixedYRange.getLowerBound()); PlotPanel.getPortSlider().setMaximum((int) fixedYRange.getUpperBound()); PlotPanel.getPortSlider().setValue((int) fixedYRange.getCentralValue()); HeatMapDepthPanel hmdp = new HeatMapDepthPanel(pHeatMap); PlotPanel.replaceDepthPanel(hmdp); } return null; }
From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java
private JFreeChart createChart(XYDataset dataset1) { JFreeChart chart_temp = ChartFactory.createScatterPlot(null, null, null, dataset1, PlotOrientation.VERTICAL, false, false, false);/* w w w. j a v a 2 s.c om*/ double range = Math.abs(data.getMaxInt() - data.getMinInt()); double dataMin, dataMax; if (range == 0.0) { dataMin = data.getMinInt() - 0.1; dataMax = data.getMaxInt() + 0.1; } else { dataMin = data.getMinInt(); dataMax = data.getMaxInt(); } PaintScale ps = new RainbowPaintScale(dataMin, dataMax); // PaintScale ps = new RedGreenPaintScale(dataMin, dataMax); BufferedImage image = ImageUtilities.createColorCodedImage(this.dataset, ps); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, dataset.GetImageWidth(), dataset.GetImageHeigth(), true); XYPlot plot = (XYPlot) chart_temp.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setVisible(false); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setVisible(false); return chart_temp; }
From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java
private void updateImagePlot(double minAmp, double maxAmp) { PaintScale ps;//from ww w .j a v a 2s . com switch (jcbColorScale.getSelectedIndex()) { case 0: { ps = new RainbowPaintScale(minAmp, maxAmp); break; } case 1: { ps = new RedGreenPaintScale(data.getMinInt(), data.getMaxInt()); break; } case 2: { ps = new GrayPaintScale(); break; } default: { ps = new RainbowPaintScale(minAmp, maxAmp); break; } } // PaintScale ps = new RedGreenPaintScale(data.getMinInt(), data.getMaxInt()); BufferedImage image = ImageUtilities.createColorCodedImage(dataset, ps, false, true); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, dataset.GetImageWidth(), dataset.GetImageHeigth(), true); XYPlot plot = (XYPlot) chartMultiSpec.getPlot(); plot.getRenderer().removeAnnotations(); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); ((PaintScaleLegend) chartMultiSpec.getSubtitle(0)).setScale(ps); ((PaintScaleLegend) chartMultiSpec.getSubtitle(0)).getAxis().setRange(minAmp, maxAmp); }