List of usage examples for org.jfree.chart ChartFrame ChartFrame
public ChartFrame(String title, JFreeChart chart)
From source file:classes.SharedClass.java
public void getStatistics() { result = db.select("member", new String[] { " count(id) id" }, new String[] { "id" }, new String[] { "99999" }, "!=", "and"); try {/*from w w w. j a v a 2s . c o m*/ if (result.next()) { memberId = result.getInt("id"); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); ex.printStackTrace(); } //book result = db.select("book", new String[] { "count(id)" }, new String[] { "id" }, new String[] { "99999" }, "!=", "and"); try { if (result.next()) { bookId = result.getInt(1); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); } //operations result = db.select("operations", new String[] { "count(id)" }, new String[] { "type" }, new String[] { "borrowed" }, "=", "and"); try { if (result.next()) { operationsId = result.getInt(1); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); } DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); dataSet.setValue(memberId, "Percent", "Members"); dataSet.setValue(bookId, "Percent", "Books"); dataSet.setValue(operationsId, "Percent", "Borrowe books"); JFreeChart chart = ChartFactory.createBarChart3D("Statistics", "Fields", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.yellow); chart.getTitle().setPaint(Color.red); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.blue); ChartFrame frame = new ChartFrame("Statistics", chart); frame.setLocationRelativeTo(null); frame.setSize(500, 550); frame.setVisible(true); }
From source file:trabajoanalisis.grafico.java
public void graficar(JTable a) { XYSeries series = new XYSeries("t/n"); // Introduccion de datos int i = 0;// w w w.ja v a 2 s .co m while (a.getValueAt(i, 1) != null) { System.out.println(a.getValueAt(i, 1).toString()); System.out.println(i); series.add(Integer.parseInt(a.getValueAt(i, 0).toString()), Integer.parseInt(a.getValueAt(i, 1).toString())); System.out.println("Se ha agregado " + Integer.parseInt(a.getValueAt(i, 0).toString()) + " y " + a.getValueAt(i, 1).toString()); i++; } // series.add(1, 1); // series.add(2, 6); // series.add(3, 3); // series.add(4, 10); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createXYLineChart("Grafica", // Ttulo "n", // Etiqueta Coordenada X "tiempo", // Etiqueta Coordenada Y dataset, // Datos PlotOrientation.VERTICAL, true, // Muestra la leyenda de los productos (Producto A) false, false); // Mostramos la grafica en pantalla ChartFrame frame = new ChartFrame("Grafica", chart); frame.pack(); frame.setVisible(true); }
From source file:PerformanceGraph.java
/** * Plots the performance graph of the best fitness value so far versus the * number of function calls (NFC).//from w w w . ja v a 2s. co m * * @param bestFitness A linked hashmap mapping the NFC to the best fitness value * found so far. * @param fitnessFunction The name of the fitness function, used for the title and the * name of the file that is saved, e.g. "De Jong". */ public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) { /* Create an XYSeries plot */ XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls"); /* Add the NFC and best fitness value data to the series */ for (Integer NFC : bestFitness.keySet()) { /* Jfreechart crashes if double values are too large! */ if (bestFitness.get(NFC) <= 10E12) { series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue()); } } /* Add the x,y series data to the dataset */ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); /* Plot the data as an X,Y line chart */ JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls", "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false, true, false); /* Configure the chart settings such as anti-aliasing, background colour */ chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); /* Set the domain range from 0 to NFC */ NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue()); /* Logarithmic range axis */ plot.setRangeAxis(new LogAxis()); /* Set the thickness and colour of the lines */ XYItemRenderer renderer = plot.getRenderer(); BasicStroke thickLine = new BasicStroke(3.0f); renderer.setSeriesStroke(0, thickLine); renderer.setPaint(Color.BLACK); /* Display the plot in a JFrame */ ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart); frame.setVisible(true); frame.setSize(1000, 600); /* Save the plot as an image named after fitness function try { ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900); } catch (IOException e) { e.printStackTrace(); }*/ }
From source file:edu.uara.wrappers.customcharts.CustomJFreeChart.java
/** * draw chart on a frame//from w w w . ja v a2 s. co m * @param frameTitle * @return */ public ChartFrame drawChart(String frameTitle) { try { ChartFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); //frame.setVisible(true); return frame; } catch (Exception ex) { System.out.println(ex.getMessage()); return null; } }
From source file:view.visualization.TXTVisualization.java
public static void drawChart(String a, String b, String txt) { String[] boje = null;//from w ww .j a v a 2 s.co m LinkedList<String> atributi = new LinkedList<String>(); LinkedList<String> sviAtributi = new LinkedList<String>(); String[] vrAtribut = null; XYSeries[] xy = null; XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); int brojac = 0; boolean kraj = false; LinkedList<Integer> numeric = new LinkedList<Integer>(); try { BufferedReader in = new BufferedReader(new FileReader(txt)); int br = Integer.parseInt(in.readLine().split(" ")[1]); for (int j = 0; j < br + 1; j++) { String pom = in.readLine(); if (pom.contains("@attribute")) { if (pom.contains("numeric")) { sviAtributi.add(pom.substring(11, pom.lastIndexOf("n") - 1)); } else { sviAtributi.add(pom.split(" ")[1]); } } if (pom.contains("@attribute") && pom.contains("numeric")) { atributi.add(pom.substring(11, pom.lastIndexOf("n") - 1)); } if (!pom.contains("numeric")) { brojac++; numeric.add(j - 2); } } String s = in.readLine(); boje = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")).split(","); xy = new XYSeries[boje.length]; for (int i = 0; i < boje.length; i++) { xy[i] = new XYSeries(boje[i]); } while (!kraj) { String pom2 = in.readLine(); if (!(pom2.contains("@data"))) { vrAtribut = pom2.split(","); for (int i = 0; i < xy.length; i++) { if (xy[i].getKey().equals(vrAtribut[vrAtribut.length - 1])) { xy[i].add(Double.parseDouble(vrAtribut[sviAtributi.indexOf(a)]), Double.parseDouble(vrAtribut[sviAtributi.indexOf(b)])); } } } } in.close(); } catch (Exception e) { e.getMessage(); } for (int i = 0; i < xy.length; i++) { xySeriesCollection.addSeries(xy[i]); } JFreeChart grafik = ChartFactory.createScatterPlot("Vizuelizacija", a, b, xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); ChartFrame proba = new ChartFrame("DataMiner", grafik); proba.setVisible(true); proba.setSize(500, 600); }
From source file:dumbara.view.Chart1.java
public static void byAgent() { DefaultPieDataset objDataset = new DefaultPieDataset(); try {/*from www . ja va 2 s.co m*/ Chart[] charts = SalesController.getAgencyAmounts(); for (Chart chart : charts) { objDataset.setValue(chart.getAgencyID(), chart.getIncomeSum()); } } catch (ClassNotFoundException | SQLException ex) { Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex); } Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, -1); Date result = cal.getTime(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd"); String format = simpleDateFormat.format(result); Date date = new Date(); String format1 = simpleDateFormat.format(date); JFreeChart objChart = ChartFactory.createPieChart( "Sales Range of Agencies from " + format + " to " + format1, objDataset, true, true, false); ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart); frame.pack(); frame.setVisible(true); frame.setLocationRelativeTo(null); }
From source file:UserInterface.CentreForDiseaseControl.AddDiseaseJPanel.java
public void displayPieChart(String diseaseName) { String sName = ""; int winnerState = 0; int totalQuantityConsumedInState = 0; DefaultPieDataset pieDataset = new DefaultPieDataset(); for (PHDEnterprise phdEnterprise : enterprise.getPhdList()) { String stateName = phdEnterprise.getStateName(); for (Order order : enterprise.getMasterOrderCatalog().getOrderList()) { if (order.getSite().getStateName().equals(stateName)) { for (OrderItem orderItem : order.getOrderItemList()) { if (orderItem.getVaccine().getDisease().getDiseaseName().equals(diseaseName) && orderItem.getIsOrderItemApprovedByCdc().equals("Approved")) { totalQuantityConsumedInState = totalQuantityConsumedInState + orderItem.getTotalQuantity(); if (totalQuantityConsumedInState > winnerState) { winnerState = totalQuantityConsumedInState; sName = stateName; }/*from w w w . ja v a 2 s. c o m*/ } } } } pieDataset.setValue(stateName, totalQuantityConsumedInState); totalQuantityConsumedInState = 0; } JFreeChart chart = ChartFactory.createPieChart("Pie Chart", pieDataset, true, true, true); PiePlot p = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Disease Summary", chart); frame.setVisible(true); frame.setSize(450, 500); stateNameJTextField.setText(sName); }
From source file:clientesbac.frmConsultaClientes.java
public void pastel() { // Fuente de Datos DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Regular", 40); data.setValue("Corporativo", 20); data.setValue("Adulto Mayor", 15); data.setValue("Embarazada", 15); data.setValue("Discapacitado", 10); // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart("Grfico de pastel por tipo de Cliente", data, true, true, false);//from w w w.j a v a 2s . com // Mostrar Grafico ChartFrame frame = new ChartFrame("Reporte", chart); frame.pack(); frame.setVisible(true); }
From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java
/** * Displays an XYPlot with Y symbolic data. * /*from w ww .j a v a 2 s . c o m*/ * @param frameTitle * the frame title. * @param data * the data. * @param chartTitle * the chart title. * @param xAxisLabel * the x-axis label. * @param yAxisLabel * the y-axis label. */ private static void displayYSymbolic(final String frameTitle, final XYDataset data, final String chartTitle, final String xAxisLabel, final String yAxisLabel) { final JFreeChart chart = createYSymbolicPlot(chartTitle, xAxisLabel, yAxisLabel, data, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green)); final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }
From source file:jmbench.plots.MemoryRelativeBarPlot.java
public void displayWindow(int width, int height) { ChartFrame window = new ChartFrame(chart.getTitle().getText(), chart); window.setMinimumSize(new Dimension(width, height)); window.setPreferredSize(window.getMinimumSize()); window.setVisible(true);/*from w w w .j a v a 2 s . c om*/ }