예제 #1
1
 private static JFreeChart createChart(CategoryDataset categorydataset) {
   JFreeChart jfreechart =
       ChartFactory.createBarChart(
           "Bar Chart Demo 1",
           "Category",
           "Value",
           categorydataset,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   categoryplot.setDomainGridlinesVisible(true);
   categoryplot.setRangeCrosshairVisible(true);
   categoryplot.setRangeCrosshairPaint(Color.blue);
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
   barrenderer.setDrawBarOutline(false);
   GradientPaint gradientpaint =
       new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
   GradientPaint gradientpaint1 =
       new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
   GradientPaint gradientpaint2 =
       new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
   barrenderer.setSeriesPaint(0, gradientpaint);
   barrenderer.setSeriesPaint(1, gradientpaint1);
   barrenderer.setSeriesPaint(2, gradientpaint2);
   barrenderer.setLegendItemToolTipGenerator(
       new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
   CategoryAxis categoryaxis = categoryplot.getDomainAxis();
   categoryaxis.setCategoryLabelPositions(
       CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
   return jfreechart;
 }
 /**
  * Returns a domain axis for a plot.
  *
  * @param plot the plot.
  * @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;
 }
  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;
    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);
      }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
  }
 private static JFreeChart createChart(CategoryDataset categorydataset) {
   JFreeChart jfreechart =
       ChartFactory.createLineChart(
           "Statistical Line Chart Demo 1",
           "Type",
           "Value",
           categorydataset,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   jfreechart.setBackgroundPaint(Color.white);
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   categoryplot.setBackgroundPaint(Color.lightGray);
   categoryplot.setRangeGridlinePaint(Color.white);
   CategoryAxis categoryaxis = categoryplot.getDomainAxis();
   categoryaxis.setUpperMargin(0.0D);
   categoryaxis.setLowerMargin(0.0D);
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   numberaxis.setAutoRangeIncludesZero(true);
   StatisticalLineAndShapeRenderer statisticallineandshaperenderer =
       new StatisticalLineAndShapeRenderer(true, false);
   statisticallineandshaperenderer.setUseSeriesOffset(true);
   categoryplot.setRenderer(statisticallineandshaperenderer);
   return jfreechart;
 }
예제 #5
0
 private static JFreeChart finishBarChart(JFreeChart chart, Color... colors) {
   CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
   categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
   categoryplot.setRangePannable(true);
   if (colors.length > 0) categoryplot.setRenderer(new CustomRenderer(colors));
   BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
   barrenderer.setItemLabelAnchorOffset(9D);
   barrenderer.setBaseItemLabelsVisible(true);
   barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
   barrenderer.setMaximumBarWidth(0.05);
   barrenderer.setItemMargin(0.03D);
   ItemLabelPosition itemlabelposition =
       new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT, -1.5707963267948966D);
   barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
   ItemLabelPosition itemlabelposition1 =
       new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT, -1.5707963267948966D);
   barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
   CategoryAxis categoryaxis = categoryplot.getDomainAxis();
   categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
   categoryaxis.setCategoryMargin(0.25D);
   categoryaxis.setUpperMargin(0.02D);
   categoryaxis.setLowerMargin(0.02D);
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   numberaxis.setUpperMargin(0.10000000000000001D);
   ChartUtilities.applyCurrentTheme(chart);
   return chart;
 }
  protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
      CategoryPlot categoryPlot = (CategoryPlot) plot;
      CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
      CategoryDataset categoryDataset = categoryPlot.getDataset();
      if (categoryDataset != null) {
        for (int i = 0; i < categoryDataset.getRowCount(); i++) {
          categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
        }
      }
      categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
      categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
      categoryPlot.setDomainGridlinesVisible(false);
      categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
      XYPlot xyPlot = (XYPlot) plot;
      XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
      XYDataset xyDataset = xyPlot.getDataset();
      if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
          xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
        }
      }
      xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
      xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
      xyPlot.setDomainGridlinesVisible(false);
      xyPlot.setRangeZeroBaselineVisible(true);
    }
  }
예제 #7
0
  public static void main(String[] args) throws IOException {
    JFreeChart chart =
        ChartFactory.createBarChart3D(
            "图书销量统计图",
            "图书", // 目录轴的显示标签
            "销量", // 数值轴的显示标签
            getDataSet(),
            PlotOrientation.VERTICAL, // 设置图表方向
            false,
            false,
            false);

    // 设置标题
    chart.setTitle(new TextTitle("图书销量统计图", new Font("黑体", Font.ITALIC, 22)));
    // 设置图表部分
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    CategoryAxis categoryAxis = plot.getDomainAxis(); // 取得横轴
    categoryAxis.setLabelFont(new Font("宋体", Font.BOLD, 22)); // 设置横轴显示标签的字体
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 分类标签以45度倾斜
    categoryAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 18)); // 分类标签字体

    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); // 取得纵轴
    numberAxis.setLabelFont(new Font("宋体", Font.BOLD, 42)); // 设置纵轴显示标签字体
    FileOutputStream fos = null;
    fos = new FileOutputStream("book1.jpg");
    ChartUtilities.writeChartAsJPEG(fos, 1, chart, 800, 600, null);

    fos.close();
  }
예제 #8
0
 private static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
   JFreeChart localJFreeChart =
       ChartFactory.createAreaChart(
           "Area Chart",
           "Category",
           "Value",
           paramCategoryDataset,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   localJFreeChart.setBackgroundPaint(Color.white);
   TextTitle localTextTitle =
       new TextTitle(
           "An area chart demonstration.  We use this subtitle as an example of what happens when you get a really long title or subtitle.");
   localTextTitle.setPosition(RectangleEdge.TOP);
   localTextTitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05D, 0.05D, 0.05D, 0.05D));
   localTextTitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
   localJFreeChart.addSubtitle(localTextTitle);
   CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
   localCategoryPlot.setForegroundAlpha(0.5F);
   localCategoryPlot.setDomainGridlinesVisible(true);
   CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
   localCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
   localCategoryAxis.setLowerMargin(0.0D);
   localCategoryAxis.setUpperMargin(0.0D);
   localCategoryAxis.addCategoryLabelToolTip("Type 1", "The first type.");
   localCategoryAxis.addCategoryLabelToolTip("Type 2", "The second type.");
   localCategoryAxis.addCategoryLabelToolTip("Type 3", "The third type.");
   NumberAxis localNumberAxis = (NumberAxis) localCategoryPlot.getRangeAxis();
   localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   localNumberAxis.setLabelAngle(0.0D);
   ChartUtilities.applyCurrentTheme(localJFreeChart);
   return localJFreeChart;
 }
예제 #9
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private static JFreeChart createchart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "Bar Chart Demo 1", // chart
            // title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // ******************************************************************
    // More than 150 demo applications are included with the JFreeChart
    // Developer Guide...for more information, see:
    //
    // > http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

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

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    // renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
예제 #10
0
  private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart =
        ChartFactory.createLineChart(
            "Daily Stock Report", // chart title
            "Type", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
            );
    chart.setBackgroundPaint(Color.white);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(
        0,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {10.0f, 6.0f},
            0.0f));
    renderer.setSeriesStroke(
        1,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {6.0f, 6.0f},
            0.0f));
    renderer.setSeriesStroke(
        2,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {2.0f, 6.0f},
            0.0f));
    return chart;
  }
  /**
   * Erstellt ein Stabdiagramm aus den Parametern.
   *
   * @param dataset Datenset
   * @param titel Titel
   * @return {@link JFreeChart}
   */
  protected JFreeChart erstelleDiagramm(
      CategoryDataset dataset,
      String titel,
      String reihenBeschriftung,
      String spaltenBeschriftung) {
    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart3D(
            titel,
            reihenBeschriftung,
            spaltenBeschriftung,
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);

    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.CENTER);
    t.setFont(new Font("Arial", Font.CENTER_BASELINE, 26));

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    for (int i = 0; i < parteienListe.size(); i++) {
      if (parteienListe.get(i).getFarbe() != null) {
        GradientPaint gp =
            new GradientPaint(
                0.0f,
                0.0f,
                parteienListe.get(i).getFarbe(),
                0.0f,
                0.0f,
                new Color(parteienListe.get(i).getFarbe().getRGB()));
        renderer.setSeriesPaint(i, gp);
      }
    }

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;
  }
예제 #12
0
  /**
   * Method returns a constructed, fully customised chart.
   *
   * @param dataset - dataset from the de-serialized Statistics object
   * @return JFreeChart chart
   */
  private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "Time taken/Cells covered Performance", // Title of the chart
            "", // X Axis label
            "Time taken", // Y axis label
            dataset, // Data used for the chart
            PlotOrientation.VERTICAL, // Orientation of the chart to be drawn
            false, // Legend
            true, // Tooltips
            false // URL
            );

    // Display an additional label undeneath the bar chart to tell the user to hover over the bar
    // chart to see more deatils
    TextTitle legendText = new TextTitle("* Hover over the bar to see the cells covered.");
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    // Background for the chart
    chart.setBackgroundPaint(Color.white);

    // Store reference to the plot to customise it
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // Y axis should display integers only (so that the time taken is given in second integers)
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // Set the colours for the graphs
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    // Set up the X axis so that the title appears diagonal
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;
  }
  private void createBarchart(
      String title,
      String categoryLabel,
      String valueLabel,
      PlotData[] data,
      String[] dataLabels,
      String filename) {

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int maxDataLength = 0;

    for (int i = 0; i < dataLabels.length; i++) {
      for (int j = 0; j < data[i].getData().length; j++) {
        dataSet.addValue(data[i].getData()[j], dataLabels[i], data[i].getLabels()[j]);
      }
      if (maxDataLength < data[i].getData().length) {
        maxDataLength = data[i].getData().length;
      }
    }

    JFreeChart chart =
        ChartFactory.createBarChart(
            title,
            categoryLabel,
            valueLabel,
            dataSet,
            PlotOrientation.VERTICAL,
            dataLabels.length > 1, // display legend
            false,
            false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    xAxis.setMaximumCategoryLabelLines(6);

    // chart.setBackgroundPaint(ChartColor.WHITE);
    int width = 50 + maxDataLength * 170;
    if (maxDataLength < 3) {
      width += 170;
    }
    int height = 400;
    try {
      File file = new File(contextPath + filename);
      ChartUtilities.saveChartAsPNG(file, chart, width, height);
    } catch (IOException e) {
      LOG.warn("createBarchart(): ", e);
    }
  }
예제 #14
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "", // chart
            // title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

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

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
예제 #15
0
  /** カテゴリ(横)軸を設定するメソッド */
  public void setCategoryAxisByDoc(Document doc)
      throws IllegalAccessException, NoSuchFieldException {

    Element root = doc.getDocumentElement();
    Element category = (Element) root.getElementsByTagName("Category").item(0);
    String categoryLabelColor =
        category.getElementsByTagName("LabelColor").item(0).getFirstChild().getNodeValue();

    CategoryPlot categoryPlot = (CategoryPlot) this.getPlot();
    CategoryAxis categoryAxis = categoryPlot.getDomainAxis(); // 軸の取得
    categoryAxis.setLabelPaint(this.createColor(categoryLabelColor)); // カテゴリラベルカラー

    categoryAxis.setLabelFont(this.getFont(doc)); // フォント
    categoryAxis.setTickLabelFont(this.getFont(doc)); // Tickラベルフォント
  }
예제 #16
0
  private JFreeChart getBarChart() {
    // Load the data, if necessary
    loadData();

    // Create the vertical bar chart
    final JFreeChart chart =
        ChartFactory.createBarChart(
            getTitle(),
            "",
            "",
            getCategoryDataset(),
            PlotOrientation.HORIZONTAL,
            false,
            true,
            false);
    final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    categoryplot.setNoDataMessage("No data available");

    final BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemLabelAnchorOffset(9D);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    // barrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1} = {2}", new
    // DecimalFormat("0")));
    final CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryMargin(0.25D);

    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    final NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);

    //    if (useLegend())
    //    {
    //      // pieplot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    //      chart.getLegend().setPosition(RectangleEdge.RIGHT);
    //      // pieplot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("{0}:
    // {2}%"));
    //    }

    return chart;
  }
