Examples of JFreeChart


Examples of org.jfree.chart.JFreeChart

   
    ChartTheme theme = ChartUtil.getChartTheme(themeName);
   
    ChartContext chartContext = new ConvertChartContext(chart);
   
    JFreeChart jfreeChart = null;
    try
    {
      jfreeChart = theme.createChart(chartContext);
    }
    catch (JRException e)
View Full Code Here

Examples of org.jfree.chart.JFreeChart

          ? JRFontUtil.getAwtFont(chartSettings.getTitleFont(), Locale.getDefault())
          : TextTitle.DEFAULT_FONT;
      
        String titleText = spiderchartBean.getTitleText();
       
        JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true);

    Color backcolor = chartSettings.getBackcolor() != null ? chartSettings.getBackcolor() : element.getBackcolor();
        if(backcolor != null)
    {
      jfreechart.setBackgroundPaint(backcolor);
    }
   
    RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP);
   
    if (titleText != null)
    {
      TextTitle title = jfreechart.getTitle();
      title.setText(titleText);
      if(chartSettings.getTitleColor() != null)
      {
        title.setPaint(chartSettings.getTitleColor());
      }
     
      title.setFont(titleFont);
      title.setPosition(titleEdge);
      jfreechart.setTitle(title);
    }

        String subtitleText = spiderchartBean.getSubtitleText();
    if (subtitleText != null)
    {
      TextTitle subtitle = new TextTitle(subtitleText);
      subtitle.setText(subtitleText);
      if(chartSettings.getSubtitleColor() != null)
      {
        subtitle.setPaint(chartSettings.getSubtitleColor());
      }

      if(chartSettings.getSubtitleColor() != null)
      {
            Font subtitleFont = chartSettings.getSubtitleFont() != null
            ? JRFontUtil.getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault())
            : TextTitle.DEFAULT_FONT;
        subtitle.setFont(subtitleFont);
      }
     
      subtitle.setPosition(titleEdge);

      jfreechart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreechart.getLegend();

    if (legend != null)
    {
      legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend()));
      if (legend.isVisible())
View Full Code Here

