コード例 #1
1
ファイル: LinkChart.java プロジェクト: printmiles/JavaNews
 /**
  * Updates the data set for both charts with the contents of the supplied Hashtable. The Hashtable
  * is expected to contain the following items:
  *
  * <ul>
  *   <li>down - The number of links currently in a down state
  *   <li>up - The number of links currently in an up state
  *   <li>unknown - The number of links currently in an unknown state
  * </ul>
  *
  * @param linkStats The hashtable containing the entries indicating current link statistics.
  */
 public void updateData(Hashtable<String, Integer> linkStats) {
   dpdCurrentData.insertValue(0, "Link Down", linkStats.get("down"));
   dpdCurrentData.insertValue(1, "Link Up", linkStats.get("up"));
   dpdCurrentData.insertValue(2, "Link State Unknown", linkStats.get("unknown"));
   dcdPreviousData.addValue(
       linkStats.get("down"), "Link Down", Calendar.getInstance().getTime().toString());
   dcdPreviousData.addValue(
       linkStats.get("up"), "Link Up", Calendar.getInstance().getTime().toString());
   dcdPreviousData.addValue(
       linkStats.get("unknown"),
       "Link State Unknown",
       Calendar.getInstance().getTime().toString());
 }
コード例 #2
0
  public static void main(String[] args) throws Exception {
    DefaultCategoryDataset line_chart_dataset = new DefaultCategoryDataset();
    line_chart_dataset.addValue(15, "schools", "1970");
    line_chart_dataset.addValue(30, "schools", "1980");
    line_chart_dataset.addValue(60, "schools", "1990");
    line_chart_dataset.addValue(120, "schools", "2000");
    line_chart_dataset.addValue(240, "schools", "2010");
    line_chart_dataset.addValue(300, "schools", "2014");

    JFreeChart lineChartObject =
        ChartFactory.createLineChart(
            "Schools Vs Years",
            "Year",
            "Schools Count",
            line_chart_dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);

    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File lineChart = new File("LineChart.jpeg");
    ChartUtilities.saveChartAsJPEG(lineChart, lineChartObject, width, height);
  }
コード例 #3
0
  /** Fills the chart with the content of the list of {@link HeapSegmentElement}. */
  private void showChart(ArrayList<HeapSegmentElement> list) {
    mAllocCountDataSet.clear();

    if (list != null) {
      String rowKey = "Alloc Count";

      long currentSize = -1;
      int currentCount = 0;
      for (HeapSegmentElement element : list) {
        if (element.getLength() != currentSize) {
          if (currentSize != -1) {
            ByteLong columnKey = new ByteLong(currentSize);
            mAllocCountDataSet.addValue(currentCount, rowKey, columnKey);
          }

          currentSize = element.getLength();
          currentCount = 1;
        } else {
          currentCount++;
        }
      }

      // add the last item
      if (currentSize != -1) {
        ByteLong columnKey = new ByteLong(currentSize);
        mAllocCountDataSet.addValue(currentCount, rowKey, columnKey);
      }
    }
  }
コード例 #4
0
ファイル: LineChart.java プロジェクト: RainerJava/inventory
  private CategoryDataset createDataset() {

    // row keys...
    final String series1 = "Closing Qty";
    final String series2 = "Issued Qty";
    final String series3 = "Received Qty";

    // column keys...
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    String dbUrl = "jdbc:mysql://localhost/ventura_enterpride";
    String query = "Select * from daily_stock";

    try {
      Class.forName("com.mysql.jdbc.Driver");
      Connection con = DriverManager.getConnection(dbUrl, "root", "admin");
      Statement stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);

      while (rs.next()) {
        dataset.addValue(rs.getDouble(2), series1, rs.getDate(3) + "Item Id :" + rs.getInt(8));
        dataset.addValue(rs.getDouble(4), series2, rs.getDate(3) + "Item Id :" + rs.getInt(8));
        dataset.addValue(rs.getDouble(6), series3, rs.getDate(3) + "Item Id :" + rs.getInt(8));
      } // end while

      con.close();
    } // end try
    catch (Exception e) {
      e.printStackTrace();
    }
    return dataset;
  }
