List of usage examples for org.jfree.chart ChartPanel setVisible
@BeanProperty(hidden = true, visualUpdate = true) public void setVisible(boolean aFlag)
From source file:com.philng.telemetrydisplay.GraphDisplay.java
/** * Build all the initial data//from w ww . ja v a 2s . c o m */ public GraphDisplay() { voltage = new TimeSeries("Voltage"); current = new TimeSeries("Current"); this.setLayout(new BorderLayout()); final JFreeChart chart = createChart(createDatasetVoltage()); final ChartPanel chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); chartPanel.setVisible(true); setVisible(true); // Add a mouse listener for when the user double clicks the mousse // on the graph, it will reset the zoome ChartMouseListener cml = new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent chartMouseEvent) { if (chartMouseEvent.getTrigger().getClickCount() == 2) { chartPanel.restoreAutoBounds(); } } @Override public void chartMouseMoved(ChartMouseEvent chartMouseEvent) { } }; chartPanel.addChartMouseListener(cml); }
From source file:parts.GraphicContent.java
public void setContent(JPanel panel) { String sprint[] = null;/*from w w w . j a va 2 s.c o m*/ int taskCount[] = null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select COUNT(*) from sprint"; result = st.executeQuery(sql); result.next(); sprint = new String[result.getInt(1)]; } catch (Exception e) { e.printStackTrace(); } try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select * from sprint"; result = st.executeQuery(sql); int i = 0; while (result.next()) { sprint[i] = result.getString("alias"); i++; } } catch (Exception e) { e.printStackTrace(); } int sprintIDs[] = new int[sprint.length]; try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select * from sprint"; result = st.executeQuery(sql); int i = 0; while (result.next()) { sprintIDs[i] = result.getInt("idsprint"); i++; } } catch (Exception e) { e.printStackTrace(); } for (int i = 0; i < sprint.length; i++) { try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select COUNT(*) from sprint_tasks where idsprint = " + sprintIDs[i]; result = st.executeQuery(sql); while (result.next()) { dataset.addValue(result.getInt(1), "Tarefas", sprint[i]); } } catch (Exception e) { e.printStackTrace(); } } JFreeChart chart = null; chart = ChartFactory.createBarChart("Quantidade de tarefas por Sprint", "Sprint", "Tarefas", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartPanel cp = new ChartPanel(chart); cp.setBounds(0, 0, panel.getWidth(), panel.getHeight()); panel.removeAll(); cp.setVisible(true); panel.add(cp); panel.revalidate(); panel.repaint(); }
From source file:view.MainFrame.java
public void showChart(int N, double[] valuesY, double[] valuesX, String axisX, String axisY, String graphName, String dataName) {/*from w ww.j a v a2 s .c o m*/ graphPanel.removeAll(); String serieName = dataName; String tittle = graphName; String xAxisName = axisX; String yAxisName = axisY; XYSeries dataSerie = new XYSeries(serieName); for (int i = 0; i < N; i++) { dataSerie.add(valuesX[i], valuesY[i]); } XYSeriesCollection sCollection = new XYSeriesCollection(); sCollection.addSeries(dataSerie); //JFreeChart jfreechart = ChartFactory.createScatterPlot(tittle, xAxisName, yAxisName, sCollection); JFreeChart jfreechart = ChartFactory.createHistogram(tittle, xAxisName, yAxisName, sCollection, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel = new ChartPanel(jfreechart); panel.setVisible(true); graphPanel.add(panel); graphPanel.setLayout(new GridLayout(1, 0)); graphPanel.validate(); graphPanel.setVisible(true); }
From source file:gui.images.CodebookVectorProfilePanel.java
/** * Sets the data to be shown./*from w w w. ja v a 2 s. c o m*/ * * @param occurrenceProfile Double array that is the neighbor occurrence * profile of this visual word. * @param codebookIndex Integer that is the index of this visual word. * @param classColors Color[] of class colors. * @param classNames String[] of class names. */ public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors, String[] classNames) { int numClasses = Math.min(classNames.length, occurrenceProfile.length); this.codebookIndex = codebookIndex; this.occurrenceProfile = occurrenceProfile; DefaultPieDataset pieData = new DefaultPieDataset(); for (int cIndex = 0; cIndex < numClasses; cIndex++) { pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]); } JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(140, 140)); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); JPanel jp = new JPanel(); jp.setPreferredSize(new Dimension(140, 140)); jp.setMinimumSize(new Dimension(140, 140)); jp.setMaximumSize(new Dimension(140, 140)); jp.setSize(new Dimension(140, 140)); jp.setLayout(new FlowLayout()); jp.add(chartPanel); jp.setVisible(true); jp.validate(); jp.repaint(); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setUndecorated(true); frame.getContentPane().add(jp); frame.pack(); BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bi.createGraphics(); jp.print(graphics); graphics.dispose(); frame.dispose(); imPanel.removeAll(); imPanel.setImage(bi); imPanel.setVisible(true); imPanel.revalidate(); imPanel.repaint(); }
From source file:org.drugis.mtc.gui.results.ConvergencePlotsDialog.java
private JPanel createPanel() { final FormLayout layout = new FormLayout("pref:grow:fill", "p, 3dlu, p, 3dlu, p"); final PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder();/*w w w .j ava 2s . com*/ final CellConstraints cc = new CellConstraints(); final XYSeriesCollection datasetRhat = new XYSeriesCollection(); final XYSeriesCollection datasetVhatVsW = new XYSeriesCollection(); datasetRhat.addSeries(d_rHatSeries); datasetVhatVsW.addSeries(d_vHatSeries); datasetVhatVsW.addSeries(d_wSeries); final JFreeChart rHatChart = createRhatChart(datasetRhat); final JFreeChart vHatvsWChart = createVhatVsWChart(datasetVhatVsW); final ChartPanel chartPanelRhat = new ChartPanel(rHatChart); final ChartPanel chartPanelVhatVsW = new ChartPanel(vHatvsWChart); chartPanelRhat.setVisible(true); chartPanelVhatVsW.setVisible(true); final JProgressBar bar = new TaskProgressBar(d_task); builder.add(bar, cc.xy(1, 1)); builder.add(chartPanelRhat, cc.xy(1, 3)); builder.add(chartPanelVhatVsW, cc.xy(1, 5)); return builder.getPanel(); }
From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java
private JPanel createPanel() { FormLayout layout = new FormLayout("pref:grow:fill", "p, 3dlu, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder();/* w w w . java 2 s.c o m*/ CellConstraints cc = new CellConstraints(); final XYSeriesCollection datasetRhat = new XYSeriesCollection(); final XYSeriesCollection datasetVhatVsW = new XYSeriesCollection(); datasetRhat.addSeries(d_rHatSeries); datasetVhatVsW.addSeries(d_vHatSeries); datasetVhatVsW.addSeries(d_wSeries); final JFreeChart rHatChart = createRhatChart(datasetRhat); final JFreeChart vHatvsWChart = createVhatVsWChart(datasetVhatVsW); final ChartPanel chartPanelRhat = new ChartPanel(rHatChart); final ChartPanel chartPanelVhatVsW = new ChartPanel(vHatvsWChart); chartPanelRhat.setVisible(true); chartPanelVhatVsW.setVisible(true); JProgressBar bar = new TaskProgressBar(d_task); builder.add(bar, cc.xy(1, 1)); builder.add(chartPanelRhat, cc.xy(1, 3)); builder.add(chartPanelVhatVsW, cc.xy(1, 5)); return builder.getPanel(); }
From source file:IHM.NewClass.java
/** * * @param title// www . j a va 2 s .c om */ public NewClass(String title /*,*JInternalFrame jp*/) { super(title); // jp = new JInternalFrame("courbes"); JFreeChart chart = createChart(createDataset()); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(500, 300)); setContentPane(panel); // jp.add(panel, BorderLayout.EAST); // jp.setVisible(true); panel.setVisible(true); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); // sets thickness for series (using strokes) renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer); plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); }
From source file:Model.OpMenu.java
public JFrame GraficoProduto() { te.LeArquivo();//from w w w .jav a 2s. c om CategoryDataset cds = te.GeraDataset(); JFreeChart grafico = ChartFactory.createBarChart3D("Venda por produto", "Legenda:", "Quantidade vendida", cds, PlotOrientation.VERTICAL, true, true, true); JFrame janela = new JFrame(" "); Painel painel = new Painel(); ChartPanel myChartPanel = new ChartPanel(grafico, true); myChartPanel.setSize(painel.getWidth(), painel.getHeight()); myChartPanel.setVisible(true); painel.removeAll(); painel.add(myChartPanel); painel.revalidate(); painel.repaint(); janela.add(painel); janela.setSize(690, 465); janela.setVisible(true); return janela; }
From source file:Model.OpMenu.java
public JFrame GraficoCliente() { tv.LeArquivo();//from www. j a v a 2 s .c om float t = tv.Entrada(); CategoryDataset cds = vc.GeraDataSet(t); JFreeChart grafico = ChartFactory.createBarChart3D("Cinco clientes que mais compraram/gastaram", "Legenda: ", "Porcentagem (%)", cds, PlotOrientation.VERTICAL, true, true, true); JFrame janela = new JFrame(" "); Painel panel = new Painel(); ChartPanel myChartPanel = new ChartPanel(grafico, true); myChartPanel.setSize(panel.getWidth(), panel.getHeight()); myChartPanel.setVisible(true); panel.removeAll(); panel.add(myChartPanel); panel.revalidate(); panel.repaint(); janela.add(panel); janela.setSize(690, 465); janela.setVisible(true); return janela; }
From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java
/** * Creates a new status frame.//from w w w . ja v a2 s . c o m * * @param groundTruthYLabel The y-axis label for the ground truth signal. * @param analyzerYLabel The units output by the analyzer. * @param setpointYLabel The units of the controller setpoint. * @param outputYLabel The units output by the controller. */ public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel, String outputYLabel) { String seriesLabel = ""; String yLabel = ""; CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs")); Font yLabelFont = new Font("Dialog", Font.PLAIN, 10); datasets = new XYSeriesCollection[4]; for (int i = 0; i < SUBPLOT_COUNT; i++) { switch (i) { case 0: seriesLabel = "True density"; yLabel = groundTruthYLabel; break; case 1: seriesLabel = "Analyzer output"; yLabel = analyzerYLabel; break; case 2: seriesLabel = "Setpoint"; yLabel = setpointYLabel; break; case 3: seriesLabel = "Controller output"; yLabel = outputYLabel; break; } XYSeries timeseries = new XYSeries(seriesLabel); datasets[i] = new XYSeriesCollection(timeseries); NumberAxis numberaxis = new NumberAxis(yLabel); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00")); XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.getRangeAxis().setLabelFont(yLabelFont); combineddomainxyplot.add(xyplot); } JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true); jfreechart.setBorderPaint(Color.black); jfreechart.setBorderVisible(true); jfreechart.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = combineddomainxyplot.getDomainAxis(); valueaxis.setAutoRange(true); // Number of frames to display valueaxis.setFixedAutoRange(2000D); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(800, 500)); chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chartpanel.setVisible(true); JPanel jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(chartpanel, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); add(jPanel); pack(); setVisible(true); }