예제 #17
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "Bar Chart Demo 8", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

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

    // disable bar outlines...
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
예제 #18
0
  /**
   * 修改字体
   *
   * @param chart
   */
  private void updateFont(JFreeChart chart) {

    // 标题
    TextTitle textTitle = chart.getTitle();
    textTitle.setFont(new Font("宋体", Font.PLAIN, 20));

    // 图表
    CategoryPlot categoryPlot = chart.getCategoryPlot();

    CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
    // X轴字体
    categoryAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
    // X轴标签字体
    categoryAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));

    ValueAxis valueAxis = categoryPlot.getRangeAxis();
    // y轴字体
    valueAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
    // y轴标签字体
    valueAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));
  }
예제 #19
0
  /**
   * Updates the plot properties to match the properties defined on the panel.
   *
   * @param plot The plot.
   */
  public void updatePlotProperties(Plot plot) {
    // set the plot properties...
    plot.setBackgroundPaint(SWTUtils.toAwtColor(getBackgroundPaint()));
    plot.setOutlinePaint(SWTUtils.toAwtColor(getOutlinePaint()));
    plot.setOutlineStroke(getOutlineStroke());

    // set the axis properties
    if (this.domainAxisPropertyPanel != null) {
      Axis domainAxis = null;
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        domainAxis = p.getDomainAxis();
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        domainAxis = p.getDomainAxis();
      }
      if (domainAxis != null) this.domainAxisPropertyPanel.setAxisProperties(domainAxis);
    }
    if (this.rangeAxisPropertyPanel != null) {
      Axis rangeAxis = null;
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        rangeAxis = p.getRangeAxis();
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        rangeAxis = p.getRangeAxis();
      }
      if (rangeAxis != null) this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis);
    }
    if (this.plotAppearance.getPlotOrientation() != null) {
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        p.setOrientation(this.plotAppearance.getPlotOrientation());
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        p.setOrientation(this.plotAppearance.getPlotOrientation());
      }
    }
  }
 public static JFreeChart createChart() {
   DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
   defaultcategorydataset.addValue(1.0D, "S1", "Category 1");
   defaultcategorydataset.addValue(4D, "S1", "Category 2");
   defaultcategorydataset.addValue(3D, "S1", "Category 3");
   defaultcategorydataset.addValue(5D, "S1", "Category 4");
   defaultcategorydataset.addValue(5D, "S1", "Category 5");
   defaultcategorydataset.addValue(7D, "S1", "Category 6");
   defaultcategorydataset.addValue(7D, "S1", "Category 7");
   defaultcategorydataset.addValue(8D, "S1", "Category 8");
   defaultcategorydataset.addValue(5D, "S2", "Category 1");
   defaultcategorydataset.addValue(7D, "S2", "Category 2");
   defaultcategorydataset.addValue(6D, "S2", "Category 3");
   defaultcategorydataset.addValue(8D, "S2", "Category 4");
   defaultcategorydataset.addValue(4D, "S2", "Category 5");
   defaultcategorydataset.addValue(4D, "S2", "Category 6");
   defaultcategorydataset.addValue(2D, "S2", "Category 7");
   defaultcategorydataset.addValue(1.0D, "S2", "Category 8");
   StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator =
       new StandardCategoryItemLabelGenerator();
   BarRenderer barrenderer = new BarRenderer();
   barrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator);
   barrenderer.setBaseItemLabelsVisible(true);
   CategoryPlot categoryplot = new CategoryPlot();
   categoryplot.setDataset(defaultcategorydataset);
   categoryplot.setRenderer(barrenderer);
   categoryplot.setDomainAxis(new CategoryAxis("Category"));
   categoryplot.setRangeAxis(new NumberAxis("Value"));
   categoryplot.setOrientation(PlotOrientation.VERTICAL);
   categoryplot.setRangeGridlinesVisible(true);
   categoryplot.setDomainGridlinesVisible(true);
   DefaultCategoryDataset defaultcategorydataset1 = new DefaultCategoryDataset();
   defaultcategorydataset1.addValue(9D, "T1", "Category 1");
   defaultcategorydataset1.addValue(7D, "T1", "Category 2");
   defaultcategorydataset1.addValue(2D, "T1", "Category 3");
   defaultcategorydataset1.addValue(6D, "T1", "Category 4");
   defaultcategorydataset1.addValue(6D, "T1", "Category 5");
   defaultcategorydataset1.addValue(9D, "T1", "Category 6");
   defaultcategorydataset1.addValue(5D, "T1", "Category 7");
   defaultcategorydataset1.addValue(4D, "T1", "Category 8");
   LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
   categoryplot.setDataset(1, defaultcategorydataset1);
   categoryplot.setRenderer(1, lineandshaperenderer);
   NumberAxis numberaxis = new NumberAxis("Axis 2");
   categoryplot.setRangeAxis(1, numberaxis);
   DefaultCategoryDataset defaultcategorydataset2 = new DefaultCategoryDataset();
   defaultcategorydataset2.addValue(94D, "R1", "Category 1");
   defaultcategorydataset2.addValue(75D, "R1", "Category 2");
   defaultcategorydataset2.addValue(22D, "R1", "Category 3");
   defaultcategorydataset2.addValue(74D, "R1", "Category 4");
   defaultcategorydataset2.addValue(83D, "R1", "Category 5");
   defaultcategorydataset2.addValue(9D, "R1", "Category 6");
   defaultcategorydataset2.addValue(23D, "R1", "Category 7");
   defaultcategorydataset2.addValue(98D, "R1", "Category 8");
   categoryplot.setDataset(2, defaultcategorydataset2);
   LineAndShapeRenderer lineandshaperenderer1 = new LineAndShapeRenderer();
   categoryplot.setRenderer(2, lineandshaperenderer1);
   categoryplot.mapDatasetToRangeAxis(2, 1);
   categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
   categoryplot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
   JFreeChart jfreechart = new JFreeChart(categoryplot);
   jfreechart.setTitle("Overlaid Bar Chart");
   return jfreechart;
 }
  /**
   * Returns a sequence plot as a ChartPanel.
   *
   * @param aProteinSequencePanelParent the protein sequence panel parent
   * @param sparklineDataset the dataset
   * @param proteinAnnotations the protein annotations
   * @param addReferenceLine if true, a reference line is added
   * @param allowZooming if true, the user can zoom in the created plot/chart
   * @return a sequence plot
   */
  public ChartPanel getSequencePlot(
      ProteinSequencePanelParent aProteinSequencePanelParent,
      JSparklinesDataset sparklineDataset,
      HashMap<Integer, ArrayList<ResidueAnnotation>> proteinAnnotations,
      boolean addReferenceLine,
      boolean allowZooming) {

    this.proteinSequencePanelParent = aProteinSequencePanelParent;
    DefaultCategoryDataset barChartDataset = new DefaultCategoryDataset();
    StackedBarRenderer renderer = new StackedBarRenderer();
    renderer.setShadowVisible(false);
    CategoryToolTipGenerator myTooltips = new ProteinAnnotations(proteinAnnotations);

    // add the data
    for (int i = 0; i < sparklineDataset.getData().size(); i++) {

      JSparklinesDataSeries sparklineDataSeries = sparklineDataset.getData().get(i);

      for (int j = 0; j < sparklineDataSeries.getData().size(); j++) {
        barChartDataset.addValue(sparklineDataSeries.getData().get(j), "" + i, "" + j);
        renderer.setSeriesPaint(i, sparklineDataSeries.getSeriesColor());
        renderer.setSeriesToolTipGenerator(i, myTooltips);
      }
    }

    // create the chart
    JFreeChart chart =
        ChartFactory.createStackedBarChart(
            null, null, null, barChartDataset, PlotOrientation.HORIZONTAL, false, false, false);

    // fine tune the chart properites
    CategoryPlot plot = chart.getCategoryPlot();

    // remove space before/after the domain axis
    plot.getDomainAxis().setUpperMargin(0);
    plot.getDomainAxis().setLowerMargin(0);

    // remove space before/after the range axis
    plot.getRangeAxis().setUpperMargin(0);
    plot.getRangeAxis().setLowerMargin(0);

    renderer.setRenderAsPercentages(true);
    renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator());

    // add the dataset to the plot
    plot.setDataset(barChartDataset);

    // hide unwanted chart details
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);

    // add a reference line in the middle of the dataset
    if (addReferenceLine) {
      DefaultCategoryDataset referenceLineDataset = new DefaultCategoryDataset();
      referenceLineDataset.addValue(1.0, "A", "B");
      plot.setDataset(1, referenceLineDataset);
      LayeredBarRenderer referenceLineRenderer = new LayeredBarRenderer();
      referenceLineRenderer.setSeriesBarWidth(0, referenceLineWidth);
      referenceLineRenderer.setSeriesFillPaint(0, referenceLineColor);
      referenceLineRenderer.setSeriesPaint(0, referenceLineColor);
      plot.setRenderer(1, referenceLineRenderer);
    }

    // set up the chart renderer
    plot.setRenderer(0, renderer);

    // hide the outline
    chart.getPlot().setOutlineVisible(false);

    // make sure the background is the same as the panel
    chart.getPlot().setBackgroundPaint(backgroundColor);
    chart.setBackgroundPaint(backgroundColor);

    final HashMap<Integer, ArrayList<ResidueAnnotation>> blockTooltips = proteinAnnotations;

    // create the chart panel
    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(
        new ChartMouseListener() {

          @Override
          public void chartMouseClicked(ChartMouseEvent cme) {
            if (cme.getEntity() != null && cme.getTrigger().getButton() == MouseEvent.BUTTON1) {

              ((CategoryItemEntity) cme.getEntity()).getDataset();
              Integer blockNumber =
                  new Integer((String) ((CategoryItemEntity) cme.getEntity()).getRowKey());

              ArrayList<ResidueAnnotation> annotation = blockTooltips.get(blockNumber);
              if (annotation != null) {
                proteinSequencePanelParent.annotationClicked(annotation, cme);
              }
            }
          }

          @Override
          public void chartMouseMoved(ChartMouseEvent cme) {

            cme.getTrigger()
                .getComponent()
                .setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

            if (cme.getEntity() != null && cme.getEntity() instanceof CategoryItemEntity) {
              ((CategoryItemEntity) cme.getEntity()).getDataset();
              Integer blockNumber =
                  new Integer((String) ((CategoryItemEntity) cme.getEntity()).getRowKey());

              ArrayList<ResidueAnnotation> annotation = blockTooltips.get(blockNumber);
              if (annotation != null && !annotation.isEmpty()) {
                if (blockTooltips.get(blockNumber).get(0).isClickable()) {
                  cme.getTrigger()
                      .getComponent()
                      .setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
                }
              }
            }
          }
        });

    if (!allowZooming) {
      chartPanel.setPopupMenu(null);
      chartPanel.setRangeZoomable(false);
    }

    chartPanel.setBackground(Color.WHITE);

    return chartPanel;
  }