コード例 #5
0
  private static DefaultCategoryDataset getDataSet(List list) {
    DefaultCategoryDataset mydata = new DefaultCategoryDataset();
    if (!list.isEmpty() && list.size() > 0) {
      for (int i = 0; i < list.size(); i++) {
        mydata.addValue(
            Integer.parseInt(((BasicDynaBean) list.get(i)).get("patrolnum").toString()),
            "巡检",
            (String) ((BasicDynaBean) list.get(i)).get("regionname"));
        mydata.addValue(
            Integer.parseInt(((BasicDynaBean) list.get(i)).get("watchnum").toString()),
            "盯防",
            (String) ((BasicDynaBean) list.get(i)).get("regionname"));
        mydata.addValue(
            Integer.parseInt(((BasicDynaBean) list.get(i)).get("collectnum").toString()),
            "采集",
            (String) ((BasicDynaBean) list.get(i)).get("regionname"));
        mydata.addValue(
            Integer.parseInt(((BasicDynaBean) list.get(i)).get("troublenum").toString()),
            "隐患",
            (String) ((BasicDynaBean) list.get(i)).get("regionname"));
        mydata.addValue(
            Integer.parseInt(((BasicDynaBean) list.get(i)).get("othernum").toString()),
            "其它",
            (String) ((BasicDynaBean) list.get(i)).get("regionname"));
      }
    }

    return mydata;
  }
コード例 #6
0
  /** Some checks for the findRangeBounds() method. */
  @Test
  public void testFindRangeBounds() {
    BarRenderer r = new BarRenderer();
    assertNull(r.findRangeBounds(null));

    // an empty dataset should return a null range
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    assertNull(r.findRangeBounds(dataset));

    dataset.addValue(1.0, "R1", "C1");
    assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
    r.setIncludeBaseInRange(false);
    assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset));
    r.setIncludeBaseInRange(true);

    dataset.addValue(-2.0, "R1", "C2");
    assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));

    dataset.addValue(null, "R1", "C3");
    assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));

    dataset.addValue(-6.0, "R2", "C1");
    assertEquals(new Range(-6.0, 1.0), r.findRangeBounds(dataset));

    r.setSeriesVisible(1, Boolean.FALSE);
    assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
  }
コード例 #7
0
ファイル: BarChart3DDemo.java プロジェクト: Rembau/media
 private static CategoryDataset getDataSet() {
   DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   dataset.addValue(47000, "", "Spring2.0宝典");
   dataset.addValue(38000, "", "轻量级的J@EEE");
   dataset.addValue(31000, "", "JavaScript权威指南");
   dataset.addValue(25000, "", "Ajax In Action");
   return dataset;
 }
コード例 #8
0
 private static CategoryDataset createDataset() {
   String s = "S1";
   String s1 = "S2";
   String s2 = "S3";
   String s3 = "C1";
   String s4 = "C2";
   String s5 = "C3";
   String s6 = "C4";
   String s7 = "C5";
   DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
   defaultcategorydataset.addValue(1.0D, s, s3);
   defaultcategorydataset.addValue(4D, s, s4);
   defaultcategorydataset.addValue(3D, s, s5);
   defaultcategorydataset.addValue(5D, s, s6);
   defaultcategorydataset.addValue(5D, s, s7);
   defaultcategorydataset.addValue(5D, s1, s3);
   defaultcategorydataset.addValue(7D, s1, s4);
   defaultcategorydataset.addValue(6D, s1, s5);
   defaultcategorydataset.addValue(8D, s1, s6);
   defaultcategorydataset.addValue(4D, s1, s7);
   defaultcategorydataset.addValue(4D, s2, s3);
   defaultcategorydataset.addValue(3D, s2, s4);
   defaultcategorydataset.addValue(2D, s2, s5);
   defaultcategorydataset.addValue(3D, s2, s6);
   defaultcategorydataset.addValue(6D, s2, s7);
   return defaultcategorydataset;
 }
