List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis
public ValueAxis getRangeAxis()
From source file:net.sf.maltcms.chromaui.charts.overlay.Peak1DHeatmapOverlay.java
/** * * @param g2// www . j a v a 2 s . c o m * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (isVisible()) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); ValueAxis yAxis = plot.getRangeAxis(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); Color c = g2.getColor(); Color fillColor = peakAnnotations.getColor(); if (fillColor == null || fillColor.equals(Color.WHITE) || fillColor.equals(new Color(255, 255, 255, 0))) { Logger.getLogger(getClass().getName()) .info("Peak annotation color was null or white, using color from treatment group!"); fillColor = peakAnnotations.getChromatogram().getTreatmentGroup().getColor(); } g2.setColor(ChartCustomizer.withAlpha(fillColor, 0.5f)); for (IPeakAnnotationDescriptor descr : peakAnnotations.getMembers()) { double x = descr.getApexTime(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); double width = xAxis.valueToJava2D(1, dataArea, xAxisEdge); double mzRange = (descr.getMassValues()[descr.getMassValues().length - 1] - descr.getMassValues()[0]); double y = mzRange / 2.0d; double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); double height = yAxis.valueToJava2D(mzRange, dataArea, yAxisEdge); AffineTransform at = AffineTransform.getTranslateInstance(xx, yy); at.concatenate(AffineTransform.getTranslateInstance(-x, -y)); Rectangle2D.Double r = new Rectangle2D.Double(xx - (width / 2.0d), yy, width, height); g2.fill(at.createTransformedShape(r)); } g2.setColor(c); g2.setClip(savedClip); } }
From source file:net.relet.freimap.LinkInfo.java
private void sexupPlot(Plot plot) { if (plot instanceof CombinedDomainXYPlot) { List<Plot> subs = (List<Plot>) (((CombinedDomainXYPlot) plot).getSubplots()); Iterator<Plot> i = subs.iterator(); while (i.hasNext()) { Plot p = i.next();// w w w. jav a 2 s . c om sexupPlot(p); } } else if (plot instanceof XYPlot) { XYPlot xyplot = (XYPlot) plot; xyplot.setBackgroundPaint(VisorFrame.bgcolor2); xyplot.setDomainAxis(new DateAxis()); sexupAxis(xyplot.getDomainAxis()); sexupAxis(xyplot.getRangeAxis()); } }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo4.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, //!legendPanelOn, true, false);/*from w w w.java 2 s .c o m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:vteaexploration.plotgatetools.gates.PolygonGate.java
@Override public void createInChartSpace(ChartPanel chart) { int[] x1Points = new int[vertices.size()]; int[] y1Points = new int[vertices.size()]; double xChartPoint; double yChartPoint; for (int i = 0; i <= vertices.size() - 1; i++) { x1Points[i] = (int) ((Point2D) vertices.get(i)).getX(); y1Points[i] = (int) ((Point2D) vertices.get(i)).getY(); }//from ww w . ja v a2 s . c o m for (int index = 0; index < x1Points.length; index++) { Rectangle2D plotArea = chart.getScreenDataArea(); XYPlot plot = (XYPlot) chart.getChart().getPlot(); xChartPoint = plot.getDomainAxis().java2DToValue(x1Points[index], plotArea, plot.getDomainAxisEdge()); yChartPoint = plot.getRangeAxis().java2DToValue(y1Points[index], plotArea, plot.getRangeAxisEdge()); this.verticesInChartSpace.add(new Point2D.Double(xChartPoint, yChartPoint)); } }
From source file:net.sf.mzmine.modules.visualization.ida.IDABottomPanel.java
/** * Returns a peak list with the top peaks defined by the parameter * "threshold"//from w w w . j a v a2 s .com */ PeakList getTopThresholdPeakList(int threshold) { PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem(); if (selectedPeakList == null) return null; SimplePeakList newList = new SimplePeakList(selectedPeakList.getName(), selectedPeakList.getRawDataFiles()); Vector<PeakListRow> peakRows = new Vector<PeakListRow>(); Range<Double> mzRange = selectedPeakList.getRowsMZRange(); Range<Double> rtRange = selectedPeakList.getRowsRTRange(); PeakThresholdMode selectedPeakOption = (PeakThresholdMode) thresholdCombo.getSelectedItem(); if (selectedPeakOption == PeakThresholdMode.TOP_PEAKS_AREA) { XYPlot xyPlot = masterFrame.getPlot().getXYPlot(); org.jfree.data.Range yAxis = xyPlot.getRangeAxis().getRange(); org.jfree.data.Range xAxis = xyPlot.getDomainAxis().getRange(); rtRange = Range.closed(xAxis.getLowerBound(), xAxis.getUpperBound()); mzRange = Range.closed(yAxis.getLowerBound(), yAxis.getUpperBound()); } for (PeakListRow peakRow : selectedPeakList.getRows()) { if (mzRange.contains(peakRow.getAverageMZ()) && rtRange.contains(peakRow.getAverageRT())) { peakRows.add(peakRow); } } Collections.sort(peakRows, new PeakListRowSorter(SortingProperty.Intensity, SortingDirection.Descending)); if (threshold > peakRows.size()) threshold = peakRows.size(); for (int i = 0; i < threshold; i++) { newList.addRow(peakRows.elementAt(i)); } return newList; }
From source file:fungus.PeerRatioChartFrame.java
public PeerRatioChartFrame(String prefix) { simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES); this.setTitle("MycoNet Statistics Chart"); graph = JungGraphObserver.getGraph(); //data.add(-1,0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.setAutoWidth(false);// w w w . j ava 2 s .c o m dataset.setIntervalWidth(simulationCycles); //averageUtilizationData = new XYSeries("Average Utilization"); //dataset.addSeries(averageUtilizationData); //averageStableUtilizationData = new XYSeries("Avg Stable Util"); //dataset.addSeries(averageStableUtilizationData); bulwarkRatioData = new XYSeries("Bulwark Ratio"); dataset.addSeries(bulwarkRatioData); biomassRatioData = new XYSeries("Biomass Ratio"); dataset.addSeries(biomassRatioData); hyphaRatioData = new XYSeries("Hypha Ratio"); dataset.addSeries(hyphaRatioData); // stableHyphaRatioData = new XYSeries("Stable Hypha Ratio"); // dataset.addSeries(stableHyphaRatioData); //XYSeriesCollection dataset; JFreeChart peerRatioChart = ChartFactory.createXYLineChart("Bulwark Metrics", "Cycle", "Peer State Ratio", dataset, PlotOrientation.VERTICAL, true, false, false); ChartPanel peerRatioChartPanel = new ChartPanel(peerRatioChart); XYPlot xyplot = peerRatioChart.getXYPlot(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(0, 1); //chart.setBackgroundPaint(Color.white); //XYPlot plot = chart.getXYPlot(); // BufferedImage chartImage = chart.createBufferedImage(500,300); // chartLabel = new JLabel(); //chartLabel.setIcon(new ImageIcon(chartImage)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(1, 1)); //chartPane.setPreferredSize(new java.awt.Dimension(500, 300)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); ////contentPane.add(labelPane,BorderLayout.PAGE_START); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(peerRatioChartPanel, BorderLayout.CENTER); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); ////contentPane.add(buttonPane, BorderLayout.PAGE_END); //data = node.getHyphaData(); //link = node.getHyphaLink(); //mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //chartPanel.add(chartLabel); /*JButton updateButton = new JButton("Refresh"); ActionListener updater = new ActionListener() { public void actionPerformed(ActionEvent e) { refreshData(); } }; updateButton.addActionListener(updater); JButton closeButton = new JButton("Close"); ActionListener closer = new ActionListener() { public void actionPerformed(ActionEvent e) { closeFrame(); } }; closeButton.addActionListener(closer); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(updateButton); buttonPane.add(Box.createRigidArea(new Dimension(5,0))); buttonPane.add(closeButton); refreshData(); */ //JungGraphObserver.addChangeListener(this); this.pack(); this.setVisible(true); }
From source file:P251.graphPanel.java
/** resizes the axis to the given limits/* ww w . j a v a 2 s . c o m*/ */ public void resizeAxis(double d0, double d1, double r0, double r1) { XYPlot plot = (XYPlot) chart.getChart().getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(d0, d1); plot.getRangeAxis().setAutoRange(false); plot.getRangeAxis().setRange(r0, r1); System.out.println(plot.getDomainAxisCount()); System.out.println(plot.getRangeAxisCount()); // plot.getRangeAxis().setDefaultAutoRange(new Range(0,1)); }
From source file:BaselinePlotGenerator.java
private JFreeChart createChart(String filename, NssBaseline nssBaseline) { XYSeries series = new XYSeries(""); float[] baselineValues = nssBaseline.getBaselineValues(); // plot subband values for (int i = 0; i < baselineValues.length; i++) { series.add(i, baselineValues[i]); }//from w ww. j a v a 2s.co m // add a final point at the end with a zero Y value, // to force the y axis to display full scale series.add(baselineValues.length, 0.0); XYDataset data = new XYSeriesCollection(series); String title = "SonATA Baseline"; String xAxisLabel = "Subband"; String yAxisLabel = "Power"; JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, false, // legend true, // tooltips false // urls ); String filenameBase = new File(filename).getName(); String subTitle1 = filenameBase; chart.addSubtitle(new TextTitle(subTitle1)); DecimalFormat freqFormatter = new DecimalFormat("0000.000 MHz "); String freqString = freqFormatter.format(nssBaseline.getCenterFreqMhz()); DecimalFormat bandwidthFormatter = new DecimalFormat("0.00 MHz "); String bandwidthString = bandwidthFormatter.format(nssBaseline.getBandwidthMhz()); String subTitle2 = "Center Freq: " + freqString + " Bandwidth: " + bandwidthString; chart.addSubtitle(new TextTitle(subTitle2)); // move the data off of the axes // by extending the minimum axis value XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot(); double axisMarginPercent = 0.02; NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); return chart; }
From source file:com.vgi.mafscaling.MafChartPanel.java
public void movePoint(MouseEvent event) { try {/*w w w . j a v a 2 s.c om*/ if (IsMovable) { int itemIndex = xyItemEntity.getItem(); int seriesIndex = xyItemEntity.getSeriesIndex(); if (!pointDraggableSet.contains(seriesIndex)) return; XYSeries series = ((XYSeriesCollection) xyItemEntity.getDataset()).getSeries(seriesIndex); XYPlot plot = chartPanel.getChart().getXYPlot(); Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); Point2D p = chartPanel.translateScreenToJava2D(event.getPoint()); double finalMovePointY = plot.getRangeAxis().java2DToValue(p.getY(), dataArea, plot.getRangeAxisEdge()); double difference = finalMovePointY - initialMovePointY; if (series.getY(itemIndex).doubleValue() + difference > plot.getRangeAxis().getRange().getLength() || series.getY(itemIndex).doubleValue() + difference < 0.0) initialMovePointY = finalMovePointY; series.updateByIndex(itemIndex, series.getY(itemIndex).doubleValue() + difference); chartHolder.onMovePoint(itemIndex, series.getX(itemIndex).doubleValue(), series.getY(itemIndex).doubleValue()); chartPanel.getChart().fireChartChanged(); chartPanel.updateUI(); initialMovePointY = finalMovePointY; } } catch (Exception e) { e.printStackTrace(); logger.error(e); } }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo6.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, //!legendPanelOn, true, false);/*w w w . ja va 2 s . c o m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }