List of usage examples for org.jfree.chart ChartPanel ChartPanel
public ChartPanel(JFreeChart chart)
From source file:ws.moor.bt.gui.charts.RawDownloadRate.java
public RawDownloadRate(CounterRepository counterRepository) { super();// ww w . j av a 2s. c o m dataSource = new CounterStatisticsDataSource(counterRepository.getStatistics("network.rawbytes.in")) { protected double getValueToShowAt(long time) { return statistics.getIncreaseAt(time); } }; chart = createChart(getTimeSeriesCollection()); setLayout(new BorderLayout()); add(new ChartPanel(chart), BorderLayout.CENTER); }
From source file:Demo.HistGraph.java
public HistGraph(List<String> paraType_list) { this.paraType_list = paraType_list; // widgets: charts(JFreeChart), parameter selector (JList) chartPane = new ChartPanel(null); charts = new JFreeChart[paraType_list.size()]; DefaultListModel modelOfList = new DefaultListModel(); paraSelector = new JList(modelOfList); for (int i = 0; i < paraType_list.size(); i++) { modelOfList.addElement(paraType_list.get(i)); charts[i] = null;/* ww w. j av a 2 s.co m*/ } paraSelector.setSelectedIndex(0); charts[0] = CreateChart(paraType_list.get(0)); chartPane.setChart(charts[0]); JScrollPane selectorPanel = new JScrollPane(); selectorPanel.setViewportView(paraSelector); paraSelector.addMouseListener(this); // layout GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 20; add(new JLabel("Distribution:"), gbc); gbc.insets = new Insets(5, 5, 5, 20); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; add(new JLabel("Parameters:"), gbc); gbc.weighty = 14; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 20; add(chartPane, gbc); gbc.insets = new Insets(5, 5, 15, 20); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1; add(selectorPanel, gbc); }
From source file:algo.PlotBar.java
public PlotBar(String applicationTitle, String chartTitle) throws FileNotFoundException, IOException { super(applicationTitle); JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Algorithms", "Execution Time(ms)", createDataset(), PlotOrientation.VERTICAL, true, true, false); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); ChartPanel chartPanel = new ChartPanel(barChart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 420)); setContentPane(chartPanel);/*from w ww . j a v a 2s . com*/ }
From source file:userinterface.CyberSecurity.ChartFactory.java
public static ChartPanel createChart(UserAccount account) { Map<String, LoginDetails> loginDetails = account.getLoginDetails(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); Collection<LoginDetails> values = loginDetails.values(); for (LoginDetails details : values) { dataset1.addValue(TimeUnit.MILLISECONDS.toHours(details.getLogoutTime() - details.getLoginTime()), HOURS_WORKED_BY_USER, details.getLoginDate()); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, details.getLoginDate()); }/*from w ww .j av a 2s. c o m*/ dataset1.addValue(2, HOURS_WORKED_BY_USER, "4-19-2016"); dataset1.addValue(3, HOURS_WORKED_BY_USER, "4-20-2016"); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-19-2016"); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-20-2016"); final CategoryItemRenderer renderer = new BarRenderer(); final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset1); plot.setRenderer(renderer); plot.setDomainAxis(new CategoryAxis("Date")); plot.setRangeAxis(new NumberAxis("Hours")); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // now create the second dataset and renderer... final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); final JFreeChart chart = new JFreeChart(plot); chart.setTitle("Employee work hours"); chart.setBackgroundPaint(Color.WHITE); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); return chartPanel; }
From source file:utils.HistogramFrame.java
/** * Constructor for the HistogramFrame./*w w w . j a va2 s. co m*/ * @param values an array of doubles containing the values to be plotted * @param title the title to display for the Histogram */ public HistogramFrame(double[] values, String title, int w, int h, String label) { super(title); this.title = title; this.values = values; this.label = label; this.createDataset(); this.createChart(); final ChartPanel chartPanel = new ChartPanel(this.chart); chartPanel.setPreferredSize(new Dimension(w, h)); super.setContentPane(chartPanel); }
From source file:SeriesDiarias.VisualizadorSeries.java
/** * Constri a visualizao dos dados. Cria a janela e o grfico a ser exibido * nela.//from w w w . ja va 2 s . com * * @param serieDados A srie de dados que ter seus dados exibidos em um grfico */ public VisualizadorSeries(SerieDadosDiarios serieDados) { // cria a janela janela = new ApplicationFrame("Visualizador Series Diarias"); janela.setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE); // cria o grfico que contm os dados da srie JFreeChart graficoLinha = ChartFactory.createLineChart(serieDados.obterIdentificacaoSerie(), // Ttulo do grfico "Dia", // Nome do eixo X "Valor", // Nome do eixo Y criarDataset(serieDados), // mtodo que cria os dados do grfico PlotOrientation.VERTICAL, // Orientao do grfico true, true, false); // legenda, tooltips, urls // adiciona o grfico na janela ChartPanel painelGrafico = new ChartPanel(graficoLinha); painelGrafico.setPreferredSize(new Dimension(600, 400)); janela.setContentPane(painelGrafico); janela.pack(); // posiciona a janela aleatoriamente na tela RefineryUtilities.positionFrameRandomly(janela); }
From source file:de.main.sessioncreator.ReportingHelper.java
public void addReport(JPanel jp) { jp.removeAll();//ww w. ja v a2 s . com PieDataset dataset = createDataset(); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "Sessions by Tester"); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.updateUI(); chartPanel.setSize(490, 350); jp.revalidate(); jp.setOpaque(true); jp.add(chartPanel); jp.revalidate(); jp.setVisible(true); jp.setSize(700, 500); jp.revalidate(); jp.repaint(); }
From source file:view.HistogramFloat.java
public HistogramFloat(String applicationTitle, String TituloGrafico, List<StringFloat> Lista) { super(applicationTitle); String legenda = Lista.get(Lista.size() - 1).getDescricao(); DefaultCategoryDataset DatasetGrafico = new DefaultCategoryDataset(); int i;//from ww w. ja va 2 s. c o m for (i = 0; i < Lista.size() - 1; i++) { DatasetGrafico.addValue(Lista.get(i).getValor(), legenda, Lista.get(i).getDescricao()); } //JFreeChart grafico = ChartFactory.createBarChart(TituloGrafico, "Legends", "Value of Quality Index using "+legenda, DatasetGrafico); JFreeChart grafico = ChartFactory.createLineChart(TituloGrafico, "Number of Clusters", "Index of Quality", DatasetGrafico, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = grafico.getCategoryPlot(); LineAndShapeRenderer renderer = new LineAndShapeRenderer(); plot.setRenderer(renderer); //createBarChart(TituloGrafico, "Legends", "Value of Quality Index using "+legenda, DatasetGrafico); this.add(new ChartPanel(grafico)); this.pack(); }
From source file:uom.research.thalassemia.util.PieChartCreator.java
/** * Creates a panel for the demo (used by SuperDemo.java). * * @param pPieDataset dataset/* w w w.j av a 2s .co m*/ * @param pTitle title * @return A panel. */ public JPanel createPanel(final PieDataset pPieDataset, final String pTitle) { title = pTitle; pieDataset = pPieDataset; // set a theme using the new shadow generator feature available in // 1.0.14 - for backwards compatibility it is not enabled by default ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true)); JFreeChart chart = createChart(pieDataset); chart.setPadding(new RectangleInsets(4, 8, 2, 2)); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new Dimension(600, 300)); return panel; }
From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java
/** * Creates new form StateReportsJPanel/*from www. j a v a 2 s. c o m*/ */ StateReportsJPanel(JPanel userProcessContainer, DonorDirectory donorDirectory, PatientDirectory patientList) { initComponents(); this.userProcessContainer = userProcessContainer; this.donorDirectory = donorDirectory; this.patientList = patientList; final CategoryDataset datasetDonors = createDataSetForDonorReports(); final JFreeChart donorChart = createDonorsReportsChart(datasetDonors); final ChartPanel donorChartPanel = new ChartPanel(donorChart); donorReportsJPanel.setLayout(new BorderLayout()); donorReportsJPanel.add(donorChartPanel, BorderLayout.CENTER); donorReportsJPanel.validate(); final CategoryDataset datasetPatients = createDataSetForPatientsReports(); final JFreeChart patientChart = createPatientReportsChart(datasetPatients); final ChartPanel patientChartPanel = new ChartPanel(patientChart); patientReportJPanel.setLayout(new BorderLayout()); patientReportJPanel.add(patientChartPanel, BorderLayout.CENTER); patientReportJPanel.validate(); final CategoryDataset patientDonordataSet = createDataSetForpatientDonorReports(); final JFreeChart patientDonorChart = createpatientDonorReportsChart(patientDonordataSet); final ChartPanel patientDonorChartPanel = new ChartPanel(patientDonorChart); patientDonorPanel.setLayout(new BorderLayout()); patientDonorPanel.add(patientDonorChartPanel, BorderLayout.CENTER); patientDonorPanel.validate(); }