예제 #1
0
  /**
   * Remove item from the model.
   *
   * <p>If the model and thus item are 'running', the item will be 'stopped'.
   *
   * @param item
   * @throws RuntimeException if item is already in model
   */
  public void removeItem(final ModelItem item) {
    if (is_running && item instanceof PVItem) {
      final PVItem pv = (PVItem) item;
      pv.stop();
      // Delete its samples:
      // For one, so save memory.
      // Also, in case item is later added back in, its old samples
      // will have gaps because the item was stopped
      pv.getSamples().clear();
    }
    if (!items.remove(item)) throw new RuntimeException("Unknown item " + item.getName());
    // Detach item from model
    item.setModel(null);

    // Notify listeners of removed item
    for (ModelListener listener : listeners) listener.itemRemoved(item);

    // Remove axis if unused
    AxisConfig axis = item.getAxis();
    item.setAxis(null);
    if (countActiveItemsOnAxis(axis) == 0) {
      removeAxis(axis);
      fireAxisChangedEvent(null);
    }
  }
예제 #2
0
 /**
  * @param axis Axis to remove
  * @throws Error when axis not in model, or axis in use by model item
  */
 public void removeAxis(final AxisConfig axis) {
   if (!axes.contains(axis)) throw new Error("Unknown AxisConfig");
   for (ModelItem item : items)
     if (item.getAxis() == axis) throw new Error("Cannot removed AxisConfig while in use");
   axis.setModel(null);
   axes.remove(axis);
   fireAxisChangedEvent(null);
 }
예제 #3
0
 /**
  * Add axis at given index. Adding at '1' means the new axis will be at index '1', and what used
  * to be at '1' will be at '2' and so on.
  *
  * @param index Index where axis will be placed.
  * @param axis New axis to add
  */
 public void addAxis(final int index, final AxisConfig axis) {
   axes.add(index, axis);
   axis.setModel(this);
   fireAxisChangedEvent(null);
 }