Пример #1
0
 /**
  * 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);
   }
 }
Пример #2
0
 /** Toggles the value of the boolean under the current selection. */
 private void toggleValue() {
   int col = fieldTable.getSelectedColumn();
   int row = fieldTable.getSelectedRow();
   Object v = (Boolean) fieldTable.getModel().getValueAt(row, col);
   Boolean value = Boolean.valueOf(false);
   if (v != null) value = (Boolean) v;
   boolean newValue = !(value.booleanValue());
   fieldTable.getModel().setValueAt(Boolean.valueOf(newValue), row, col);
   model.getDrawingView().repaint();
 }
Пример #3
0
 /**
  * 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();
 }
Пример #4
0
 /**
  * Returns <code>true</code> if the text has to be shown, <code>false</code> otherwise.
  *
  * @return See above.
  */
 boolean isShowText() {
   if (fieldTable == null) return false;
   int n = fieldTable.getRowCount();
   if (n > 4) {
     Object v = fieldTable.getModel().getValueAt(getRowIndex(MeasurementAttributes.SHOWTEXT), 1);
     if (v == null) return false;
     return (Boolean) v;
   }
   return false;
 }
Пример #5
0
 /**
  * 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();
 }
Пример #6
0
 /**
  * Returns <code>true</code> if the figure dimensions are to be scaled proportionally, <code>false
  * </code> otherwise.
  *
  * @return See above.
  */
 boolean isScaleProportionally() {
   if (fieldTable == null) return false;
   int n = fieldTable.getRowCount();
   if (n > 1) {
     Object v =
         fieldTable
             .getModel()
             .getValueAt(getRowIndex(MeasurementAttributes.SCALE_PROPORTIONALLY), 1);
     if (v == null) return false;
     return (Boolean) v;
   }
   return false;
 }
Пример #7
0
 /**
  * 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);
   }
 }
Пример #8
0
  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();
  }
Пример #9
0
 /** Clear the inspector after saving the data. */
 void clearData() {
   FigureTableModel tm = (FigureTableModel) fieldTable.getModel();
   tm.clearData();
 }
Пример #10
0
 /**
  * Sets the data.
  *
  * @param figure The data to set.
  */
 void setModelData(ROIFigure figure) {
   FigureTableModel tableModel = (FigureTableModel) fieldTable.getModel();
   tableModel.setData(figure);
   fieldTable.repaint();
 }
Пример #11
0
 /**
  * Sets the passed color to the currently selected cell. Returns the selected row.
  *
  * @param c The color to set.
  */
 int setCellColor(Color c) {
   int col = fieldTable.getSelectedColumn();
   int row = fieldTable.getSelectedRow();
   fieldTable.getModel().setValueAt(c, row, col);
   return row;
 }