コード例 #9
0
 private static CategoryDataset createDataset() {
   String s = "First";
   String s1 = "Second";
   String s2 = "Third";
   String s3 = "Category 1";
   String s4 = "Category 2";
   String s5 = "Category 3";
   String s6 = "Category 4";
   String s7 = "Category 5";
   DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
   defaultcategorydataset.addValue(1.0D, s, s3);
   defaultcategorydataset.addValue(4D, s, s4);
   defaultcategorydataset.addValue(3D, s, s5);
   defaultcategorydataset.addValue(5D, s, s6);
   defaultcategorydataset.addValue(5D, s, s7);
   defaultcategorydataset.addValue(5D, s1, s3);
   defaultcategorydataset.addValue(7D, s1, s4);
   defaultcategorydataset.addValue(6D, s1, s5);
   defaultcategorydataset.addValue(8D, s1, s6);
   defaultcategorydataset.addValue(4D, s1, s7);
   defaultcategorydataset.addValue(4D, s2, s3);
   defaultcategorydataset.addValue(3D, s2, s4);
   defaultcategorydataset.addValue(2D, s2, s5);
   defaultcategorydataset.addValue(3D, s2, s6);
   defaultcategorydataset.addValue(6D, s2, s7);
   return defaultcategorydataset;
 }
コード例 #10
0
  /**
   * Creates a sample dataset.
   *
   * @return a sample dataset.
   */
  private CategoryDataset createPositionDataset() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (int i = 0; i < measurement_error.length; i++) {
      dataset.addValue(measurement_error[i], mLabel, String.valueOf(i));
    }

    for (int i = 0; i < kalman_error.length; i++) {
      dataset.addValue(kalman_error[i], kLabel, String.valueOf(i));
    }

    return dataset;
  }
コード例 #11
0
  /**
   * Creates a dataset.
   *
   * @return A dataset.
   */
  public static CategoryDataset createDataset1() {
    DefaultCategoryDataset result = new DefaultCategoryDataset();
    String series1 = "First";
    String series2 = "Second";
    String type1 = "Type 1";
    String type2 = "Type 2";
    String type3 = "Type 3";
    String type4 = "Type 4";
    String type5 = "Type 5";
    String type6 = "Type 6";
    String type7 = "Type 7";
    String type8 = "Type 8";

    result.addValue(1.0, series1, type1);
    result.addValue(4.0, series1, type2);
    result.addValue(3.0, series1, type3);
    result.addValue(5.0, series1, type4);
    result.addValue(5.0, series1, type5);
    result.addValue(7.0, series1, type6);
    result.addValue(7.0, series1, type7);
    result.addValue(8.0, series1, type8);

    result.addValue(5.0, series2, type1);
    result.addValue(7.0, series2, type2);
    result.addValue(6.0, series2, type3);
    result.addValue(8.0, series2, type4);
    result.addValue(4.0, series2, type5);
    result.addValue(4.0, series2, type6);
    result.addValue(2.0, series2, type7);
    result.addValue(1.0, series2, type8);

    return result;
  }
コード例 #12
0
ファイル: BarChart_AWT.java プロジェクト: Romuald44/tirage
  private CategoryDataset createDataset(int nbpers) {
    final String animateur = "Animateur";
    final String secretaire = "Secretaire";
    final String scribe = "Scribe";
    final String gestionnaire = "Gestionnaire";
    final String frequence = "Fréquence";
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    dataset.addValue(iofile.freq_anim(nbpers), animateur, frequence);
    dataset.addValue(iofile.freq_secret(nbpers), secretaire, frequence);
    dataset.addValue(iofile.freq_scribe(nbpers), scribe, frequence);
    dataset.addValue(iofile.freq_gest(nbpers), gestionnaire, frequence);

    return dataset;
  }
コード例 #13
0
ファイル: HistogramPanel.java プロジェクト: iraida95/Kata7
 private DefaultCategoryDataset createDataset(Histogram histogram) {
   DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
   for (Object key : histogram.keySet()) {
     dataSet.addValue(histogram.get(key), "", (Comparable) key);
   }
   return dataSet;
 }
