Package org.eobjects.analyzer.beans.valuedist

Examples of org.eobjects.analyzer.beans.valuedist.ValueCount


        }
      };

      final String label = "Value distribution for group '" + LabelUtils.getLabel(res.getGroupName()) + "'";

      final ValueCount distinctValue = getDistinctValueCount(res);
      final DCCollapsiblePanel collapsiblePanel;
      if (distinctValue == null) {
        collapsiblePanel = new DCCollapsiblePanel(label, label, false, componentRef);
      } else {
        final String collapsedLabel = label + ": " + LabelUtils.getLabel(distinctValue.getValue()) + "="
            + distinctValue.getCount() + "";
        collapsiblePanel = new DCCollapsiblePanel(collapsedLabel, label, true, componentRef);
      }
      panel.add(collapsiblePanel.toPanel());
    }
    return panel;
View Full Code Here


   * @param res
   * @return
   */
  private ValueCount getDistinctValueCount(ValueDistributionGroupResult res) {
    int distinctValueCounter = 0;
    ValueCount valueCount = null;
    if (res.getNullCount() > 0) {
      distinctValueCounter++;
      valueCount = new ValueCount(LabelUtils.NULL_LABEL, res.getNullCount());
    }
    int uniqueCount = res.getUniqueCount();
    if (uniqueCount > 0) {
      if (uniqueCount > 1) {
        // more than one distinct value
        return null;
      }
      distinctValueCounter++;
      final Collection<String> uniqueValues = res.getUniqueValues();
      String label = LabelUtils.UNIQUE_LABEL;
      if (!uniqueValues.isEmpty()) {
        label = uniqueValues.iterator().next();
      }
      valueCount = new ValueCount(label, 1);
    }
    if (distinctValueCounter > 1) {
      // more than one distinct value
      return null;
    }
View Full Code Here

        group.size());

    final Iterator<ValueCount> valueCounts = group.getValueCounts();
    int i = 0;
    while (valueCounts.hasNext()) {
      ValueCount vc = valueCounts.next();
      model.setValueAt(LabelUtils.getLabel(vc.getValue()), i, 0);
      model.setValueAt(vc.getCount(), i, 1);
      i++;
    }
    _table.setModel(model);
    _backButton.setVisible(showBackButton);
  }
