/** * 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(); }
/** * Add stats in the column for area figures. * * @param fig the figure where the stats come from. * @param data the data being populated. * @param count the column in the table being populated. */ private void addValuesForAreaFigure(ROIFigure fig, Double data[][], int channel, int count) { data[count][6] = AnnotationKeys.AREA.get(fig.getROIShape()); data[count][7] = fig.getBounds().getX(); data[count][8] = fig.getBounds().getY(); data[count][9] = AnnotationKeys.WIDTH.get(fig.getROIShape()); data[count][10] = AnnotationKeys.HEIGHT.get(fig.getROIShape()); data[count][11] = AnnotationKeys.CENTREX.get(fig.getROIShape()); data[count][12] = AnnotationKeys.CENTREY.get(fig.getROIShape()); }
/** * 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(); }
private void setFigureDimension(ROIFigure figure, AttributeKey key, double dimension) { if (figure instanceof MeasureEllipseFigure || figure instanceof MeasureRectangleFigure || figure instanceof MeasureBezierFigure || figure instanceof MeasureTextFigure || figure instanceof MeasureLineConnectionFigure || figure instanceof MeasureLineFigure) { figure.setAttribute(key, dimension); } }
/** * Populate the data for use in the summary table for the figure fig, and for channel. * * @param fig see above. * @param data see above. * @param channel see above. * @param count the column the data is being placed in. */ private void populateSummaryColumn(ROIFigure fig, Double data[][], int channel, int count) { data[count][0] = channelMin.get(channel); data[count][1] = channelMax.get(channel); data[count][2] = channelSum.get(channel); data[count][3] = channelMean.get(channel); data[count][4] = channelStdDev.get(channel); data[count][5] = (double) fig.getPoints().size(); if (areaFigure(fig)) addValuesForAreaFigure(fig, data, channel, count); else if (lineFigure(fig)) addValuesForLineFigure(fig, data, channel, count); else if (pointFigure(fig)) addValuesForPointFigure(fig, data, channel, count); }
/** * Selects the collection of figures. * * @param l The collection of objects to select. * @param clear Pass <code>true</code> to clear the selection <code>false</code> otherwise. */ void setSelectedFigures(List<ROIShape> l, boolean clear) { Iterator<ROIShape> i = l.iterator(); TreeSelectionModel tsm = objectsTable.getTreeSelectionModel(); ROIFigure figure = null; ROIShape shape; if (clear) tsm.clearSelection(); objectsTable.removeTreeSelectionListener(treeSelectionListener); try { while (i.hasNext()) { shape = i.next(); figure = shape.getFigure(); objectsTable.selectROIShape(figure.getROIShape()); } objectsTable.repaint(); if (figure != null) objectsTable.scrollToROIShape(figure.getROIShape()); } catch (Exception e) { MeasurementAgent.getRegistry().getLogger().info(this, "Figure selection " + e); } objectsTable.addTreeSelectionListener(treeSelectionListener); }
/** * Removes the passed figure from the table. * * @param figure The figure to remove. */ void removeFigure(ROIFigure figure) { if (figure == null) return; objectsTable.removeROIShape(figure.getROIShape()); objectsTable.repaint(); }