Commit 938c7881 authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Simplified to use the new VarROIDescriptor variable

parent 07682f6c
package plugins.stef.roi.bloc.property;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import icy.plugin.abstract_.Plugin;
import icy.plugin.interface_.PluginBundled;
......@@ -15,13 +12,11 @@ import icy.system.IcyExceptionHandler;
import icy.util.StringUtil;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.gui.model.ValueSelectionModel;
import plugins.adufour.vars.lang.VarMutable;
import plugins.adufour.vars.lang.VarROIArray;
import plugins.adufour.vars.lang.VarROIDescriptor;
import plugins.adufour.vars.lang.VarSequence;
import plugins.adufour.vars.lang.VarString;
import plugins.adufour.vars.util.VarException;
import plugins.kernel.roi.descriptor.measure.ROIInteriorDescriptor;
import plugins.stef.roi.bloc.RoiBlocks;
/**
......@@ -34,19 +29,19 @@ public class GetROIDescriptorValue extends Plugin implements ROIBlock, PluginLib
// we use ROI array for convenience here but only the first ROI is considered
final protected VarROIArray rois = new VarROIArray("ROI", null);
final protected VarSequence sequence = new VarSequence("Sequence", null);
final protected VarString descriptors = new VarString("Value of", "");
final protected VarROIDescriptor descriptor = new VarROIDescriptor("Value of");
final protected VarMutable value = new VarMutable("Value", Double.class);
@Override
public void run()
{
final Sequence seq = sequence.getValue();
final String descriptorId = descriptors.getValue();
final String descriptorId = descriptor.getValue();
final ROIDescriptor roiDescriptor = ROIDescriptor.getDescriptor(ROIDescriptor.getDescriptors().keySet(),
descriptorId);
if (roiDescriptor == null)
throw new VarException(descriptors, "Cannot found '" + descriptorId + "' ROI descriptor !");
throw new VarException(descriptor, "Cannot found '" + descriptorId + "' ROI descriptor !");
for (ROI roi : rois.getValue())
{
......@@ -105,33 +100,9 @@ public class GetROIDescriptorValue extends Plugin implements ROIBlock, PluginLib
@Override
public void declareInput(VarList inputMap)
{
final List<ROIDescriptor> roiDescriptors = new ArrayList<ROIDescriptor>(
ROIDescriptor.getDescriptors().keySet());
// build list of descriptor id
final List<String> descriptorsId = new ArrayList<String>();
String sizeDescriptorId = null;
for (ROIDescriptor descriptor : roiDescriptors)
{
final String id = descriptor.getId();
// keep trace of size descriptor
if (StringUtil.equals(ROIInteriorDescriptor.ID, id))
sizeDescriptorId = id;
descriptorsId.add(id);
}
// alpha sort
Collections.sort(descriptorsId);
// initialize descriptors field
descriptors.setDefaultEditorModel(new ValueSelectionModel<String>(
descriptorsId.toArray(new String[descriptorsId.size()]), sizeDescriptorId, false));
inputMap.add("rois", rois);
inputMap.add("sequence", sequence);
inputMap.add("descriptors", descriptors);
inputMap.add("descriptors", descriptor);
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment