List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesLinesVisible
public void setSeriesLinesVisible(int series, boolean visible)
From source file:ip.ui.plot.PlotGenerator.java
public void generateResultsChart(ResultsPlotData data, String fileName) throws IOException { XYSeries expectedData = new XYSeries("Expected output"); XYSeries networkData = new XYSeries("Network output"); List<double[]> inputs = new ArrayList(data.getInputs().size()); data.getInputs().stream().forEach((InputRow row) -> { inputs.add(row.getValues());/*from w ww.java 2s . c o m*/ }); List<double[]> expectedOutputs = new ArrayList(data.getInputs().size()); data.getInputs().stream().forEach((InputRow row) -> { expectedOutputs.add(row.getExpectedOutput()); }); List<double[]> outputs = data.getOutputs(); for (int i = 0; i < inputs.size(); ++i) { expectedData.add(inputs.get(i)[0], expectedOutputs.get(i)[0]); networkData.add(inputs.get(i)[0], outputs.get(i)[0]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(expectedData); dataset.addSeries(networkData); JFreeChart chart = ChartFactory.createXYLineChart(data.getPlotName(), data.getxAxisLabel(), data.getyAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, true); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, false); chart.getXYPlot().setRenderer(renderer); File XYChart = new File(fileName); ChartUtilities.saveChartAsJPEG(XYChart, chart, chartWidth, chartHeight); }
From source file:com.seniorproject.augmentedreality.test.LineChartDemo6.java
/** * Creates a chart./*from w w w. ja v a 2s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:physical_network.OscilloscopePanel.java
public OscilloscopePanel() { super("Oscilloscope"); // Set initial (time, voltage) datapoint of (0.0, 0.0). voltages.add(0.0, 0.0);//from ww w . j a va 2 s . co m XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(voltages); JFreeChart chart = ChartFactory.createXYLineChart("Oscilloscope", "Time (seconds)", "Voltage", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, 10.0); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(-5.0, 5.0); range.setTickUnit(new NumberTickUnit(1.0)); plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:com.kurvlrgui.gui.ChartPanel.java
/** * Creates new form ChartPanel//from w w w. ja va 2 s . c o m */ public ChartPanel(String title, NumericData s1, NumericData s2) { initComponents(); calculated = new XYSeries("Calculated"); for (NumericPair np : s1.values) { calculated.add(np.x, np.y); } observed = null; if (s2 != null) { observed = new XYSeries("Observed"); for (NumericPair np : s2.values) { observed.add(np.x, np.y); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(calculated); if (s2 != null) dataset.addSeries(observed); JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); panel = new org.jfree.chart.ChartPanel(chart); panel.setHorizontalAxisTrace(true); panel.setVerticalAxisTrace(true); this.add(panel); }
From source file:statUtil.TurnMovementPlot.java
public TurnMovementPlot(String title) throws IOException { super(title); Data data = CSVData.getCSVData(TURN_CSV_LOG); JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", XYDatasetGenerator.generateXYDataset(data.csvData)); final XYPlot xyPlot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3f)); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); Shape cross = ShapeUtilities.createDiagonalCross(2f, 0.5f); renderer.setSeriesShape(1, cross);/* w w w . jav a 2s .c o m*/ xyPlot.setRenderer(renderer); xyPlot.setQuadrantOrigin(new Point(0, 0)); int i = 0; for (Double[] csvRow : data.csvData) { if (i % 20 == 1) { final XYTextAnnotation annotation = new XYTextAnnotation(Double.toString(csvRow[3]), csvRow[0], csvRow[1]); annotation.setFont(new Font("SansSerif", Font.PLAIN, 10)); xyPlot.addAnnotation(annotation); } i++; } int width = (int) Math.round(data.maxX - data.minX) + 50; int height = (int) Math.round(data.maxY - data.minY) + 50; ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(width, height)); setContentPane(chartPanel); File XYChart = new File(FILE_PATH + "\\TurnMovementPlot.png"); ChartUtilities.saveChartAsPNG(XYChart, chart, width, height); }
From source file:com.cs572.assignments.Project2.view.LineChartPanel.java
/** * Creates a chart./*from w ww . j av a 2 s. co m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Expression Tree", // chart title "DataPoints", // x axis label "Output", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:adams.gui.visualization.jfreechart.chart.ScatterPlot.java
/** * Performs the actual generation of the chart. * * @param data the data to use/*from w w w . j a v a 2 s.co m*/ * @return the chart */ @Override protected JFreeChart doGenerate(XYDataset data) { JFreeChart result = ChartFactory.createScatterPlot(m_Title, m_LabelX, m_LabelY, data, m_Orientation.getOrientation(), m_Legend, m_ToolTips, false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); if (result.getXYPlot().getSeriesCount() == 2) { renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShapesVisible(1, false); result.getXYPlot().setRenderer(renderer); } return result; }
From source file:presentationGui.GraphFrame.java
/** * Creates a chart./*from w w w. j a v a 2 s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Comportamento Asintotico del throughput", // chart title "numero job", // x axis label "throughput", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... /*final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());*/ // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:grafix.graficos.indices.IndiceADX.java
@Override public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) { XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); r.setSeriesLinesVisible(0, true); r.setSeriesShapesVisible(0, false);// ww w. ja v a 2 s . c o m r.setSeriesPaint(0, Color.BLUE); r.setSeriesStroke(0, new BasicStroke(.75f)); r.setSeriesPaint(1, Color.RED); r.setSeriesStroke(1, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 3.0f, 4.0f }, 0.0f)); r.setSeriesLinesVisible(1, true); r.setSeriesShapesVisible(1, false); r.setSeriesPaint(2, new Color(0f, .6f, 0f)); r.setSeriesStroke(2, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f, new float[] { 3.0f, 4.0f }, 0.0f)); r.setSeriesLinesVisible(2, true); r.setSeriesShapesVisible(2, false); r.setToolTipGenerator(new IndiceToolTipGenerator(this)); plot.setRenderer(contador, r); plot.setDataset(contador, getDataSet(janela)); }
From source file:syg_package01.PanelRysunek2.java
private void initGUI() { try {//from www . ja v a 2 s .c om GridLayout thisLayout = new GridLayout(1, 1); thisLayout.setHgap(5); thisLayout.setVgap(5); thisLayout.setColumns(1); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); if (this.wykres) { double punkt = this.sygnalWyswietlany.gett1(); HistogramDataset histogramDataset = new HistogramDataset(); histogramDataset.setType(HistogramType.FREQUENCY); ArrayList<Double> punkty = new ArrayList<Double>(); double ta = this.sygnalWyswietlany.gett1(); if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY || sygnalWyswietlany.getPunktyY().size() <= 0) { while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) { punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta); // this.sygnalWyswietlany.setPunktyY (punkt); punkty.add(punkt); ta = ta + this.sygnalWyswietlany.getkroczek(); } } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY) { int iloscProbek = (int) (this.sygnalWyswietlany.getT() / (Double) this.sygnalWyswietlany.getkroczek()); for (int i = 0; i < iloscProbek; i++) { punkt = this.sygnalWyswietlany.getPunktzindexu(i); punkty.add(punkt); ta = ta + this.sygnalWyswietlany.getkroczek(); } } JFreeChart chartHist; if (this.iloscPrzedzialowHistogramu > 0) { double[] tablicaHistogramu = new double[punkty.size()]; for (int licznik = 0; licznik < punkty.size(); ++licznik) tablicaHistogramu[licznik] = punkty.get(licznik); histogramDataset.addSeries("Histogram (" + iloscPrzedzialowHistogramu + ")", tablicaHistogramu, this.iloscPrzedzialowHistogramu); chartHist = ChartFactory.createHistogram("Histogram", null, null, histogramDataset, PlotOrientation.VERTICAL, true, false, false); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); ChartPanel chartpanel1 = new ChartPanel(chartHist); chartpanel1.setDomainZoomable(true); this.add(chartpanel1); } } Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this); } catch (Exception e) { e.printStackTrace(); } }