List of usage examples for org.jfree.chart JFreeChart setBorderVisible
public void setBorderVisible(boolean visible)
From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java
public static void main(String args[]) throws Exception { MarinogramTemperaturePlot mp = new MarinogramTemperaturePlot(800, 200, "UTC", "en"); mp.setDescription("Temperature"); MarinogramTemperaturePlot mp1 = new MarinogramTemperaturePlot(800, 200, "UTC", "en"); mp1.setDescription("Temperature1"); MarinogramPlot marinogram = new MarinogramWrapper(900, 200, "UTC", "en"); marinogram.setDescription("marinogram"); MarinogramWrapper marinogram1 = new MarinogramWrapper(940, 200, "UTC", "en"); // //ww w.j a v a2s. com // 30.95, 71.5 // 58.9653, 5.7180 //41.8947&longitude=12.4839 //41.0138 //5.04092, 58.89468 //16.66, 68.56 //10.72938, 71.50000 ChartPlottingInfo cpi = new ChartPlottingInfo.Builder(5.32905, 74.39825).width(mp1.getWidth()) .showAirTemperature(true).showWaterTemperature(true).showDewpointTemperature(true) .showPressure(true).showWaveDirection(true).showWaveHeight(true).showCurrentDirection(true) .showCurrentSpeed(true).showWindDirection(true).showWindSpeed(true).timezone("UTC").language("en") .build(); JFreeChart jchart = marinogram1.createMarinogram(cpi); jchart.setBorderVisible(false); Paint paint = new GradientPaint(0, 0, Color.WHITE, marinogram1.getWidth(), 0, Color.WHITE); jchart.setBackgroundPaint(paint); jchart.removeLegend(); ChartFrame frame = new ChartFrame(jchart, new java.awt.Dimension(900, 400)); frame.pack(); frame.setVisible(true); }
From source file:mzmatch.ipeak.normalisation.VanDeSompele.java
public static void main(String args[]) { try {//from w w w .ja v a2 s.co m Tool.init(); // parse the commandline options Options options = new Options(); CmdLineParser cmdline = new CmdLineParser(options); // check whether we need to show the help cmdline.parse(args); if (options.help) { Tool.printHeader(System.out, application, version); cmdline.printUsage(System.out, ""); return; } if (options.verbose) { Tool.printHeader(System.out, application, version); cmdline.printOptions(); } // check the command-line parameters { // if the output directories do not exist, create them if (options.output != null) Tool.createFilePath(options.output, true); } // load the data if (options.verbose) System.out.println("Loading data"); ParseResult result = PeakMLParser.parse(new FileInputStream(options.input), true); Header header = result.header; IPeakSet<IPeakSet<? extends IPeak>> peaksets = (IPeakSet<IPeakSet<? extends IPeak>>) result.measurement; int nrmeasurements = header.getNrMeasurementInfos(); // remove the stability factor annotation for (IPeak peak : peaksets) peak.removeAnnotation("stability factor"); // load the database if (options.verbose) System.out.println("Loading the molecule database"); HashMap<String, Molecule> database = MoleculeIO.parseXml(new FileInputStream(options.database)); // filter the set to include only identifiable metabolites if (options.verbose) System.out.println("Creating selection"); Vector<IPeakSet<? extends IPeak>> selection = new Vector<IPeakSet<? extends IPeak>>(); for (Molecule molecule : database.values()) { double mass = molecule.getMass(Mass.MONOISOTOPIC); double delta = PeriodicTable.PPM(mass, options.ppm); // get the most intense peak containing all the measurements Vector<IPeakSet<? extends IPeak>> neighbourhoud = peaksets.getPeaksInMassRange(mass - delta, mass + delta); Collections.sort(neighbourhoud, IPeak.sort_intensity_descending); for (IPeakSet<? extends IPeak> neighbour : neighbourhoud) if (count(neighbour) == nrmeasurements) { selection.add(neighbour); break; } } // calculate the stability factor for each peak in the selection if (options.verbose) System.out.println("Calculating stability factors"); for (int peakid1 = 0; peakid1 < selection.size(); ++peakid1) { double stddeviations[] = new double[selection.size()]; IPeakSet<? extends IPeak> peakset1 = selection.get(peakid1); for (int peakid2 = 0; peakid2 < selection.size(); ++peakid2) { IPeakSet<? extends IPeak> peakset2 = selection.get(peakid2); double values[] = new double[nrmeasurements]; for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) { int measurementid1 = peakset1.get(measurementid).getMeasurementID(); int setid1 = header.indexOfSetInfo(header.getSetInfoForMeasurementID(measurementid1)); int measurementid2 = peakset2.get(measurementid).getMeasurementID(); int setid2 = header.indexOfSetInfo(header.getSetInfoForMeasurementID(measurementid2)); if (setid1 != setid2 || measurementid1 != measurementid2) System.err.println("[WARNING]: differing setid or spectrumid for comparison"); values[measurementid] = Math.log(peakset1.get(measurementid).getIntensity() / peakset2.get(measurementid).getIntensity()) / Math.log(2); } stddeviations[peakid2] = Statistical.stddev(values); } peakset1.addAnnotation("stability factor", Statistical.mean(stddeviations)); } // sort on the stability factor Collections.sort(selection, new IPeak.AnnotationAscending("stability factor")); // take the top 10% and calculate the geometric mean if (options.verbose) System.out.println("Calculating normalisation factors"); int nrselected = (int) (0.1 * selection.size()); if (nrselected < 10) nrselected = (10 < selection.size() ? 10 : selection.size()); double normalization_factors[] = new double[nrmeasurements]; for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) { double values[] = new double[nrselected]; for (int i = 0; i < nrselected; ++i) { IPeak peak = selection.get(i).get(measurementid); values[i] = peak.getIntensity(); } normalization_factors[measurementid] = Statistical.geomean(values); } // scale the found normalization factors double maxnf = Statistical.max(normalization_factors); for (int sampleid = 0; sampleid < nrmeasurements; ++sampleid) normalization_factors[sampleid] /= maxnf; // write the selection if needed if (options.selection != null) { if (options.verbose) System.out.println("Writing original selection data"); PeakMLWriter.write(result.header, selection, null, new GZIPOutputStream(new FileOutputStream(options.selection)), null); } // normalize all the peaks if (options.verbose) System.out.println("Normalizing all the entries"); for (IPeakSet<? extends IPeak> peakset : peaksets) { for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) { // TODO why did I do this again ? int id = 0; int setid = 0; int spectrumid = 0; for (int i = 0; i < header.getNrSetInfos(); ++i) { SetInfo set = header.getSetInfos().get(i); if (id + set.getNrMeasurementIDs() > measurementid) { setid = i; spectrumid = measurementid - id; break; } else id += set.getNrMeasurementIDs(); } MassChromatogram<Peak> masschromatogram = null; for (IPeak p : peakset) { int mymeasurementid = p.getMeasurementID(); int mysetid = header.indexOfSetInfo(header.getSetInfoForMeasurementID(mymeasurementid)); if (mysetid == setid && mymeasurementid == spectrumid) { masschromatogram = (MassChromatogram<Peak>) p; break; } } if (masschromatogram == null) continue; for (IPeak peak : masschromatogram.getPeaks()) peak.setIntensity(peak.getIntensity() / normalization_factors[measurementid]); } } // write the selection if needed if (options.selection_normalized != null) { if (options.verbose) System.out.println("Writing the normalized selection data"); PeakMLWriter.write(result.header, selection, null, new GZIPOutputStream(new FileOutputStream(options.selection_normalized)), null); } // write the factors if needed if (options.factors != null) { if (options.verbose) System.out.println("Writing the normalization factors"); PrintStream out = new PrintStream(options.factors); for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) out.println(header.getMeasurementInfo(measurementid).getLabel() + "\t" + normalization_factors[measurementid]); } // write the plot if needed if (options.img != null) { if (options.verbose) System.out.println("Writing the graph"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart linechart = ChartFactory.createLineChart(null, "measurement", "normalization factor", dataset, PlotOrientation.VERTICAL, false, // legend false, // tooltips false // urls ); CategoryPlot plot = (CategoryPlot) linechart.getPlot(); CategoryAxis axis = (CategoryAxis) plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesFilled(0, true); renderer.setSeriesShapesVisible(0, true); linechart.setBackgroundPaint(Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // create the datasets for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) dataset.addValue(normalization_factors[measurementid], "", header.getMeasurementInfo(measurementid).getLabel()); JFreeChartTools.writeAsPDF(new FileOutputStream(options.img), linechart, 800, 500); } // write the normalized values if (options.verbose) System.out.println("Writing the normalized data"); PeakMLWriter.write(result.header, peaksets.getPeaks(), null, new GZIPOutputStream(new FileOutputStream(options.output)), null); } catch (Exception e) { Tool.unexpectedError(e, application); } }
From source file:mzmatch.ipeak.align.CowCoda.java
@SuppressWarnings("unchecked") public static void main(String args[]) { final String lbl_mcq = "mcq"; try {/*from w w w .j a va2 s .co m*/ Tool.init(); // parse the commandline options final Options options = new Options(); CmdLineParser cmdline = new CmdLineParser(options); // check whether we need to show the help cmdline.parse(args); if (options.help) { Tool.printHeader(System.out, application, version); cmdline.printUsage(System.out, ""); return; } if (options.verbose) { Tool.printHeader(System.out, application, version); cmdline.printOptions(); } // check the command-line parameters int filetype = JFreeChartTools.PDF; { if (options.ppm == -1) { System.err.println("[ERROR]: the ppm-value needs to be set."); System.exit(0); } if (options.order == -1) { System.err.println("[ERROR]: the order for the polynomial fit needs to be set."); System.exit(0); } if (options.maxrt == -1) { System.err.println("[ERROR]: the maximum retention time shift is not set."); System.exit(0); } if (options.image != null) { String extension = options.image.substring(options.image.lastIndexOf('.') + 1); if (extension.toLowerCase().equals("png")) filetype = JFreeChartTools.PNG; else if (extension.toLowerCase().equals("pdf")) filetype = JFreeChartTools.PDF; else { System.err.println( "[ERROR]: file extension of the image file needs to be either PDF or PNG."); System.exit(0); } } // if the output directories do not exist, create them if (options.output != null) Tool.createFilePath(options.output, true); if (options.image != null) Tool.createFilePath(options.image, true); if (options.selection != null) Tool.createFilePath(options.selection, true); } // load the data if (options.verbose) System.out.println("Loading the data"); double maxrt = 0; Vector<ParseResult> data = new Vector<ParseResult>(); Vector<IPeakSet<IPeak>> matchdata = new Vector<IPeakSet<IPeak>>(); for (String file : options.input) { System.out.println("- " + new File(file).getName()); // load the mass chromatogram data ParseResult result = PeakMLParser.parse(new FileInputStream(file), true); data.add(result); // select the best mass chromatograms Vector<IPeak> selection = new Vector<IPeak>(); for (IPeak peak : (IPeakSet<IPeak>) result.measurement) { maxrt = Math.max(maxrt, maxRT(peak)); double mcq = codaDW(peak); peak.addAnnotation(lbl_mcq, Double.toString(mcq), Annotation.ValueType.DOUBLE); if (mcq >= options.codadw) selection.add(peak); } // keep track of the selected mass chromatograms int id = options.input.indexOf(file); IPeakSet<IPeak> peakset = new IPeakSet<IPeak>(selection); peakset.setMeasurementID(id); for (IPeak mc : peakset) mc.setMeasurementID(id); matchdata.add(peakset); } // match the selection together if (options.verbose) System.out.println("Matching the data"); Vector<IPeakSet<IPeak>> matches = IPeak.match((Vector) matchdata, options.ppm, new IPeak.MatchCompare<IPeak>() { public double distance(IPeak peak1, IPeak peak2) { double diff = Math.abs(peak1.getRetentionTime() - peak2.getRetentionTime()); if (diff > options.maxrt) return -1; Signal signal1 = new Signal(peak1.getSignal()); signal1.normalize(); Signal signal2 = new Signal(peak2.getSignal()); signal2.normalize(); double offset = bestOffSet(peak1, peak2, options.maxrt); for (int i = 0; i < signal2.getSize(); ++i) signal2.getX()[i] += offset; double correlation = signal2 .pearsonsCorrelation(signal1)[Statistical.PEARSON_CORRELATION]; if (correlation < 0.5) return -1; // the match-function optimizes toward 0 (it's a distance) return 1 - correlation; } }); // filter out all incomplete sets Vector<IPeakSet<IPeak>> valids = new Vector<IPeakSet<IPeak>>(); for (IPeakSet<IPeak> set : matches) { if (set.size() < options.input.size()) continue; valids.add((IPeakSet) set); } // calculate the alignment factors if (options.verbose) System.out.println("Calculating the alignment factors"); double medians[] = new double[valids.size() + 2]; DataFrame.Double dataframe = new DataFrame.Double(valids.size() + 2, options.input.size()); medians[0] = 0; medians[medians.length - 1] = maxrt; for (int i = 0; i < options.input.size(); ++i) { dataframe.set(0, i, 0.1); dataframe.set(dataframe.getNrRows() - 1, i, 0); } for (int matchid = 0; matchid < valids.size(); ++matchid) { IPeakSet<IPeak> match = valids.get(matchid); // find the most central double offsets[][] = new double[match.size()][match.size()]; for (int i = 0; i < match.size(); ++i) for (int j = i + 1; j < match.size(); ++j) { offsets[i][j] = bestOffSet(match.get(i), match.get(j), options.maxrt); offsets[j][i] = -offsets[i][j]; } int besti = 0; double bestabssum = Double.MAX_VALUE; for (int i = 0; i < match.size(); ++i) { double abssum = 0; for (int j = 0; j < match.size(); ++j) abssum += Math.abs(offsets[i][j]); if (abssum < bestabssum) { besti = i; bestabssum = abssum; } } for (int i = 0; i < match.size(); ++i) dataframe.set(matchid + 1, match.get(i).getMeasurementID(), (i == besti ? 0 : offsets[i][besti])); medians[matchid + 1] = match.get(besti).getRetentionTime(); dataframe.setRowName(matchid, Double.toString(match.get(besti).getRetentionTime())); } double minmedian = Statistical.min(medians); double maxmedian = Statistical.max(medians); // calculate for each profile the correction function PolynomialFunction functions[] = new PolynomialFunction[valids.size()]; for (int i = 0; i < options.input.size(); ++i) functions[i] = PolynomialFunction.fit(options.order, medians, dataframe.getCol(i)); // make a nice plot out of the whole thing if (options.verbose) System.out.println("Writing results"); if (options.image != null) { org.jfree.data.xy.XYSeriesCollection dataset = new org.jfree.data.xy.XYSeriesCollection(); JFreeChart linechart = ChartFactory.createXYLineChart(null, "Retention Time (seconds)", "offset", dataset, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); // setup the colorkey Colormap colormap = new Colormap(Colormap.EXCEL); // get the structure behind the graph XYPlot plot = (XYPlot) linechart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // setup the plot area linechart.setBackgroundPaint(java.awt.Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // create the datasets for (int i = 0; i < options.input.size(); ++i) { org.jfree.data.xy.XYSeries series = new org.jfree.data.xy.XYSeries(dataframe.getColName(i)); org.jfree.data.xy.XYSeries function = new org.jfree.data.xy.XYSeries( dataframe.getColName(i) + "-function"); dataset.addSeries(series); dataset.addSeries(function); renderer.setSeriesPaint(dataset.getSeriesCount() - 1, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesPaint(dataset.getSeriesCount() - 2, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesLinesVisible(dataset.getSeriesCount() - 2, false); renderer.setSeriesShapesVisible(dataset.getSeriesCount() - 2, true); // add the data-points for (int j = 0; j < valids.size(); ++j) series.add(medians[j], dataframe.get(j, i)); for (double x = minmedian; x < maxmedian; ++x) function.add(x, functions[i].getY(x)); } dataset.removeAllSeries(); for (int i = 0; i < options.input.size(); ++i) { Function function = functions[i]; org.jfree.data.xy.XYSeries series = new org.jfree.data.xy.XYSeries(dataframe.getColName(i)); dataset.addSeries(series); renderer.setSeriesPaint(i, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); // add the data-points for (int j = 0; j < valids.size(); ++j) series.add(medians[j], dataframe.get(j, i) - function.getY(medians[j])); } JFreeChartTools.writeAs(filetype, new FileOutputStream(options.image), linechart, 800, 500); } // save the selected if (options.selection != null) { Header header = new Header(); // set the number of peaks to be stored header.setNrPeaks(valids.size()); // create a set for the measurements SetInfo set = new SetInfo("", SetInfo.SET); header.addSetInfo(set); // create the measurement infos for (int i = 0; i < options.input.size(); ++i) { String file = options.input.get(i); // create the measurement info MeasurementInfo measurement = new MeasurementInfo(i, data.get(i).header.getMeasurementInfo(0)); measurement.addFileInfo(new FileInfo(file, file)); header.addMeasurementInfo(measurement); // add the file to the set set.addChild(new SetInfo(file, SetInfo.SET, i)); } // write the data PeakMLWriter.write(header, (Vector) valids, null, new GZIPOutputStream(new FileOutputStream(options.selection)), null); } // correct the values with the found function and save them for (int i = 0; i < options.input.size(); ++i) { Function function = functions[i]; ParseResult result = data.get(i); IPeakSet<MassChromatogram<Peak>> peakset = (IPeakSet<MassChromatogram<Peak>>) result.measurement; for (IPeak peak : peakset) align(peak, function); File filename = new File(options.input.get(i)); String name = filename.getName(); PeakMLWriter.write(result.header, (Vector) peakset.getPeaks(), null, new GZIPOutputStream(new FileOutputStream(options.output + "/" + name)), null); } } catch (Exception e) { Tool.unexpectedError(e, application); } }
From source file:jgnash.ui.budget.BudgetSparkline.java
public static Icon getSparklineImage(final List<BigDecimal> amounts) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final boolean[] negate = new boolean[amounts.size()]; for (int i = 0; i < amounts.size(); i++) { dataset.addValue(amounts.get(i), CATEGORY, i); negate[i] = amounts.get(i).signum() == -1; }/*from www . j a va2 s.co m*/ CategoryAxis xAxis = new CategoryAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); xAxis.setAxisLineVisible(false); xAxis.setVisible(false); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setAutoRangeIncludesZero(true); yAxis.setAutoRange(true); yAxis.setVisible(false); BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { return negate[column] ? Color.RED : Color.BLACK; } }; renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setInsets(INSETS); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(CLEAR); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBorderVisible(false); chart.setBackgroundPaint(CLEAR); Icon icon = EMPTY_ICON; try { byte[] image = ENCODER .encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null)); icon = new ImageIcon(image); } catch (IOException ex) { Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex); } return icon; }
From source file:eu.kprod.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false);//from w w w . j a v a2s.c om axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:org.multiwii.swingui.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false);//from ww w. j a va2s. co m axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java
private static JFreeChart createJFreeChart(String title, Plot plot, int width) { JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBorderVisible(false); Paint paint = new GradientPaint(0, 0, Color.WHITE, width, 0, Color.WHITE); chart.setBackgroundPaint(paint);//from w w w.j av a 2 s. c o m return chart; }
From source file:org.nbheaven.sqe.codedefects.dashboard.controlcenter.panels.Statistics.java
private static JFreeChart createOverviewPanel(DefaultCategoryDataset dataSet) { JFreeChart overview = org.jfree.chart.ChartFactory.createStackedBarChart(null, null, "CodeDefects", dataSet, PlotOrientation.HORIZONTAL, false, true, false); overview.setBorderVisible(false); overview.setBackgroundPaint(Color.WHITE); overview.setAntiAlias(true);// w w w . j ava 2 s. com overview.setNotify(true); CategoryPlot overviewPlot = overview.getCategoryPlot(); overviewPlot.setRangeGridlinePaint(Color.BLACK); overviewPlot.setDomainGridlinePaint(Color.BLACK); overviewPlot.setBackgroundPaint(Color.WHITE); overviewPlot.setForegroundAlpha(0.7f); overviewPlot.setRangeAxisLocation(AxisLocation.getOpposite(overviewPlot.getRangeAxisLocation())); CategoryAxis domainAxis = overviewPlot.getDomainAxis(); domainAxis.setVisible(true); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setLabel(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); overviewPlot.setRangeAxis(rangeAxis); CategoryItemRenderer categoryItemRenderer = new StackedBarRenderer(); //3D(); // categoryItemRenderers[0].setPaint(Color.RED); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); categoryItemRenderer.setBaseItemLabelsVisible(true); overviewPlot.setRenderer(categoryItemRenderer); return overview; }
From source file:org.fhaes.fhrecorder.util.ColorBar.java
/** * Creates a chart when given a data set. * //from www . ja v a2 s. co m * @param dataset to be plotted. * @return the created chart. */ private static JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", dataset, PlotOrientation.HORIZONTAL, false, true, false); chart.setPadding(RectangleInsets.ZERO_INSETS); chart.setBorderVisible(false); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setBarPainter(new StandardBarPainter()); // Remove shine renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setShadowVisible(false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRenderer(renderer); // plot.setBackgroundAlpha(0.0f); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.getRangeAxis().setVisible(false); plot.getRangeAxis().setLowerMargin(0); plot.getRangeAxis().setUpperMargin(0); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); return chart; }
From source file:fr.gouv.diplomatie.applitutoriel.utility.Graphique.java
/** * Creer camember3 d.//from w w w . j a v a 2 s . co m * * @param title * the title * @param dataset * the dataset * @param legend * the legend * @param tooltips * the tooltips * @param urls * the urls * @return the j free chart * @throws FontFormatException * the font format exception * @throws IOException * Signals that an I/O exception has occurred. */ public static JFreeChart creerCamember3D(final String title, final DefaultPieDataset dataset, final boolean legend, final boolean tooltips, final boolean urls) throws FontFormatException, IOException { dataset.sortByValues(SortOrder.DESCENDING); final JFreeChart jfreeChart = ChartFactory.createPieChart3D(title, dataset, legend, tooltips, urls); jfreeChart.setBackgroundPaint(Color.white); jfreeChart.setBorderVisible(true); jfreeChart.getLegend().setPosition(RectangleEdge.LEFT); final GraphicsEnvironment graph = GraphicsEnvironment.getLocalGraphicsEnvironment(); final InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("hornet/framework/font/LiberationSans-Bold.ttf"); final Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream); graph.registerFont(font); jfreeChart.getLegend().setItemFont(new Font("Liberation Sans", Font.BOLD, 11)); jfreeChart.getLegend().setHeight(400); jfreeChart.getLegend().setBorder(0, 0, 0, 0); jfreeChart.setTitle(new TextTitle(title, new Font("Liberation Sans", Font.BOLD, 16))); final PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); final int nbData = dataset.getItemCount(); int cptColor = 0; for (int x = 0; x < nbData; x++) { if (cptColor >= listColor.size()) { cptColor = 0; } piePlot.setSectionPaint(dataset.getKey(x), listColor.get(cptColor)); cptColor++; } piePlot.setForegroundAlpha(0.5f); piePlot.setLabelFont(new Font("Liberation Sans", Font.BOLD, 12)); piePlot.setLabelOutlineStroke(null); piePlot.setLabelLinkStroke(new BasicStroke(0.4f)); piePlot.setLabelBackgroundPaint(Color.WHITE); piePlot.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); piePlot.setBackgroundAlpha(0); piePlot.setOutlineVisible(false); piePlot.setForegroundAlpha(1); // transparence piePlot.setInteriorGap(0); // le camembert occupe plus de place piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}")); piePlot.setStartAngle(70); piePlot.setCircular(true); // force pour avoir un cercle et pas un oval piePlot.setMaximumLabelWidth(0.20); piePlot.setBaseSectionOutlinePaint(Color.BLACK); // bordure du camembert return jfreeChart; }