List of usage examples for org.jfree.chart.renderer.xy XYBlockRenderer setPaintScale
public void setPaintScale(PaintScale scale)
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.SimpleBlockChart.java
/** * Creates a chart for the specified dataset. * /*from ww w . jav a 2s . com*/ * @param dataset the dataset. * * @return A chart instance. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1"); JFreeChart chart = null; NumberAxis xAxis = new NumberAxis(xLabel); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (xLowerBound != null && xUpperBound != null) { xAxis.setLowerBound(xLowerBound); xAxis.setUpperBound(xUpperBound); } else { xAxis.setAutoRange(true); } xAxis.setAxisLinePaint(Color.white); xAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { xAxis.setLabelFont(addLabelsStyle.getFont()); xAxis.setLabelPaint(addLabelsStyle.getColor()); } NumberAxis yAxis = new NumberAxis(yLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (yLowerBound != null && yUpperBound != null) { yAxis.setLowerBound(yLowerBound); yAxis.setUpperBound(yUpperBound); } else yAxis.setAutoRange(true); yAxis.setAxisLinePaint(Color.white); yAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { yAxis.setLabelFont(addLabelsStyle.getFont()); yAxis.setLabelPaint(addLabelsStyle.getColor()); } XYBlockRenderer renderer = new XYBlockRenderer(); PaintScale paintScale = null; if (grayPaintScale) { paintScale = new GrayPaintScale(minScaleValue, maxScaleValue); } else { if (scaleLowerBound != null && scaleUpperBound != null) { paintScale = new LookupPaintScale(scaleLowerBound, scaleUpperBound, Color.gray); } else { paintScale = new LookupPaintScale(minScaleValue, maxScaleValue, Color.gray); } for (int i = 0; i < zRangeArray.length; i++) { ZRange zRange = zRangeArray[i]; ((LookupPaintScale) paintScale).add(zRange.getValue().doubleValue(), zRange.getColor()); } } renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setForegroundAlpha(0.66f); chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.removeLegend(); NumberAxis scaleAxis = new NumberAxis(zLabel); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); if (scaleLowerBound != null && scaleUpperBound != null) { scaleAxis.setLowerBound(scaleLowerBound); scaleAxis.setUpperBound(scaleUpperBound); } else scaleAxis.setAutoRange(true); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { scaleAxis.setLabelFont(addLabelsStyle.getFont()); scaleAxis.setLabelPaint(addLabelsStyle.getColor()); } if (blockHeight != null && blockWidth != null) { renderer.setBlockWidth(blockWidth.doubleValue()); renderer.setBlockHeight(blockHeight.doubleValue()); } PaintScaleLegend legend = new PaintScaleLegend(paintScale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.black)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(color); chart.addSubtitle(legend); // chart.setBackgroundPaint(new Color(180, 180, 250)); chart.setBackgroundPaint(color); logger.debug("OUT"); return chart; }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param dataset/* ww 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; }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param fragments//from www.j a va 2s. co 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:SciTK.PlotXYZBlock.java
private void init(String x_label, String y_label, String window_title) { chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);//w w w.ja va 2s . c om // turn off borders of the plot: XYPlot p = chart.getXYPlot(); p.getDomainAxis().setLowerMargin(0.0); p.getDomainAxis().setUpperMargin(0.0); p.getRangeAxis().setLowerMargin(0.0); p.getRangeAxis().setUpperMargin(0.0); // -------------------------------------------- // set up a lookup table // -------------------------------------------- // this is how we render the block plots: XYBlockRenderer renderer = new XYBlockRenderer(); // need to find max and min z of the data set: double min = 0; double max = 0; for (int i = 0; i < data.getSeriesCount(); i++) // iterate over data sets { for (int j = 0; j < data.getItemCount(i); j++) // iterate over points in dataset { if (data.getZValue(i, j) < min) min = data.getZValue(i, j); else if (data.getZValue(i, j) > max) max = data.getZValue(i, j); } } // create paint scale using min and max values, default color black: LookupPaintScale paintScale = new LookupPaintScale(min, max, Color.black); // set up the LUT: double step_size = (max - min) / 255.; // step size for LUT for (int i = 0; i < 256; i++) { paintScale.add(min + i * step_size, new Color(i, i, i, 255)); } renderer.setPaintScale(paintScale); // set this renderer to the plot: p.setRenderer(renderer); // -------------------------------------------- // set up a color bar // -------------------------------------------- // create an array of display labels: num_labels = 10; // default to 10 labels on color bar double display_step_size = (max - min) / ((double) num_labels); String[] scale_bar_labels = new String[num_labels + 1]; // to format numbers in scientific notation: DecimalFormat formater = new DecimalFormat("0.#E0"); // create list of labesl: for (int i = 0; i <= num_labels; i++) { scale_bar_labels[i] = formater.format(min + i * display_step_size); } // create axis: SymbolAxis scaleAxis = new SymbolAxis(null, scale_bar_labels); scaleAxis.setRange(min, max); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); // set up the paint scale: psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setBackgroundPaint(new Color(255, 255, 255, 0)); // clear background // set up frame with buffer region to allow text display psl.setFrame(new LineBorder((Paint) Color.BLACK, new BasicStroke((float) 1.0), new RectangleInsets(15, 10, 15, 10))); psl.setAxisOffset(5.0); // display on right side: psl.setPosition(RectangleEdge.RIGHT); // margin around color scale: psl.setMargin(new RectangleInsets(20, 15, 20, 15)); // add to the chart so it will be displayed by default: chart.addSubtitle(psl); // -------------------------------------------- // WINDOW-RELATED UI // -------------------------------------------- // set up the generic plot UI: super.window_title = window_title; super.initUI(); // add another menu item JMenuBar mb = super.getJMenuBar(); // get the menu bar // find menu named "Plot" JMenu menu_plot = null; for (int i = 0; i < mb.getMenuCount(); i++) { if (mb.getMenu(i).getText() == "Plot") menu_plot = mb.getMenu(i); } // Add a new checkbox for the color scale bar JCheckBoxMenuItem menu_plot_scalebar = new JCheckBoxMenuItem("Color Scale"); menu_plot_scalebar.setToolTipText("Show color scale bar?"); menu_plot_scalebar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setScaleBar(selected); } }); // set appropirate checkbox state: menu_plot_scalebar.setState(true); if (menu_plot != null) // sanity check menu_plot.add(menu_plot_scalebar); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
protected void resetRenderer(final IScope scope, final String serieid) { final XYBlockRenderer newr = (XYBlockRenderer) this.getOrCreateRenderer(scope, serieid); // newr.setSeriesStroke(0, new BasicStroke(0)); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (myserie.getMycolor() != null) { newr.setSeriesPaint(0, myserie.getMycolor()); }//from w w w. ja v a 2 s . c om if (myserie.getSValues(scope).size() > 0) { final double maxval = Collections.max(myserie.getSValues(scope)); final double minval = Collections.min(myserie.getSValues(scope)); Color cdeb = new Color(0, 0, 0, 0); if (myserie.getMyMincolor() != null) cdeb = myserie.getMyMincolor(); Color cend = new Color(0.9f, 0.9f, 0.9f, 1.0f); if (myserie.getMycolor() != null) cend = myserie.getMycolor(); LookupPaintScale paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, cend); if (myserie.getMyMedcolor() != null) paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, myserie.getMyMedcolor(), cend); newr.setPaintScale(paintscale); final NumberAxis scaleAxis = new NumberAxis(myserie.getName()); scaleAxis.setAxisLinePaint(this.axesColor); scaleAxis.setTickMarkPaint(this.axesColor); scaleAxis.setTickLabelFont(this.getTickFont()); scaleAxis.setRange(minval, maxval); scaleAxis.setAxisLinePaint(axesColor); scaleAxis.setLabelFont(getLabelFont()); if (textColor != null) { scaleAxis.setLabelPaint(textColor); scaleAxis.setTickLabelPaint(textColor); } if (!this.getXTickValueVisible(scope)) { scaleAxis.setTickMarksVisible(false); scaleAxis.setTickLabelsVisible(false); } final PaintScaleLegend legend = new PaintScaleLegend(paintscale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); // legend.setMargin(new RectangleInsets(5, 5, 5, 5)); // legend.setFrame(new BlockBorder(Color.red)); // legend.setPadding(new RectangleInsets(10, 10, 10, 10)); // legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(this.backgroundColor); // ArrayList<PaintScaleLegend> caxe=new // ArrayList<PaintScaleLegend>(); // caxe.add(legend); // chart.setSubtitles(caxe); if (!this.series_label_position.equals("none")) chart.addSubtitle(legend); } }
From source file:whitebox.stats.Kriging.java
/** * Draw Semivariogram surface map and also draw the search are if * Anisotropic/*from w w w.j ava 2s . com*/ * * @param Radius * @param AnIsotropic */ public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) { double[][] data = new double[3][BinSurface.length * BinSurface[0].length]; int n = 0; double max = Double.MIN_VALUE; for (int i = 0; i < BinSurface.length; i++) { for (int j = 0; j < BinSurface[i].length; j++) { data[0][n] = BinSurface[i][j].GridHorDistance; data[1][n] = BinSurface[i][j].GridVerDistance; if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius && !Double.isNaN(BinSurface[i][j].Value)) { data[2][n] = BinSurface[i][j].Value; if (max < data[2][n]) { max = data[2][n]; } } else { data[2][n] = -1; } n++; } } DefaultXYZDataset dataset = new DefaultXYZDataset(); dataset.addSeries("Value", data); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(LagSize); renderer.setBlockHeight(LagSize); renderer.setBlockAnchor(RectangleAnchor.CENTER); LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white); double colorRange = max / 6; //double colorRange = 23013; paintScale.add(0.0, Color.blue); paintScale.add(1 * colorRange, Color.green); paintScale.add(2 * colorRange, Color.cyan); paintScale.add(3 * colorRange, Color.yellow); paintScale.add(4 * colorRange, Color.ORANGE); paintScale.add(5 * colorRange, Color.red); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); if (AnIsotropic) { CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot(); XYSeries seriesT1 = new XYSeries("1"); XYSeriesCollection AngleCollct = new XYSeriesCollection(); double bw = BandWidth; double r = bw / Math.sin(Tolerance); if (r > Radius) { bw = Radius * Math.sin(Tolerance); r = Radius; } seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y2); } } else { double x1 = -bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x1, y2); } } } else { double y1 = bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y1); } } AngleCollct.addSeries(seriesT1); XYSeries seriesT2 = new XYSeries("2"); seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); seriesT2.add(0.0, 0.0); AngleCollct.addSeries(seriesT2); XYSeries seriesT3 = new XYSeries("3"); seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle)); seriesT3.add(0, 0); AngleCollct.addSeries(seriesT3); XYSeries seriesT4 = new XYSeries("4"); seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); seriesT4.add(0, 0); AngleCollct.addSeries(seriesT4); XYSeries seriesT5 = new XYSeries("5"); seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y2); } } else { double x1 = bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x1, y2); } } } else { double y1 = -bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y1); } } AngleCollct.addSeries(seriesT5); plot.setDataset(1, AngleCollct); XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < AngleCollct.getSeriesCount(); i++) { //plot.getRenderer().setSeriesPaint(i , Color.BLUE); lineshapRend.setSeriesPaint(i, Color.BLACK); } plot.setRenderer(1, lineshapRend); combinedrangexyplot.add(plot); } plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart("Semivariogram Surface", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); // create and display a frame... ChartFrame frame = new ChartFrame("", chart); frame.pack(); //frame.setSize(100, 50); frame.setVisible(true); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.blockcharts.TimeBlockChart.java
@Override public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); super.createChart(datasets); DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1"); DateAxis xAxis = new DateAxis(yLabel); xAxis.setLowerMargin(0.0);//from ww w . j a v a 2 s.c o m xAxis.setUpperMargin(0.0); xAxis.setInverted(false); xAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy")); if (dateAutoRange) { xAxis.setAutoRange(true); } else { DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1, formatter); xAxis.setTickUnit(unit); } if (dateMin != null && dateMax != null) { xAxis.setRange(dateMin, addDay(dateMax)); } else { xAxis.setRange(minDateFound, addDay(maxDateFound)); } // Calendar c=new GregorianCalendar(); // c.set(9 + 2000, Calendar.JANUARY, 1); // java.util.Date minima=c.getTime(); // Calendar c1=new GregorianCalendar(); // c1.set(9 + 2000, Calendar.FEBRUARY, 1); // java.util.Date massima=c1.getTime(); NumberAxis yAxis = new NumberAxis(xLabel); yAxis.setUpperMargin(0.0); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setRange(hourMin, hourMax); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(BLOCK_HEIGHT); // one block for each minute! renderer.setBlockHeight(0.017); //renderer.setBlockWidth(1); renderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); // MyXYItemLabelGenerator my=new MyXYItemLabelGenerator(); // renderer.setItemLabelsVisible(null); // renderer.setSeriesItemLabelGenerator(0, my); // renderer.setSeriesItemLabelsVisible(0, true); // XYTextAnnotation annotation1 = new XYTextAnnotation( // "P_",1.2309372E12, 14.3); // XYTextAnnotation annotation2 = new XYTextAnnotation( // "P_",1.2308508E12, 16.3); for (Iterator iterator = annotations.keySet().iterator(); iterator.hasNext();) { String annotationCode = (String) iterator.next(); AnnotationBlock annotationBlock = annotations.get(annotationCode); XYTextAnnotation xyAnnotation = new XYTextAnnotation(annotationBlock.getAnnotation(), annotationBlock.getXPosition() + ANNOTATION_HEIGHT, annotationBlock.getYPosition()); if (styleAnnotation != null) { xyAnnotation.setFont(new Font(styleAnnotation.getFontName(), Font.BOLD, styleAnnotation.getSize())); xyAnnotation.setPaint(styleAnnotation.getColor()); } else { xyAnnotation.setFont(new Font("Nome", Font.BOLD, 8)); xyAnnotation.setPaint(Color.BLACK); } xyAnnotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); renderer.addAnnotation(xyAnnotation); } logger.debug("Annotation set"); LookupPaintScale paintScale = new LookupPaintScale(0.5, ranges.size() + 0.5, color); String[] labels = new String[ranges.size() + 1]; labels[0] = ""; // ******************** SCALE **************************** for (Iterator iterator = ranges.iterator(); iterator.hasNext();) { RangeBlocks range = (RangeBlocks) iterator.next(); Integer index = patternRangeIndex.get(range.getPattern()); Color color = range.getColor(); if (color != null) { //Paint colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(), 50); Paint colorTransparent = null; if (addTransparency == true) { colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50); } else { colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue()); } paintScale.add(index + 0.5, colorTransparent); } //String insertLabel=" "+range.getLabel(); String insertLabel = range.getLabel(); labels[index + 1] = insertLabel; } renderer.setPaintScale(paintScale); SymbolAxis scaleAxis = new SymbolAxis(null, labels); scaleAxis.setRange(0.5, ranges.size() + 0.5); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); org.jfree.chart.title.PaintScaleLegend psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setMargin(new RectangleInsets(3, 10, 3, 10)); psl.setPosition(RectangleEdge.BOTTOM); psl.setAxisOffset(5.0); // ******************** END SCALE **************************** logger.debug("Scale Painted"); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); logger.debug("Plot set"); JFreeChart chart = new JFreeChart(name, plot); if (styleTitle != null) { TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); } chart.removeLegend(); chart.setBackgroundPaint(Color.white); chart.addSubtitle(psl); logger.debug("OUT"); return chart; }