List of usage examples for org.jfree.chart.axis SymbolAxis setVisible
public void setVisible(boolean flag)
From source file:web.diva.server.model.LineChartGenerator.java
/** * Creates a chart./*from w w w. j a va 2s . com*/ * * @param dataset the data for the chart. * @param lcr the line chart result * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, String[] colors, String[] columnIds, int[] selection) { final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "", // x axis label "", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); if (selection == null) { for (int x = 0; x < colors.length; x++) { renderer.setSeriesShapesVisible(x, false); renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[x])); } } else { for (int x = 0; x < selection.length; x++) { renderer.setSeriesShapesVisible(x, false); renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[selection[x]])); } } plot.setRenderer(renderer); SymbolAxis rangeAxis = new SymbolAxis("", columnIds); rangeAxis.setGridBandsVisible(false); rangeAxis.setVerticalTickLabels(true); rangeAxis.setVisible(true); // rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 1)); rangeAxis.setFixedDimension(51.0); boolean auto = rangeAxis.getAutoRangeIncludesZero(); rangeAxis.setAutoRangeIncludesZero(true ^ auto); rangeAxis.setTickUnit(new NumberTickUnit(1)); rangeAxis.setRange(0, columnIds.length); plot.setDomainAxis(rangeAxis); return chart; }
From source file:web.diva.server.unused.ProfilePlotGenerator.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings.// w w w.ja v a 2 s.c om * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return The chart. */ private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } Font f = new Font("ARIAL", 1, 7); // NumberAxis xAxis = new NumberAxis(xAxisLabel); // xAxis.setAutoRangeIncludesZero(false); SymbolAxis xAxis = new SymbolAxis("", columnIds); xAxis.setAxisLineVisible(false); xAxis.setGridBandsVisible(false); xAxis.setVerticalTickLabels(true); xAxis.setVisible(true); xAxis.setTickLabelPaint(shadowColor); xAxis.setTickLabelFont(f); xAxis.setFixedDimension(51.0); boolean auto = xAxis.getAutoRangeIncludesZero(); xAxis.setAutoRangeIncludesZero(true ^ auto); xAxis.setTickUnit(new NumberTickUnit(1)); xAxis.setRange(0, columnIds.length); // NumberAxis yAxis = new NumberAxis(yAxisLabel); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(true ^ auto); yAxis.setAxisLineVisible(false); yAxis.setTickLabelFont(f); yAxis.setTickLabelPaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseShapesVisible(false); renderer.setPaint(shadowColor); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(shadowColor); plot.setRangeGridlinePaint(shadowColor); plot.setOutlinePaint(Color.BLUE); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // plot.setRenderer(renderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); plot.setDomainAxis(xAxis); if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Create a SNP block graph for the given parameters. This graph * will show where the intervals do and don't exist. Interval lists * are organized with the X axis label matching the list's key * @param snpIntervals//from w w w .j av a 2 s .c o m * the blocks * @param startInBasePairs * the x location to start the graph at * @param extentInBasePairs * the extent to use for the graph * @param maximumImageBlockCount * the max # of separate image blocks to use * @param renderAxes * if true render the axes... otherwise dont * @param legendText * the text to use for the legend * @param yAxisText * the text to use for the y axis * @param trueColor * the color to use for true * @param falseColor * the color to use for false * @return * the graph */ public JFreeChart createSnpIntervalGraph( final Map<String, ? extends List<? extends BasePairInterval>> snpIntervals, final long startInBasePairs, final long extentInBasePairs, final int maximumImageBlockCount, final boolean renderAxes, final String legendText, final String yAxisText, final Color trueColor, final Color falseColor) { XYDataset dataset = snpIntervalsToDataset(snpIntervals, startInBasePairs, extentInBasePairs, maximumImageBlockCount); NumberAxis xAxis = new NumberAxis("SNP Position (Base Pairs)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(new Range(startInBasePairs, startInBasePairs + extentInBasePairs)); String[] sortedStrainNames = extractSortedStrainNames(snpIntervals); for (int strainIndex = 0; strainIndex < sortedStrainNames.length; strainIndex++) { LOG.info("Strain Name: " + sortedStrainNames[strainIndex]); } SymbolAxis yAxis = new SymbolAxis(yAxisText == null ? "" : yAxisText, sortedStrainNames); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); LegendItemCollection items = new LegendItemCollection(); if (legendText != null) { items.add(new LegendItem(legendText, null, null, null, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0), trueColor, new BasicStroke(), Color.BLACK)); } plot.setFixedLegendItems(items); XYBlockRenderer r = new XYBlockRenderer(); SmoothPaintScale ps = new SmoothPaintScale(0.0, 1.0, falseColor, trueColor); r.setPaintScale(ps); r.setBlockHeight(1.0); r.setBlockWidth(1.0); plot.setRenderer(r); final JFreeChart chart; if (renderAxes) { chart = new JFreeChart("Identical By State Blocks", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { xAxis.setVisible(false); yAxis.setVisible(false); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); chart = new JFreeChart(plot); } chart.setBackgroundPaint(Color.WHITE); return chart; }