List of usage examples for org.jfree.chart.renderer.xy XYBlockRenderer setBaseToolTipGenerator
@Override public void setBaseToolTipGenerator(XYToolTipGenerator generator)
From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java
public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) { super(new BorderLayout()); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(1.0);//w w w.ja v a 2 s . com xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(1.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { XYZDataset xyzDataset = (XYZDataset) dataset; double x = xyzDataset.getXValue(series, item); double y = xyzDataset.getYValue(series, item); double z = xyzDataset.getZValue(series, item); return ("X=" + x + ", Y=" + y + ", Z=" + z); } }); PaintScale scale = new ColorPaintScale(lowerBound, upperBound); renderer.setPaintScale(scale); ValueAxis axis = new NumberAxis(); axis.setLowerBound(scale.getLowerBound()); axis.setUpperBound(scale.getUpperBound()); PaintScaleLegend legend = new PaintScaleLegend(scale, axis); legend.setMargin(new RectangleInsets(10, 10, 10, 10)); legend.setPosition(RectangleEdge.RIGHT); MatrixXYDataset dataset = new MatrixXYDataset(m); plot = new XYPlot(dataset, xAxis, yAxis, renderer); chart = new JFreeChart(plot); chart.removeLegend(); chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDisplayToolTips(true); this.add(chartPanel, BorderLayout.CENTER); }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);// w ww . java2s. c o m xAxis.setUpperMargin(0.0); flagNames = createFlagNames(Dddb.getInstance().getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER)); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); final XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param fragments//from w w w. jav a 2 s .c o m * @param ticvar * @param useRT * @return */ public XYPlot provide1DCoPlot(List<IFileFragment> fragments, String ticvar, boolean useRT) { final String satVar = "scan_acquisition_time"; DefaultXYZDataset cd = new DefaultXYZDataset(); int rowIdx = 0; double min = 0; double max = 1; double minRT = Double.POSITIVE_INFINITY; double maxRT = Double.NEGATIVE_INFINITY; int y = 0; for (IFileFragment f : fragments) { double[] domainValues = null; if (useRT) { domainValues = (double[]) f.getChild(satVar).getArray().get1DJavaArray(double.class); } else { domainValues = (double[]) f.getChild("scan_index").getArray().get1DJavaArray(double.class); } double[] tic = (double[]) f.getChild(ticvar).getArray().get1DJavaArray(double.class); double maxtic = MathTools.max(tic); double mintic = MathTools.min(tic); double[][] values = new double[3][tic.length]; for (int i = 0; i < tic.length; i++) { values[0][i] = domainValues[i]; values[1][i] = y; values[2][i] = Math.sqrt((tic[i] - mintic) / (maxtic - mintic)); } y++; cd.addSeries(f.getName(), values); } // ArrayDouble.D1 a = new ArrayDouble.D1(npoints); // int offset = 0; // for (IFileFragment f : t) { // Array tic = f.getChild(ticvar).getArray(); // int len = tic.getShape()[0]; // Array.arraycopy(tic, 0, a, offset, len); // offset += len; // } // histogram with fixed binsize // fill intensities into adequate bin, raise count in bin by one // afterwards, relative frequency within a bin gives a normalization // coefficient XYBlockRenderer xyb = new XYBlockRenderer(); GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), min, max, ImageTools.rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv"))); xyb.setPaintScale(ps); final String[] colnames = new String[fragments.size()]; for (int i = 0; i < colnames.length; i++) { colnames[i] = StringTools.removeFileExt(fragments.get(i).getName()); } NumberAxis na = null; if (useRT) { na = new NumberAxis("time [s]"); na.setAutoRangeIncludesZero(false); na.setLowerMargin(0); na.setUpperMargin(0); } else { na = new NumberAxis("scan index"); } // na.setVerticalTickLabels(true); XYPlot xyp = new XYPlot(cd, na, new SymbolAxis("chromatogram", colnames), xyb); xyb.setBlockWidth(1); xyp.setBackgroundPaint(Color.BLACK); xyb.setBaseToolTipGenerator(new XYZToolTipGenerator() { @Override public String generateToolTip(XYZDataset xyzd, int i, int i1) { return colnames[xyzd.getY(i, i1).intValue()] + " @" + xyzd.getXValue(i, i1) + " = " + xyzd.getZValue(i, i1); } @Override public String generateToolTip(XYDataset xyd, int i, int i1) { if (xyd instanceof XYZDataset) { return generateToolTip((XYZDataset) xyd, i, i1); } return colnames[xyd.getY(i, i1).intValue()] + ":" + xyd.getXValue(i, i1); } }); return xyp; }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param dataset/* w w w .j a v a 2 s .c o m*/ * @param tooltipGenerator * @param minRange * @param maxRange * @param useRT * @return */ public XYPlot provide1DCoPlot(XYZDataset dataset, SelectionAwareXYTooltipGenerator tooltipGenerator, double minRange, double maxRange, boolean useRT) { XYBlockRenderer xyb = new XYBlockRenderer(); GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), minRange, maxRange, ImageTools.rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv"))); xyb.setPaintScale(ps); final String[] colnames = new String[dataset.getSeriesCount()]; for (int i = 0; i < dataset.getSeriesCount(); i++) { colnames[i] = "" + dataset.getSeriesKey(i);//StringTools.removeFileExt(fragments.get(i).getName()); } NumberAxis na = null; if (useRT) { na = new NumberAxis("time [s]"); na.setAutoRangeIncludesZero(false); na.setLowerMargin(0); na.setUpperMargin(0); } else { na = new NumberAxis("scan index"); } // na.setVerticalTickLabels(true); XYPlot xyp = new XYPlot(dataset, na, new SymbolAxis("chromatogram", colnames), xyb); //xyb.setBlockWidth(1); xyp.setBackgroundPaint(ps.getPaint(ps.getLowerBound())); tooltipGenerator.setXYToolTipGenerator(new XYZToolTipGenerator() { @Override public String generateToolTip(XYZDataset xyzd, int i, int i1) { return colnames[xyzd.getY(i, i1).intValue()] + " @" + xyzd.getXValue(i, i1) + " = " + xyzd.getZValue(i, i1); } @Override public String generateToolTip(XYDataset xyd, int i, int i1) { if (xyd instanceof XYZDataset) { return generateToolTip((XYZDataset) xyd, i, i1); } return colnames[xyd.getY(i, i1).intValue()] + ":" + xyd.getXValue(i, i1); } }); xyb.setBaseToolTipGenerator(tooltipGenerator); return xyp; }