コード例 #14
0
  public CategoryDataset generateData() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    List<Map> results = statistikPendidikanDosenDAO.getStatistikPendidikan();
    String[] jenjangs = {"S1", "S2", "S3"};

    for (Map prodi : statistikPendidikanDosenDAO.getProdi()) {
      String kodeProdi = "160" + prodi.get("Kd_prg").toString() + "0";
      for (String jenjang : jenjangs) {
        Map map = new HashMap();
        int pendidikan = 0;
        for (Map data : results) {
          if (kodeProdi.equalsIgnoreCase(data.get("kodeUnit").toString())) {
            if (data.get("Nm_jenjang").toString().equals(jenjang.toString())) {
              pendidikan++;
            }
          }
        }
        map.put("prodi", prodi.get("Nama_prg"));
        map.put("pendidikan", jenjang.toString());
        map.put("jumlah", pendidikan);
        dataset.addValue(
            Integer.valueOf(map.get("jumlah").toString()),
            map.get("pendidikan").toString(),
            map.get("prodi").toString());
      }
    }
    return dataset;
  }
コード例 #15
0
  /**
   * @param response
   * @param type
   * @param alphaList
   * @param title
   * @param xTitle
   * @param yTitle
   */
  protected void createChart(
      final CollStatInfo csi,
      final Vector<Pair<String, Integer>> list,
      final String xTitle,
      final String yTitle) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Pair<String, Integer> p : list) {
      dataset.addValue(p.second, p.first, "");
    }

    // if (StringUtils.isEmpty(csi.getInstName()))
    // {
    //    csi.setInstName(getProviderNameFromInstCode(csi.getProviderId()));
    // }

    JFreeChart chart =
        ChartFactory.createBarChart(
            csi.getTitle(), xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, true, false);

    // chart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer());

    chart.setBackgroundPaint(new Color(228, 243, 255));

    try {
      Integer hashCode = csi.hashCode();
      csi.setChartFileName(hashCode + ".png");
      DataOutputStream dos =
          new DataOutputStream(
              new FileOutputStream(new File("reports/charts/" + csi.getChartFileName())));
      ChartUtilities.writeChartAsPNG(dos, chart, 700, 600);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #16
0
  private JFreeChart getChart() {
    final Calendar now = Calendar.getInstance();
    final DefaultCategoryDataset sourceSet = new DefaultCategoryDataset();
    final boolean legend = false;
    final boolean tooltips = false;
    final boolean urls = false;

    final StringBuffer stringBuffer = new StringBuffer();
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {

        now.add(Calendar.DAY_OF_YEAR, 1);

        stringBuffer.setLength(0);

        sourceSet.addValue(
            new Integer(stringBuffer.append(i).append(j).toString()),
            String.valueOf(i),
            now.getTime());
      }
    }

    return ChartFactory.createBarChart(
        "fooTitle",
        "fooYLabel",
        "fooXLabel",
        sourceSet,
        PlotOrientation.VERTICAL,
        legend,
        tooltips,
        urls);
  }
コード例 #17
0
ファイル: QualityChartDialog.java プロジェクト: NKSG/crucian
 private void addData(String type, DefaultCategoryDataset dataset, boolean useRate) {
   AbstractAlgorithmStatus algorithmStatus = statsProvider.getStatus(type);
   if (algorithmStatus != null) {
     Number value = useRate ? algorithmStatus.getRatio() : algorithmStatus.getValue();
     dataset.addValue(value, type, statsProvider.getTime());
   }
 }
コード例 #18
0
ファイル: HistogramDisplay.java プロジェクト: Droikojan/KATA4
 private DefaultCategoryDataset createDataset() {
   DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   for (String key : histogram.keySet()) {
     dataset.addValue(histogram.get(key), "", key);
   }
   return dataset;
 }
コード例 #19
0
  /**
   * Creates a dataset.
   *
   * @return A dataset.
   */
  public static CategoryDataset createDataset2(String symbol) { // grafik volume
    DefaultCategoryDataset result = new DefaultCategoryDataset();

    String series1 = "Tahun";
    String series2 = "Tahun";

    try {
      Statement stat = koneksiDB.condb().createStatement();
      ResultSet rs =
          stat.executeQuery(
              "select year(reg_periksa.tgl_registrasi),count(year(reg_periksa.tgl_registrasi)) as jumlah "
                  + "from reg_periksa  "
                  + symbol
                  + " group by year(reg_periksa.tgl_registrasi)");
      while (rs.next()) {
        String tksbr = rs.getString(1) + "(" + rs.getString(2) + ")";
        double field1 = rs.getDouble(2);
        double field2 = rs.getDouble(2);

        result.addValue(field1, series1, tksbr);
        // result.addValue(field2, series2,tksbr);
      }
    } catch (SQLException e) {
      System.out.println("Error : " + e);
    }
    return result;
  }
