Ejemplo n.º 1
0
 /**
  * Description:
  *
  * @param view
  */
 public NodeStatusController(NodeStatusPanel view) {
   super();
   this.view = view;
   dataset = new DefaultPieDataset();
   StateLongTypeViz[] states = StateLongTypeViz.values();
   for (int i = 0; i < states.length; i++) {
     dataset.setValue(states[i].getName(), 0);
   }
   view.setDataset(dataset, StateLongTypeViz.colors);
 }
Ejemplo n.º 2
0
  public void updateStates(EnumMap<NoticeSeverity, Integer> states, final int total) {
    lastStates = states;
    lastTotal = total;

    if (lastStates == null) {
      view.clear();
      return;
    }

    final int[] counts = StateLongTypeViz.getDistributionValues(states, total);
    int countsLen = 0;
    if (counts != null) {
      countsLen = counts.length;
    }
    final double[] values = new double[countsLen];
    final String[] labels = new String[countsLen];
    final String[] tooltips = new String[countsLen];
    Util.runInEDT(
        new Runnable() {
          @Override
          public void run() {
            for (int i = 0; i < counts.length; i++) {
              dataset.setValue(StateLongTypeViz.values()[i].getName(), counts[i]);
              if (total > 0) {
                values[i] = (double) counts[i] / total;
                labels[i] =
                    UIConstants.INTEGER.format(counts[i])
                        + " ("
                        + UIConstants.PERCENTAGE.format(values[i])
                        + ") ";
                tooltips[i] =
                    UILabels.STL10202_NODE_STATES.getDescription(
                        UIConstants.INTEGER.format(counts[i]),
                        UIConstants.PERCENTAGE.format(values[i]),
                        StateLongTypeViz.names[i]);
              } else {
                labels[i] = STLConstants.K0039_NOT_AVAILABLE.getValue();
                tooltips[i] = null;
              }
            }

            view.setStates(values, labels, tooltips);
          }
        });
  }