/**
  * 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();
 }
  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();
  }