List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a single room. Uses * red for normal rooms, blue for cellar rooms and green for misc rooms. * // w ww. ja va2 s.c o m * @param title * The headline of the chart. Will be hidden if set to null. * @param room * The room object containing the radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a single room. */ public static JFreeChart createRoomChart(String title, OMRoom room, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (room.getType() == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (room.getType() == OMRoomType.Cellar) { lineColor = new Color(0, 0, 255, 128); rangeColor = new Color(222, 222, 255, 128); } else { lineColor = new Color(0, 128, 0, 255); rangeColor = new Color(222, 255, 222, 128); } } double[] values = room.getValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries series = new XYSeries("Radon"); int count = room.getCount(); double maxPointerKey = 0; for (int i = 0; i < count; i++) { series.add(i, values[i]); if (values[i] == room.getMaximum()) { maxPointerKey = i; } } dataSet.addSeries(series); title = title + ": " + room.getType().toString() + " " + room.getId(); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); double positiveDeviation = room.getAverage() + room.getDeviation(); double negativeDeviation = room.getAverage() - room.getDeviation(); IntervalMarker deviation = new IntervalMarker(negativeDeviation, positiveDeviation); float[] dash = { 5, 3 }; deviation.setPaint(rangeColor); deviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(deviation, Layer.BACKGROUND); ValueMarker arithMarker = new ValueMarker(room.getAverage(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithMarker); ValueMarker maxiMarker = new ValueMarker(room.getMaximum(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiMarker); XYTextAnnotation amLabel = new XYTextAnnotation("AM=" + (int) room.getAverage(), count, room.getAverage() * 1.01); plot.addAnnotation(amLabel); XYTextAnnotation sdLabel = new XYTextAnnotation("SD=" + (int) room.getDeviation(), count, (room.getAverage() + room.getDeviation()) * 1.01); plot.addAnnotation(sdLabel); XYTextAnnotation maxLabel = new XYTextAnnotation("MAX=" + (int) room.getMaximum(), count, room.getMaximum() * 1.01); plot.addAnnotation(maxLabel); XYPointerAnnotation maxPointer = new XYPointerAnnotation("", maxPointerKey, room.getMaximum(), Math.PI * 1.1); plot.addAnnotation(maxPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:view.Dashboard.java
/** * Creates new form Dashboard/*from w ww . ja v a 2 s.c om*/ */ public Dashboard() { cc = new ConnectionController(); voltageSeries = new XYSeries("voltage"); setPointSeries = new XYSeries("setpoint"); voltageSeries.add(currentTime, 0); currentTime++; voltageDataset = new XYSeriesCollection(); voltageDataset.addSeries(voltageSeries); voltageDataset.addSeries(setPointSeries); voltageLineChart = generateVoltageLineChart(); initComponents(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2); this.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); baudRate.setSelectedItem(baudRate.getItemAt(3)); }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo3.java
/** * creaets XYDataset// w w w . j a v a 2 s. c o m * @param isDemo true use the demo data, false use data from the JTable * @return XYDataset */ protected XYDataset createDataset(boolean isDemo) { if (isDemo) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < 4; i++) { XYSeries series = new XYSeries("S" + i); for (int j = 0; j < 4; j++) { series.add(j, Math.random() * 100); } dataset.addSeries(series); } return dataset; } else return super.createDataset(false); }
From source file:tl.lib.dataCollection.gui.NumXYChart.java
public NumXYChart(_CollectionGUIScenario scenario, String label, String description, String labelAxisY) { super(null);//from w w w .ja v a2s .c om this.sourceDescriptor = scenario.getSourceDescriptor(); this.collection = new XYSeriesCollection(); // ChartTheme currentTheme = new StandardChartTheme("JFree"); NumberAxis valueAxisX = new NumberAxis("Sample Number"); valueAxisX.setAutoRangeIncludesZero(false); // override default NumberAxis valueAxisY = new NumberAxis(labelAxisY); valueAxisY.setAutoRangeIncludesZero(false); // override default XYToolTipGenerator toolTipGenerator = null; toolTipGenerator = new StandardXYToolTipGenerator(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); // XYURLGenerator urlGenerator = new StandardXYURLGenerator(); renderer.setBaseToolTipGenerator(toolTipGenerator); // renderer.setURLGenerator(urlGenerator); this.plot = new XYPlot(collection, valueAxisX, valueAxisY, renderer); this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // currentTheme.apply(chart); renderingInfo = new ChartRenderingInfo(); this.scenario = scenario; this.description = description; this.label = label; this.selected = new Vector<SourceId>(); default_all = true; super.setChart(chart); }
From source file:Hyperbole.java
private XYDataset createDataset() { XYSeries series = new XYSeries("Points"); this.series = series; // x^2/12 - y^2/3 = -1 draw("(Math.pow(i, 2)/12) - (Math.pow(i*2, 2)/3) +1;"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series);/*from w w w. j ava2s . c o m*/ return dataset; }
From source file:org.pf.midea.SimulationController.java
@Override public void run() { textAreaNumeric.setText(""); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); double progress = 0; double progressStep = 100.0 / (planCells.length * (hSquareHigh - hSquareLow + hSquareStep) / hSquareStep); progressBar.setValue(0);/* w w w .j a v a 2 s . c o m*/ for (int i = 0; i < planCells.length; i++) { XYSeries xySeries; if (showLineNumbers) xySeries = new XYSeries(String.valueOf(i + 1) + ") " + planCells[i].getShortDescription()); else xySeries = new XYSeries(planCells[i].getShortDescription()); textAreaNumeric.append(planCells[i].getDescription() + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); PlanStates.SourceType currentSourceType = planCells[i].getSourceCell().getSourceType(); PlanStates.CodeType currentCodeType = planCells[i].getCodeCell().getCodeType(); PlanStates.ModulationType currentModulationType = planCells[i].getModulationCell().getModulationType(); PlanStates.ChannelType currentChannelType = planCells[i].getChannelCell().getChannelType(); PlanStates.ErrorsType currentErrorsType = planCells[i].getErrorsCell().getErrorsType(); BinaryNumber[] sourcePoints = null; switch (currentSourceType) { case ST_TEST: sourcePoints = ConstellationPointsGenerator.getTestPoints(currentModulationType, iterationsCount); break; case ST_RANDOM: sourcePoints = ConstellationPointsGenerator.getRandomPoints(currentModulationType, iterationsCount); break; } Coder coder = null; Decoder decoder = null; switch (currentCodeType) { case CT_NONE: coder = new CoderNone(); decoder = new DecoderNone(); break; case CT_HAMMING74: coder = new CoderHamming74(); decoder = new DecoderHamming74(); break; case CT_CYCLIC: coder = new CoderCyclic85(); decoder = new DecoderCyclic85(); break; case CT_BCH155: coder = new CoderBCH155(); decoder = new DecoderBCH155(); break; } Modulator modulator = null; Demodulator demodulator = null; switch (currentModulationType) { case MT_ASK: modulator = new ModulatorASK(); demodulator = new DemodulatorASK(); break; case MT_FSK: modulator = new ModulatorFSK(); demodulator = new DemodulatorFSK(); break; case MT_BPSK: modulator = new ModulatorBPSK(); demodulator = new DemodulatorBPSK(); break; case MT_QPSK: modulator = new ModulatorQPSK(); demodulator = new DemodulatorQPSK(); break; case MT_8PSK: modulator = new Modulator8PSK(); demodulator = new Demodulator8PSK(); break; case MT_16PSK: modulator = new Modulator16PSK(); demodulator = new Demodulator16PSK(); break; case MT_32PSK: modulator = new Modulator32PSK(); demodulator = new Demodulator32PSK(); break; case MT_16QAM: modulator = new Modulator16QAM(); demodulator = new Demodulator16QAM(); break; case MT_32QAM: modulator = new Modulator32QAM(); demodulator = new Demodulator32QAM(); break; case MT_64QAM: modulator = new Modulator64QAM(); demodulator = new Demodulator64QAM(); break; case MT_256QAM: modulator = new Modulator256QAM(); demodulator = new Demodulator256QAM(); break; } Channel channel = null; switch (currentChannelType) { case CHT_AWGN: channel = new ChannelAWGN(); break; case CHT_RAYLEIGH: channel = new ChannelRayleigh(); break; } BinaryNumber[] encoded = coder.encode(sourcePoints); Signal[] modulated = modulator.modulate(encoded); double error = 0; for (double h = hSquareLow; h <= hSquareHigh; h += hSquareStep) { double realH; if (dBs) realH = StatisticsTools.decibelsToTimes(h); else realH = h; Signal[] noised = channel.noise(realH, modulated); BinaryNumber[] demodulated = demodulator.demodulate(noised); noised = null; System.gc(); BinaryNumber[] decoded = decoder.decode(demodulated); demodulated = null; System.gc(); switch (currentErrorsType) { case ET_SER: error = StatisticsTools.getSER(sourcePoints, decoded); break; case ET_BER: error = StatisticsTools.getBER(sourcePoints, decoded); break; } decoded = null; System.gc(); if (error > 0) { xySeries.add(h, error); textAreaNumeric.append(String.valueOf(h) + "\t" + String.valueOf(error) + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } progress += progressStep; progressBar.setValue((int) Math.round(progress)); } xySeriesCollection.addSeries(xySeries); textAreaNumeric.append("\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } JFreeChart chart = ChartFactory.createXYLineChart("", dBs ? "" : "", "?", xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); chart.getLegend().setPosition(RectangleEdge.RIGHT); XYPlot xyPlot = chart.getXYPlot(); for (int i = 0; i < planCells.length; i++) { xyPlot.getRenderer().setSeriesStroke(i, new BasicStroke(planCells[i].getLineWidth())); if (planCells[i].getLineColor() != null) xyPlot.getRenderer().setSeriesPaint(i, planCells[i].getLineColor()); if (showLineNumbers) { XYSeries currentSeries = xySeriesCollection.getSeries(i); double annotationY = currentSeries.getY(0).doubleValue(); double annotationX = currentSeries.getX(0).doubleValue(); for (int j = 1; j < currentSeries.getItemCount(); j++) if (currentSeries.getY(j).doubleValue() == 0) { annotationY = currentSeries.getY(j - 1).doubleValue(); annotationX = currentSeries.getX(j - 1).doubleValue(); break; } else { annotationY = currentSeries.getY(j).doubleValue(); annotationX = currentSeries.getX(j).doubleValue(); } XYTextAnnotation annotation = new XYTextAnnotation(String.valueOf(i + 1), annotationX, annotationY); annotation.setBackgroundPaint(Color.WHITE); annotation.setFont(new Font("Dialog", 0, 14)); xyPlot.addAnnotation(annotation); } } xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); NumberAxis domainAxis = new NumberAxis("h, " + (dBs ? "" : "")); LogAxis rangeAxis = new LogAxis("?"); rangeAxis.setNumberFormatOverride(new HumanNumberFormat(1)); domainAxis.setTickLabelFont(new Font("Dialog", 0, 14)); rangeAxis.setTickLabelFont(new Font("Dialog", 0, 14)); xyPlot.setDomainAxis(domainAxis); xyPlot.setRangeAxis(rangeAxis); ChartPanel nestedPanel = new ChartPanel(chart); chartPanel.removeAll(); chartPanel.add(nestedPanel, new CellConstraints()); chartPanel.updateUI(); }
From source file:userinterface.patientRole.LineChart.java
private XYDataset createDataset() { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(bR);/*from w w w . j a v a 2 s. com*/ dataset.addSeries(pR); dataset.addSeries(bS); dataset.addSeries(bP); return dataset; }
From source file:org.pf.midea.MainUI.java
private void showConstellationWindow(ConstellationPoint[] _map, String _name) { JFrame constellation = new JFrame(" ?? " + _name); constellation.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); XYSeriesCollection dots = new XYSeriesCollection(); XYSeries series = new XYSeries(_name); JFreeChart chart = ChartFactory.createScatterPlot("", "I", "Q", dots, PlotOrientation.VERTICAL, false, false, false);/*from w w w. java 2s . c om*/ XYPlot xyPlot = chart.getXYPlot(); CustomXYToolTipGenerator tooltipsGenerator = new CustomXYToolTipGenerator(); ArrayList<String> tooltips = new ArrayList<>(); for (ConstellationPoint ccp : _map) { double I = ccp.getI(); double Q = ccp.getQ(); series.add(I, Q); tooltips.add(ccp.getCode().getStringSequence()); } tooltipsGenerator.addToolTipSeries(tooltips); xyPlot.getRenderer().setBaseToolTipGenerator(tooltipsGenerator); double maxX = StatisticsTools.round(Math.abs(series.getMaxX()), 3); double maxY = StatisticsTools.round(Math.abs(series.getMaxY()), 3); double minX = StatisticsTools.round(Math.abs(series.getMinX()), 3); double minY = StatisticsTools.round(Math.abs(series.getMinY()), 3); if (maxX != 0 || minX != 0) { double X = Math.max(minX, maxX); xyPlot.getDomainAxis().setRange(-1.1 * X, 1.1 * X); } else xyPlot.getDomainAxis().setRange(-1, 1); if (maxY != 0 || minY != 0) { double Y = Math.max(minY, maxY); xyPlot.getRangeAxis().setRange(-1.1 * Y, 1.1 * Y); } else xyPlot.getRangeAxis().setRange(-1, 1); dots.addSeries(series); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); xyPlot.getRenderer().setSeriesPaint(0, Color.BLACK); xyPlot.setDomainZeroBaselineVisible(true); xyPlot.setRangeZeroBaselineVisible(true); ChartPanel chartPanel = new ChartPanel(chart); JPanel nestedPanel = new JPanel(); nestedPanel.add(chartPanel, new CellConstraints()); constellation.add(nestedPanel); constellation.pack(); constellation.setLocationRelativeTo(null); constellation.setResizable(false); constellation.setVisible(true); }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetPlot.java
@Override protected void update() { XYSeriesCollection dataset = new XYSeriesCollection(); for (ResultKey key : frame.getSelectedResults()) { NondominatedPopulation population = new EpsilonBoxDominanceArchive(EPSILON); for (Accumulator accumulator : controller.get(key)) { if (!accumulator.keySet().contains(metric)) { continue; }/*from w w w. ja va 2 s . c o m*/ List<?> list = (List<?>) accumulator.get(metric, accumulator.size(metric) - 1); for (Object object : list) { population.add((Solution) object); } } if (!population.isEmpty()) { XYSeries series = new XYSeries(key, false, true); for (Solution solution : population) { if (solution.getNumberOfObjectives() == 1) { series.add(solution.getObjective(0), solution.getObjective(0)); } else if (solution.getNumberOfObjectives() > 1) { series.add(solution.getObjective(0), solution.getObjective(1)); } } dataset.addSeries(series); } } JFreeChart chart = ChartFactory.createScatterPlot(metric, localization.getString("text.objective", 1), localization.getString("text.objective", 2), dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); for (int i = 0; i < dataset.getSeriesCount(); i++) { Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i)); renderer.setSeriesStroke(i, new BasicStroke(3f, 1, 1)); renderer.setSeriesPaint(i, paint); renderer.setSeriesFillPaint(i, paint); } plot.setRenderer(renderer); //add overlay if (controller.getShowLastTrace() && (controller.getLastAccumulator() != null) && controller.getLastAccumulator().keySet().contains(metric)) { XYSeriesCollection dataset2 = new XYSeriesCollection(); NondominatedPopulation population = new EpsilonBoxDominanceArchive(EPSILON); if (controller.getLastAccumulator().keySet().contains(metric)) { List<?> list = (List<?>) controller.getLastAccumulator().get(metric, controller.getLastAccumulator().size(metric) - 1); for (Object object : list) { population.add((Solution) object); } } if (!population.isEmpty()) { XYSeries series = new XYSeries(localization.getString("text.last"), false, true); for (Solution solution : population) { series.add(solution.getObjective(0), solution.getObjective(1)); } dataset2.addSeries(series); } XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true); renderer2.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } removeAll(); add(new ChartPanel(chart), BorderLayout.CENTER); revalidate(); repaint(); }
From source file:com.al.cellplugin.LineChart.java
public XYDataset setDataset(Object[][] data, Object[] names) { final XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 1; i < data.length; i++) { String name = (String) data[i][0]; System.out.println("Name: " + name); System.out.println("val: " + data[i][0]); Object[] odata = data[i]; XYSeries series = new XYSeries((String) odata[0]); for (int j = 1; j < odata.length; j++) { System.out.println(odata[j]); series.add(Double.parseDouble((String) odata[j]), i + 1); }// w ww. ja v a2 s . c o m dataset.addSeries(series); } return dataset; }