List of usage examples for org.jfree.chart JFreeChart getTitle
public TextTitle getTitle()
From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java
private JFreeChart createPatientReportsChart(CategoryDataset dataset) { JFreeChart barChart = ChartFactory.createBarChart("Average Waiting period of Patients", "Year", "Avg Waiting period(months)", dataset, PlotOrientation.VERTICAL, true, true, false); barChart.setBackgroundPaint(Color.white); // Set the background color of the chart barChart.getTitle().setPaint(Color.DARK_GRAY); barChart.setBorderVisible(true);//www. j a v a 2s .c o m // Adjust the color of the title CategoryPlot plot = barChart.getCategoryPlot(); plot.getRangeAxis().setLowerBound(0.0); // Get the Plot object for a bar graph plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.blue); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.decode("#00008B")); //return chart; return barChart; }
From source file:view.statistics.RequestStatsAndPrediction.java
private void predictButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_predictButtonActionPerformed int year = yearChooser.getYear(); int month = monthChooser.getMonth() + 1; int currentYear = Calendar.getInstance().get(Calendar.YEAR); int currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1; int data[][] = null; try {//ww w . ja v a2s . c om data = sdcontroller.getYearlyRequestCountsOf(month); } catch (ClassNotFoundException ex) { } catch (SQLException ex) { } if (year >= currentYear && month >= currentMonth) { try { predictText.setText(Predictions.getPredictedRequestsOf(year, month) + ""); } catch (ClassNotFoundException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Predictions available only for future months. Only the graph will be drawn", "Error", JOptionPane.ERROR_MESSAGE); predictText.setText("Invalid input!"); } //if (data != null) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (data != null) { for (int i = 0; i < data[0].length; i++) { dataset.setValue(data[1][i], "Year", data[0][i] + ""); } } JFreeChart chart = ChartFactory.createLineChart3D( "Yearly Blood Request Count For The Month of " + getMontName(month + ""), "Year", "Request Count", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.PINK); chart.getTitle().setPaint(Color.RED); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new java.awt.Dimension(200, 350)); chartAreaPanel.setLayout(new GridLayout()); chartAreaPanel.removeAll(); chartAreaPanel.revalidate(); chartAreaPanel.add(panel); chartAreaPanel.repaint(); this.repaint(); //} }
From source file:com.manydesigns.portofino.chart.ChartBarGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);//from w w w . j a v a 2s . co m Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer || renderer instanceof BarRenderer3D) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); // ? setSeriesItemLabelGenerator barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.05); // ????? // ??90,??/3.14 ItemLabelPosition itemLabelPositionFallback = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT, TextAnchor.HALF_ASCENT_LEFT, -1.57D); // ??labelposition // barRenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback); // barRenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setItemLabelsVisible(true); // ? barRenderer.setBaseOutlinePaint(Color.BLACK); // ??? barRenderer.setDrawBarOutline(true); // ??? barRenderer.setItemMargin(0.0); // ? barRenderer.setIncludeBaseInRange(true); barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); // ? plot.setForegroundAlpha(1.0f); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:view.statistics.RequestStatsAndPrediction.java
/** * Creates new form PredictRequests/*w ww .j a v a 2s .co m*/ */ public RequestStatsAndPrediction() throws FileNotFoundException, IOException { initComponents(); FileInputStream imgStream = null; File imgfile = new File("..\\BBMS\\src\\images\\drop.png"); imgStream = new FileInputStream(imgfile); BufferedImage bi = ImageIO.read(imgStream); ImageIcon myImg = new ImageIcon(bi); this.setFrameIcon(myImg); setTitle("Request Statistics and Prediction"); sdcontroller = new SampleDetailsController(); Calendar calendar = Calendar.getInstance(); yearChooser.setStartYear(calendar.get(Calendar.YEAR)); monthChooser.setMonth(calendar.get(calendar.MONTH) + 1); int year = yearChooser.getYear(); int month = monthChooser.getMonth() + 1; int currentYear = Calendar.getInstance().get(Calendar.YEAR); int currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1; int data[][] = null; try { data = sdcontroller.getYearlyRequestCountsOf(month); } catch (ClassNotFoundException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } if (year >= currentYear && month >= currentMonth) { try { predictText.setText(Predictions.getPredictedRequestsOf(year, month) + ""); } catch (ClassNotFoundException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Predictions available only for future months. Only the graph will be drawn", "Error", JOptionPane.ERROR_MESSAGE); predictText.setText("Invalid input!"); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (data != null) { for (int i = 0; i < data[0].length; i++) { dataset.setValue(data[1][i], "Bla bla bla", data[0][i] + ""); } } JFreeChart chart = ChartFactory.createLineChart3D( "Yearly Blood Request Count For The Month of " + getMontName(month + ""), "Year", "Request Count", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.PINK); chart.getTitle().setPaint(Color.RED); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new java.awt.Dimension(200, 350)); chartAreaPanel.setLayout(new GridLayout()); chartAreaPanel.removeAll(); chartAreaPanel.revalidate(); chartAreaPanel.add(panel); chartAreaPanel.repaint(); this.repaint(); }
From source file:com.manydesigns.portofino.chart.ChartStackedBarGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);/*from w w w . j a v a2s . c om*/ Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add // ? barRenderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.06); } if (renderer instanceof StackedBarRenderer3D || renderer instanceof StackedBarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add // ? setSeriesItemLabelGenerator barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.06); // ????? ItemLabelPosition itemLabelPositionFallback = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT, TextAnchor.HALF_ASCENT_LEFT, -1.57D); // ??labelposition barRenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setItemLabelsVisible(true); barRenderer.setItemMargin(10); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:com.att.aro.ui.view.overviewtab.FileTypesChartPanel.java
private JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("chart.filetype.title"), null, ResourceBundleHelper.getMessageString("simple.percent"), null, PlotOrientation.HORIZONTAL, false, false, false);//from www . j a v a 2 s .c o m //chart.setBackgroundPaint(fileTypePanel.getBackground()); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.cPlot = chart.getCategoryPlot(); cPlot.setBackgroundPaint(Color.white); cPlot.setDomainGridlinePaint(Color.gray); cPlot.setRangeGridlinePaint(Color.gray); cPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = cPlot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(.5f); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) cPlot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { FileTypeSummary summary = fileTypeContent.get(column); return MessageFormat.format(ResourceBundleHelper.getMessageString("chart.filetype.tooltip"), NumberFormat.getIntegerInstance().format(summary.getBytes())); } }); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); BarPainter painter = new StandardBarPainter(); renderer.setBarPainter(painter); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(0.1); cPlot.setRenderer(renderer); cPlot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:edu.msu.cme.rdp.classifier.train.validation.distance.TaxaSimilarityMain.java
public void createPlot(String plotTitle, File outdir) throws IOException { XYSeriesCollection dataset = new XYSeriesCollection(); DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset(); PrintStream boxchart_dataStream = new PrintStream(new File(outdir, plotTitle + ".boxchart.txt")); boxchart_dataStream.println(//from w w w .ja v a 2 s. co m "#\tkmer" + "\trank" + "\t" + "max" + "\t" + "avg" + "\t" + "min" + "\t" + "Q1" + "\t" + "median" + "\t" + "Q3" + "\t" + "98Pct" + "\t" + "2Pct" + "\t" + "comparisons" + "\t" + "sum"); for (int i = 0; i < ranks.size(); i++) { long[] countArray = sabCoutMap.get(ranks.get(i)); if (countArray == null) continue; double sum = 0.0; int max = 0; int min = 100; double mean = 0; int Q1 = -1; int median = -1; int Q3 = -1; int pct_98 = -1; int pct_2 = -1; long comparisons = 0; int minOutlier = 0; // we don't care about the outliers int maxOutlier = 0; // XYSeries series = new XYSeries(ranks.get(i)); for (int c = 0; c < countArray.length; c++) { if (countArray[c] == 0) continue; comparisons += countArray[c]; sum += countArray[c] * c; if (c < min) { min = c; } if (c > max) { max = c; } } // create series double cum = 0; for (int c = 0; c < countArray.length; c++) { if (countArray[c] == 0) continue; cum += countArray[c]; int pct = (int) Math.floor(100 * cum / comparisons); series.add(c, pct); if (pct_2 == -1 && pct >= 5) { pct_2 = c; } if (Q3 == -1 && pct >= 25) { Q3 = c; } if (median == -1 && pct >= 50) { median = c; } if (Q1 == -1 && pct >= 75) { Q1 = c; } if (pct_98 == -1 && pct >= 98) { pct_98 = c; } } if (!series.isEmpty()) { dataset.addSeries(series); BoxAndWhiskerItem item = new BoxAndWhiskerItem(sum / comparisons, median, Q1, Q3, pct_2, pct_98, minOutlier, maxOutlier, new ArrayList()); scatterDataset.add(item, ranks.get(i), ""); boxchart_dataStream.println("#\t" + GoodWordIterator.getWordsize() + "\t" + ranks.get(i) + "\t" + max + "\t" + format.format(sum / comparisons) + "\t" + min + "\t" + Q1 + "\t" + median + "\t" + Q3 + "\t" + pct_98 + "\t" + pct_2 + "\t" + comparisons + "\t" + sum); } } boxchart_dataStream.close(); Font lableFont = new Font("Helvetica", Font.BOLD, 28); JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, "Similarity%", "Percent Comparisions", dataset, PlotOrientation.VERTICAL, true, true, false); ((XYPlot) chart.getPlot()).getRenderer().setStroke(new BasicStroke(2.0f)); chart.getLegend().setItemFont(new Font("Helvetica", Font.BOLD, 24)); chart.getTitle().setFont(lableFont); ((XYPlot) chart.getPlot()).getDomainAxis().setLabelFont(lableFont); ((XYPlot) chart.getPlot()).getDomainAxis().setTickLabelFont(lableFont); ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis(); rangeAxis.setRange(0, 100); rangeAxis.setTickLabelFont(lableFont); rangeAxis.setLabelFont(lableFont); ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(5)); ChartUtilities.writeScaledChartAsPNG(new PrintStream(new File(outdir, plotTitle + ".linechart.png")), chart, 800, 1000, 3, 3); BoxPlotUtils.createBoxplot(scatterDataset, new PrintStream(new File(outdir, plotTitle + ".boxchart.png")), plotTitle, "Rank", "Similarity%", lableFont); }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private Image createCallDirectionCallsPieImage(List<CdrGraphBean> beans) { // Create a dataset DefaultKeyedValuesDataset data = new DefaultKeyedValuesDataset(); // Fill dataset with beans data for (CdrGraphBean directionCall : beans) { data.setValue(directionCall.getKey(), directionCall.getCount()); }//from w ww. j a va 2 s . c o m // Create a chart with the dataset JFreeChart chart = ChartFactory.createPieChart(EMPTY_TITLE, data, true, true, false); chart.setBackgroundPaint(Color.lightGray); chart.setTitle("Summary - " + getMessages().getMessage(TITLE_CALLDIRECTION_REPORT_KEY)); chart.getTitle().setPaint(Color.BLACK); PiePlot chartplot = (PiePlot) chart.getPlot(); chartplot.setCircular(true); chartplot.setLabelGenerator(new StandardPieSectionLabelGenerator(PIECHART_SECTIONLABEL_FORMAT)); // Create and return the image return chart.createBufferedImage(500, 220, BufferedImage.TYPE_INT_RGB, null); }
From source file:ui.Interface.java
private void butChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butChartActionPerformed try {/*from w ww. j a v a 2 s. c om*/ if (txtNumbersAll.getText().equals("")) { JOptionPane.showMessageDialog(this, "Please fill out the Empty fields!", "Sorting Algo Simulator v2.0", javax.swing.JOptionPane.ERROR_MESSAGE); return; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(InsertInstructionCount, "InsertionSort", "InsertionSort"); dataset.setValue(SelectInstructionCount, "SelectionSort", "SelectionSort"); JFreeChart chart = ChartFactory.createBarChart("Instruction Count", "Instruction Count", "Unique Counts", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.blue); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); ChartFrame frame1 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart); Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); Dimension windowSize = new Dimension(getPreferredSize()); int wdwLeft2 = screenSize.width / 2 - windowSize.width / 2 - 200; int wdwTop2 = screenSize.height / 2 - windowSize.height / 2; frame1.setLocation(wdwLeft2, wdwTop2); frame1.pack(); frame1.setSize(400, 350); frame1.setVisible(true); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(InsertTimeDiff, "InsertionSort", "InsertionSort"); dataset2.setValue(SelectTimeDiff, "SelectionSort", "SelectionSort"); JFreeChart chart2 = ChartFactory.createBarChart("Time Complexity* (can be vary)", "Time Complexity", "Nano Seconds", dataset2, PlotOrientation.VERTICAL, false, true, false); chart2.setBackgroundPaint(Color.white); chart2.getTitle().setPaint(Color.blue); CategoryPlot p2 = chart2.getCategoryPlot(); p2.setRangeGridlinePaint(Color.red); ChartFrame frame2 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart2); int wdwLeft = 50 + screenSize.width / 2 - windowSize.width / 2 + 200; int wdwTop = screenSize.height / 2 - windowSize.height / 2; frame2.setLocation(wdwLeft, wdwTop); frame2.pack(); frame2.setVisible(true); frame2.setSize(400, 350); } catch (Exception e) { e.printStackTrace(); } }
From source file:ecg.ecgshow.ECGShowUI.java
private void createGuardData() { GuardDataPanel = new JPanel(); GuardDataPanel.setBackground(new Color(0, 150, 255)); // GuardDataPanel.setBounds(); // BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS); // GuardDataPanel.setLayout(layout); GroupLayout layout = new GroupLayout(GuardDataPanel); GuardDataPanel.setLayout(layout);/* w ww .j a va2s . c om*/ JPanel temperatureData = new JPanel(); temperatureData.setLayout(new FlowLayout()); // temperatureData.setLayout(null); // temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11)); temperatureData.setBackground(new Color(0, 150, 255)); temperatureLabel = new JLabel("--.- "); temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070))); temperatureLabel.setBackground(new Color(0, 150, 255)); temperatureLabel.setForeground(Color.RED); // temperatureLabel.setBounds(0,0,200,100); temperatureLabel.setOpaque(true); JLabel temperatureLabelName = new JLabel(" "); temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); temperatureLabelName.setBackground(new Color(0, 150, 255)); temperatureLabelName.setForeground(Color.BLACK); temperatureLabelName.setBounds(0, 0, 100, 100); temperatureLabelName.setOpaque(true); //?? temperatureData.add(temperatureLabelName); temperatureData.add(temperatureLabel); // JPanel emptyPanel=new JPanel(); // emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2)); // emptyPanel.setBackground(new Color(0,150,255)); // GuardDataPanel.add(emptyPanel); JPanel lightValueData = new JPanel(); lightValueData.setLayout(new BorderLayout()); lightValueData.setBackground(new Color(0, 150, 255)); // lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30)); lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22)); lightValueDataSet = new DefaultValueDataset(); DialPlot lightValueDialPlot = new DialPlot(); lightValueDialPlot.setDataset(lightValueDataSet); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setVisible(false); lightValueDialPlot.setDialFrame(dialFrame); GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 170)); DialBackground dialBackground = new DialBackground(gradientpaint); dialBackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); lightValueDialPlot.setBackground(dialBackground); // ?? DialTextAnnotation dialtextannotation = new DialTextAnnotation(""); dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT))); dialtextannotation.setRadius(0.1D); lightValueDialPlot.addLayer(dialtextannotation); DialValueIndicator dialValueIndicator = new DialValueIndicator(0); dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT))); dialValueIndicator.setOutlinePaint(Color.darkGray); dialValueIndicator.setRadius(0.4D); dialValueIndicator.setAngle(-90.0); lightValueDialPlot.addLayer(dialValueIndicator); StandardDialScale dialScale = new StandardDialScale(); dialScale.setLowerBound(0D); // dialScale.setUpperBound(1024); // dialScale.setMajorTickIncrement(100); dialScale.setStartAngle(-120D); // 120,? dialScale.setExtent(-300D); // 300,? dialScale.setTickRadius(0.85D); // , dialScale.setTickLabelOffset(0.1D); // ,0 bloodDialRange = new StandardDialRange(500D, 750D, Color.red); bloodDialRange.setInnerRadius(0.52000000000000002D); bloodDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bloodDialRange); // bubbleDialRange = new StandardDialRange(0D, 500D, Color.black); bubbleDialRange.setInnerRadius(0.52000000000000002D); bubbleDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bubbleDialRange); // normalDialRange = new StandardDialRange(750D, 1024D, Color.green); normalDialRange.setInnerRadius(0.52000000000000002D); normalDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(normalDialRange); dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // lightValueDialPlot.addScale(0, dialScale); DialPointer.Pointer pointer = new DialPointer.Pointer(); lightValueDialPlot.addPointer(pointer); lightValueDialPlot.mapDatasetToScale(0, 0); DialCap dialCap = new DialCap(); dialCap.setRadius(0.07D); JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot); lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255)); lightValueDialChart.setTitle("??"); lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15), (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(temperatureData, GroupLayout.Alignment.LEADING) .addComponent(lightValueData, GroupLayout.Alignment.LEADING)))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(temperatureData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(lightValueData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)))); // JPanel alarmMessage=new JPanel(); // alarmMessage.setBackground(new Color(0,150,255)); // alarmMessLabel=new JLabel(""); // alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020))); // alarmMessLabel.setBackground(new Color(0,150,255)); // alarmMessage.add(alarmMessLabel); // GuardDataPanel.add(alarmMessage); }