List of usage examples for org.jfree.chart.axis NumberAxis setTickMarksVisible
public void setTickMarksVisible(boolean flag)
From source file:org.hxzon.demo.jfreechart.PolarChartDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { boolean legend = true; PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);//from w w w. j a v a2 s.c o m NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:jgnash.ui.budget.BudgetSparkline.java
public static Icon getSparklineImage(final List<BigDecimal> amounts) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final boolean[] negate = new boolean[amounts.size()]; for (int i = 0; i < amounts.size(); i++) { dataset.addValue(amounts.get(i), CATEGORY, i); negate[i] = amounts.get(i).signum() == -1; }/* w w w.j a v a2 s . c o m*/ CategoryAxis xAxis = new CategoryAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); xAxis.setAxisLineVisible(false); xAxis.setVisible(false); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setAutoRangeIncludesZero(true); yAxis.setAutoRange(true); yAxis.setVisible(false); BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { return negate[column] ? Color.RED : Color.BLACK; } }; renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setInsets(INSETS); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(CLEAR); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBorderVisible(false); chart.setBackgroundPaint(CLEAR); Icon icon = EMPTY_ICON; try { byte[] image = ENCODER .encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null)); icon = new ImageIcon(image); } catch (IOException ex) { Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex); } return icon; }
From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java
public static MappingQualityMatrixChart createSimpleChart(MappingQualityMatrixDataset dataset, PaintScale paintScale) {//from ww w . j a va 2 s . co m NumberAxis xAxis = new NumberAxis(""); // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); // xAxis.setLowerMargin(0.0); // xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(""); // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); // yAxis.setLowerMargin(0.0); // yAxis.setUpperMargin(0.0); MappingQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale); chart.getPlot().setOutlineVisible(false); chart.getPlot().setInsets(new RectangleInsets(0, 0, 0, 0)); return chart; }
From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java
public static MeanQualityMatrixChart createSimpleChart(MeanQualityMatrixDataset dataset, PaintScale paintScale) {//from ww w . j a v a2 s . c o m NumberAxis xAxis = new NumberAxis(""); // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); // xAxis.setLowerMargin(0.0); // xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(""); // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); // yAxis.setLowerMargin(0.0); // yAxis.setUpperMargin(0.0); MeanQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale); chart.getPlot().setOutlineVisible(false); chart.getPlot().setInsets(new RectangleInsets(0, 0, 0, 0)); return chart; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);//from w ww.j a va 2 s .c o m rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:org.gwaspi.reports.PlinkReportLoader.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection seriesCol) {//ww w . j a v a 2s . c o m XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); subplot.setDomainGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainGridlinePaint(Color.blue); subplot.setRangeGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeGridlinePaint(Color.blue); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(true); chrAxis.setTickMarksVisible(true); chrAxis.setTickUnit(new NumberTickUnit(10000)); chrAxis.setAutoRangeIncludesZero(false); NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis(); log10Axis.setTickMarkInsideLength(2.0f); log10Axis.setTickMarkOutsideLength(2.0f); log10Axis.setMinorTickCount(2); log10Axis.setMinorTickMarksVisible(true); log10Axis.setAxisLineVisible(true); log10Axis.setAutoRangeIncludesZero(false); XYItemRenderer lblRenderer = subplot.getRenderer(); MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesItemLabelsVisible(0, true); lblRenderer.setSeriesItemLabelsVisible(1, true); combinedPlot.add(subplot, 1); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createPolarChart(XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);/*from w w w . j a v a2s .co m*/ NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); return chart; }
From source file:org.cyberoam.iview.charts.CustomDomainAxis.java
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null;/* ww w .jav a 2s .c o m*/ // DefaultCategoryDataset dataset=null; CustomCategoryDataset datasetCustom = null; try { ReportColumnBean reportColumnBeanX = null; ReportColumnBean reportColumnBeanY = null; ReportColumnBean reportColumnBeanZ = null; GraphBean graphBean = null; graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId()); reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBeanX.getDbColumnName(); reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBeanY.getDbColumnName(); String zColumnDBname = null; datasetCustom = new CustomCategoryDataset(); rsw.beforeFirst(); String data = ""; int count = -1; Boolean showLegend = false; if (graphBean.getZColumnId() == -1) { while (rsw.next()) { data = rsw.getString(xColumnDBname); datasetCustom.addValue(rsw.getLong(yColumnDBname), "", data); } } else { String zData; showLegend = true; reportColumnBeanZ = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); zColumnDBname = reportColumnBeanZ.getDbColumnName(); while (rsw.next()) { data = rsw.getString(xColumnDBname); zData = rsw.getString(zColumnDBname); datasetCustom.addValue(rsw.getLong(yColumnDBname), zData, data); count++; } } chart = ChartFactory.createLineChart("", // chart title "", // domain axis label "", // range axis label datasetCustom, // data PlotOrientation.VERTICAL, // orientation showLegend, // include legend true, // tooltips false // urls ); LegendTitle legendTitle = chart.getLegend(); if (legendTitle != null) legendTitle.setItemFont(new Font("Vandara", Font.BOLD, 11)); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelInsets(new RectangleInsets(0, 0, 0, 5)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); CustomDomainAxis catAxis = new CustomDomainAxis(); CustomDomainAxis.counter = 0; CustomDomainAxis.colCount = datasetCustom.getColumnCount(); catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); catAxis.setTickMarksVisible(false); catAxis.setTickLabelInsets(new RectangleInsets(10, 15, 30, 10)); catAxis.setAxisLineVisible(false); catAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(20 * Math.PI / 180)); plot.setDomainAxis(catAxis); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); if (count > 0) { Color[] colors = null; colors = new Color[5]; colors[0] = new Color(24, 112, 176); colors[1] = new Color(168, 192, 232); colors[2] = new Color(248, 120, 8); colors[3] = new Color(248, 184, 120); colors[4] = new Color(152, 216, 136); for (int i = 0; i < count && i < colors.length; i++) renderer.setSeriesPaint(i, colors[i]); } } catch (Exception e) { CyberoamLogger.appLog.debug("LineChart: " + e.getMessage(), e); } return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);/*w w w . jav a 2s .c o m*/ NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:org.cyberoam.iview.charts.XYLine.java
/** * This method generates JFreeChart instance for XYLine chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from URL. * @return jfreechart instance with iView Customization. *//*from w w w . j a v a 2 s . co m*/ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; XYDataset dataset = null; XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries(reportBean.getTitle()); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBean.getDbColumnName(); String xColumnName = reportColumnBean.getColumnName(); //Wheather DataLink is Given For X Axis column if (reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); String yColumnName = reportColumnBean.getColumnName(); //if DataLink is not Given For X Axis column then Check of Y Axis Column if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); String zColumnDbname = reportColumnBean.getDbColumnName(); //Preparing DataSet String data = ""; rsw.beforeFirst(); while (rsw.next()) { data = rsw.getString(xColumnDBname); series.add(Long.parseLong((data).substring(data.length() - 2)), new Long(rsw.getLong(yColumnDBname)).longValue()); } seriesCollection.addSeries(series); dataset = seriesCollection; // create the chart... chart = ChartFactory.createXYLineChart("", // chart title "", // domain axis label "", seriesCollection, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); /* * Additional iView Customization. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setForegroundAlpha(0.7f); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); Axis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); renderer.setSeriesStroke(0, new BasicStroke(1)); } catch (Exception e) { e.printStackTrace(); } return chart; }