Exemplo n.º 1
0
  public void handleItemChanged(TimeStampedDataItem changedItem) {
    int index = myInput.getItems().indexOf(changedItem);
    if (index < 0) {
      return;
    }

    double currentXValue = myXComponent.getDoubleValue(changedItem);
    BackedXYDataItem chartItem = (BackedXYDataItem) mySeries.getDataItem(index);
    if (chartItem.getDomainItem() != changedItem) {
      int shouldBeAt = myInput.getItems().indexOf(chartItem.getDomainItem());
      throw new IllegalStateException(
          "domain position for element: "
              + changedItem
              + //
              " is "
              + index
              + //
              ", but chart series contains "
              + chartItem.getDomainItem()
              + //
              " which should be at position: "
              + shouldBeAt);
    }
    if (currentXValue == chartItem.getXValue()) {
      mySeries.updateByIndex(index, myYComponent.getDoubleValue(changedItem));
    } else {
      handleItemDeleted(index, changedItem);
      handleItemAdded(index, changedItem);
    }
  }
Exemplo n.º 2
0
 private BackedXYDataItem createChartItem(TimeStampedDataItem domainItem) {
   double xValue = myXComponent.getDoubleValue(domainItem);
   double yValue = myYComponent.getDoubleValue(domainItem);
   return new BackedXYDataItem(xValue, yValue, domainItem);
 }