Package org.jfree.chart.axis

Examples of org.jfree.chart.axis.CategoryAxis


    protected void calculateBarWidth(CategoryPlot plot,
                                     Rectangle2D dataArea,
                                     int rendererIndex,
                                     CategoryItemRendererState state) {

        CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
        CategoryDataset dataset = plot.getDataset(rendererIndex);
        if (dataset != null) {
            int columns = dataset.getColumnCount();
            int rows = state.getVisibleSeriesCount() >= 0
                    ? state.getVisibleSeriesCount() : dataset.getRowCount();
            double space = 0.0;
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                space = dataArea.getHeight();
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                space = dataArea.getWidth();
            }
            double maxWidth = space * getMaximumBarWidth();
            double categoryMargin = 0.0;
            double currentItemMargin = 0.0;
            if (columns > 1) {
                categoryMargin = domainAxis.getCategoryMargin();
            }
            if (rows > 1) {
                currentItemMargin = getItemMargin();
            }
            double used = space * (1 - domainAxis.getLowerMargin()
                                     - domainAxis.getUpperMargin()
                                     - categoryMargin - currentItemMargin);
            if ((rows * columns) > 0) {
                state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
            }
            else {
View Full Code Here


     */
    protected void calculateItemWidth(CategoryPlot plot,
            Rectangle2D dataArea, int rendererIndex,
            CategoryItemRendererState state) {

        CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
        CategoryDataset dataset = plot.getDataset(rendererIndex);
        if (dataset != null) {
            int columns = dataset.getColumnCount();
            int rows = state.getVisibleSeriesCount() >= 0
                    ? state.getVisibleSeriesCount() : dataset.getRowCount();
            double space = 0.0;
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                space = dataArea.getHeight();
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                space = dataArea.getWidth();
            }
            double maxWidth = space * getMaximumItemWidth();
            double categoryMargin = 0.0;
            double currentItemMargin = 0.0;
            if (columns > 1) {
                categoryMargin = domainAxis.getCategoryMargin();
            }
            if (rows > 1) {
                currentItemMargin = getItemMargin();
            }
            double used = space * (1 - domainAxis.getLowerMargin()
                                     - domainAxis.getUpperMargin()
                                     - categoryMargin - currentItemMargin);
            if ((rows * columns) > 0) {
                state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
            }
            else {
View Full Code Here

        // calculate the bar width - this calculation differs from the
        // BarRenderer calculation because the bars are layered on top of one
        // another, so there is effectively only one bar per category for
        // the purpose of the bar width calculation
        CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
        CategoryDataset dataset = plot.getDataset(rendererIndex);
        if (dataset != null) {
            int columns = dataset.getColumnCount();
            int rows = dataset.getRowCount();
            double space = 0.0;
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                space = dataArea.getHeight();
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                space = dataArea.getWidth();
            }
            double maxWidth = space * getMaximumBarWidth();
            double categoryMargin = 0.0;
            if (columns > 1) {
                categoryMargin = domainAxis.getCategoryMargin();
            }
            double used = space * (1 - domainAxis.getLowerMargin()
                - domainAxis.getUpperMargin() - categoryMargin);
            if ((rows * columns) > 0) {
                state.setBarWidth(Math.min(used / (dataset.getColumnCount()),
                        maxWidth));
            }
            else {
View Full Code Here

     * @param index  the axis index.
     *
     * @return A domain axis.
     */
    protected CategoryAxis getDomainAxis(CategoryPlot plot, int index) {
        CategoryAxis result = plot.getDomainAxis(index);
        if (result == null) {
            result = plot.getDomainAxis();
        }
        return result;
    }
View Full Code Here

        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setMaximumBarWidth(0.5);

        final CategoryAxis xAxis = new CategoryAxis(dataName);
        final NumberAxis yAxis = new NumberAxis(getMessage("ChartsUtils.report.box-plot.values-range"));
        yAxis.setAutoRangeIncludesZero(false);
        renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
        plot.setRenderer(renderer);
View Full Code Here

    protected void setupCategoryChart(JFreeChart chart) {

        if (!(chart.getPlot() instanceof CategoryPlot)) return;
        CategoryPlot cp = chart.getCategoryPlot();

        CategoryAxis catAxis = cp.getDomainAxis();
        ValueAxis otherAxis  = cp.getRangeAxis();

        if (!chromeless) {
            String catAxisLabel = data.getColName(0);
            if (catAxisLabel == null)
                catAxisLabel = Translator.translate("Project/Task");

            String otherAxisLabel = Translator.translate(getSetting("units"));
            if ((otherAxisLabel == null || otherAxisLabel.length() == 0)
                && data.numCols() == 1)
                otherAxisLabel = data.getColName(1);
            if (otherAxisLabel == null)
                otherAxisLabel = Translator.translate("Value");

            String catLabels = getParameter("categoryLabels");

            catAxis.setLabel(catAxisLabel);
            otherAxis.setLabel(otherAxisLabel);
            if ("vertical".equalsIgnoreCase(catLabels))
                catAxis.setVerticalCategoryLabels(true);
            else if ("none".equalsIgnoreCase(catLabels))
                catAxis.setTickLabelsVisible(false);
        }

        if (data.numCols() == 1) {
            chart.setLegend(null);
            chart.getPlot().setInsets(new Insets(5,2,2,5));
View Full Code Here

    protected void setupCategoryChart(JFreeChart chart) {

        if (!(chart.getPlot() instanceof CategoryPlot)) return;
        CategoryPlot cp = chart.getCategoryPlot();

        CategoryAxis catAxis = cp.getDomainAxis();
        ValueAxis otherAxis  = cp.getRangeAxis();

        if (!chromeless) {
            String catAxisLabel = data.getColName(0);
            if (catAxisLabel == null)
                catAxisLabel = Translator.translate("Project/Task");

            String otherAxisLabel = Translator.translate(getSetting("units"));
            if ((otherAxisLabel == null || otherAxisLabel.length() == 0)
                && data.numCols() == 1)
                otherAxisLabel = data.getColName(1);
            if (otherAxisLabel == null)
                otherAxisLabel = Translator.translate("Value");

            String catLabels = getParameter("categoryLabels");

            catAxis.setLabel(catAxisLabel);
            otherAxis.setLabel(otherAxisLabel);
            if ("vertical".equalsIgnoreCase(catLabels))
                catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
            else if ("none".equalsIgnoreCase(catLabels))
                catAxis.setTickLabelsVisible(false);
        }

        if (data.numCols() == 1) {
            chart.removeLegend();
            chart.getPlot().setInsets(new RectangleInsets(5,2,2,5));
View Full Code Here

   
    diagramWindow.setVisible(true);
//    diagramWindow.getPanel().setImg(cs.createBufferedImage(350, 350));
   
    final CategoryPlot plot = cs.getCategoryPlot();
    final CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions
        .createUpRotationLabelPositions(Math.PI / 8.0));

  }
View Full Code Here

  private JFreeChart createStackedBarChart(ReportChart reportChart,
      ChartValue[] values, boolean displayInline)
  {
    CategoryDataset dataset = createCategoryDataset(values);

    CategoryAxis categoryAxis = new CategoryAxis3D(reportChart.getXAxisLabel());
    ValueAxis valueAxis = new NumberAxis3D(reportChart.getYAxisLabel());

    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
View Full Code Here

          axis.setTickLabelFont(tickLabelFont);
        }

        // 设置分类/标题轴的信息
        {
          CategoryAxis axis = plot.getDomainAxis();
          axis.setLabelFont(labelFont);
          axis.setTickLabelFont(tickLabelFont);
        }
      }
      break;
    }
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.axis.CategoryAxis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.