List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:org.cytoscape.dyn.internal.graphMetrics.GenerateChart.java
public JFreeChart generateTimeSeries() { dataset = new XYSeriesCollection(); XYSeries[] attributeSeries = new XYSeries[(selectedNodes.size() + selectedEdges.size()) * (checkedAttributes.size() + edgeCheckedAttributes.size())]; int j = 0;//from w ww . ja v a2 s . co m /*creating dataseries for each node and its checked attribute and adding it to the dataset*/ for (CyNode node : selectedNodes) { // System.out.println(checkedAttributes.size()); for (int i = 0; i < checkedAttributes.size(); i++) { attributeSeries[j] = new XYSeries(dynamicNetwork.getNodeLabel(node) + checkedAttributes.get(i), false, true); // System.out.println(dynamicNetwork.getDynAttribute(node, // checkedAttributes.get(i)).getKey().getColumn()); for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(node, checkedAttributes.get(i)) .getIntervalList()) { // System.out.println(interval.getOnValue()); double value; if (interval.getOnValue() instanceof Double) value = (Double) interval.getOnValue(); else value = ((Integer) interval.getOnValue()).doubleValue(); // System.out.println(value); attributeSeries[j].add(interval.getStart(), value); attributeSeries[j].add(interval.getEnd(), value); //System.out.println("interval start ="+interval.getStart()); //System.out.println("interval end ="+interval.getEnd()); //System.out.println("--------"); } dataset.addSeries(attributeSeries[j++]); } } /*creating dataseries for each edge and its checked attribute and adding it to the dataset*/ for (CyEdge edge : selectedEdges) { // System.out.println(checkedAttributes.size()); for (int i = 0; i < edgeCheckedAttributes.size(); i++) { attributeSeries[j] = new XYSeries(dynamicNetwork.getEdgeLabel(edge) + edgeCheckedAttributes.get(i), false, true); // System.out.println(dynamicNetwork.getDynAttribute(node, // checkedAttributes.get(i)).getKey().getColumn()); for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(edge, edgeCheckedAttributes.get(i)) .getIntervalList()) { // System.out.println(interval.getOnValue()); double value; if (interval.getOnValue() instanceof Double) value = (Double) interval.getOnValue(); else if (interval.getOnValue() instanceof Integer) value = ((Integer) interval.getOnValue()).doubleValue(); else if (interval.getOnValue() instanceof Short) value = ((Short) interval.getOnValue()).doubleValue(); else value = ((Long) interval.getOnValue()).doubleValue(); // System.out.println(value); attributeSeries[j].add(interval.getStart(), value); attributeSeries[j].add(interval.getEnd(), value); } dataset.addSeries(attributeSeries[j++]); } } String title = "Dynamic Graph Metrics"; String xAxisLabel = "Time"; String yAxisLabel = "Centrality Value"; JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend true, // tooltips false // urls ); NumberAxis xaxis = new NumberAxis(); xaxis.setAutoRangeMinimumSize(1.0); xaxis.setLabel("Time"); chart.getXYPlot().setDomainAxis(xaxis); NumberAxis yaxis = new NumberAxis(); yaxis.setAutoRangeIncludesZero(true); yaxis.setLabel("Centrality/Attribute Value"); chart.getXYPlot().setRangeAxis(yaxis); chart.setBackgroundPaint(Color.white); //chart.setPadding(new RectangleInsets(20,20,20,20)); chart.getXYPlot().setBackgroundPaint(Color.white); chart.getXYPlot().setDomainGridlinePaint(Color.gray); chart.getXYPlot().setRangeGridlinePaint(Color.gray); return chart; }
From source file:org.nees.rpi.vis.ui.XYChartPanelProxy.java
public XYChartPanelProxy(int width, int height) { selectionGroup = new SelectionGroup(); selectionGroup.setSelection(true);//from ww w . j a v a 2 s. co m dataSet = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart(null, domainAxisLabel, rangeAxisLabel, dataSet, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setPosition(RectangleEdge.RIGHT); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); chartPanel.setFillZoomRectangle(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); toolPanel = new JPanel(); toolPanel.setOpaque(false); toolPanel.setLayout(new BoxLayout(toolPanel, BoxLayout.Y_AXIS)); toolPanel.setBorder(BorderFactory.createTitledBorder("Plot Control")); toolPanel.setPreferredSize(new Dimension(155, 100)); chartAreaPanel = new JPanel(); chartAreaPanel.setOpaque(true); chartAreaPanel.setBackground(Color.white); chartAreaPanel.setLayout(new BorderLayout()); chartAreaPanel.add(chartPanel, BorderLayout.CENTER); chartAreaPanel.add(toolPanel, BorderLayout.WEST); initClearSelectionButton(toolPanel); initResetPlotButton(toolPanel); initSaveToImageButton(toolPanel); initShowAsProfilePlotButton(toolPanel); }
From source file:max.hubbard.Factoring.Graphing.java
private static XYDataset createDataset(LinkedList<LinkedHashMap<Float, Integer>> list, String orig) { final XYSeries series1 = new XYSeries(orig); for (double i = -10; i < 11; i++) { float v = 0; for (LinkedHashMap<Float, Integer> map : list) { for (Float f : map.keySet()) { if (map.get(f) != 0) { v = v + f * (float) Math.pow(i, map.get(f)); } else { v = v + f;//from w w w . j a va 2 s .com } } } series1.add(i, v); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); return dataset; }
From source file:org.owasp.benchmark.score.report.ScatterScores.java
private JFreeChart display(String title, int height, int width, List<Report> toolResults) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); for (int i = 0; i < toolResults.size(); i++) { Report toolReport = toolResults.get(i); OverallResults overallResults = toolReport.getOverallResults(); series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100); }/*ww w . j a v a 2 s . c o m*/ dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Arial"; DecimalFormat pctFormat = new DecimalFormat("0'%'"); theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); xyplot.setOutlineVisible(true); rangeAxis.setRange(-5, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); domainAxis.setRange(-5, 105); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); // // setup item labels // XYItemRenderer renderer = xyplot.getRenderer(); // Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f); // for ( int i = 0; i < dataset.getSeriesCount(); i++ ) { // renderer.setSeriesShape(i, circle); // renderer.setSeriesPaint(i, Color.blue); // String label = ""+((String)dataset.getSeries(i).getKey()); // int idx = label.indexOf( ':'); // label = label.substring( 0, idx ); // StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(label); // renderer.setSeriesItemLabelGenerator(i, generator); // renderer.setSeriesItemLabelsVisible(i, true); // ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER ); // renderer.setSeriesPositiveItemLabelPosition(i, position); // } makeDataLabels(toolResults, xyplot); makeLegend(toolResults, 57, 48, dataset, xyplot); Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 }, 0); for (XYDataItem item : (List<XYDataItem>) series.getItems()) { double x = item.getX().doubleValue(); double y = item.getY().doubleValue(); double z = (x + y) / 2; XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue); xyplot.addAnnotation(score); } // // put legend inside plot // LegendTitle lt = new LegendTitle(xyplot); // lt.setItemFont(theme.getSmallFont()); // lt.setPosition(RectangleEdge.RIGHT); // lt.setItemFont(theme.getSmallFont()); // XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT); // ta.setMaxWidth(0.48); // xyplot.addAnnotation(ta); // draw guessing line XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red); xyplot.addAnnotation(guessing); XYPointerAnnotation worse = makePointer(75, 5, "Worse than guessing", TextAnchor.TOP_CENTER, 90); xyplot.addAnnotation(worse); XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270); xyplot.addAnnotation(better); XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107); stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT); stroketext.setBackgroundPaint(Color.white); stroketext.setPaint(Color.red); stroketext.setFont(theme.getRegularFont()); xyplot.addAnnotation(stroketext); XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red); xyplot.setBackgroundPaint(Color.white); xyplot.addAnnotation(strokekey); ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:guineu.modules.filter.Alignment.RANSACGCGC.AlignmentGCGCRansacPlot.java
public AlignmentGCGCRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);/* ww w . j a v a2 s . com*/ chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); // legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(renderer); }
From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java
public HeadingNeuralNetworkTrainer() { outputGraphNetworkSeries = new XYSeries("Network Prediction"); outputGraphDataSeries = new XYSeries("Error"); final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(outputGraphDataSeries); data.addSeries(outputGraphNetworkSeries); outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data, PlotOrientation.VERTICAL, true, true, false); NumberAxis xAxis = new NumberAxis(); xAxis.setRange(new Range(-Math.PI, Math.PI)); xAxis.setAutoRange(false);/*from ww w . ja va2 s . co m*/ NumberAxis yAxis = new NumberAxis(); yAxis.setRange(new Range(-1, 1)); XYPlot plot = (XYPlot) outputGraph.getPlot(); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent()); try { SwingUtilities.invokeAndWait(() -> { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container content = frame.getContentPane(); content.setLayout(new BorderLayout()); outputGraphPanel = new ChartPanel(outputGraph); outputGraphPanel.setDomainZoomable(false); outputGraphPanel.setRangeZoomable(false); graphPanel.add(outputGraphPanel); graphPanel.setLayout(new GridLayout(1, 1)); content.add(graphPanel, BorderLayout.CENTER); { JLabel etaLabel = new JLabel("Eta:"); etaLabel.setLabelFor(etaField); etaField.setText(Double.toString(network.getEta())); etaField.setColumns(5); etaField.addPropertyChangeListener("value", (evt) -> eta = ((Number) evt.getNewValue()).doubleValue()); controlPanel.add(etaLabel); controlPanel.add(etaField); JLabel momentumLabel = new JLabel("Momentum:"); momentumLabel.setLabelFor(etaField); momentumField.setText(Double.toString(network.getMomentum())); momentumField.setColumns(5); momentumField.addPropertyChangeListener("value", (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue()); controlPanel.add(momentumLabel); controlPanel.add(momentumField); JLabel iterationsLabel = new JLabel("Iterations:"); iterationsLabel.setLabelFor(iterationsField); iterationsField.setText(Integer.toString(iterations)); iterationsField.setColumns(10); iterationsField.addPropertyChangeListener("value", (evt) -> iterations = ((Number) evt.getNewValue()).intValue()); controlPanel.add(iterationsLabel); controlPanel.add(iterationsField); } chooseDataButton.addActionListener((e) -> { if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) { dataDirectory = dataDirectoryChooser.getSelectedFile(); displayData(); } }); controlPanel.add(chooseDataButton); trainButton.addActionListener((e) -> trainNetwork()); controlPanel.add(trainButton); saveButton.addActionListener((e) -> { saveNetwork(); }); controlPanel.add(saveButton); content.add(controlPanel, BorderLayout.SOUTH); dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } }
From source file:Interfaz.XYLineChart.java
private XYDataset xyDataset(ArrayList<Restriccion> rest, ArrayList<Coordenada> cor) { //se declaran las series y se llenan los datos XYSeriesCollection xyseriescollection = new XYSeriesCollection(); for (int i = 0; i < rest.size(); i++) { XYSeries sIngresos1 = new XYSeries("Grafica: " + rest.get(i).variable.get(0).getValor() + "X + " + rest.get(i).variable.get(1).getValor()); for (int j = 0; j < ordenarArray(cor).get(0).getX(); j++) { if (rest.get(i).variable.get(3).getValor() != 0) { sIngresos1.add(j,// w w w. j a va2s.c o m rest.get(i).variable.get(0).getValor() * j + rest.get(i).variable.get(1).getValor()); } else { sIngresos1.add(rest.get(i).variable.get(1).getValor(), j * 1000); } } xyseriescollection.addSeries(sIngresos1); } return xyseriescollection; }
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static JFreeChart getPlot(double[] yData, String title, String xlabel, String ylabel) { double[] xData = getXDataDouble(yData.length); XYSeriesCollection datCol = getCollection(xData, yData, "Data"); // Create the chart JFreeChart chart = ChartFactory.createXYLineChart(title, // Title xlabel, // X-Axis label ylabel, // Y-Axis label new XYSeriesCollection(), // Dataset PlotOrientation.VERTICAL, true, // Show legend true, true);/*from w w w. j a v a 2s. c o m*/ // Add the series chart.getXYPlot().setDataset(0, datCol); // Set the rendering XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true); chart.getXYPlot().setRenderer(0, rend1); return chart; }
From source file:net.sf.mzmine.modules.peaklistmethods.alignment.ransac.AlignmentRansacPlot.java
public AlignmentRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);// w w w . ja va 2s .c om chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(renderer); }
From source file:beadAnalyzer.DrawPoints.java
public XYSeries drawLinePoints(final ArrayList<GaussianLineFitParam> beadLineparams, final String name, final int numBins) { final XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries seriesname = new XYSeries(name); List<Double> Xvalues = new ArrayList<Double>(); List<Double> Yvalues = new ArrayList<Double>(); if (name == "Sigma") { for (final GaussianLineFitParam param : beadLineparams) { if (param != null) { seriesname.add(param.Sigma[0], param.Sigma[1]); Xvalues.add(param.Sigma[0]); Yvalues.add(param.Sigma[1]); }/* w w w . j a v a2s.c o m*/ } } dataset.addSeries(seriesname); final JFreeChart histXchart = makehistXChart(Xvalues, numBins); final JFreeChart histYchart = makehistYChart(Yvalues, numBins); display(histXchart, new Dimension(500, 500)); display(histYchart, new Dimension(500, 500)); return seriesname; }