Package org.jfree.chart.renderer.category

Examples of org.jfree.chart.renderer.category.BarRenderer


    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // set the max width of each bar
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setMaxBarWidth(0.10);

    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
    response.setContentType("image/jpeg");
View Full Code Here


    // set the X axis labels to be slanted
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 3.0));
   
    // set the max width of each bar
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setMaxBarWidth(0.10);

    // format the number labels on the Y axis
    // TODO: figure out how to format the Y axis values as US Currency

View Full Code Here

    {
      final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS
      final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS
      final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS

      final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer());
      plot.setRenderer(1, new LineAndShapeRenderer());

      // add lines dataset and axis to plot
      plot.setDataset(1, createDataset());
      plot.setRangeAxis(1, linesAxis);
View Full Code Here

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);
    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    final BarRenderer br = (BarRenderer) renderer;
    br.setDrawBarOutline(isChartSectionOutline());
    if (maxBarWidth != null)
    {
      br.setMaximumBarWidth(maxBarWidth.doubleValue());
    }

    if (itemMargin != null)
    {
      br.setItemMargin(itemMargin.doubleValue());
    }
   
    if ((isStacked()) && stackedBarRenderPercentages && (br instanceof StackedBarRenderer))
    {
      final StackedBarRenderer sbr = (StackedBarRenderer) br;
View Full Code Here

        barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
        barPlot.getValueAxisLineColor(), true,
        (Comparable)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
        (Comparable)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();
    categoryRenderer.setBaseItemLabelsVisible( isShowLabels );
    if(isShowLabels)
    {
      JRItemLabel itemLabel = barPlot.getItemLabel();
      JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null);
      categoryRenderer.setBaseItemLabelFont(JRFontUtil.getAwtFont(font, getLocale()));
      if(itemLabel != null)
      {
        if(itemLabel.getColor() != null)
        {
          categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor());
        }
        else
        {
          categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
        }
//        categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//        if(itemLabel.getMask() != null)
//        {
//          categoryRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//              StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING,
//              new DecimalFormat(itemLabel.getMask())));
//        }
//        else
//        {
          categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//        }
      }
      else
      {
        categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
        categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
      }
    }
    categoryRenderer.setShadowVisible(false);
   
    return jfreeChart;
  }
View Full Code Here

//        categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().
//        true
//        );
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer)categoryRenderer;
    List seriesPaints = (List)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
    barRenderer.setSeriesPaint(0, (Paint)seriesPaints.get(3));
    barRenderer.setSeriesPaint(1, (Paint)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);
      }
View Full Code Here

        (Comparable)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
        (Comparable)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
        );


    BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();
    categoryRenderer.setBaseItemLabelsVisible( isShowLabels );
    if(isShowLabels)
    {
      JRItemLabel itemLabel = barPlot.getItemLabel();
      JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null);
      categoryRenderer.setBaseItemLabelFont(JRFontUtil.getAwtFont(font, getLocale()));
      if(itemLabel != null)
      {
        if(itemLabel.getColor() != null)
        {
          categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor());
        }
        else
        {
          categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
        }
//        categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//        if(itemLabel.getMask() != null)
//        {
//          categoryRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//              StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING,
//              new DecimalFormat(itemLabel.getMask())));
//        }
//        else
//        {
          categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//        }
      }
      else
      {
        categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
        categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
      }
    }
   
    categoryRenderer.setShadowVisible(false);
   
    return jfreeChart;
  }
View Full Code Here

    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);

    BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
        barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
        barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
View Full Code Here

      barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
      (Comparable)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
      (Comparable)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
      );

    BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    return jfreeChart;
  }
View Full Code Here

        barPlot.getOwnValueAxisLineColor(), true,
        (Comparable)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
        (Comparable)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));


    BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();
    categoryRenderer.setBaseItemLabelsVisible( isShowLabels );
    if(isShowLabels)
    {
      JRItemLabel itemLabel = barPlot.getItemLabel();
      Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
      JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
      categoryRenderer.setBaseItemLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

      if(itemLabel != null)
      {
        if(itemLabel.getColor() != null)
        {
          categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor());
        }
        else
        {
          categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
        }
//        categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//        if(itemLabel.getMask() != null)
//        {
//          categoryRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//              StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING,
//              new DecimalFormat(itemLabel.getMask())));
//        }
//        else
//        {
          categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//        }
      }
      else
      {
        categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
        categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
      }
    }
    categoryRenderer.setShadowVisible(false);
   
    return jfreeChart;
  }
View Full Code Here

TOP

Related Classes of org.jfree.chart.renderer.category.BarRenderer

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.