예제 #22
0
  /** Creates the chart below the statistics table */
  private void createChart() {
    mAllocCountDataSet = new DefaultCategoryDataset();
    mChart =
        ChartFactory.createBarChart(
            null,
            "Size",
            "Count",
            mAllocCountDataSet,
            PlotOrientation.VERTICAL,
            false,
            true,
            false);

    // get the font to make a proper title. We need to convert the swt font,
    // into an awt font.
    Font f = mStatisticsBase.getFont();
    FontData[] fData = f.getFontData();

    // event though on Mac OS there could be more than one fontData, we'll only use
    // the first one.
    FontData firstFontData = fData[0];

    java.awt.Font awtFont =
        SWTUtils.toAwtFont(mStatisticsBase.getDisplay(), firstFontData, true /* ensureSameSize */);

    mChart.setTitle(new TextTitle("Allocation count per size", awtFont));

    Plot plot = mChart.getPlot();
    if (plot instanceof CategoryPlot) {
      // get the plot
      CategoryPlot categoryPlot = (CategoryPlot) plot;

      // set the domain axis to draw labels that are displayed even with many values.
      CategoryAxis domainAxis = categoryPlot.getDomainAxis();
      domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

      CategoryItemRenderer renderer = categoryPlot.getRenderer();
      renderer.setBaseToolTipGenerator(
          new CategoryToolTipGenerator() {
            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {
              // get the key for the size of the allocation
              ByteLong columnKey = (ByteLong) dataset.getColumnKey(column);
              String rowKey = (String) dataset.getRowKey(row);
              Number value = dataset.getValue(rowKey, columnKey);

              return String.format(
                  "%1$d %2$s of %3$d bytes", value.intValue(), rowKey, columnKey.getValue());
            }
          });
    }
    mChartComposite =
        new ChartComposite(
            mStatisticsBase,
            SWT.BORDER,
            mChart,
            ChartComposite.DEFAULT_WIDTH,
            ChartComposite.DEFAULT_HEIGHT,
            ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT,
            3000, // max draw width. We don't want it to zoom, so we put a big number
            3000, // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            false, // zoom
            true); // tooltips

    mChartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
  }
  /**
   * Updates the plot properties to match the properties defined on the panel.
   *
   * @param plot The plot.
   */
  public void updatePlotProperties(Plot plot) {

    // set the plot properties...
    plot.setOutlinePaint(getOutlinePaint());
    plot.setOutlineStroke(getOutlineStroke());
    plot.setBackgroundPaint(getBackgroundPaint());
    plot.setInsets(getPlotInsets());

    // then the axis properties...
    if (this.domainAxisPropertyPanel != null) {
      Axis domainAxis = null;
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        domainAxis = p.getDomainAxis();
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        domainAxis = p.getDomainAxis();
      }
      if (domainAxis != null) {
        this.domainAxisPropertyPanel.setAxisProperties(domainAxis);
      }
    }

    if (this.rangeAxisPropertyPanel != null) {
      Axis rangeAxis = null;
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        rangeAxis = p.getRangeAxis();
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        rangeAxis = p.getRangeAxis();
      } else if (plot instanceof PolarPlot) {
        PolarPlot p = (PolarPlot) plot;
        rangeAxis = p.getAxis();
      }
      if (rangeAxis != null) {
        this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis);
      }
    }

    if (this.plotOrientation != null) {
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        p.setOrientation(this.plotOrientation);
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        p.setOrientation(this.plotOrientation);
      }
    }

    if (this.drawLines != null) {
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        CategoryItemRenderer r = p.getRenderer();
        if (r instanceof LineAndShapeRenderer) {
          ((LineAndShapeRenderer) r).setLinesVisible(this.drawLines.booleanValue());
        }
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        XYItemRenderer r = p.getRenderer();
        if (r instanceof StandardXYItemRenderer) {
          ((StandardXYItemRenderer) r).setPlotLines(this.drawLines.booleanValue());
        }
      }
    }

    if (this.drawShapes != null) {
      if (plot instanceof CategoryPlot) {
        CategoryPlot p = (CategoryPlot) plot;
        CategoryItemRenderer r = p.getRenderer();
        if (r instanceof LineAndShapeRenderer) {
          ((LineAndShapeRenderer) r).setShapesVisible(this.drawShapes.booleanValue());
        }
      } else if (plot instanceof XYPlot) {
        XYPlot p = (XYPlot) plot;
        XYItemRenderer r = p.getRenderer();
        if (r instanceof StandardXYItemRenderer) {
          ((StandardXYItemRenderer) r).setBaseShapesVisible(this.drawShapes.booleanValue());
        }
      }
    }

    // dmo: added this panel for colorbar control. (start dmo additions)
    if (this.colorBarAxisPropertyPanel != null) {
      ColorBar colorBar = null;
      if (plot instanceof ContourPlot) {
        ContourPlot p = (ContourPlot) plot;
        colorBar = p.getColorBar();
      }
      if (colorBar != null) {
        this.colorBarAxisPropertyPanel.setAxisProperties(colorBar);
      }
    }
    // dmo: (end dmo additions)

  }
  private BufferedImage generarGraficoBarrasDistribucionResultados(
      String titulo,
      String ejeHorizontal,
      String ejeVertical,
      double[] valores,
      String[] funciones,
      boolean porcentaje,
      boolean leyenda,
      int intervaloAprobacion,
      int anchoImagen,
      int altoImagen) {
    if (valores.length != funciones.length) {
      return null;
    }
    DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
    for (int i = 0; i < valores.length; i++) {
      pieDataset.addValue(valores[i], "Serie 1", funciones[i]);
    }
    JFreeChart chart =
        ChartFactory.createBarChart(
            titulo,
            ejeHorizontal,
            ejeVertical,
            pieDataset,
            PlotOrientation.VERTICAL,
            leyenda,
            true,
            false);
    chart.setBackgroundPaint(null);
    chart.setBorderVisible(false);
    chart.getTitle().setPaint(LookAndFeelEntropy.COLOR_FUENTE_TITULO_PANEL);
    chart.getTitle().setFont(LookAndFeelEntropy.FUENTE_TITULO_GRANDE);
    if (leyenda) {
      chart.getLegend().setItemFont(LookAndFeelEntropy.FUENTE_REGULAR);
      chart.getLegend().setBackgroundPaint(LookAndFeelEntropy.COLOR_TABLA_PRIMARIO);
    }

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setBackgroundImageAlpha(0.0f);
    plot.setOutlineVisible(false);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    if (porcentaje) {
      rangeAxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    final AprobadoDesaprobadoBarRenderer renderer = new AprobadoDesaprobadoBarRenderer();
    renderer.setIntervaloAprobacion(intervaloAprobacion);
    plot.setRenderer(renderer);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    this.lastChart = chart;

    // Generamos una imagen
    return chart.createBufferedImage(anchoImagen, altoImagen);
  }
예제 #25
0
  private String geraTabelaMeses(
      String tituloSLA,
      Integer idAcordoNivelServico,
      HttpServletRequest request,
      UsuarioDTO usuarioDto)
      throws ParseException, IOException {
    ControleGenerateSLAPorAcordoNivelServicoByMesAno
        controleGenerateSLAPorAcordoNivelServicoByMesAno =
            new ControleGenerateSLAPorAcordoNivelServicoByMesAno();
    int m = UtilDatas.getMonth(UtilDatas.getDataAtual());
    int y = UtilDatas.getYear(UtilDatas.getDataAtual());
    int mPesq = (m + 1); // Faz este incremento de 1, pois logo que entrar no laço, faz um -1
    String strTable = "<table width='100%' border='1'>";
    String strHeader = "";
    String strDados = "";
    strHeader += "<tr>";
    strDados += "<tr>";

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < 6; i++) {
      mPesq = (mPesq - 1);
      if (mPesq <= 0) {
        mPesq = 12;
        y = y - 1;
      }
      strHeader = strHeader + "<td colspan='2' style='border:1px solid black; text-align:center'>";
      strHeader = strHeader + (mPesq + "/" + y);
      strHeader = strHeader + "</td>";

      List lst =
          controleGenerateSLAPorAcordoNivelServicoByMesAno.execute(idAcordoNivelServico, y, mPesq);
      double qtdeDentroPrazo = 0;
      double qtdeForaPrazo = 0;
      if (lst != null && lst.size() > 0) {
        for (Iterator itSLA = lst.iterator(); itSLA.hasNext(); ) {
          Object[] objs = (Object[]) itSLA.next();
          if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
            qtdeForaPrazo = (Double) objs[2];
          } else {
            qtdeDentroPrazo = (Double) objs[2];
          }
        }
      }
      double qtdeDentroPrazoPerc = 0;
      if ((qtdeDentroPrazo + qtdeForaPrazo) > 0) {
        qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
      }
      double qtdeForaPrazoPerc = 0;
      if ((qtdeDentroPrazo + qtdeForaPrazo) > 0) {
        qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
      }
      strDados = strDados + "<td style='border:1px solid black'>";
      strDados = strDados + UtilFormatacao.formatDouble(qtdeDentroPrazoPerc, 2) + "%";
      strDados = strDados + "</td>";
      strDados = strDados + "<td style='border:1px solid black'>";
      strDados = strDados + UtilFormatacao.formatDouble(qtdeForaPrazoPerc, 2) + "%";
      strDados = strDados + "</td>";

      dataset.setValue(
          new Double(qtdeDentroPrazoPerc),
          UtilI18N.internacionaliza(request, "sla.avaliacao.noprazo"),
          "" + (mPesq + "/" + y));
      dataset.setValue(
          new Double(qtdeForaPrazoPerc),
          UtilI18N.internacionaliza(request, "sla.avaliacao.foraprazo"),
          "" + (mPesq + "/" + y));
    }
    strHeader += "</tr>";
    strDados += "</tr>";

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            tituloSLA, // chart title
            UtilI18N.internacionaliza(request, "sla.avaliacao.indicadores"), // domain axis label
            UtilI18N.internacionaliza(request, "sla.avaliacao.resultado"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

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

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0, 64, 0));

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    String nomeImgAval =
        CITCorporeUtil.caminho_real_app
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLAXX_"
            + idAcordoNivelServico
            + ".png";
    String nomeImgAvalRel =
        br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
            + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLAXX_"
            + idAcordoNivelServico
            + ".png";
    File arquivo2 = new File(nomeImgAval);
    if (arquivo2.exists()) {
      arquivo2.delete();
    }
    ChartUtilities.saveChartAsPNG(arquivo2, chart, 500, 200);
    strTable += "<tr>";
    strTable += "<td colspan='12'>";
    strTable += "<img src='" + nomeImgAvalRel + "' border='0'/>";
    strTable += "</td>";
    strTable += "</tr>";

    strTable += strHeader;
    strTable += strDados;

    strTable += "</table>";
    return strTable;
  }
  /** Comienzo de mètodos básicos. */
  private BufferedImage generarGraficoBarrasApiladas(
      String titulo,
      String ejeHorizontal,
      String ejeVertical,
      ArrayList<Serie> series,
      boolean porcentaje,
      boolean leyenda,
      PlotOrientation orientacion,
      int anchoImagen,
      int altoImagen) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (Serie serie : series) {
      if (serie.valores.length != serie.funciones.length) {
        continue;
      }
      for (int i = 0; i < serie.valores.length; i++) {
        dataset.addValue(serie.valores[i], serie.funciones[i], serie.nombre);
      }
    }
    JFreeChart chart =
        ChartFactory.createStackedBarChart(
            titulo,
            ejeHorizontal,
            ejeVertical,
            dataset,
            orientacion,
            leyenda,
            true, // tooltips
            false // urls
            );

    chart.setBackgroundPaint(null);
    chart.getTitle().setPaint(LookAndFeelEntropy.COLOR_FUENTE_TITULO_PANEL);
    chart.getTitle().setFont(LookAndFeelEntropy.FUENTE_TITULO_GRANDE);
    chart.setBorderVisible(false);
    if (leyenda) {
      chart.getLegend().setItemFont(LookAndFeelEntropy.FUENTE_REGULAR);
      chart.getLegend().setBackgroundPaint(LookAndFeelEntropy.COLOR_TABLA_PRIMARIO);
    }

    GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
    KeyToGroupMap map = new KeyToGroupMap(series.get(0).nombre);
    for (Serie serie : series) {
      map.mapKeyToGroup(serie.nombre, serie.nombre);
    }
    renderer.setSeriesToGroupMap(map);
    renderer.setDrawBarOutline(false);
    renderer.setRenderAsPercentages(porcentaje);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());

    for (Serie serie : series) {
      for (int i = 0; i < serie.valores.length; i++) {
        if (Serie.colores.size() - 1 < i || Serie.colores.get(i) == null) {
          Color color = generarColorAleatorio(Color.orange);
          GradientPaint gp = new GradientPaint(0.0f, 0.0f, color, 0.0f, 0.0f, color);
          Serie.colores.add(gp);
        }
        renderer.setSeriesPaint(i, Serie.colores.get(i));
      }
    }

    renderer.setGradientPaintTransformer(
        new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setBackgroundImageAlpha(0.0f);
    plot.setOutlineVisible(false);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    if (porcentaje) {
      rangeAxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    domainAxis.setCategoryMargin(0.05);

    plot.setRenderer(renderer);

    // Generamos una imagen
    this.lastChart = chart;
    return chart.createBufferedImage(anchoImagen, altoImagen);
  }
  private BufferedImage generarGraficoBarras(
      String titulo,
      String ejeHorizontal,
      String ejeVertical,
      ArrayList<Serie> series,
      boolean porcentaje,
      boolean leyenda,
      int anchoImagen,
      int altoImagen) {
    DefaultCategoryDataset barDataset = new DefaultCategoryDataset();
    for (Serie serie : series) {
      if (serie.valores.length != serie.funciones.length) {
        continue;
      }
      for (int i = 0; i < serie.valores.length; i++) {
        barDataset.addValue(serie.valores[i], serie.nombre, serie.funciones[i]);
      }
    }

    JFreeChart chart =
        ChartFactory.createBarChart(
            titulo,
            ejeHorizontal,
            ejeVertical,
            barDataset,
            PlotOrientation.VERTICAL,
            leyenda,
            true,
            false);
    chart.setBackgroundPaint(null);
    chart.getTitle().setPaint(LookAndFeelEntropy.COLOR_FUENTE_TITULO_PANEL);
    chart.getTitle().setFont(LookAndFeelEntropy.FUENTE_TITULO_GRANDE);
    chart.setBorderVisible(false);
    if (leyenda) {
      chart.getLegend().setItemFont(LookAndFeelEntropy.FUENTE_REGULAR);
      chart.getLegend().setBackgroundPaint(LookAndFeelEntropy.COLOR_TABLA_PRIMARIO);
    }

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setBackgroundImageAlpha(0.0f);
    plot.setOutlineVisible(false);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    if (porcentaje) {
      rangeAxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    for (Serie serie : series) {
      for (int i = 0; i < serie.valores.length; i++) {
        Color color = generarColorAleatorio(Color.orange);
        if (Serie.colores.size() - 1 < i || Serie.colores.get(i) == null) {
          GradientPaint gp = new GradientPaint(0.0f, 0.0f, color, 0.0f, 0.0f, color);
          Serie.colores.add(gp);
        }
        renderer.setSeriesPaint(i, Serie.colores.get(i));
      }
    }

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    // Generamos una imagen
    this.lastChart = chart;
    return chart.createBufferedImage(anchoImagen, altoImagen);
  }
예제 #28
0
  public Drawable createChart(ADCDataset dataset, Dimension dimension) {
    JFreeChart chart =
        ChartFactory.createBarChart(
            "", // chart title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            false, // legend
            false, // tooltips
            false // urls
            );
    TextTitle textTitle = new TextTitle(dataset.get(Attribute.TITLE), TITLE_FONT);
    textTitle.setPadding(new RectangleInsets(10, 0, 0, 0));
    chart.setTitle(textTitle);

    chart.addLegend(createLegend(dataset.getRowKey(0).toString(), dataset.getRowKey(1).toString()));
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineVisible(false);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlineStroke(new BasicStroke(2));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoTickUnitSelection(true);
    rangeAxis.setTickUnit(new NumberTickUnit(0.2, percentFormatter()));
    rangeAxis.setAxisLineVisible(true);
    rangeAxis.setLabel(dataset.get(Attribute.Y_AXIS_LABEL));
    rangeAxis.setAxisLineStroke(new BasicStroke(2));
    rangeAxis.setAxisLinePaint(Color.black);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setLabelPaint(AXIS_LABEL_COLOR);
    rangeAxis.setLabelFont(AXIS_LABEL_FONT);
    rangeAxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0));
    rangeAxis.setUpperMargin(0);
    rangeAxis.setAutoRange(false);
    rangeAxis.setRange(0, 1);

    CategoryAxis cAxis = plot.getDomainAxis();
    cAxis.setTickMarksVisible(false);
    cAxis.setAxisLinePaint(Color.black);
    cAxis.setAxisLineStroke(new BasicStroke(2));
    cAxis.setLabel(dataset.get(Attribute.X_AXIS_LABEL));
    cAxis.setTickLabelsVisible(true);
    cAxis.setUpperMargin(0.05);
    cAxis.setLowerMargin(0.05);
    cAxis.setTickLabelFont(CAXIS_LABEL_FONT);
    cAxis.setTickLabelPaint(Color.black);
    CustomBarRenderer renderer = new CustomBarRenderer();
    plot.setRenderer(renderer);
    renderer.setDrawBarOutline(false);
    renderer.setBaseItemLabelsVisible(false);
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setMaximumBarWidth(0.08);
    renderer.setItemMargin(0.01);
    return new JFreeChartDrawable(chart, dimension);
  }
  public JFreeChart getChart(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart =
        ChartFactory.createBarChart3D(
            "Загрузка данных", // chart title
            "Дата", // domain axis label
            "Значение (кб.)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    //		#44639C;

    TextTitle title = new TextTitle("Динамика загрузки данных", labelFont);
    //		Paint paint = title.getPaint();
    title.setPaint(new Color(68, 99, 156));
    chart.setTitle(title);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // final IntervalMarker target = new IntervalMarker(2000000, 3000000);
    // target.setLabel("Ожидаемый диапазон");
    // target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    // target.setLabelAnchor(RectangleAnchor.LEFT);
    // target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    // target.setPaint(new Color(222, 222, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);

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

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.10);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue);
    final GradientPaint gp1 =
        new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)
        // CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
        );
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
예제 #30
0
  public ChartPanel getChartPanel() {
    JFreeChart c = null;
    CombinedDomainCategoryPlot combinedP = null;

    for (final String valueProperty : valueP) {
      final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
      for (int i = 0; i < set.getNumResults(); i++)
        dataset.addValue(
            (Double) set.getResultValue(i, valueProperty),
            set.getResultValue(i, seriesP).toString(),
            set.getResultValue(i, categoryP).toString());
      JFreeChart chart =
          ChartFactory.createLineChart(
              title,
              xAxisLabel,
              ((yAxisLabel == null) ? set.getNiceProperty(valueProperty) : yAxisLabel)
                  + yAxisLabelSuffix,
              dataset,
              PlotOrientation.VERTICAL,
              showLegend,
              tooltips,
              false /*urls*/);

      chart.getPlot().setBackgroundPaint(Color.WHITE);
      ((CategoryPlot) chart.getPlot()).setRangeGridlinePaint(Color.GRAY);
      //			((CategoryPlot) chart.getPlot()).setDomainGridlinesVisible(true);
      //			((CategoryPlot) chart.getPlot()).setDomainGridlinePaint(Color.GRAY);
      chart.setBackgroundPaint(new Color(0, 0, 0, 0));
      CategoryPlot plot = (CategoryPlot) chart.getPlot();

      Color cols[];
      Shape shapes[] = null;
      if (dataset.getRowCount() == 2) {
        cols =
            new Color[] {
              ColorUtil.bright(FreeChartUtil.COLORS[0]), ColorUtil.dark(FreeChartUtil.COLORS[1])
            };
        shapes =
            new Shape[] {ShapeUtilities.createDiamond(4.5f), new Ellipse2D.Float(-3f, -3f, 6f, 6f)};
      } else if (dataset.getRowCount() == 3) {
        Color orange = new Color(244, 125, 43);
        // Color orange = new Color(255, 145, 63);
        Color red = new Color(238, 46, 47);
        Color blue = new Color(24, 90, 169);
        // Color blue = new Color(4, 70, 149);
        cols = new Color[] {red, orange, blue};

        //
        //				Color bright = Color.MAGENTA;
        //				Color medium = Color.RED;
        //				Color dark = new Color(0, 0, 75);
        //				cols = new Color[] { bright, medium, dark };
      } else cols = FreeChartUtil.COLORS;

      //			for (int i = 0; i < cols.length; i++)
      //			{
      //				cols[i] = ColorUtil.grayscale(cols[i]);
      //				int color = cols[i].getRGB();
      //				int red = (color >>> 16) & 0xFF;
      //				int green = (color >>> 8) & 0xFF;
      //				int blue = (color >>> 0) & 0xFF;
      //				float luminance = (red * 0.2126f + green * 0.7152f + blue * 0.0722f) / 255;
      //				System.out.println(luminance);
      //			}

      //			for (int i = 0; i < dataset.getColumnCount(); i++)
      //			{
      //				//							int seriesIdx = -1;
      //				//							for (int j = 0; j < dataset.getRowCount(); j++)
      //				//							{
      //				//								String seriesValue = dataset.getRowKey(j).toString();
      //				//								String categoryValue = dataset.getColumnKey(i).toString();
      //				//								if ((drawShape.containsKey(valueProperty) &&
      // seriesValue.equals(drawShape.get(valueProperty).get(
      //				//										categoryValue))))
      //				//								{
      //				//									seriesIdx = j;
      //				//									break;
      //				//								}
      //				//							}
      //				//
      //				//							if (seriesIdx != -1)
      //				//							{
      //				CategoryLineAnnotation anno = new CategoryLineAnnotation(dataset.getColumnKey(i),
      // dataset
      //						.getValue(0, i).doubleValue(), dataset.getColumnKey(i), dataset.getValue(1,
      // i).doubleValue(),
      //						ColorUtil.transparent(Color.GRAY, 200), new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
      //								BasicStroke.JOIN_ROUND, 5.0f, new float[] { 2.0f, 2.0f }, 5.0f));
      //				int thick = 10;
      //				Color back = new Color(255, 255, 255);
      //
      //				//				CategoryLineAnnotation anno = new CategoryLineAnnotation(dataset.getColumnKey(i),
      // dataset
      //				//						.getValue(0, i).doubleValue(), dataset.getColumnKey(i), dataset.getValue(1,
      // i).doubleValue(),
      //				//						ColorUtil.transparent(back, 200), new BasicStroke(thick, BasicStroke.CAP_ROUND,
      //				//								BasicStroke.JOIN_ROUND));
      //				plot.addAnnotation(anno);
      //
      //				if (dataset.getValue(0, i).doubleValue() > dataset.getValue(1, i).doubleValue())
      //				{
      //					addAnnotation(plot, dataset, i, 1, cols, back, thick, true, valueProperty);
      //					addAnnotation(plot, dataset, i, 0, cols, back, thick, false, valueProperty);
      //				}
      //				else
      //				{
      //					addAnnotation(plot, dataset, i, 0, cols, back, thick, false, valueProperty);
      //					addAnnotation(plot, dataset, i, 1, cols, back, thick, true, valueProperty);
      //
      //				}
      //			}

      LineAndShapeRenderer renderer =
          new LineAndShapeRenderer() {
            @Override
            public boolean getItemShapeVisible(int series, int item) {
              //					//					return dataset.getValue(series, item).doubleValue() > dataset.getValue(1
              // - series, item)
              //					//							.doubleValue();
              //
              //					String seriesValue = dataset.getRowKey(series).toString();
              //					String categoryValue = dataset.getColumnKey(item).toString();
              //					return (drawShape.containsKey(valueProperty) &&
              // seriesValue.equals(drawShape.get(valueProperty)
              //							.get(categoryValue)));
              //					//					return new Random().nextBoolean();

              return false;
            }

            @Override
            public boolean getItemShapeFilled(int series, int item) {
              String seriesValue = dataset.getRowKey(series).toString();
              String categoryValue = dataset.getColumnKey(item).toString();
              return (drawShape.containsKey(valueProperty)
                  && seriesValue.equals(drawShape.get(valueProperty).get(categoryValue)));
            }

            @Override
            public Boolean getSeriesLinesVisible(int series) {
              return true;
            }
          };

      //			Polygon p1 = new Polygon();
      //			p1.addPoint(0, -9);
      //			p1.addPoint(-3, -5);
      //			p1.addPoint(3, -5);
      //			renderer.setBaseShape(p1);

      plot.setRenderer(renderer);
      //			LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
      //			renderer.set

      if (markers != null && markers.containsKey(valueProperty))
        for (String category : markers.keySet2(valueProperty)) {
          CategoryMarker marker = new CategoryMarker(category);
          marker.setOutlinePaint(null);
          marker.setPaint(new Color(150, 150, 150));
          marker.setDrawAsLine(true);
          marker.setLabel(" " + markers.get(valueProperty, category));

          //				marker.setLabelFont(plot.getDomainAxis().getLabelFont());
          //				marker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
          //				marker.setLabelOffset(new RectangleInsets(10.0, 0.0, 0.0, 0.0));

          marker.setLabelAnchor(RectangleAnchor.BOTTOM);
          marker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
          marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);

          plot.addDomainMarker(marker, Layer.BACKGROUND);
        }
      //
      //			marker = new CategoryMarker("elephant");
      //			marker.setOutlinePaint(null);
      //			marker.setPaint(new Color(150, 150, 150));
      //			plot.addDomainMarker(marker, Layer.BACKGROUND);

      //			CategoryPointerAnnotation p = new CategoryPointerAnnotation("", "mouse", 0.5,
      // Math.toRadians(270.0));
      //			p.setPaint(Color.RED);
      //			plot.addAnnotation(p);

      //			for (int i = 0; i < cols.length; i++)
      //				cols[i] = ColorUtil.grayscale(cols[i]);

      for (int i = 0; i < dataset.getRowCount(); i++) {
        //				renderer.setSeriesShape(i, p1);

        //				double ratio = i / (double) (dataset.getRowCount() - 1);
        //				System.out.println(i + " " + ratio);
        //				//			renderer.setSeriesPaint(i, ColorGradient.get2ColorGradient(ratio, Color.BLACK,
        // Color.LIGHT_GRAY));
        //				//				renderer.setSeriesPaint(i, new ColorGradient(new Color(200, 0, 0),
        // Color.LIGHT_GRAY, new Color(150,
        //				//						150, 255)).getColor(ratio));
        //				renderer.setSeriesPaint(i, new ColorGradient(new Color(0, 0, 200), Color.LIGHT_GRAY,
        // new Color(150,
        //						150, 255)).getColor(ratio));
        renderer.setSeriesPaint(i, cols[i]);

        renderer.setSeriesOutlinePaint(i, Color.BLACK);
        renderer.setSeriesFillPaint(i, Color.BLACK);

        if (shapes != null) renderer.setSeriesShape(i, shapes[i]);

        float thick = 1.0f;

        //				if ((dataset.getRowCount() == 2 || dataset.getRowCount() == 3) && i == 1)
        //					renderer.setSeriesStroke(i, new BasicStroke(thick, BasicStroke.CAP_ROUND,
        // BasicStroke.JOIN_ROUND,
        //							1.0f, new float[] { 6f * thick, 1.5f * thick }, 3f * thick));
        //				else if ((dataset.getRowCount() == 2 || dataset.getRowCount() == 3) && i == 2)
        //					renderer.setSeriesStroke(i, new BasicStroke(thick, BasicStroke.CAP_ROUND,
        // BasicStroke.JOIN_ROUND,
        //							1.0f, new float[] { 1.5f * thick, 1.5f * thick }, 3f * thick));
        //				else
        renderer.setSeriesStroke(
            i, new BasicStroke(thick, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

        // , 1.0f,new float[] { dash, 2 * thick }, dash / 2));

      }

      if (yAxisRange != null)
        ((NumberAxis) plot.getRangeAxis()).setRange(yAxisRange[0], yAxisRange[1]);
      if (yAxisRangePerValue.containsKey(valueProperty))
        ((NumberAxis) plot.getRangeAxis())
            .setRange(
                yAxisRangePerValue.get(valueProperty)[0], yAxisRangePerValue.get(valueProperty)[1]);
      if (yAxisTickUnitsPerValue.containsKey(valueProperty))
        ((NumberAxis) plot.getRangeAxis())
            .setTickUnit(new NumberTickUnit(yAxisTickUnitsPerValue.get(valueProperty)));

      // ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(true);

      CategoryAxis axis = plot.getDomainAxis();

      //			axis.setTickLabelsVisible(true);

      if (c == null) {
        c = chart;
      } else if (combinedP == null) {
        combinedP = new CombinedDomainCategoryPlot(new CategoryAxis(xAxisLabel));
        combinedP.setOrientation(PlotOrientation.VERTICAL);
        combinedP.add(c.getCategoryPlot());
        combinedP.add(chart.getCategoryPlot());
        c = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, combinedP, false);
        c.setBackgroundPaint(new Color(0, 0, 0, 0));
        c.addLegend(chart.getLegend());
        axis = plot.getDomainAxis();
      } else {
        combinedP.add(chart.getCategoryPlot());
      }

      if (rotateXLabels == XLabelsRotation.diagonal)
        axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
      if (rotateXLabels == XLabelsRotation.vertical) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
        axis.setMaximumCategoryLabelWidthRatio(1.0f);
      }
      axis.setLowerMargin(0);
      axis.setUpperMargin(0);
      if (!showDomainAxis) axis.setVisible(false);
    }
    ChartPanel cp = new ChartPanel(c);
    return cp;
  }