List of usage examples for org.jfree.chart ChartFrame ChartFrame
public ChartFrame(String title, JFreeChart chart, boolean scrollPane)
From source file:spectrex.Charts.java
/** * @param data initial data for chart creation * @param title text which would be displayed at the top of the frame and in * the frame's title/*from ww w. j a va 2 s . co m*/ * @param columnLabel text which would be displayed on the left of the * Y-axis * @param rowLabel text which would be displayed under X-axis * @param frameSize size of chart frame * @return Bar chart JFrame link * @author ReaLgressA */ public static JFrame createBarChart(ChartData data, String title, String columnLabel, String rowLabel, Dimension frameSize) { JFreeChart chart = ChartFactory.createStackedBarChart(title, columnLabel, rowLabel, data.getDataset(), PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame(title, chart, true); frame.setVisible(true); frame.setSize(frameSize); frame.setResizable(true); return (JFrame) frame; }
From source file:view.tankDepthDetails.BarrChart.java
/** * Creates new form BarrChart//from w ww . ja va2 s.c o m */ public BarrChart() { initComponents(); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); float s = 8; dcd.setValue(s, "Marks", "Dumindu"); dcd.setValue(88.80, "Marks", "lakal"); dcd.setValue(78.80, "Marks", "Charitha"); dcd.setValue(7.80, "Marks", "lahiru"); dcd.setValue(76.80, "Marks", "mahin"); dcd.setValue(90.80, "Marks", "gin"); JFreeChart Jchart = ChartFactory.createBarChart("Tank Level Records", "Time", "Tank Level", dcd, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = Jchart.getCategoryPlot(); plot.setRangeGridlinePaint(java.awt.Color.black); ChartFrame chartfra = new ChartFrame("Tank Level Records", Jchart, true); // chartfra.setVisible(true); chartfra.setSize(400, 500); ChartPanel chartPanel = new ChartPanel(Jchart); jPanel2.removeAll(); jPanel2.add(chartPanel); jPanel2.updateUI(); }
From source file:muh.GrafikDeneme.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed DefaultCategoryDataset dcd = new DefaultCategoryDataset(); dcd.setValue(78.80, "Marks", "Ganesh"); dcd.setValue(68.80, "Marks", "Dinesh"); dcd.setValue(88.80, "Marks", "John"); dcd.setValue(98.80, "Marks", "Ali"); dcd.setValue(58.80, "Marks", "Sachin"); JFreeChart jchart = ChartFactory.createBarChart3D("Student Record", "Student Name", "Student Marks", dcd, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = jchart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.black); ChartFrame chartFrm = new ChartFrame("Student Record", jchart, true); chartFrm.setVisible(true);//from w w w .j a va2 s.c o m chartFrm.setSize(500, 400); //SMD PENCERENN NE KOYACAAAAAAAAAAAAAAAAK ChartPanel chartPanel = new ChartPanel(jchart); // DESGNDEN PANELN ADINI DETRD pnlReport ,,set layout=box pnlReport.removeAll(); pnlReport.add(chartPanel); pnlReport.updateUI(); }
From source file:org.audiveris.omr.util.ChartPlotter.java
/** * Wrap chart into a frame with specific title and display the frame at provided * location./*from w w w . j a va 2 s .c o m*/ * * @param title frame title * @param location frame location */ public void display(String title, Point location) { ChartFrame frame = new ChartFrame(title, chart, true); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setLocation(location); frame.setVisible(true); }
From source file:omr.glyph.ui.TextAreaBrowser.java
private void showHistogram(TextArea area, Oriented orientation) { int[] histo = area.getHistogram(orientation); boolean vertical = orientation.isVertical(); Rectangle rect = area.getAbsoluteContour(); // Projection data XYSeries dataSeries = new XYSeries("Foreground Pixels"); int offset = vertical ? rect.x : rect.y; for (int i = 0; i < histo.length; i++) { if (vertical) { dataSeries.add(offset + i, histo[i]); } else {//from w w w .j ava 2 s. com dataSeries.add(i - offset - histo.length + 1, histo[histo.length - 1 - i]); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dataSeries); // Chart JFreeChart chart; if (vertical) { chart = ChartFactory.createXYAreaChart("Vertical Projections", // Title "Abscissa", "Cumulated Pixels", dataset, // Dataset PlotOrientation.VERTICAL, // orientation, false, // Show legend false, // Show tool tips false // urls ); } else { // Thresholds addLine(dataset, area, "Base", area.getBaseline()); addLine(dataset, area, "Median", area.getMedianLine()); addLine(dataset, area, "Top", area.getTopline()); chart = ChartFactory.createXYLineChart( "Horizontal Projections top:" + area.getTopline() + " median:" + area.getMedianLine() + " base:" + area.getBaseline(), // Title "Ordinate", "Cumulated Pixels", dataset, // Dataset PlotOrientation.HORIZONTAL, // orientation, true, // Show legend true, // Show tool tips false // urls ); } // Hosting frame ChartFrame frame = new ChartFrame("Histogram of " + rect, chart, true); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
From source file:net.sf.maltcms.common.charts.api.CategoryChartBuilder.java
/** * * @param scrollPane//from w ww . j a v a2 s . com * @return */ public ChartFrame buildFrame(boolean scrollPane) { ChartFrame chartFrame = new ChartFrame(chartTitle, chart, scrollPane); return chartFrame; }
From source file:org.activequant.util.charting.Chart.java
/** * Creates a JFrame that can be displayed on the screen. The returned JFrame * is not yet visible. To actually show it, do the following: * <ul>/*ww w . j a v a2 s . c o m*/ * <li><code>setBounds()</code> to set frame bounds. * <li><code>setVisible(true)</code> to show it. * </ul> * * @param title frame title. * @param scrollPane true is scroll pane is needed. * * @return JFrame */ public JFrame getJFrame(String title, boolean scrollPane) { return new ChartFrame(title, this.getChart(), scrollPane); }
From source file:virgil.meanback.HistoryInfo.java
public void printChart(Stock stock, List<String[]> list, int days) throws Exception { //?//from w ww .j a va 2 s . co m StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.BOLD, 12)); //? standardChartTheme.setLargeFont(new Font("", Font.BOLD, 18)); //? ChartFactory.setChartTheme(standardChartTheme); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = list.size() - 1; i >= 0; i--) { String[] s = (String[]) list.get(i); dataSet.addValue(Double.parseDouble(s[1]), days + "", s[0]); dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "", s[0]); float sub = Float.parseFloat(s[2]); float error = Float.parseFloat(s[3]); if (sub > error * 2) { dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "??", s[0]); } } //?????Legend //???? //??URL JFreeChart chart = ChartFactory.createLineChart( stock.getName() + "(" + stock.getCode() + ") ", "", "", dataSet, PlotOrientation.VERTICAL, true, true, false); CategoryPlot cp = chart.getCategoryPlot(); cp.setBackgroundPaint(ChartColor.WHITE); // CategoryAxis categoryAxis = cp.getDomainAxis(); // Lable 90 Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 10); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); categoryAxis.setTickLabelFont(labelFont);//X?? ValueAxis yAxis = cp.getRangeAxis(); yAxis.setAutoRange(true); double[] d = getAxiasThresold(stock, list); yAxis.setLowerBound(d[0] - 0.15); yAxis.setUpperBound(d[1] + 0.15); LineAndShapeRenderer lasp = (LineAndShapeRenderer) cp.getRenderer(); lasp.setBaseFillPaint(ChartColor.RED); lasp.setDrawOutlines(true); lasp.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); LineAndShapeRenderer renderer = (LineAndShapeRenderer) cp.getRenderer(1);//? DecimalFormat decimalformat1 = new DecimalFormat("##.##");//??? renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1)); //???? renderer.setItemLabelsVisible(true);// renderer.setBaseItemLabelsVisible(true);// //????? renderer.setShapesFilled(Boolean.TRUE);//?? renderer.setShapesVisible(true);//? ChartFrame chartFrame = new ChartFrame("??", chart, true); //chart?JavaChartFramejavaJframe???? chartFrame.pack(); //?? chartFrame.setVisible(true);//??? }
From source file:edu.ku.brc.specify.toycode.BugParse.java
/** * @param lines//w w w . j a v a2s . c o m */ protected void createChart(final List<String> lines, final String engineer) { int[] mins = new int[lines.size() - 1]; for (int index = 1; index < lines.size(); index++) { String line = lines.get(index); String[] values = StringUtils.splitPreserveAllTokens(line, ","); int inx = 0; while (inx < values.length && values[inx].equals("0")) { inx++; } mins[index - 1] = inx < values.length ? inx : Integer.MAX_VALUE; System.err.println(mins[index - 1]); } int startInx = Integer.MAX_VALUE; for (int min : mins) { startInx = Math.min(startInx, min); System.out.println(min + " " + startInx); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String[] headers = StringUtils.split(lines.get(0), ","); int len = headers.length - startInx; System.out.println(headers.length + " " + len); List<double[]> valArray = new Vector<double[]>(); for (int i = 1; i < lines.size(); i++) { String[] values = StringUtils.splitPreserveAllTokens(lines.get(i), ","); double[] vals = new double[len]; int inx = 0; double prev = -1; for (int j = startInx; j < headers.length; j++) { if (StringUtils.isNotEmpty(values[j])) { prev = Double.parseDouble(values[j]); vals[inx++] = prev; } else { vals[inx++] = 0.0; } } valArray.add(vals); } double[] vals = valArray.get(0); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Bugs", headers[i + startInx]); } vals = valArray.get(1); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Resolved", headers[i + startInx]); } vals = valArray.get(2); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Open", headers[i + startInx]); } JFreeChart chart = ChartFactory.createLineChart("Bugs - " + engineer, "Time", "Bugs", dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); //plot.setBackgroundPaint(Color.lightGray); //plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setAxisLineVisible(true); CategoryAxis catAxis = plot.getDomainAxis(); catAxis.setAxisLineVisible(true); catAxis.setTickMarksVisible(true); ChartFrame frame = new ChartFrame("", chart, false); frame.setBackground(Color.WHITE); frame.setSize(500, 500); frame.setVisible(true); }
From source file:correcao.PanelCorrecao.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: final CategoryDataset dcd = createDataset(); //for (int i = 0 ; i<p.nome.size() ; i++) { // dcd.addValue(resp.get(i), "Questes acertadas", p.nome.get(i)); //}/* ww w .j a v a2 s . c om*/ JFreeChart jc; jc = ChartFactory.createBarChart3D("Grfico de Aproveitamento da Turma", "Nome do aluno", "Questes Acertadas", dcd, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = jc.getCategoryPlot(); plot.setRangeGridlinePaint(Color.black); CategoryItemRenderer rend = plot.getRenderer(); rend.setSeriesPaint(0, new Color(0, 0, 159)); rend.setSeriesPaint(1, new Color(18, 230, 3)); ChartFrame cf = new ChartFrame("Aproveitamento", jc, true); cf.setVisible(true); cf.setSize(700, 500); }