private CategoryLabelPositions categoryLabelPosition(String position) { if (position == null) { return CategoryLabelPositions.STANDARD; } else if (position.equals("UP_45")) { return CategoryLabelPositions.UP_45; } else if (position.equals("UP_90")) { return CategoryLabelPositions.UP_90; } else if (position.equals("DOWN_45")) { return CategoryLabelPositions.DOWN_45; } else if (position.equals("DOWN_90")) { return CategoryLabelPositions.DOWN_90; } double angle = Double.parseDouble(position); if (angle>0) { return CategoryLabelPositions.createUpRotationLabelPositions(angle); } else { return CategoryLabelPositions.createDownRotationLabelPositions(-angle); } }
public void setCategoryLabelRotation( final Node rotationDirection, final Node rotationAngle ) { // down is the default String direction = "down"; //$NON-NLS-1$ if ( rotationDirection != null ) { direction = rotationDirection.getText(); } if ( rotationAngle != null ) { if ( "up".equalsIgnoreCase( direction ) ) { //$NON-NLS-1$ setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Double .parseDouble( rotationAngle.getText() ) ) ); } else { setCategoryLabelPositions( CategoryLabelPositions.createDownRotationLabelPositions( Double .parseDouble( rotationAngle.getText() ) ) ); } } }
CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0));
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setShadowPaint(Color.LIGHT_GRAY); renderer.setShadowVisible(true); CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); } }
setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.45D));
/** * It creates a chart for the given dataset and adds the chart to the panel. * * @param dataset The dataset that will provide the values for the chart. */ private void addChart() { JFreeChart chart = ChartFactory.createStackedBarChart3D( getTitle(), null, "Breakdown" + unitSuffix(), dataset, PlotOrientation.VERTICAL, true, true, false); CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); chart.addProgressListener(locker); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(dataset); mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); }
CategoryLabelPositions.createUpRotationLabelPositions( (-labelRotation / 180.0) * Math.PI));