List of usage examples for org.jfree.chart ChartFactory createBarChart
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:rev.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from www.j av a2s . c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, ClassNotFoundException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String a = request.getParameter("userMsg"); /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE HTML>\n" + "<head>\n" + "<link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\"/>\n" + "<link href=\"css/slider.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\"/>\n" + "<script type=\"text/javascript\" src=\"js/jquery-1.9.0.min.js\"></script>\n" + "<script type=\"text/javascript\" src=\"js/move-top.js\"></script>\n" + "<script type=\"text/javascript\" src=\"js/easing.js\"></script>\n" + "<script type=\"text/javascript\" src=\"js/jquery.nivo.slider.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(window).load(function() {\n" + " $('#slider').nivoSlider();\n" + " });\n" + " <%! String n;\n" + " %>\n" + " <% \n" + " \n" + " n=(String)session.getAttribute(\"uname\"); \n" + " %>\n" + " </script>\n" + "</head>\n" + "<body>\n" + " <div class=\"header\">\n" + " <div class=\"headertop_desc\">\n" + " <div class=\"wrap\">\n" + " <div class=\"nav_list\">\n" + " \n" + " </div>\n" + " <div class=\"account_desc\">\n" + " <ul>\n" + " <li><a href=\"available.jsp\">Available movies</a></li>\n" + " <li><a href=\"takereview.jsp\">Review Movies</a></li>\n" + " <li><a href=\"rated.jsp\">Movies Rated</a></li>\n" + " <li><a href=\"abc.jsp\">Recommend Me</a></li>\n" + " \n" + " <li><a href=\"contact.html\">Contact</a></li>\n" + " <li><a href=\"logout\">Logout</a></li>\n" + " </ul>\n" + " </div>\n" + " <div class=\"clear\"></div>\n" + " </div>\n" + " </div>\n" + " <div class=\"wrap\">\n" + " <div class=\"header_top\">\n" + " <div class=\"logo\">\n" + " <a href=\"index.html\"><img src=\"images/logo1.jpg\" alt=\"\" /></a>\n" + " </div>\n" + " <div class=\"header_top_right\">\n" + " <div class=\"search_box\">\n" + " \n" + " </div>\n" + " <div class=\"clear\"></div>\n" + " </div>\n" + " \n" + " <div class=\"clear\"></div>\n" + " </div>\n" + " \n" + " \n" + "\n" + "\n" + ""); String line = "this book is too good to sleep"; Properties props = new Properties(); props.setProperty("annotators", "tokenize, ssplit, parse, sentiment, lemma"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); Annotation annotation = new Annotation(a); pipeline.annotate(annotation); annotation.toShorterString(); List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class); if (sentences != null && !sentences.isEmpty()) { for (int i = 0; i < sentences.size(); i++) { CoreMap sentence = sentences.get(i); Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class); int sentiment = RNNCoreAnnotations.getPredictedClass(tree); String sentimentName = sentence.get(SentimentCoreAnnotations.SentimentClass.class); //Class.forName("com.mysql.jdbc.Driver"); /*String connectionURL = "jdbc:mysql://localhost:3306/review"; Connection conn; Statement stmt; ResultSet rs; conn = DriverManager.getConnection (connectionURL,"root",""); stmt = conn.createStatement(); // rs = stmt.executeQuery(""); out.println(); */ out.println("The sentence is:"); sentence.get(CoreAnnotations.TextAnnotation.class); //out.println("Sentiment of \n> \""++"\"\nis: " + sentiment+" (i.e., "+sentimentName+")"); out.println(sentimentName + " " + sentiment); if (sentimentName.equalsIgnoreCase("Negative")) { final String negative = "negative"; final String positive = "positive"; final String nuetral = "nuetral"; final String verypositive = "very positive"; final String verynegative = " very negative"; final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //out.println("NOT"); dataset.addValue(0, positive, positive); dataset.addValue(sentiment, negative, negative); dataset.addValue(0, nuetral, nuetral); dataset.addValue(0, verynegative, verynegative); dataset.addValue(0, verypositive, verypositive); JFreeChart barChart = ChartFactory.createBarChart("Movie Reviews", "Ratings", "Sentiments", dataset, PlotOrientation.VERTICAL, true, true, false); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File BarChart = new File("/home/rishabh/NetBeansProjects/minor/web/images/k.jpeg"); ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height); out.println("<img src=\"images/BarChart.jpeg\">"); } else if (sentimentName.equalsIgnoreCase("Positive")) { final String negative = "negative"; final String positive = "positive"; final String nuetral = "nuetral"; final String verypositive = "very positive"; final String verynegative = " very negative"; final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // out.println("Good"); dataset.addValue(sentiment, positive, positive); dataset.addValue(0, negative, negative); dataset.addValue(0, nuetral, nuetral); dataset.addValue(0, verynegative, verynegative); dataset.addValue(0, verypositive, verypositive); JFreeChart barChart = ChartFactory.createBarChart("Movie Reviews", "Ratings", "Sentiments", dataset, PlotOrientation.VERTICAL, true, true, false); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File BarChart = new File("/home/rishabh/NetBeansProjects/minor/web/images/k.jpeg"); ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height); out.println("<img src=\"images/BarChart1.jpeg\">"); } else if (sentimentName.equalsIgnoreCase("Neutral")) { final String negative = "negative"; final String positive = "positive"; final String nuetral = "nuetral"; final String verypositive = "very positive"; final String verynegative = " very negative"; final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //out.println("Good"); dataset.addValue(0, positive, positive); dataset.addValue(0, negative, negative); dataset.addValue(sentiment, nuetral, nuetral); dataset.addValue(0, verynegative, verynegative); dataset.addValue(0, verypositive, verypositive); JFreeChart barChart = ChartFactory.createBarChart("Movie Reviews", "Ratings", "Sentiments", dataset, PlotOrientation.VERTICAL, true, true, false); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File BarChart = new File("/home/rishabh/NetBeansProjects/minor/web/images/k.jpeg"); ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height); out.println("<img src=\"images/BarChart2.jpeg\">"); } else if (sentimentName.equalsIgnoreCase("Very Positive")) { final String negative = "negative"; final String positive = "positive"; final String nuetral = "nuetral"; final String verypositive = "very positive"; final String verynegative = " very negative"; final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //out.println("Good"); dataset.addValue(0, positive, positive); dataset.addValue(0, negative, negative); dataset.addValue(0, nuetral, nuetral); dataset.addValue(0, verynegative, verynegative); dataset.addValue(sentiment, verypositive, verypositive); JFreeChart barChart = ChartFactory.createBarChart("Movie Reviews", "Ratings", "Sentiments", dataset, PlotOrientation.VERTICAL, true, true, false); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File BarChart = new File("/home/rishabh/NetBeansProjects/minor/web/images/k.jpeg"); ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height); out.println("<img src=\"images/BarChart4.jpeg\">"); } else if (sentimentName.equalsIgnoreCase("Very Negative")) { final String negative = "negative"; final String positive = "positive"; final String nuetral = "nuetral"; final String verypositive = "very positive"; final String verynegative = " very negative"; final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //out.println("Good"); dataset.addValue(0, positive, positive); dataset.addValue(0, negative, negative); dataset.addValue(0, nuetral, nuetral); dataset.addValue(sentiment, verynegative, verynegative); dataset.addValue(0, verypositive, verypositive); JFreeChart barChart = ChartFactory.createBarChart("Movie Reviews", "Ratings", "Sentiments", dataset, PlotOrientation.VERTICAL, true, true, false); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File BarChart = new File("/home/rishabh/NetBeansProjects/minor/web/images/k.jpeg"); ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height); out.println("<img src=\"images/BarChart3.jpeg\">"); } } } out.println("<div class=\"footer\">\n" + " <div class=\"wrap\">\n" + " <div class=\"section group\">\n" + " <div class=\"col span\">\n" + " <h4>Information</h4>\n" + " <ul>\n" + " <li><a href=\"#\">About Us</a></li>\n" + " \n" + " <li><a href=\"contact.html\">Contact Us</a></li>\n" + " </ul>\n" + " </div>\n" + " <div class=\"col span\">\n" + " <h4>Know us better</h4>\n" + " <ul>\n" + " <li><a href=\"#\">About Us</a></li>\n" + " \n" + " <li><a href=\"contact.html\">Site Map</a></li>\n" + " <li><a href=\"#\">Search Terms</a></li>\n" + " </ul>\n" + " </div>\n" + " \n" + " <div class=\"col span\">\n" + " <h4>Contact</h4>\n" + " <ul>\n" + " <li><span>9971825755</span></li>\n" + " <li><span>8130527232</span></li>\n" + " </ul>\n" + " <div class=\"social-icons\">\n" + " <h4>Follow Us</h4>\n" + " <ul>\n" + " <li><a href=\"#\" target=\"_blank\"><img src=\"images/facebook.png\" alt=\"\" /></a></li>\n" + " <li><a href=\"#\" target=\"_blank\"><img src=\"images/twitter.png\" alt=\"\" /></a></li>\n" + " <li><a href=\"#\" target=\"_blank\"><img src=\"images/skype.png\" alt=\"\" /> </a></li>\n" + " <li><a href=\"#\" target=\"_blank\"> <img src=\"images/linkedin.png\" alt=\"\" /></a></li>\n" + " <div class=\"clear\"></div>\n" + " </ul>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " <div class=\"copy_right\">\n" + " <p>Company Name All rights Reseverd </p>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " <script type=\"text/javascript\">\n" + " $(document).ready(function() {\n" + " $().UItoTop({ easingType: 'easeOutQuart' });\n" + "\n" + " });\n" + " </script>\n" + " <a href=\"#\" id=\"toTop\"><span id=\"toTopHover\"> </span></a>\n" + "</body>\n" + "</html>\n" + "\n" + ""); } }
From source file:com.voterData.graph.Graph.java
public static JFreeChart getAgeDistChart2008(Map<String, Double> dataMap) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String key : dataMap.keySet()) { if (key.equals("Age17_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "DEM", "17-25 Yrs"); } else if (key.equals("Age17_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "REP", "17-25 Yrs"); } else if (key.equals("Age17_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "UNA", "17-25 Yrs"); } else if (key.equals("Age26_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "DEM", "26-35 Yrs"); } else if (key.equals("Age26_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "REP", "26-35 Yrs"); } else if (key.equals("Age26_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "UNA", "26-35 Yrs"); } else if (key.equals("Age36_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "DEM", "36-50 Yrs"); } else if (key.equals("Age36_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "REP", "36-50 Yrs"); } else if (key.equals("Age36_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "UNA", "36-50 Yrs"); } else if (key.equals("Age51_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "DEM", "51-65 Yrs"); } else if (key.equals("Age51_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "REP", "51-65 Yrs"); } else if (key.equals("Age51_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "UNA", "51-65 Yrs"); } else if (key.equals("Age65_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "DEM", ">65 Yrs"); } else if (key.equals("Age65_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "REP", ">65 Yrs"); } else if (key.equals("Age65_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "UNA", ">65 Yrs"); }//from w ww . j av a 2 s . c om } JFreeChart jfreechart = ChartFactory.createBarChart("Age based Distribution - Year 2008", "Age in Years", " Votes in %", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot cplot = (CategoryPlot) jfreechart.getPlot(); cplot.setBackgroundPaint(Color.lightGray);//change background color //set bar chart color // ((BarRenderer) cplot.getRenderer()).setBarPainter(new StandardBarPainter()); BarRenderer r = (BarRenderer) jfreechart.getCategoryPlot().getRenderer(); r.setSeriesPaint(0, Color.green); r.setSeriesPaint(1, Color.red); r.setSeriesPaint(2, Color.blue); return jfreechart; }
From source file:drugsupplychain.neu.css.gui.common.pharmaco.ProductDistributionDetailJPanel.java
/** * show distribution//from w ww . j a v a2 s . com */ private void showDistribution() { // TODO add your handling code here: DefaultCategoryDataset barchartDataset = new DefaultCategoryDataset(); if (null != product && null != product.getProductTracker() && product.getProductTracker().size() > 0) { for (String id : product.getProductTracker().keySet()) { TrackOrganization trackOrganization = product.getProductTracker().get(id); if (trackOrganization.getOrganization() instanceof Distributor) { barchartDataset.setValue(trackOrganization.getQuantity(), "QUANTITY", trackOrganization.getOrganization().getLocation()); } } JFreeChart barChartData = ChartFactory.createBarChart("MEDICINE DISTRIBUTION", "LOCATION", "QUANTITY", barchartDataset, PlotOrientation.VERTICAL, false, true, true); CategoryPlot barchart = barChartData.getCategoryPlot(); barchart.setRangeGridlinePaint(Color.ORANGE); ChartPanel barPanel = new ChartPanel(barChartData); barPanelDisplay.removeAll(); barPanelDisplay.add(barPanel, BorderLayout.CENTER); barPanelDisplay.validate(); } }
From source file:UserInterface.DoctorRole.DoctorReportChartJPanel.java
private void personneljButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personneljButton3ActionPerformed // TODO add your handling code here: ReportToReporter report = enterprise.getReport(); if (report.getStatus() != null) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(report.getTimeofadmin(), "Adminstration", "Adminstration"); dataset.addValue(report.getTimeofnurse(), "Nurse", "Nurse"); dataset.addValue(report.getTimeofpathology(), "Pathologist", "Pathologist"); dataset.addValue(report.getTimeofphar(), "Pharmacist", "Pharmacist"); dataset.addValue(report.getTimeofphysician(), "Physician", "Physician"); dataset.addValue(report.getTimeofsurgeon(), "Surgeon", "Surgeon"); //dataset.setValue(80, "masd", "sss"); JFreeChart chart = ChartFactory.createBarChart("Personnel", "Position", "Times", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.WHITE); ChartFrame frame = new ChartFrame("Chart for ERROR", chart); frame.setVisible(true);/*from w ww .jav a 2 s . c o m*/ frame.setSize(550, 550); } else { JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated"); } }
From source file:edu.uara.wrappers.customcharts.CustomBarChart.java
@Override public void generateBarChart(CategoryDataset dataset) { this.ds = dataset;//store reference to dataset to do update try {//from w ww.j av a2s. com if (dataset == null) throw new Exception("No dataset provided"); chart = ChartFactory.createBarChart(title, // chart title domainAxisLabel, // domain axis label rangeAxisLabel, // range axis label dataset, // data orientation, // orientation legend, // include legend false, // no tooltips false // URLs? ); currentDatasetType = DatasetTypes.CategoryDataset; } catch (Exception ex) { //handle exception } }
From source file:org.remus.marketplace.scheduling.GenerateStatisticsJob.java
private void createDownloadStatistics(Integer id, File folder, Node node, Calendar instance) { Map<Date, Integer> map = new HashMap<Date, Integer>(); for (int i = 0, n = month; i < n; i++) { Calendar instance2 = Calendar.getInstance(); instance2.setTime(new Date()); instance2.add(Calendar.MONTH, i * -1); map.put(instance2.getTime(), 0); }//w w w. ja v a 2 s .c om AdvancedCriteria criteria = new AdvancedCriteria() .addRestriction(Restrictions.between(Download.TIME, instance.getTime(), new Date())) .addRestriction(Restrictions.eq(Download.NODE, node)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.count(Download.NODE)); projectionList .add(Projections.sqlGroupProjection("month({alias}.time) as month, year({alias}.time) as year", "month({alias}.time), year({alias}.time)", new String[] { "month", "year" }, new Type[] { Hibernate.INTEGER, Hibernate.INTEGER })); criteria.setProjection(projectionList); List<Object> query = downloadDao.query(criteria); for (Object object : query) { Object[] data = (Object[]) object; Integer count = (Integer) data[0]; Integer month = (Integer) data[1]; Integer year = (Integer) data[2]; Set<Date> keySet = map.keySet(); for (Date date : keySet) { Calendar instance2 = Calendar.getInstance(); instance2.setTime(date); if (instance2.get(Calendar.YEAR) == year && instance2.get(Calendar.MONTH) == month - 1) { map.put(date, count); } } } DefaultCategoryDataset data = new DefaultCategoryDataset(); List<Date> keySet = new ArrayList<Date>(map.keySet()); Collections.sort(keySet, new Comparator<Date>() { @Override public int compare(Date o1, Date o2) { return o1.compareTo(o2); } }); for (Date date : keySet) { Integer integer = map.get(date); Calendar instance2 = Calendar.getInstance(); instance2.setTime(date); int year = instance2.get(Calendar.YEAR); int month = instance2.get(Calendar.MONTH) + 1; data.addValue(integer, "Column1", month + "-" + year); } JFreeChart createBarChart = ChartFactory.createBarChart("Downloads", "Month", "", data, PlotOrientation.VERTICAL, false, false, false); File file = new File(folder, "download_" + id + ".png"); if (file.exists()) { file.delete(); } try { ChartUtilities.saveChartAsPNG(file, createBarChart, 500, 300); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of a Histogram. * //w w w .j a va 2 s. co m * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param data * The array of values. * @return a chart panel with the graphical representation. */ public static ChartPanel createHistogram(String title, String x, String y, double[] data) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); log.info(Arrays.toString(data)); for (int i = 0; i < data.length; i++) { if (title.contains("Start")) { log.info(i + " " + data[i]); dataset.addValue(data[i], y, (Comparable) i); } else if (data[i] != 0) { log.info(i + " " + data[i]); dataset.addValue(data[i], y, (Comparable) i); } } PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createBarChart(title, x, y, dataset, orientation, show, toolTips, urls); return new ChartPanel(chart); }
From source file:UserInterface.StoreManager.StoreReportsPanel.java
private void storeKeeperButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_storeKeeperButtonActionPerformed // TODO add your handling code here: ArrayList<Comparison> cmp1 = new ArrayList<>(); int x = 0;// www.j av a 2 s.c o m for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) { if (org instanceof StoreKeeperOrganization) { System.out.println("Hi"); for (UserAccount ua : org.getUserAccountDirectory().getUserAccountList()) { x = 0; for (WorkRequest w : ua.getWorkQueue().getWorkRequestList()) { x++; } Comparison c = new Comparison(ua.getEmployee().getName(), x); cmp1.add(c); } } } Collections.sort(cmp1); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (cmp1.size() >= 3) { dataset.setValue(cmp1.get(0).getNumber(), "WorkRequests", cmp1.get(0).getString()); dataset.setValue(cmp1.get(1).getNumber(), "WorkRequests", cmp1.get(1).getString()); dataset.setValue(cmp1.get(2).getNumber(), "WorkRequests", cmp1.get(2).getString()); } else { for (Comparison c : cmp1) { dataset.setValue(c.getNumber(), "WorkRequests", c.getString()); } } JFreeChart chart = ChartFactory.createBarChart("Top StoreKeepers", "Storekeepers", "No of Workrequests Solved", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("StoreKeeper Report", chart); frame.setVisible(true); frame.setSize(600, 400); }
From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java
private void viewAlignmentBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAlignmentBtnActionPerformed DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) { dataSet.setValue(carList.getAlignment(), "Alignment", carList.getTimestamp()); }// www.ja va2 s. c om JFreeChart chart = ChartFactory.createBarChart("Alignment", "Timestamp", "Alignment", dataSet, PlotOrientation.HORIZONTAL.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("ALIGNMENT GRAPH", chart); frame.setVisible(true); frame.setSize(600, 600); // TODO add your handling code here: }
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
/** * Creates a bar chart.//from w ww.j a va 2 s . c o m * * @param title * @param categoryAxisLabel * (X-Axis label) * @param valueAxisLabel * (Y-Axis label) * @param dataset * @return JfreeChart instance. */ public JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(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.01); domainAxis.setUpperMargin(0.01); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); BarRenderer renderer = (BarRenderer) 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; }