View Full Code Here

      logger.debug("Lowest repeated frequency above {} found: {}. Fetching from {} ungrouped values", new Object[] {
          previousGroupFrequency, groupFrequency, valueCounts.size() });

      for (Iterator<ValueCount> it = valueCounts.iterator(); it.hasNext();) {
        ValueCount vc = (ValueCount) it.next();
        final int count = vc.getCount();
        if (groupFrequency == count) {
          groupContent.add(vc);
          it.remove();
        }
      }

      if (groupContent.size() == 1) {
        logger.debug("Skipping this group because it has only one occurrence");
        skipCounts.add(groupFrequency);
        valueCounts.add(groupContent.get(0));
      } else {
        logger.info("Grouping {} values to group: {}", groupContent.size(), groupName);
        Collection<String> groupContentValues = new ArrayList<String>(groupContent.size());
        for (ValueCount valueCount : groupContent) {
          groupContentValues.add(valueCount.getValue());
        }

        PieSliceGroup group = new PieSliceGroup(groupName, groupContentValues, groupFrequency);
        _groups.put(groupName, group);
      }

      previousGroupFrequency = groupFrequency;
    }

    // code block for creating aggregated groups if slice count is still too
    // high
    {
      if (datasetItemCount + _groups.size() + valueCounts.size() > _maxSlices) {
        final int aggregatedGroupCount = _maxSlices - _groups.size();
        logger.info("Amount of groups outgrowed the preferred count, creating {} aggregated groups",
            aggregatedGroupCount);

        //
        //
        // final int diffFrequency = maxFrequency - minFrequency;
        final int aggregatedGroupSize = valueCounts.size() / aggregatedGroupCount;

        logger.info("Creating {} range groups", aggregatedGroupCount);

        for (int i = 0; i < aggregatedGroupCount; i++) {
          final LinkedList<ValueCount> groupContent = new LinkedList<ValueCount>();

          while (groupContent.size() < aggregatedGroupSize && !valueCounts.isEmpty()) {
            int minFrequency = -1;

            for (ValueCount vc : valueCounts) {
              final int count = vc.getCount();
              if (minFrequency == -1) {
                minFrequency = count;
              } else {
                minFrequency = Math.min(count, minFrequency);
              }
            }

            logger.debug("Adding values with count={} to range group {}.", minFrequency, i + 1);
            for (Iterator<ValueCount> it = valueCounts.iterator(); it.hasNext();) {
              ValueCount vc = it.next();
              if (vc.getCount() == minFrequency) {
                groupContent.add(vc);
                it.remove();
              }
            }
          }
View Full Code Here

        }

        @Override
        public ValueCount next() {
          String value = it.next();
          return new ValueCount(value, _fixedValueCount);
        }

        @Override
        public void remove() {
          throw new UnsupportedOperationException();
View Full Code Here

  public void testNoGrouping() throws Exception {
    ValueCountListImpl topValueCount = ValueCountListImpl.createFullList();
    for (int i = 0; i < 40; i++) {
      // 40 values with unique counts
      topValueCount.register(new ValueCount("v" + i, i + 1));
    }

    ValueDistributionResultSwingRendererGroupDelegate r = new ValueDistributionResultSwingRendererGroupDelegate("foo",
        50, 60);
    r.renderGroupResult(new ValueDistributionGroupResult(column.getName(), topValueCount, null, 0, 0, 0, 0));
View Full Code Here

  }

  public void testGroupEverythingOrNothing() throws Exception {
    ValueCountListImpl topValueCount = ValueCountListImpl.createFullList();

    topValueCount.register(new ValueCount("a", 2));
    topValueCount.register(new ValueCount("b", 2));
    topValueCount.register(new ValueCount("c", 2));
    topValueCount.register(new ValueCount("d", 2));
    topValueCount.register(new ValueCount("e", 2));
    topValueCount.register(new ValueCount("f", 3));
    topValueCount.register(new ValueCount("g", 3));
    topValueCount.register(new ValueCount("h", 3));
    topValueCount.register(new ValueCount("i", 4));
    topValueCount.register(new ValueCount("j", 4));
    topValueCount.register(new ValueCount("k", 4));
    topValueCount.register(new ValueCount("l", 4));
    topValueCount.register(new ValueCount("m", 5));
    topValueCount.register(new ValueCount("n", 5));
    topValueCount.register(new ValueCount("o", 6));
    topValueCount.register(new ValueCount("p", 6));
    topValueCount.register(new ValueCount("q", 7));
    topValueCount.register(new ValueCount("r", 7));
    topValueCount.register(new ValueCount("s", 8));
    topValueCount.register(new ValueCount("t", 8));
    topValueCount.register(new ValueCount("u", 9));
    topValueCount.register(new ValueCount("v", 9));

    // even though it is not nescesary for the slice threshold to group
    // these 4 values, we do so for the sake of "grouping consistency"
    // (because they all have count=9).
    topValueCount.register(new ValueCount("hi", 10));
    topValueCount.register(new ValueCount("hello", 10));
    topValueCount.register(new ValueCount("howdy", 10));
    topValueCount.register(new ValueCount("mjellow", 10));

    // preferred size is 13, which would earlier on mean that all the 4
    // values above could be individually included in the dataset.
    ValueDistributionResultSwingRendererGroupDelegate r = new ValueDistributionResultSwingRendererGroupDelegate("foo",
        13, 100);
View Full Code Here

  public void testPreferredSizeGrouping() throws Exception {
    ValueCountListImpl topValueCount = ValueCountListImpl.createFullList();
    for (int i = 0; i < 2000; i++) {
      // 2000 values but with only 10 different counts - should yield 10
      // groups
      topValueCount.register(new ValueCount("v" + i, 2 + (int) (Math.random() * 10)));
    }

    ValueDistributionResultSwingRendererGroupDelegate r = new ValueDistributionResultSwingRendererGroupDelegate("foo",
        17, 20);
    r.renderGroupResult(new ValueDistributionGroupResult("foo", topValueCount, null, 0, 0, 0, 0));
View Full Code Here

  public void testMaxSizeGrouping() throws Exception {
    ValueCountListImpl topValueCount = ValueCountListImpl.createFullList();
    for (int i = 0; i < 5000; i++) {
      // 5000 values with 10 different counts
      topValueCount.register(new ValueCount("v" + i, 2 + (int) (Math.random() * 10)));
    }

    // 10 additional values that will be grouped in 3 range-groups
    topValueCount.register(new ValueCount("r1", 100));
    topValueCount.register(new ValueCount("r2", 110));
    topValueCount.register(new ValueCount("r3", 130));
    topValueCount.register(new ValueCount("r4", 160));
    topValueCount.register(new ValueCount("r5", 210));
    topValueCount.register(new ValueCount("r6", 340));
    topValueCount.register(new ValueCount("r7", 520));
    topValueCount.register(new ValueCount("r8", 525));
    topValueCount.register(new ValueCount("r9", 530));

    ValueDistributionResultSwingRendererGroupDelegate r = new ValueDistributionResultSwingRendererGroupDelegate("foo",
        10, 13);
    r.renderGroupResult(new ValueDistributionGroupResult("foo", topValueCount, null, 0, 0, 0, 0));

View Full Code Here

TOP

Related Classes of org.eobjects.analyzer.beans.valuedist.ValueCount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.