コード例 #20
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
  protected void update() {
    // We have to rebuild the dataset from scratch (deleting and replacing it) because JFreeChart's
    // piechart facility doesn't have a way to move series.  Just like the histogram system: stupid
    // stupid stupid.

    SeriesAttributes[] sa = getSeriesAttributes();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (int i = 0; i < sa.length; i++)
      if (sa[i].isPlotVisible()) {
        PieChartSeriesAttributes attributes = (PieChartSeriesAttributes) (sa[i]);

        Object[] elements = attributes.getElements();
        double[] values = null;
        String[] labels = null;
        if (elements != null) {
          HashMap map = convertIntoAmountsAndLabels(elements);
          labels = revisedLabels(map);
          values = amounts(map, labels);
        } else {
          values = attributes.getValues();
          labels = attributes.getLabels();
        }

        UniqueString seriesName = new UniqueString(attributes.getSeriesName());

        for (int j = 0; j < values.length; j++)
          dataset.addValue(values[j], labels[j], seriesName); // ugh
      }

    setSeriesDataset(dataset);
  }
コード例 #21
0
 private CategoryDataset createDataset() {
   DefaultCategoryDataset setCategory = new DefaultCategoryDataset();
   try {
     Part part = this.mainFrame.getCurrentPart();
     BookModel model = this.mainFrame.getBookModel();
     Session session = model.beginTransaction();
     StrandDAOImpl daoStrand = new StrandDAOImpl(session);
     List strands = daoStrand.findAll();
     SceneDAOImpl daoScene = new SceneDAOImpl(session);
     List scenes = daoScene.findDistinctDates(part);
     double d = 0.0D;
     Iterator iStrand = strands.iterator();
     while (iStrand.hasNext()) {
       Strand strand = (Strand) iStrand.next();
       Iterator iScene = scenes.iterator();
       while (iScene.hasNext()) {
         Date date = (Date) iScene.next();
         long l = daoStrand.countByDate(date, strand);
         setCategory.addValue(l, strand, date);
         d += l;
       }
     }
     model.commit();
     this.average = (d / (strands.size() + scenes.size()));
   } catch (Exception exc) {
     System.err.println("StrandsByDateChart.createDataset() Exception : " + exc.getMessage());
   }
   return setCategory;
 }
コード例 #22
0
ファイル: WtdkCountByArea.java プロジェクト: gaowenhui/eam23
  public Object produceDataset(Map arg0) throws DatasetProduceException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    HashMap map = new HashMap();
    String sql1 =
        " select ww.he/10000 as he, ww.gl_opun_cod, c.code_value as   cityName "
            + " from ( "
            + "select  qq.he, qq.gl_opun_cod from ( "
            + "select sum(e.gl_dr_bal) he, substr(e.gl_opun_cod,0,3) gl_opun_cod  from "
            + "CRT_TOTAL_ACCOUNT e "
            + "where  e.gl_lg_no='79600000'  and DATA_DATE =(select max(DATA_DATE) from CRT_TOTAL_ACCOUNT) "
            + "group by substr(e.gl_opun_cod,0,3)"
            + "order by  sum(GL_DR_BAL) desc "
            + ") qq  where rownum <=10 )"
            + " ww,  ZCYM_CODE c where "
            + "ww.gl_opun_cod = substr(c.code_key,0,3) and c.code_name='省份' ";

    map.put("sql1", sql1);
    List list = chartUCC.queryDataList(map);
    double num = 0;
    HashMap map2 = null;
    if (list != null) {
      for (int i = 0; i < list.size(); i++) {
        map2 = (HashMap) list.get(i);
        BigDecimal big = (BigDecimal) map2.get("he");
        String cityName = (String) map2.get("cityName");
        if (big != null) {
          num = big.doubleValue();
        }
        dataset.addValue(num, "委托贷款余额", cityName);
      }
    }

    return dataset;
  }
