private JFreeChart createContourPlot() {
    String title = Settings.getProjectName();
    String xAxisLabel = I18n.tr("Date");
    String yAxisLabel = I18n.tr("Modules");
    String zAxisLabel = I18n.tr("Commit Activity (%)");

    xAxis = new DateAxis(xAxisLabel);
    // xAxis = new HorizontalNumberAxis(xAxisLabel);

    List dirs = content.getDirectories();
    String[] ax = new String[dirs.size()];
    for (int i = 0; i < dirs.size(); i++) {
      ax[i] = (String) ((Directory) dirs.get(i)).getPath();
    }
    yAxis = new AlignedVerticalSymbolicAxis(yAxisLabel, ax);

    zAxis = new ColorBar(zAxisLabel);

    // yAxis.setAutoRangeIncludesZero(false);
    // zAxis.setAutoRangeIncludesZero(false);

    yAxis.setInverted(true);

    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    // zAxis.setInverted(false);
    // zAxis.setTickMarksVisible(true);

    ContourDataset data = createDataset();
    ContourPlot plot = new ContourPlot(data, xAxis, yAxis, zAxis);
    // plot.setRenderAsPoints(true);
    ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    plot.setDataAreaRatio(ratio);

    return new JFreeChart(title, null, plot, false);
  }
Exemple #2
0
 /**
  * Configures the color bar.
  *
  * @param plot the plot.
  */
 public void configure(ContourPlot plot) {
   double minZ = plot.getDataset().getMinZValue();
   double maxZ = plot.getDataset().getMaxZValue();
   setMinimumValue(minZ);
   setMaximumValue(maxZ);
 }
  /**
   * 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)

  }