/**
  * Removes the ROI figure.
  *
  * @param figure The figure to remove.
  */
 void removeROIFigure(ROIFigure figure) {
   if (figure == null) return;
   FigureTableModel tm = (FigureTableModel) fieldTable.getModel();
   ROIFigure value = tm.getFigure();
   if (value == null) return;
   if (value.getROI().getID() == figure.getROI().getID()) tm.clearData();
 }
 /**
  * Shows or hides the text for the currently selected figure.
  *
  * @param show Pass <code>true</code> to show the text, <code>false</code> otherwise.
  * @param figure The selected figure.
  */
 void showText(boolean show, ROIFigure figure) {
   if (fieldTable == null) return;
   int n = fieldTable.getRowCount();
   if (n > 4) {
     FigureTableModel ftm = (FigureTableModel) fieldTable.getModel();
     ROIFigure f = ftm.getFigure();
     if (f != null && f == figure)
       fieldTable.getModel().setValueAt(show, getRowIndex(MeasurementAttributes.SHOWTEXT), 1);
   }
 }
 /**
  * Removes the ROI figures.
  *
  * @param figures The figures to remove.
  */
 void removeROIFigures(List<ROIFigure> figures) {
   if (figures == null || figures.size() == 0) return;
   FigureTableModel tm = (FigureTableModel) fieldTable.getModel();
   ROIFigure value = tm.getFigure();
   if (value == null) return;
   Iterator<ROIFigure> i = figures.iterator();
   ROIFigure figure;
   while (i.hasNext()) {
     figure = i.next();
     if (value.getROI().getID() == figure.getROI().getID()) tm.clearData();
   }
   fieldTable.repaint();
 }
 /**
  * Sets the new figure retrieved from the passed collection.
  *
  * @param l The collection to handle.
  */
 void setSelectedFigures(List<ROIShape> l) {
   FigureTableModel tableModel = (FigureTableModel) fieldTable.getModel();
   Iterator<ROIShape> i = l.iterator();
   // Register error and notify user.
   ROIShape shape;
   try {
     TableCellEditor editor = fieldTable.getCellEditor();
     if (editor != null) editor.stopCellEditing();
     while (i.hasNext()) {
       shape = i.next();
       tableModel.setData(shape.getFigure());
       fieldTable.repaint();
     }
   } catch (Exception e) {
     MeasurementAgent.getRegistry().getLogger().info(this, "Figures selection" + e);
   }
 }
  private void handleValueChanged(String text) {
    int row = fieldTable.getEditingRow();

    if (row < 0 || row >= attributeFields.size()) {
      return;
    }

    AttributeKey attr = getAttributeKey(row);

    FigureTableModel ftm = (FigureTableModel) fieldTable.getModel();
    ROIFigure figure = ftm.getFigure();

    if (attr.equals(MeasurementAttributes.TEXT)) {
      if (TextHolderFigure.class.isAssignableFrom(figure.getClass())) {
        ((TextHolderFigure) figure).setText(text);
      }
    } else if (attr.equals(MeasurementAttributes.FONT_SIZE)) {
      double d = parseDouble(text);
      figure.setAttribute(MeasurementAttributes.FONT_SIZE, d);
      figure.changed();
    } else if (attr.equals(MeasurementAttributes.STROKE_WIDTH)) {
      double d = parseDouble(text);
      figure.setAttribute(MeasurementAttributes.STROKE_WIDTH, d);
    } else if (attr.equals(MeasurementAttributes.WIDTH)) {
      try {
        double d = parseDouble(text);
        setFigureDimension(figure, MeasurementAttributes.WIDTH, d);
        if (isScaleProportionally()) {
          setFigureDimension(figure, MeasurementAttributes.HEIGHT, d);
        }
      } catch (Exception e) {
      }
    } else if (attr.equals(MeasurementAttributes.HEIGHT)) {
      try {
        double d = parseDouble(text);
        setFigureDimension(figure, MeasurementAttributes.HEIGHT, d);
        if (isScaleProportionally()) {
          setFigureDimension(figure, MeasurementAttributes.WIDTH, d);
        }
      } catch (Exception e) {
      }
    }
    model.getDrawingView().repaint();
  }
 /** Clear the inspector after saving the data. */
 void clearData() {
   FigureTableModel tm = (FigureTableModel) fieldTable.getModel();
   tm.clearData();
 }
 /**
  * Sets the data.
  *
  * @param figure The data to set.
  */
 void setModelData(ROIFigure figure) {
   FigureTableModel tableModel = (FigureTableModel) fieldTable.getModel();
   tableModel.setData(figure);
   fieldTable.repaint();
 }