コード例 #23
0
  @Override
  protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    // Get the time function
    String func = ServletRequestUtils.getStringParameter(request, "func", "hour");

    UsageStatisticsService svc = Context.getService(UsageStatisticsService.class);

    int[][] timeStats = new int[0][0];
    String xAxisLabel = null;
    String[] categories = null;
    if (func.equals("hour")) {
      timeStats = svc.getHourStats(getFromDate(), getUntilInclusiveDate(), getLocation());
      xAxisLabel = ContextProvider.getMessage("usagestatistics.chart.hour");
    } else if (func.equals("dayofweek")) {
      timeStats = svc.getDayOfWeekStats(getFromDate(), getUntilInclusiveDate(), getLocation());
      xAxisLabel = ContextProvider.getMessage("usagestatistics.chart.day");
      categories = ContextProvider.getMessage("usagestatistics.chart.dayNames").split("\\|");
    }

    String yAxisLabel = ContextProvider.getMessage("usagestatistics.chart.records");
    String seriesView = ContextProvider.getMessage("usagestatistics.results.views");
    String seriesUpdates = ContextProvider.getMessage("usagestatistics.results.updates");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int c = 0; c < timeStats.length; c++) {
      dataset.addValue(
          timeStats[c][0], seriesView, (categories != null) ? categories[c] : (c + ""));
      dataset.addValue(
          timeStats[c][1], seriesUpdates, (categories != null) ? categories[c] : (c + ""));
    }

    JFreeChart chart =
        ChartFactory.createBarChart(
            null, // Chart title
            xAxisLabel, // Domain axis label
            yAxisLabel, // Range axis label
            dataset, // Data
            PlotOrientation.VERTICAL, // Orientation
            true, // Include legend
            false, // Tooltips?
            false // URLs?
            );

    return chart;
  }
コード例 #24
0
 /**
  * A check for the datasetIndex and seriesIndex fields in the LegendItem returned by the
  * getLegendItem() method.
  */
 @Test
 public void testGetLegendItemSeriesIndex() {
   DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
   dataset0.addValue(21.0, "R1", "C1");
   dataset0.addValue(22.0, "R2", "C1");
   DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
   dataset1.addValue(23.0, "R3", "C1");
   dataset1.addValue(24.0, "R4", "C1");
   dataset1.addValue(25.0, "R5", "C1");
   BarRenderer r = new BarRenderer();
   CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r);
   plot.setDataset(1, dataset1);
   /*JFreeChart chart =*/ new JFreeChart(plot);
   LegendItem li = r.getLegendItem(1, 2);
   assertEquals("R5", li.getLabel());
   assertEquals(1, li.getDatasetIndex());
   assertEquals(2, li.getSeriesIndex());
 }
コード例 #25
0
  public void fillDataset() {
    if (datas != null && !datas.isEmpty()) {
      Iterator iter = datas.keySet().iterator();

      while (iter.hasNext()) {
        String key = (String) iter.next();
        PmdReportBean pmdReportBean = (PmdReportBean) datas.get(key);
        // String project = this.getTitle();
        String classes = this.bundle.getString("report.pmd.label.nbclasses");
        String violations = this.bundle.getString("report.pmd.label.nbviolations");

        ((DefaultCategoryDataset) defaultdataset)
            .addValue(pmdReportBean.getNbClasses(), classes, key);
        ((DefaultCategoryDataset) defaultdataset)
            .addValue(pmdReportBean.getNbViolations(), violations, key);
      }
    }
  }
