List of usage examples for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions
public void setCategoryLabelPositions(CategoryLabelPositions positions)
From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java
protected JFreeChart createChart(CategoryDataset dataset, String title, String yaxis, int max, int min) { final JFreeChart chart = ChartFactory.createStackedAreaChart(title, // chart // title null, // unused yaxis, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/* w ww . jav a 2s . c om*/ final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.BOTTOM); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(max); rangeAxis.setLowerBound(min); final StackedAreaRenderer renderer = (StackedAreaRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:UserInterface.PatientRole.ManageMyVitalSignsAndFitnessRecordJPanel.java
private void createChart() { DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset(); int selectedRow = viewVitalSignsJTable1.getSelectedRow(); ArrayList<Record> recordList = patient.getRecordHistory().getRecordList(); /*At least 2 vital sign records needed to show chart */ if (recordList.isEmpty() || recordList.size() == 1) { JOptionPane.showMessageDialog(this, "No Fitness Record or only one fitness record found. At least 2 fitness records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return;//from ww w . j ava2s. c o m } for (Record record : recordList) { vitalSignDataset.addValue(record.getStandTime(), "StandTime", record.getDate()); vitalSignDataset.addValue(record.getMoveTime(), "MoveTime", record.getDate()); vitalSignDataset.addValue(record.getExcerciseTime(), "ExcerciseTime", record.getDate()); vitalSignDataset.addValue(record.getTotalTime(), "TotalTime", record.getDate()); } JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Fitness Record Chart", "Time Stamp", "Time(mins)", vitalSignDataset, PlotOrientation.VERTICAL, true, false, false); vitalSignChart.setBackgroundPaint(Color.white); CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot(); vitalSignChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }
From source file:gov.nih.nci.cma.web.graphing.GEPlot.java
public String generateGeometricMeanIntensityChart(String xAxisLabel, String yAxisLabel, HttpSession session, PrintWriter pw) {/* w w w . ja va2 s . c o m*/ String gmfilename = ""; JFreeChart gmChart = null; try { gmChart = ChartFactory.createBarChart(null, xAxisLabel, // domain axis label yAxisLabel, gmDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); gmChart.setBackgroundPaint(java.awt.Color.white); // lets start some customization to retro fit w/jcharts lookand feel CategoryPlot plot = gmChart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); axis.setLowerMargin(0.02); // two percent axis.setCategoryMargin(0.20); // 20 percent axis.setUpperMargin(0.02); // two percent //StatisticalBarRenderer renderer = new StatisticalBarRenderer(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); // BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setItemMargin(0.01); // one percent renderer.setDrawBarOutline(true); renderer.setOutlinePaint(Color.BLACK); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String stdDev = (String) stdDevMap .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + "<br/>Std. Dev.: " + stdDev + "<br/>"; } }); plot.setRenderer(renderer); gmChart.removeLegend(); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); //gmfilename = ServletUtilities.saveChartAsPNG(gmChart, imgW, 400, info, session); gmfilename = ServletUtilities.saveChartAsPNG(gmChart, imgW, 400, info, session); ChartUtilities.writeImageMap(pw, gmfilename, info, new CustomOverlibToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator()); } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); } return gmfilename; }
From source file:gov.nih.nci.cma.web.graphing.GEPlot.java
public String generateLog2Chart(String xAxisLabel, String yAxisLabel, HttpSession session, PrintWriter pw) { String log2Filename = ""; JFreeChart log2Chart = null;// w w w . j av a 2s. c om try { log2Chart = ChartFactory.createBarChart(null, xAxisLabel, // domain axis label yAxisLabel, log2Dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); log2Chart.setBackgroundPaint(java.awt.Color.white); // lets start some customization to retro fit w/jcharts lookand feel CategoryPlot plot = log2Chart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); axis.setLowerMargin(0.02); // two percent axis.setCategoryMargin(0.20); // 20 percent axis.setUpperMargin(0.02); // two percent StatisticalBarRenderer renderer = new StatisticalBarRenderer(); // BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setItemMargin(0.01); // one percent renderer.setDrawBarOutline(true); renderer.setOutlinePaint(Color.BLACK); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String stdDev = (String) stdDevMap .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + "<br/>Std. Dev.: " + stdDev + "<br/>"; } }); // LegendTitle lg = chart.getLegend(); plot.setRenderer(renderer); // lets generate a custom legend - assumes theres only one source? //LegendItemCollection lic = log2Chart.getLegend().getSources()[0].getLegendItems(); //legendHtml = LegendCreator.buildLegend(lic, "Probesets"); log2Chart.removeLegend(); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); log2Filename = ServletUtilities.saveChartAsPNG(log2Chart, imgW, 400, info, session); ChartUtilities.writeImageMap(pw, log2Filename, info, new CustomOverlibToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator()); } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); } return log2Filename; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.SimpleBar.java
public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); PlotOrientation plotOrientation = PlotOrientation.VERTICAL; if (horizontalView) { plotOrientation = PlotOrientation.HORIZONTAL; }// w w w .ja va 2 s . c o m JFreeChart chart = ChartFactory.createBarChart(name, // chart title categoryLabel, // domain axis label valueLabel, // range axis label dataset, // data plotOrientation, // orientation false, // include legend true, // tooltips? false // URLs? ); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } // set the background color for the chart... chart.setBackgroundPaint(color); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberFormat nf = NumberFormat.getNumberInstance(locale); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setUpperMargin(0.10); rangeAxis.setNumberFormatOverride(nf); if (firstAxisLB != null && firstAxisUB != null) { rangeAxis.setLowerBound(firstAxisLB); rangeAxis.setUpperBound(firstAxisUB); } if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } else rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // add CategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("{0}"); renderer.setLegendItemLabelGenerator(generator); if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } if (showValueLabels) { renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); // if(valueLabelsPosition.equalsIgnoreCase("inside")){ // renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); // renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); // } else { // renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); // renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); // } } // PROVA LEGENDA if (legend == true) { drawLegend(chart); /*BlockContainer wrapper = new BlockContainer(new BorderArrangement()); wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0)); LabelBlock titleBlock = new LabelBlock("Legend Items:", new Font("SansSerif", Font.BOLD, 12)); title.setPadding(5, 5, 5, 5); wrapper.add(titleBlock, RectangleEdge.TOP); LegendTitle legend = new LegendTitle(chart.getPlot()); BlockContainer items = legend.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend.setWrapper(wrapper); if(legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if(legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT); else if(legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT); else if(legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP); else legend.setPosition(RectangleEdge.BOTTOM); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); chart.addSubtitle(legend);*/ } int seriesN = dataset.getRowCount(); // the order color vedctor overrides the color map!! if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { logger.debug("color serie by SERIES_COLORS template specification"); for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getRowKey(i); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serieName; serieName = (String) seriesCaptions.get(serieName); index = dataset.getRowIndex(labelName); } else index = dataset.getRowIndex(serieName); Color color = (Color) colorMap.get(serieName); if (color != null) { //renderer.setSeriesPaint(i, color); renderer.setSeriesPaint(index, color); renderer.setSeriesItemLabelFont(i, new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); renderer.setSeriesItemLabelPaint(i, defaultLabelsStyle.getColor()); } } } CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); domainAxis.setUpperMargin(0.10); logger.debug("OUT"); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart.java
/** * Creates a chart.//from w w w.ja v a2 s . c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart(chartTitle, //"Bar Chart Demo", // chart title domainLabel, //"Category", // domain axis label rangeLabel, //"Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:gov.nih.nci.cma.web.graphing.GEPlot.java
public String generateBWLog2IntensityChart(String xAxisLabel, String yAxisLabel, HttpSession session, PrintWriter pw, boolean isCoinPlot) { String bwFilename = ""; //PlotSize ps = PlotSize.MEDIUM; JFreeChart bwChart = null;//from w w w .j ava2 s.c o m try { //IMAGE Size Control CategoryAxis xAxis = new CategoryAxis(xAxisLabel); xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(true); BoxAndWhiskerCoinPlotRenderer bwRenderer = null; CategoryPlot bwPlot = null; if (isCoinPlot) { Map<String, List<Double>> groupMap = rawDataMap.get(reporterName); DefaultBoxAndWhiskerCategoryDataset smallBwdataset = new DefaultBoxAndWhiskerCategoryDataset(); int row = 0; int column = 0; HashMap<String, List> caIntegatorCoinList = new HashMap<String, List>(); for (String group : groupList) { smallBwdataset.add(groupMap.get(group), reporterName, group); caIntegatorCoinList.put(row + "_" + column++, groupMap.get(group)); } bwRenderer = new BoxAndWhiskerCoinPlotRenderer(caIntegatorCoinList); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setDisplayCoinCloud(true); bwRenderer.setDisplayMean(false); bwRenderer.setFillBox(false); bwRenderer.setPlotColor(null); bwPlot = new CategoryPlot(smallBwdataset, xAxis, yAxis, bwRenderer); if (groupList.size() < 6) imgW = 200; } else { bwRenderer = new BoxAndWhiskerCoinPlotRenderer(); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } String returnString = "onclick=\"popCoin('" + geneSymbol + "','" + key + "');\" | "; return returnString + tt; } }); bwRenderer.setFillBox(false); bwPlot = new CategoryPlot(bwdataset, xAxis, yAxis, bwRenderer); } bwChart = new JFreeChart(bwPlot); bwChart.setBackgroundPaint(java.awt.Color.white); LegendTitle title = bwChart.getLegend(); LegendItemSource[] sources = title.getSources(); legendItemCollection = sources[0].getLegendItems(); bwChart.removeLegend(); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); // BW if (bwChart != null) { //int bwwidth = new BigDecimal(1.5).multiply(new BigDecimal(imgW)).intValue(); bwFilename = ServletUtilities.saveChartAsPNG(bwChart, imgW, 400, info, session); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); ttip.setExtra(" href='javascript:void(0);' "); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, bwFilename, info, ttip, new StandardURLTagFragmentGenerator()); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); } //END BW pw.flush(); } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); } // return filename; //charts.put("errorBars", log2Filename); //charts.put("noErrorBars", rawFilename); //charts.put("bwFilename", bwFilename); //charts.put("legend", legendHtml); //charts.put("size", ps.toString()); return bwFilename; }
From source file:ds.monte.carlo.Application.java
private void createLengthGraph(HashMap<Integer, Integer> probability) { DefaultCategoryDataset pDataset = new DefaultCategoryDataset(); for (Integer key : probability.keySet()) { pDataset.setValue(probability.get(key), "", "" + key); }// www. j a va 2 s .c o m JFreeChart growChart = ChartFactory.createLineChart("Simulated annealing", "", "", pDataset, PlotOrientation.VERTICAL, false, false, false); growChart.setBackgroundPaint(Color.WHITE); CategoryPlot catPlot = growChart.getCategoryPlot(); catPlot.setRangeGridlinePaint(new Color(92, 184, 92)); ValueAxis vAxis = catPlot.getRangeAxis(); CategoryAxis cAxis = catPlot.getDomainAxis(); cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); cAxis.setTickLabelsVisible(false); Font font = new Font("SansSerif", Font.PLAIN, 12); Font fontTitle = new Font("SansSerif", Font.PLAIN, 14); vAxis.setTickLabelFont(font); growChart.getTitle().setFont(fontTitle); LineAndShapeRenderer renderer = (LineAndShapeRenderer) catPlot.getRenderer(); Color bootstrapGreen = new Color(92, 184, 92); renderer.setSeriesPaint(0, bootstrapGreen); ChartPanel chartPanel = new ChartPanel(growChart); jPanel9.removeAll(); jPanel9.add(chartPanel, BorderLayout.CENTER); jPanel9.validate(); }
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
/** * Creates an area chart./*from w w w .j av a 2 s. co m*/ * * @param title * @param categoryAxisLabel * (X-Axis label) * @param valueAxisLabel * (Y-Axis label) * @param dataset * @return JfreeChart instance. */ public JFreeChart createAreaChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createAreaChart(title, categoryAxisLabel, valueAxisLabel, dataset, this.orientation, this.drawLegend, false, false); // set the background color for the chart... chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); AreaRenderer renderer = (AreaRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesPaint(2, Color.green); renderer.setSeriesPaint(3, Color.darkGray); renderer.setSeriesPaint(4, Color.yellow); return chart; }
From source file:ds.monte.carlo.Application.java
private void createFrequencyGraph(HashMap<Long, Integer> dictionary) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); long checksum = 0; for (Long key : dictionary.keySet()) { dataset.setValue(dictionary.get(key), "", "" + key); checksum += dictionary.get(key); }//from w ww. j a v a 2s .c o m JFreeChart chart = ChartFactory.createBarChart("Frequency graph", "", "", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(new Color(92, 184, 92)); ValueAxis vAxis = catPlot.getRangeAxis(); CategoryAxis cAxis = catPlot.getDomainAxis(); cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); Font font = new Font("SansSerif", Font.PLAIN, 12); Font fontTitle = new Font("SansSerif", Font.PLAIN, 14); Font fontc = new Font("SansSerif", Font.PLAIN, 10); vAxis.setTickLabelFont(font); chart.getTitle().setFont(fontTitle); cAxis.setTickLabelFont(fontc); BarRenderer renderer = (BarRenderer) catPlot.getRenderer(); Color bootstrapGreen = new Color(92, 184, 92); renderer.setSeriesPaint(0, bootstrapGreen); ChartPanel chartPanel = new ChartPanel(chart); jPanel5.removeAll(); jPanel5.add(chartPanel, BorderLayout.CENTER); jPanel5.validate(); //jPanel5.setVisible(true); System.out.println("Checksum " + checksum); System.out.println("NumberOfReplications " + numberOfReplications); }