List of usage examples for org.jfree.chart.axis CategoryLabelPositions STANDARD
CategoryLabelPositions STANDARD
To view the source code for org.jfree.chart.axis CategoryLabelPositions STANDARD.
Click Source Link
From source file:org.toobsframework.pres.chart.ChartUtil.java
public static CategoryAxis createCategoryAxis(IRequest componentRequest, DomainAxisDef categoryAxisDef, Map params, boolean is3D) { CategoryAxis categoryAxis;//from w w w .jav a 2s .c o m if (is3D) { categoryAxis = new CategoryAxis3D(); } else { categoryAxis = new CategoryAxis(); } if (categoryAxisDef != null) { if (categoryAxisDef.getDomainLabel() != null) { categoryAxis .setLabel(evaluateTextLabel(componentRequest, categoryAxisDef.getDomainLabel(), params)); if (categoryAxisDef.getDomainLabel().getFont() != null) { categoryAxis.setLabelFont(getFont(categoryAxisDef.getDomainLabel(), null)); } categoryAxis.setLabelPaint(getColor(categoryAxisDef.getDomainLabel().getColor())); } if (categoryAxisDef.getLabelPosition() != null) { Integer labelPos = domainLabelPositions.get(ParameterUtil.resolveParam(componentRequest, categoryAxisDef.getLabelPosition(), params, "standard")[0]); if (labelPos != null) { switch (labelPos) { case DOM_LABEL_STANDARD_TYPE: categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); break; case DOM_LABEL_UP_45_TYPE: categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); break; case DOM_LABEL_DOWN_45_TYPE: categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); break; case DOM_LABEL_UP_90_TYPE: categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); break; case DOM_LABEL_DOWN_90_TYPE: categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); break; } } } double domainMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest, categoryAxisDef.getDomainMargin(), params, "0.0")[0]); double lowerMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest, categoryAxisDef.getLowerMargin(), params, "0.0")[0]); double upperMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest, categoryAxisDef.getUpperMargin(), params, "0.0")[0]); categoryAxis.setCategoryMargin(domainMargin); categoryAxis.setLowerMargin(lowerMargin); categoryAxis.setUpperMargin(upperMargin); } return categoryAxis; }
From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; @SuppressWarnings("unchecked") List<Paint> seriesPaints = (List<Paint>) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, seriesPaints.get(3)); barRenderer.setSeriesPaint(1, seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); }/*from w w w . ja v a2 s .c om*/ } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
From source file:org.jajuk.ui.views.StatView.java
/** * Track number bars./* ww w. j av a2 s . c o m*/ * * @return the chart */ private ChartPanel createTrackNumber() { try { final DateFormat additionFormatter = UtilString.getAdditionDateFormatter(); CategoryDataset cdata = null; JFreeChart jfchart = null; // number of months we show, mounts // before are set together in 'before' int iMonthsNumber = 5; // contains number of tracks for each month, first cell is 'before' // data int iTracksByMonth[] = new int[iMonthsNumber + 1]; int[] iMounts = getMonths(iMonthsNumber); ReadOnlyIterator<Track> tracks = TrackManager.getInstance().getTracksIterator(); while (tracks.hasNext()) { Track track = tracks.next(); int i = Integer.parseInt(additionFormatter.format(track.getDiscoveryDate())) / 100; for (int j = 0; j < iMonthsNumber + 1; j++) { if (i <= iMounts[j]) { iTracksByMonth[j]++; } } } double[][] data = new double[1][iMonthsNumber + 1]; // cannot use System.arraycopy() here because we have different types in // the arrays... // System.arraycopy(iTracksByMonth, 0, data[0], 0, iMonthsNumber); for (int i = 0; i < iMonthsNumber + 1; i++) { data[0][i] = iTracksByMonth[i]; } cdata = DatasetUtilities.createCategoryDataset(new String[] { "" }, getMonthsLabels(iMonthsNumber), data); // chart, use local copy of method to use better format string for // tooltips jfchart = createBarChart3D(Messages.getString("StatView.12"), // chart // title Messages.getString("StatView.13"), // domain axis label Messages.getString("StatView.14"), // range axis label cdata, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false, // urls "{1} = {2}"); CategoryPlot plot = jfchart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 8.0, CategoryLabelWidthType.CATEGORY, 0); axis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // set the background color for the chart... plot.setNoDataMessage(Messages.getString("StatView.15")); plot.setForegroundAlpha(0.5f); plot.setBackgroundAlpha(0.5f); // plot.setBackgroundImage(IconLoader.IMAGES_STAT_PAPER).getImage()); return new ChartPanel(jfchart); } catch (Exception e) { Log.error(e); return null; } }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *//* w w w .j a v a 2 s . c o m*/ protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.getDomainAxis().setTickLabelsVisible( //barPlot.isShowTickLabels() true); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; barRenderer.setSeriesPaint(0, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3)); barRenderer.setSeriesPaint(1, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.getDomainAxis().setTickLabelsVisible( //barPlot.isShowTickLabels() true);/* w w w . j a v a 2 s . c o m*/ CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3)); barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }