List of usage examples for org.jfree.chart.plot XYPlot setRangeAxis
public void setRangeAxis(ValueAxis axis)
From source file:uk.co.petertribble.jangle.SnmpChart.java
private void setAxes() { XYPlot xyplot = chart.getXYPlot(); String ylabel = showdelta ? SnmpResources.getString("CHART.RATE") : SnmpResources.getString("CHART.VALUE"); NumberAxis loadaxis = new NumberAxis(ylabel); loadaxis.setAutoRange(true);//from w w w .ja v a 2 s . co m loadaxis.setAutoRangeIncludesZero(true); xyplot.setRangeAxis(loadaxis); DateAxis daxis = new DateAxis(SnmpResources.getString("CHART.TIME")); daxis.setAutoRange(true); daxis.setFixedAutoRange(maxage); xyplot.setDomainAxis(daxis); }
From source file:juicebox.windowui.QCDialog.java
public QCDialog(MainWindow mainWindow, HiC hic, String title) { super(mainWindow); Dataset dataset = hic.getDataset();//from w w w .jav a 2 s . c om String text = dataset.getStatistics(); String textDescription = null; String textStatistics = null; String graphs = dataset.getGraphs(); JTextPane description = null; JTabbedPane tabbedPane = new JTabbedPane(); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("table { border-collapse: collapse;}"); styleSheet.addRule("body {font-family: Sans-Serif; font-size: 12;}"); styleSheet.addRule("td { padding: 2px; }"); styleSheet.addRule( "th {border-bottom: 1px solid #000; text-align: left; background-color: #D8D8D8; font-weight: normal;}"); if (text != null) { int split = text.indexOf("</table>") + 8; textDescription = text.substring(0, split); textStatistics = text.substring(split); description = new JTextPane(); description.setEditable(false); description.setContentType("text/html"); description.setEditorKit(kit); description.setText(textDescription); tabbedPane.addTab("About Library", description); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setContentType("text/html"); textPane.setEditorKit(kit); textPane.setText(textStatistics); JScrollPane pane = new JScrollPane(textPane); tabbedPane.addTab("Statistics", pane); } boolean success = true; if (graphs != null) { long[] A = new long[2000]; long sumA = 0; long[] mapq1 = new long[201]; long[] mapq2 = new long[201]; long[] mapq3 = new long[201]; long[] intraCount = new long[100]; final XYSeries intra = new XYSeries("Intra Count"); final XYSeries leftRead = new XYSeries("Left"); final XYSeries rightRead = new XYSeries("Right"); final XYSeries innerRead = new XYSeries("Inner"); final XYSeries outerRead = new XYSeries("Outer"); final XYSeries allMapq = new XYSeries("All MapQ"); final XYSeries intraMapq = new XYSeries("Intra MapQ"); final XYSeries interMapq = new XYSeries("Inter MapQ"); Scanner scanner = new Scanner(graphs); try { while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 2000; idx++) { A[idx] = scanner.nextLong(); sumA += A[idx]; } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 201; idx++) { mapq1[idx] = scanner.nextInt(); mapq2[idx] = scanner.nextInt(); mapq3[idx] = scanner.nextInt(); } for (int idx = 199; idx >= 0; idx--) { mapq1[idx] = mapq1[idx] + mapq1[idx + 1]; mapq2[idx] = mapq2[idx] + mapq2[idx + 1]; mapq3[idx] = mapq3[idx] + mapq3[idx + 1]; allMapq.add(idx, mapq1[idx]); intraMapq.add(idx, mapq2[idx]); interMapq.add(idx, mapq3[idx]); } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 100; idx++) { int tmp = scanner.nextInt(); if (tmp != 0) innerRead.add(logXAxis[idx], tmp); intraCount[idx] = tmp; tmp = scanner.nextInt(); if (tmp != 0) outerRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) rightRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) leftRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; if (idx > 0) intraCount[idx] += intraCount[idx - 1]; if (intraCount[idx] != 0) intra.add(logXAxis[idx], intraCount[idx]); } } catch (NoSuchElementException exception) { JOptionPane.showMessageDialog(getParent(), "Graphing file improperly formatted", "Error", JOptionPane.ERROR_MESSAGE); success = false; } if (success) { final XYSeriesCollection readTypeCollection = new XYSeriesCollection(); readTypeCollection.addSeries(innerRead); readTypeCollection.addSeries(outerRead); readTypeCollection.addSeries(leftRead); readTypeCollection.addSeries(rightRead); final JFreeChart readTypeChart = ChartFactory.createXYLineChart("Types of reads vs distance", // chart title "Distance (log)", // domain axis label "Binned Reads (log)", // range axis label readTypeCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Binned Reads (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(readTypeChart); final XYSeriesCollection reCollection = new XYSeriesCollection(); final XYSeries reDistance = new XYSeries("Distance"); for (int i = 0; i < A.length; i++) { if (A[i] != 0) reDistance.add(i, A[i] / (float) sumA); } reCollection.addSeries(reDistance); final JFreeChart reChart = ChartFactory.createXYLineChart( "Distance from closest restriction enzyme site", // chart title "Distance (bp)", // domain axis label "Fraction of Reads (log)", // range axis label reCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot rePlot = reChart.getXYPlot(); rePlot.setDomainAxis(new NumberAxis("Distance (bp)")); rePlot.setRangeAxis(new LogarithmicAxis("Fraction of Reads (log)")); rePlot.setBackgroundPaint(Color.white); rePlot.setRangeGridlinePaint(Color.lightGray); rePlot.setDomainGridlinePaint(Color.lightGray); reChart.setBackgroundPaint(Color.white); rePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel2 = new ChartPanel(reChart); final XYSeriesCollection intraCollection = new XYSeriesCollection(); intraCollection.addSeries(intra); final JFreeChart intraChart = ChartFactory.createXYLineChart("Intra reads vs distance", // chart title "Distance (log)", // domain axis label "Cumulative Sum of Binned Reads (log)", // range axis label intraCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot intraPlot = intraChart.getXYPlot(); intraPlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); intraPlot.setRangeAxis(new NumberAxis("Cumulative Sum of Binned Reads (log)")); intraPlot.setBackgroundPaint(Color.white); intraPlot.setRangeGridlinePaint(Color.lightGray); intraPlot.setDomainGridlinePaint(Color.lightGray); intraChart.setBackgroundPaint(Color.white); intraPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel3 = new ChartPanel(intraChart); final XYSeriesCollection mapqCollection = new XYSeriesCollection(); mapqCollection.addSeries(allMapq); mapqCollection.addSeries(intraMapq); mapqCollection.addSeries(interMapq); final JFreeChart mapqChart = ChartFactory.createXYLineChart("MapQ Threshold Count", // chart title "MapQ threshold", // domain axis label "Count", // range axis label mapqCollection, // data PlotOrientation.VERTICAL, true, // include legend true, // include tooltips false); final XYPlot mapqPlot = mapqChart.getXYPlot(); mapqPlot.setBackgroundPaint(Color.white); mapqPlot.setRangeGridlinePaint(Color.lightGray); mapqPlot.setDomainGridlinePaint(Color.lightGray); mapqChart.setBackgroundPaint(Color.white); mapqPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel4 = new ChartPanel(mapqChart); tabbedPane.addTab("Pair Type", chartPanel); tabbedPane.addTab("Restriction", chartPanel2); tabbedPane.addTab("Intra vs Distance", chartPanel3); tabbedPane.addTab("MapQ", chartPanel4); } } final ExpectedValueFunction df = hic.getDataset().getExpectedValues(hic.getZoom(), hic.getNormalizationType()); if (df != null) { double[] expected = df.getExpectedValues(); final XYSeriesCollection collection = new XYSeriesCollection(); final XYSeries expectedValues = new XYSeries("Expected"); for (int i = 0; i < expected.length; i++) { if (expected[i] > 0) expectedValues.add(i + 1, expected[i]); } collection.addSeries(expectedValues); String title1 = "Expected at " + hic.getZoom() + " norm " + hic.getNormalizationType(); final JFreeChart readTypeChart = ChartFactory.createXYLineChart(title1, // chart title "Distance between reads (log)", // domain axis label "Genome-wide expected (log)", // range axis label collection, // data PlotOrientation.VERTICAL, false, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance between reads (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Genome-wide expected (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel5 = new ChartPanel(readTypeChart); tabbedPane.addTab("Expected", chartPanel5); } if (text == null && graphs == null) { JOptionPane.showMessageDialog(this, "Sorry, no metrics are available for this dataset", "Error", JOptionPane.ERROR_MESSAGE); setVisible(false); dispose(); } else { getContentPane().add(tabbedPane); pack(); setModal(false); setLocation(100, 100); setTitle(title); setVisible(true); } }
From source file:org.ujmp.jfreechart.MatrixChartPanel.java
public synchronized void redraw() { Dataset dataset = null;/*from ww w .j av a 2s. c o m*/ dataset = new XYSeriesCollectionWrapper(getMatrix()); // dataset = new CategoryDatasetWrapper(getMatrix()); String title = getMatrix().getLabel(); String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null; // setChart(ChartFactory.createLineChart(title, xLabel, yLabel, // (CategoryDataset) dataset, PlotOrientation.VERTICAL, true, // true, false)); setChart(ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset, PlotOrientation.VERTICAL, true, true, false)); XYPlot plot = getChart().getXYPlot(); if (getConfig().isLogScaleDomain()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setDomainAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } if (getConfig().isLogScaleRange()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setRangeAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } getChart().setTitle((String) null); getChart().setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); for (int i = 0; i < getMatrix().getColumnCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(3)); plot.setRenderer(i, renderer); } plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRangeAxis().setAutoRange(true); plot.getDomainAxis().setAutoRange(true); plot.getDomainAxis().setUpperMargin(0); setMouseZoomable(false); }
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private void showDetail(Graphs g) { XYPlot plot = detailChart.getXYPlot(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelPaint(Color.GRAY); plot.setRangeAxis(yAxis); NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new NumberTickUnit(10)); xAxis.setRange(horizons.get(0), horizons.get(horizons.size() - 1)); xAxis.setVerticalTickLabels(true);/* w ww.ja v a 2s . c o m*/ plot.setDomainAxis(xAxis); plot.setDataset(TRUE_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_))); plot.setDataset(FCTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_))); plot.setDataset(ARIMA_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_))); rescaleAxis((NumberAxis) plot.getRangeAxis()); detailChart.setTitle(g.label_); chartPanel.setChart(detailChart); chartPanel.setToolTipText("Right click to show complete data"); chartPanel.setPopupMenu(buildMenu().getPopupMenu()); onColorSchemeChanged(); selectedGraph = g; }
From source file:vteaexploration.plottools.panels.XYChartPanel.java
public void setChartPanelRanges(int axis, double low, double high) { XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot(); ValueAxis newaxis = new NumberAxis(); newaxis.setLowerBound(low);//from w w w. ja v a 2s. c o m newaxis.setUpperBound(high); if (axis == XYChartPanel.XAXIS) { plot.setDomainAxis(newaxis); } else if (axis == XYChartPanel.YAXIS) { plot.setRangeAxis(newaxis); } }
From source file:ec.ui.view.RevisionSaSeriesView.java
private void configureAxis(XYPlot plot) { SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy"); DateAxis dateAxis = new DateAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateAxis.setDateFormatOverride(sdf); plot.setDomainAxis(dateAxis);/*w w w .j av a 2 s .c o m*/ NumberAxis yaxis = new NumberAxis(); if (range != null) { yaxis.setRange(range); } plot.setRangeAxis(yaxis); }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildMainChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, String fileName) {/* w w w . j a v a 2 s . c o m*/ final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createMatrixDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.addSubtitle(new TextTitle(subTitle)); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( y ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, this.array.length); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.array.length); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(false); ren.setSeriesItemLabelPaint(0, Color.BLACK); plot1.setRenderer(ren); this.mainChart = chart; }
From source file:ec.ui.view.DistributionView.java
private static JFreeChart createDistributionViewChart() { XYPlot plot = new XYPlot(); XYLineAndShapeRenderer dRenderer = new XYSplineRenderer(); dRenderer.setBaseShapesVisible(false); dRenderer.setAutoPopulateSeriesPaint(false); dRenderer.setAutoPopulateSeriesStroke(false); dRenderer.setBaseStroke(TsCharts.getStrongStroke(LinesThickness.Thin)); dRenderer.setDrawSeriesLineAsPath(true); // not sure if useful plot.setDataset(DISTRIBUTION_INDEX, Charts.emptyXYDataset()); plot.setRenderer(DISTRIBUTION_INDEX, dRenderer); XYBarRenderer hRenderer = new XYBarRenderer(); hRenderer.setShadowVisible(false);/*from w w w . j av a 2 s. co m*/ hRenderer.setDrawBarOutline(true); hRenderer.setAutoPopulateSeriesPaint(false); hRenderer.setAutoPopulateSeriesOutlinePaint(false); hRenderer.setBaseSeriesVisibleInLegend(false); plot.setDataset(HISTOGRAM_INDEX, Charts.emptyXYDataset()); plot.setRenderer(HISTOGRAM_INDEX, hRenderer); NumberAxis domainAxis = new NumberAxis(); domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setDomainAxis(domainAxis); plot.setDomainGridlinesVisible(false); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); rangeAxis.setTickUnit(new NumberTickUnit(0.05)); rangeAxis.setNumberFormatOverride(new DecimalFormat("0.###")); plot.setRangeAxis(rangeAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); JFreeChart result = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); result.setPadding(TsCharts.CHART_PADDING); result.getTitle().setFont(TsCharts.CHART_TITLE_FONT); result.getLegend().setFrame(BlockBorder.NONE); result.getLegend().setBackgroundPaint(null); return result; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildLegendChart(int nbValues) { this.legendValues = new int[nbValues + 1]; this.legendValues[0] = 0; int offset = 255 / nbValues; int step = offset; if (this.scaleMode == Chart.Scale.LOGARITHMIC) { double logStep = (Math.log(this.maxValue) / Math.log(2)) / nbValues; for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (int) Math.pow(2, logStep * i); }//from ww w.j a v a2 s . com } else { // Linear scale mode for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (step * this.maxValue) / 255; step += offset; } } final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createLegendDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart("", "", "", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( x ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, 1); domainAxis.setVisible(false); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setTickUnit(new CustomTickUnit(rangeAxis.getTickUnit().getSize())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.legendValues.length); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarkInsideLength(4); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(true); ren.setSeriesItemLabelPaint(0, Color.BLUE); plot1.setRenderer(ren); plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); this.legendChart = chart; }
From source file:org.n52.oxf.render.sos.TimeSeriesMapChartRenderer.java
/** * The resulting chart consists a TimeSeries for each FeatureOfInterest contained in the * observationCollection.//from ww w.ja va2s .c o m * * @param foiIdArray * the IDs of the FeaturesOfInterest whose Observations shall be rendered * @param observationCollection * @return */ protected XYPlot drawChart4FOI(String foiID, Map<ITimePosition, ObservedValueTuple> timeMap) { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries timeSeries = new TimeSeries(foiID, Second.class); for (ITimePosition timePos : timeMap.keySet()) { Number value = (Number) timeMap.get(timePos).getValue(0); timeSeries.add( new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(), timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()), value); } dataset.addSeries(timeSeries); dataset.setDomainIsPointsInTime(true); // // create Plot: // XYPlot plot = new XYPlot(); plot.setDataset(dataset); plot.setBackgroundPaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); DateAxis dateAxis = new DateAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.START); dateAxis.setTickMarksVisible(true); dateAxis.setVerticalTickLabels(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd'.'MM'.'")); plot.setDomainAxis(dateAxis); plot.setRangeAxis(new NumberAxis()); return plot; }