Examples of org.jfree.chart.JFreeChart

  public AbstractShape createShape(String name) {
      AbstractShape res = null;
     
    if (name.equals(PLOT_STANDARD)) {
      SourceXYDataset dst = new SourceXYDataset();
      JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dst, true, true, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new StandardPlotShape(chart);;
   
    } else if (name.equals(AREA_CHART)) {
      SourceXYDataset dst = new SourceXYDataset();
      JFreeChart chart = ChartFactory.createXYAreaChart("", "", "", dst, PlotOrientation.VERTICAL, true, true, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new AreaPlotShape(chart);;
   
    } else if (name.equals(PLOT_CYCLIC)) {
      SourceXYDataset dst = new SourceXYDataset();
      JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dst, true, true, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new CyclicPlotShape(chart);;
   
    } else if (name.equals(PLOT_SCATTER)) {
      SourceXYDataset dst = new SourceXYDataset();
      JFreeChart chart = ChartFactory.createScatterPlot("", "", "", dst, PlotOrientation.VERTICAL, true, true, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      XYPlot plot = chart.getXYPlot();
      NumberAxis axis = new NumberAxis();
      plot.setDomainAxis(axis);
      axis.setAutoRange(true);
      axis.setAutoRangeIncludesZero(false);
      ValueAxis vaxis = plot.getRangeAxis();
      axis.setAutoRange(true);
      if (vaxis instanceof NumberAxis) {((NumberAxis)vaxis).setAutoRangeIncludesZero(false);}
      res = new ScatterPlotShape(chart);;
   
    } else if (name.equals(PLOT_PARAMETRIC)) {
      SourceXYDataset dst = new SourceXYDataset();
      JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dst, true, true, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      XYPlot plot = chart.getXYPlot();
      NumberAxis axis = new NumberAxis();
      plot.setDomainAxis(axis);
      axis.setAutoRange(true);
      axis.setAutoRangeIncludesZero(false);
      ValueAxis vaxis = plot.getRangeAxis();
      axis.setAutoRange(true);
      if (vaxis instanceof NumberAxis) {((NumberAxis)vaxis).setAutoRangeIncludesZero(false);}
      res = new ParametricPlotShape(chart);
   
    } else if (name.equals(METER)) {
      SourceMeterDataset dst = new SourceMeterDataset();
      DatasetDelegatedMeterPlot plot = new DatasetDelegatedMeterPlot(dst);
      plot.setDialShape(DialShape.CIRCLE);
      JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new MeterShape(chart);
   
    } else if (name.equals(BAR_CHART)) {
      SourceCategoryDataset dst = new SourceCategoryDataset();
      JFreeChart chart = ChartFactory.createBarChart("","","",dst,PlotOrientation.VERTICAL,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new BarChartShape(chart);
   
    } else if (name.equals(BAR_CHAR_3D)) {
      SourceCategoryDataset dst = new SourceCategoryDataset();
      JFreeChart chart = ChartFactory.createBarChart3D("","","",dst,PlotOrientation.VERTICAL,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new BarChartShape(chart);
   
    } else if (name.equals(BAR_CHART_STACKED)) {
      SourceCategoryDataset dst = new SourceCategoryDataset();
      JFreeChart chart = ChartFactory.createStackedBarChart("","","",dst,PlotOrientation.VERTICAL,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new BarChartShape(chart);
   
    } else if (name.equals(BAR_CHART_STACKED_3D)) {
      SourceCategoryDataset dst = new SourceCategoryDataset();
      JFreeChart chart = ChartFactory.createStackedBarChart3D("","","",dst,PlotOrientation.VERTICAL,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new BarChartShape(chart);
   
    } else if (name.equals(PIE_CHART)) {
      SourcePieDataset dst = new SourcePieDataset();
      JFreeChart chart = ChartFactory.createPieChart("",dst,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new PieChartShape(chart);
 
    } else if (name.equals(PIE_CHART_3D)) {
      SourcePieDataset dst = new SourcePieDataset();
      JFreeChart chart = ChartFactory.createPieChart3D("",dst,true,true,false);
      chart.setAntiAlias(AbstractShape.ANTI_ALIASING);
      res = new PieChartShape(chart);
    }   
    return res;
  }
View Full Code Here

Examples of org.jfree.chart.JFreeChart

    private static void drawImage(OutputStream os, int width, int height, double unavailable)
        throws Exception {
        // create dataset...
        final PieDataset dataset = createDataset(unavailable);
        // create the chart...
        final JFreeChart chart = createChart(dataset);
        // return as image
        // Encode as a JPEG
        JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(os);
        jpeg.encode(chart.createBufferedImage(width, height));
    }
View Full Code Here

Examples of org.jfree.chart.JFreeChart

     *
     * @return A chart.
     */
    private static JFreeChart createChart(final PieDataset dataset) {

        final JFreeChart chart = ChartFactory.createPieChart(
                null, // chart title
                dataset, // data
                false, // include legend
                false,
                false);
        // E6EEF9
        chart.setBackgroundPaint(new Color(230, 238, 249));
        chart.setBorderVisible(false);
       
        final PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelLinkPaint(Color.red);
        plot.setLabelGap(0.02);
View Full Code Here

Examples of org.jfree.chart.JFreeChart

    private static void drawImage(OutputStream os, int width, int height,
        Map<String, ObjectAttribute> whole, Map<String, ObjectAttribute> others) throws Exception {
        // create dataset...
        final PieDataset dataset = createDataset(whole, others);
        // create the chart...
        final JFreeChart chart = createChart(dataset);
        // return as image
        // Encode as a JPEG
        JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(os);
        jpeg.encode(chart.createBufferedImage(width, height));
    }
View Full Code Here

Examples of org.jfree.chart.JFreeChart

     *
     * @return A chart.
     */
    private static JFreeChart createChart(final PieDataset dataset) {

        final JFreeChart chart = ChartFactory.createPieChart(
                null, // chart title
                dataset, // data
                false, // include legend
                false,
                false);
        // E6EEF9
        chart.setBackgroundPaint(new Color(230, 238, 249));
        chart.setBorderVisible(false);
       
        final PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelLinkPaint(Color.red);
        plot.setLabelGap(0.02);
View Full Code Here

Examples of org.jfree.chart.JFreeChart

   */
  public JFreeChart createChart(ChartContext chartContext) throws JRException
  {
    this.chartContext = chartContext;
   
    JFreeChart jfreeChart = null;
   
    switch(getChart().getChartType()) {
      case JRChart.CHART_TYPE_AREA:
        jfreeChart = createAreaChart();
        break;
View Full Code Here

Examples of org.jfree.chart.JFreeChart

   *
   */
  protected JFreeChart createAreaChart() throws JRException
  {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart =
      ChartFactory.createAreaChart(
        (String)evaluateExpression(getChart().getTitleExpression()),
        (String)evaluateExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()),
        (String)evaluateExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()),
        (CategoryDataset)getDataset(),
        getPlot().getOrientation(),
        isShowLegend(),
        true,
        false);

    configureChart(jfreeChart);
    JRAreaPlot areaPlot = (JRAreaPlot)getPlot();
    // Handle the axis formating for the category axis
    configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
        areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
        areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(),
        areaPlot.getCategoryAxisLineColor(), false,
        (Comparable)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
        (Comparable)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));
   
    // Handle the axis formating for the value axis
    configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(),
        areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
        areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(),
        areaPlot.getValueAxisLineColor(), true,
        (Comparable)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
        (Comparable)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));
View Full Code Here

Examples of org.jfree.chart.JFreeChart


  protected JFreeChart createBar3DChart() throws JRException
  {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart =
      ChartFactory.createBarChart3D(
          (String)evaluateExpression(getChart().getTitleExpression()),
          (String)evaluateExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
          (String)evaluateExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
          (CategoryDataset)getDataset(),
          getPlot().getOrientation(),
          isShowLegend(),
          true,
          false );

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
    JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot();

    BarRenderer3D barRenderer3D =
      new BarRenderer3D(
        bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble().doubleValue(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.