List of usage examples for org.jfree.data.xy XYSeries getDescription
public String getDescription()
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);/*from w ww . java2 s . com*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); widths = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { String type = xyDataset.getSeries(row).getDescription(); Paint color; if (type.equals(PeakType.MODEL.name())) color = COLORS[row % COLORS.length]; else color = new Color(0, 0, 0, 50); return color; } @Override public Stroke getSeriesStroke(int series) { XYSeries s = xyDataset.getSeries(series); String type = s.getDescription(); float width; if (type.equals((PeakType.MODEL.name()))) width = 2.0f; else width = 1.0f; return new BasicStroke(width); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }
From source file:org.spantus.exp.segment.exec.DrawSegmentComparision.java
/** * initialize// ww w . j av a 2s .co m */ public void init() { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); plot.setOrientation(PlotOrientation.VERTICAL); XYSeries[] seriesArr = createSeries(getWavName(), getMarkerName()); for (XYSeries series : seriesArr) { final XYSeriesCollection data1 = new XYSeriesCollection(series); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis(series.getDescription()); final XYPlot subplot = new XYPlot(data1, null, rangeAxis1, renderer1); plot.add(subplot, 1); } final JFreeChart chart = new JFreeChart("Segmentation Result", JFreeChart.DEFAULT_TITLE_FONT, plot, false); final ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); chartPanel.setPreferredSize(new Dimension(500, 270)); }
From source file:com.vgi.mafscaling.VECalc.java
protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);// ww w .ja v a 2 s .c o m chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); chartPanel.setMouseZoomable(false); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; gbl_chartPanel.insets = new Insets(3, 3, 3, 3); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 1; plotPanel.add(chartPanel, gbl_chartPanel); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = 7593430826693873496L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis xAxis = new NumberAxis(xAxisName); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisName); yAxis.setAutoRangeIncludesZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); }
From source file:com.vgi.mafscaling.MafCompare.java
/** * Initialize the contents of the frame. *//*from w ww .jav a2s. c om*/ private void initialize() { try { ImageIcon tableImage = new ImageIcon(getClass().getResource("/table.jpg")); setTitle(Title); setIconImage(tableImage.getImage()); setBounds(100, 100, 621, 372); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setSize(Config.getCompWindowSize()); setLocation(Config.getCompWindowLocation()); setLocationRelativeTo(null); setVisible(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Utils.clearTable(origMafTable); Utils.clearTable(newMafTable); Utils.clearTable(compMafTable); Config.setCompWindowSize(getSize()); Config.setCompWindowLocation(getLocation()); origMafData.clear(); newMafData.clear(); } }); JPanel dataPanel = new JPanel(); GridBagLayout gbl_dataPanel = new GridBagLayout(); gbl_dataPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_dataPanel.rowHeights = new int[] { RowHeight, RowHeight, RowHeight, RowHeight, RowHeight, 0 }; gbl_dataPanel.columnWeights = new double[] { 0.0, 0.0, 0.0 }; gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; dataPanel.setLayout(gbl_dataPanel); getContentPane().add(dataPanel); JLabel origLabel = new JLabel(origMaf); GridBagConstraints gbc_origLabel = new GridBagConstraints(); gbc_origLabel.anchor = GridBagConstraints.PAGE_START; gbc_origLabel.insets = new Insets(1, 1, 1, 5); gbc_origLabel.weightx = 0; gbc_origLabel.weighty = 0; gbc_origLabel.gridx = 0; gbc_origLabel.gridy = 0; gbc_origLabel.gridheight = 2; dataPanel.add(origLabel, gbc_origLabel); JLabel newLabel = new JLabel(newMaf); GridBagConstraints gbc_newLabel = new GridBagConstraints(); gbc_newLabel.anchor = GridBagConstraints.PAGE_START; gbc_newLabel.insets = new Insets(1, 1, 1, 5); gbc_newLabel.weightx = 0; gbc_newLabel.weighty = 0; gbc_newLabel.gridx = 0; gbc_newLabel.gridy = 2; gbc_newLabel.gridheight = 2; dataPanel.add(newLabel, gbc_newLabel); JLabel compLabel = new JLabel("Change"); GridBagConstraints gbc_compLabel = new GridBagConstraints(); gbc_compLabel.anchor = GridBagConstraints.PAGE_START; gbc_compLabel.insets = new Insets(1, 1, 1, 5); gbc_compLabel.weightx = 0; gbc_compLabel.weighty = 0; gbc_compLabel.gridx = 0; gbc_compLabel.gridy = 4; dataPanel.add(compLabel, gbc_compLabel); JLabel origVoltLabel = new JLabel("volt"); GridBagConstraints gbc_origVoltLabel = new GridBagConstraints(); gbc_origVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_origVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_origVoltLabel.weightx = 0; gbc_origVoltLabel.weighty = 0; gbc_origVoltLabel.gridx = 1; gbc_origVoltLabel.gridy = 0; dataPanel.add(origVoltLabel, gbc_origVoltLabel); JLabel origGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_origGsLabel = new GridBagConstraints(); gbc_origGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_origGsLabel.insets = new Insets(1, 1, 1, 5); gbc_origGsLabel.weightx = 0; gbc_origGsLabel.weighty = 0; gbc_origGsLabel.gridx = 1; gbc_origGsLabel.gridy = 1; dataPanel.add(origGsLabel, gbc_origGsLabel); JLabel newVoltLabel = new JLabel("volt"); GridBagConstraints gbc_newVoltLabel = new GridBagConstraints(); gbc_newVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_newVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_newVoltLabel.weightx = 0; gbc_newVoltLabel.weighty = 0; gbc_newVoltLabel.gridx = 1; gbc_newVoltLabel.gridy = 2; dataPanel.add(newVoltLabel, gbc_newVoltLabel); JLabel newGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_newGsLabel = new GridBagConstraints(); gbc_newGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_newGsLabel.insets = new Insets(1, 1, 1, 5); gbc_newGsLabel.weightx = 0; gbc_newGsLabel.weighty = 0; gbc_newGsLabel.gridx = 1; gbc_newGsLabel.gridy = 3; dataPanel.add(newGsLabel, gbc_newGsLabel); JLabel compPctLabel = new JLabel(" % "); GridBagConstraints gbc_compPctLabel = new GridBagConstraints(); gbc_compPctLabel.anchor = GridBagConstraints.PAGE_START; gbc_compPctLabel.insets = new Insets(1, 1, 1, 5); gbc_compPctLabel.weightx = 0; gbc_compPctLabel.weighty = 0; gbc_compPctLabel.gridx = 1; gbc_compPctLabel.gridy = 4; dataPanel.add(compPctLabel, gbc_compPctLabel); JPanel tablesPanel = new JPanel(); GridBagLayout gbl_tablesPanel = new GridBagLayout(); gbl_tablesPanel.columnWidths = new int[] { 0 }; gbl_tablesPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_tablesPanel.columnWeights = new double[] { 0.0 }; gbl_tablesPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 }; tablesPanel.setLayout(gbl_tablesPanel); JScrollPane mafScrollPane = new JScrollPane(tablesPanel); mafScrollPane.setMinimumSize(new Dimension(1600, 107)); mafScrollPane.getHorizontalScrollBar().setMaximumSize(new Dimension(20, 20)); mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); GridBagConstraints gbc_mafScrollPane = new GridBagConstraints(); gbc_mafScrollPane.weightx = 1.0; gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START; gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL; gbc_mafScrollPane.gridx = 2; gbc_mafScrollPane.gridy = 0; gbc_mafScrollPane.gridheight = 5; dataPanel.add(mafScrollPane, gbc_mafScrollPane); origMafTable = new JTable(); origMafTable.setColumnSelectionAllowed(true); origMafTable.setCellSelectionEnabled(true); origMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); origMafTable.setRowHeight(RowHeight); origMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); origMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); origMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); origMafTable.setTableHeader(null); Utils.initializeTable(origMafTable, ColumnWidth); GridBagConstraints gbc_origMafTable = new GridBagConstraints(); gbc_origMafTable.anchor = GridBagConstraints.PAGE_START; gbc_origMafTable.insets = new Insets(0, 0, 0, 0); gbc_origMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_origMafTable.weightx = 1.0; gbc_origMafTable.weighty = 0; gbc_origMafTable.gridx = 0; gbc_origMafTable.gridy = 0; tablesPanel.add(origMafTable, gbc_origMafTable); excelAdapter.addTable(origMafTable, false, false, false, false, true, false, true, false, true); newMafTable = new JTable(); newMafTable.setColumnSelectionAllowed(true); newMafTable.setCellSelectionEnabled(true); newMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); newMafTable.setRowHeight(RowHeight); newMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); newMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); newMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); newMafTable.setTableHeader(null); Utils.initializeTable(newMafTable, ColumnWidth); GridBagConstraints gbc_newMafTable = new GridBagConstraints(); gbc_newMafTable.anchor = GridBagConstraints.PAGE_START; gbc_newMafTable.insets = new Insets(0, 0, 0, 0); gbc_newMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_newMafTable.weightx = 1.0; gbc_newMafTable.weighty = 0; gbc_newMafTable.gridx = 0; gbc_newMafTable.gridy = 1; tablesPanel.add(newMafTable, gbc_newMafTable); excelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true); compMafTable = new JTable(); compMafTable.setColumnSelectionAllowed(true); compMafTable.setCellSelectionEnabled(true); compMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); compMafTable.setRowHeight(RowHeight); compMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); compMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); compMafTable.setModel(new DefaultTableModel(1, MafTableColumnCount)); compMafTable.setTableHeader(null); Utils.initializeTable(compMafTable, ColumnWidth); NumberFormatRenderer numericRenderer = new NumberFormatRenderer(); numericRenderer.setFormatter(new DecimalFormat("0.000")); compMafTable.setDefaultRenderer(Object.class, numericRenderer); GridBagConstraints gbc_compMafTable = new GridBagConstraints(); gbc_compMafTable.anchor = GridBagConstraints.PAGE_START; gbc_compMafTable.insets = new Insets(0, 0, 0, 0); gbc_compMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_compMafTable.weightx = 1.0; gbc_compMafTable.weighty = 0; gbc_compMafTable.gridx = 0; gbc_compMafTable.gridy = 2; tablesPanel.add(compMafTable, gbc_compMafTable); compExcelAdapter.addTable(compMafTable, false, true, false, false, false, true, true, false, true); TableModelListener origTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = origMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, newMafTable); Utils.ensureColumnCount(colCount, compMafTable); origMafData.clear(); String origY, origX, newY; for (int i = 0; i < colCount; ++i) { origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) { origX = origMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, origX)) origMafData.add(Double.valueOf(origX), Double.valueOf(origY), false); newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } origMafData.fireSeriesChanged(); } } }; TableModelListener newTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = newMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, origMafTable); Utils.ensureColumnCount(colCount, compMafTable); newMafData.clear(); String newY, newX, origY; for (int i = 0; i < colCount; ++i) { newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) { newX = newMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, newX)) newMafData.add(Double.valueOf(newX), Double.valueOf(newY), false); origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } newMafData.fireSeriesChanged(); } } }; origMafTable.getModel().addTableModelListener(origTableListener); newMafTable.getModel().addTableModelListener(newTableListener); Action action = new AbstractAction() { private static final long serialVersionUID = 8148393537657380215L; public void actionPerformed(ActionEvent e) { TableCellListener tcl = (TableCellListener) e.getSource(); if (Pattern.matches(Utils.fpRegex, compMafTable.getValueAt(0, tcl.getColumn()).toString())) { if (Pattern.matches(Utils.fpRegex, origMafTable.getValueAt(1, tcl.getColumn()).toString())) { double corr = Double.valueOf(compMafTable.getValueAt(0, tcl.getColumn()).toString()) / 100.0 + 1.0; newMafTable.setValueAt( Double.valueOf(origMafTable.getValueAt(1, tcl.getColumn()).toString()) * corr, 1, tcl.getColumn()); } } else compMafTable.setValueAt(tcl.getOldValue(), 0, tcl.getColumn()); } }; setCompMafCellListener(new TableCellListener(compMafTable, action)); // CHART JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, true, false); chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.PAGE_START; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.insets = new Insets(1, 1, 1, 1); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 5; gbl_chartPanel.gridheight = 1; gbl_chartPanel.gridwidth = 3; dataPanel.add(chartPanel, gbl_chartPanel); XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesStroke(1, stroke); lineRenderer.setSeriesPaint(0, new Color(201, 0, 0)); lineRenderer.setSeriesPaint(1, new Color(0, 0, 255)); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setSeriesShape(1, ShapeUtilities.createDownTriangle((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = -4045338273187150888L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis mafvDomain = new NumberAxis(XAxisName); mafvDomain.setAutoRangeIncludesZero(false); mafvDomain.setAutoRange(true); mafvDomain.setAutoRangeStickyZero(false); NumberAxis mafgsRange = new NumberAxis(YAxisName); mafgsRange.setAutoRangeIncludesZero(false); mafgsRange.setAutoRange(true); mafgsRange.setAutoRangeStickyZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); origMafData.setDescription(origMaf); newMafData.setDescription(newMaf); lineDataset.addSeries(origMafData); lineDataset.addSeries(newMafData); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, mafvDomain); plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); } catch (Exception e) { logger.error(e); } }
From source file:com.vgi.mafscaling.LogView.java
private void updateChart() { if (logDataTable.getColumnCount() != dataset.getSeriesCount()) return;/* w ww . ja v a 2 s . c o m*/ Column col; String colName; String val; XYSeries series; int seriesIdx = 0; for (int i = 0; i < logDataTable.getColumnCount(); ++i) { int colIdx = logDataTable.getCurrentIndexForOriginalColumn(i); col = logDataTable.getColumn(colIdx); colName = col.getHeaderValue().toString(); series = dataset.getSeries(seriesIdx++); if (!series.getDescription().equals(colName)) { JOptionPane.showMessageDialog(null, "Invalid series found for the column index " + colIdx + ": series name " + series.getDescription() + " doesn't match column name " + colName, "Invalid value", JOptionPane.ERROR_MESSAGE); return; } series.clear(); for (int j = 0; j < logDataTable.getRowCount(); ++j) { try { val = (String) logDataTable.getValueAt(j, colIdx); series.add(j, Double.valueOf(val), false); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid numeric value in column " + colName + ", row " + (j + 1), "Invalid value", JOptionPane.ERROR_MESSAGE); return; } } series.fireSeriesChanged(); } chartPanel.repaint(); }
From source file:com.vgi.mafscaling.LogView.java
public boolean setMarkers(double x, boolean isLeft) { xyMarker.clearLabels(false);/*from w w w . j a v a 2 s . c om*/ if (x < 0 || x >= logDataTable.getRowCount()) return false; XYSeries series = null; if (isLeft) { xyMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); xyMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else { xyMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); xyMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } if (rpmDataset.getSeriesCount() > 0 && rpmPlotRenderer.isSeriesVisible(0)) { series = rpmDataset.getSeries(0); xyMarker.addLabel(series.getDescription() + ": " + series.getY((int) x), rpmPlotRenderer.getSeriesPaint(0), false); } for (int i = 0; i < dataset.getSeriesCount(); ++i) { if (plotRenderer.isSeriesVisible(i)) { series = dataset.getSeries(i); xyMarker.addLabel(series.getDescription() + ": " + series.getY((int) x), plotRenderer.getSeriesPaint(i), false); } } xyMarker.setValue(x); return (series != null); }
From source file:com.vgi.mafscaling.LogView.java
private void addXYSeries(TableModel model, int column, String name, Color color) { setCursor(new Cursor(Cursor.WAIT_CURSOR)); try {//from w w w . ja v a2 s. c om XYSeries series; if (column == rpmCol) { series = rpmDataset.getSeries(0); ((NumberAxis) plot.getRangeAxis(0)).setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis(0).setTickLabelsVisible(true); rpmPlotRenderer.setSeriesPaint(0, color); rpmPlotRenderer.setSeriesVisible(0, true); } else { series = dataset.getSeries(column); plot.getRangeAxis(1).setTickLabelsVisible(true); plotRenderer.setSeriesPaint(column, color); plotRenderer.setSeriesVisible(column, true); displCount += 1; } if (xyMarker.count() > 0) xyMarker.addLabel(series.getDescription() + ": " + series.getY((int) xyMarker.getValue()), color, true); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } chartPanel.revalidate(); }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Dump the (partial) contents of each Series in an XYdatset. * * @param dump/*from ww w . ja v a 2s .co m*/ * @param calendar * @param dataset * @param dumprowcount * @param title */ public static void dumpXYDataset(final boolean dump, final Calendar calendar, final XYDataset dataset, final int dumprowcount, final String title) { final String SOURCE = "ChartHelper.dumpXYDataset() "; if (dump) { LOGGER.log(title); if ((dataset != null) && (dataset instanceof XYSeriesCollection)) { final XYSeriesCollection seriesCollection; seriesCollection = (XYSeriesCollection) dataset; LOGGER.log("XYSeriesCollection"); LOGGER.log(" [series.count=" + seriesCollection.getSeriesCount() + "]"); LOGGER.log(" [domain.lowerbound.interval.true=" + (long) seriesCollection.getDomainLowerBound(true) + "]"); LOGGER.log(" [domain.lowerbound.interval.false=" + (long) seriesCollection.getDomainLowerBound(false) + "]"); LOGGER.log(" [domain.upperbound.interval.true=" + (long) seriesCollection.getDomainUpperBound(true) + "]"); LOGGER.log(" [domain.upperbound.interval.false=" + (long) seriesCollection.getDomainUpperBound(false) + "]"); LOGGER.log(" [domain.order=" + seriesCollection.getDomainOrder() + "]"); for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) { final XYSeries xySeries; LOGGER.log(""); LOGGER.log(" [xyseries.index=" + intSeriesIndex + "]"); xySeries = seriesCollection.getSeries(intSeriesIndex); LOGGER.log(" [xyseries.itemcount=" + xySeries.getItemCount() + "]"); LOGGER.log(" [xyseries.key=" + xySeries.getKey() + "]"); LOGGER.log(" [xyseries.xmin=" + xySeries.getMinX() + "]"); LOGGER.log(" [xyseries.xmax=" + xySeries.getMaxX() + "]"); LOGGER.log(" [xyseries.ymin=" + xySeries.getMinY() + "]"); LOGGER.log(" [xyseries.ymax=" + xySeries.getMaxY() + "]"); LOGGER.log(" [xyseries.description=" + xySeries.getDescription() + "]"); LOGGER.log(" [xyseries.autosort=" + xySeries.getAutoSort() + "]"); LOGGER.log(" [xyseries.allowduplicatex=" + xySeries.getAllowDuplicateXValues() + "]"); // Dump the first chunk for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, xySeries.getItemCount())); intItemIndex++) { final XYDataItem item; item = xySeries.getDataItem(intItemIndex); LOGGER.log(" [item.index=" + intItemIndex + "] [item.x=" + item.getXValue() + "] [item.y=" + item.getYValue() + "]"); } LOGGER.log(" ..."); // Dump the last chunk for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, xySeries.getItemCount())); intItemIndex++) { final XYDataItem item; final int intIndex; intIndex = Math.max(0, xySeries.getItemCount() - dumprowcount) + intItemIndex; item = xySeries.getDataItem(intIndex); LOGGER.log(" [item.index=" + intIndex + "] [item.x=" + item.getXValue() + "] [item.y=" + item.getYValue() + "]"); } } } else if ((dataset != null) && (dataset instanceof TimeSeriesCollection)) { final TimeSeriesCollection seriesCollection; seriesCollection = (TimeSeriesCollection) dataset; LOGGER.log("TimeSeriesCollection"); LOGGER.log(" [series.count=" + seriesCollection.getSeriesCount() + "]"); LOGGER.log(" [domain.lowerbound.interval.true=" + (long) seriesCollection.getDomainLowerBound(true) + "]"); LOGGER.log(" [domain.lowerbound.interval.false=" + (long) seriesCollection.getDomainLowerBound(false) + "]"); LOGGER.log(" [domain.upperbound.interval.true=" + (long) seriesCollection.getDomainUpperBound(true) + "]"); LOGGER.log(" [domain.upperbound.interval.false=" + (long) seriesCollection.getDomainUpperBound(false) + "]"); LOGGER.log(" [domain.order=" + seriesCollection.getDomainOrder() + "]"); for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) { final TimeSeries timeSeries; LOGGER.log(""); LOGGER.log(" [timeseries.index=" + intSeriesIndex + "]"); timeSeries = seriesCollection.getSeries(intSeriesIndex); LOGGER.log(" [timeseries.itemcount=" + timeSeries.getItemCount() + "]"); LOGGER.log(" [timeseries.key=" + timeSeries.getKey() + "]"); LOGGER.log(" [timeseries.ymin=" + timeSeries.getMinY() + "]"); LOGGER.log(" [timeseries.ymax=" + timeSeries.getMaxY() + "]"); LOGGER.log(" [timeseries.domain=" + timeSeries.getDomainDescription() + "]"); LOGGER.log(" [timeseries.range=" + timeSeries.getRangeDescription() + "]"); LOGGER.log( " [timeseries.timeperiodclass=" + timeSeries.getTimePeriodClass().getName() + "]"); for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, timeSeries.getItemCount())); intItemIndex++) { final TimeSeriesDataItem item; item = timeSeries.getDataItem(intItemIndex); LOGGER.log(" [item.index=" + intItemIndex + "] [item.period.serialindex=" + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis=" + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value=" + item.getValue() + "]"); } LOGGER.log(" ..."); for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, timeSeries.getItemCount())); intItemIndex++) { final TimeSeriesDataItem item; final int intIndex; intIndex = Math.max(0, timeSeries.getItemCount() - dumprowcount) + intItemIndex; item = timeSeries.getDataItem(intIndex); LOGGER.log(" [item.index=" + intIndex + "] [item.period.serialindex=" + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis=" + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value=" + item.getValue() + "]"); } } } else { LOGGER.error(SOURCE + "Unsupported XYDataset type"); } } }