コード例 #26
0
  public static DefaultCategoryDataset createDatasetForCriterionEvaluationCompareBarChart(
      List<Fragebogen> fragebogenList) {

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();

    ArrayList<Bereich> bereiche =
        EvaluationHelper.getBereicheFromEvaluationHelper(fragebogenList.get(0).getBewertungen());

    for (Fragebogen f : fragebogenList) {

      double[] values = new double[bereiche.size()];
      int valCount = 0;
      for (Bereich bereich : bereiche) {
        valCount = 0;
        for (Bewertung bewertung : f.getBewertungen()) {
          if (bewertung.getItem() != null) {
            if (bereich.equals(bewertung.getItem().getBereich())) {
              if (!bewertung.getWert().isEmpty())
                values[bereiche.indexOf(bereich)] += Double.parseDouble(bewertung.getWert());
              valCount++;
            }
          }
        }
        if (valCount != 0) {
          values[bereiche.indexOf(bereich)] /= valCount;
        } else {
          values[bereiche.indexOf(bereich)] = 0;
        }
      }
      ArrayList<Handlungsfeld> hfList = new ArrayList<Handlungsfeld>();

      for (Bereich bereich : bereiche) {
        if (!hfList.contains(bereich.getHandlungsfeld())) {
          hfList.add(bereich.getHandlungsfeld());
        }
      }

      for (Handlungsfeld hf : hfList) {
        double ret = 0;
        int i = 0;
        for (Bereich bereich : bereiche) {
          if (bereich.getHandlungsfeld().equals(hf)) {
            ret += values[bereiche.indexOf(bereich)];
            i++;
          }
        }
        if (i > 0) {
          ret /= i;
        } else {
          ret = 0;
        }
        defaultcategorydataset.addValue(ret, f.getPerspektive().getName(), hf.getName());
      }
    }

    return defaultcategorydataset;
  }
コード例 #27
0
ファイル: TrendChart.java プロジェクト: andreasmauczka/SubCat
  public void addData(ChartIdentifier identifier, TrendChartData data) {
    assert (identifier != null);
    assert (data != null);

    for (int i = 0; i < 12; i++) {
      dataset.addValue(data.getData()[i], identifier, TimeChartControlPanel.MONTHS[i]);
    }

    fixChartColours();
  }
コード例 #28
0
ファイル: media.java プロジェクト: pimenta53/BibliUM
 private static CategoryDataset createDataset(ResultSet dt) throws Exception {
   DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   ResultSet dx = dt;
   int x = 1;
   while (dx.next() && x < 5) {
     dataset.addValue(Integer.parseInt(dx.getString(2)), "", dx.getString(1));
     x++;
   }
   dx.close();
   return dataset;
 }
コード例 #29
0
 /**
  * Draws the chart with a <code>null</code> info object to make sure that no exceptions are thrown
  * (particularly by code in the renderer).
  */
 public void testDrawWithNullInfo() {
   boolean success = false;
   try {
     DefaultCategoryDataset dataset = new DefaultCategoryDataset();
     dataset.addValue(1.0, "S1", "C1");
     dataset.addValue(2.0, "S1", "C2");
     dataset.addValue(3.0, "S2", "C1");
     dataset.addValue(4.0, "S2", "C2");
     GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
     CategoryPlot plot =
         new CategoryPlot(
             dataset, new CategoryAxis("Category"), new NumberAxis("Value"), renderer);
     JFreeChart chart = new JFreeChart(plot);
     /* BufferedImage image = */ chart.createBufferedImage(300, 200, null);
     success = true;
   } catch (NullPointerException e) {
     e.printStackTrace();
     success = false;
   }
   assertTrue(success);
 }
コード例 #30
0
  public static DefaultCategoryDataset createDatasetForStudentBereich(
      EvaluationHelper eh,
      Fragebogen fragebogen,
      ArrayList<Bereich> bereiche,
      double[] avValueBereich) {

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();

    for (int i = 0; i < bereiche.size(); i++) {
      defaultcategorydataset.addValue(
          avValueBereich[i],
          SeCatResourceBundle.getInstance().getString("scene.chart.all.averagevalues"),
          bereiche.get(i).getName());
    }

    double avValue[] = new double[bereiche.size()];
    int valCount = 0;
    for (Bereich bereich : bereiche) {
      valCount = 0;
      for (Item item : eh.getItems()) {

        if (bereich.equals(item.getBereich())) {
          if (!eh.getItemWertung().get(valCount).isEmpty()) {
            avValue[bereiche.indexOf(bereich)] +=
                Double.parseDouble(eh.getItemWertung().get(valCount));
          }
          valCount++;
        }
      }
      if (valCount != 0) {
        avValue[bereiche.indexOf(bereich)] /= valCount;
      }
    }
    for (int j = 0; j < avValue.length; j++) {
      defaultcategorydataset.addValue(avValue[j], eh.getRawId(), bereiche.get(j).getName());
    }

    return defaultcategorydataset;
  }