/** Creates the combobox holding the channel list. */
  private void createComboBox() {
    Object[][] channelCols = new Object[channelName.size()][2];
    List<ChannelData> metadata = model.getMetadata();
    Iterator<ChannelData> i = metadata.iterator();
    ChannelData channelData;
    int channel;
    int index = 0;
    while (i.hasNext()) {
      channelData = i.next();
      channel = channelData.getIndex();
      if (channelName.containsKey(channel)) {
        channelCols[index] = new Object[] {channelColour.get(channel), channelName.get(channel)};
        index++;
      }
    }
    // if (channelCols.length == 0)
    // return;

    channelSelection.setModel(new DefaultComboBoxModel(channelCols));
    channelSelection.setRenderer(new ColorListRenderer());
    if (selectedChannelName != null)
      if (nameMap.containsKey(selectedChannelName))
        selectedChannel = nameMap.get(selectedChannelName);
      else selectedChannel = 0;
    else selectedChannel = 0;
    if (selectedChannel >= channelSelection.getItemCount() || selectedChannel < 0) return;
    channelSelection.setSelectedIndex(selectedChannel);
    channelSelection.setEnabled(true);
  }
Пример #2
0
 /**
  * Returns the list of grid images for openGL.
  *
  * @return See above.
  */
 List<GridImage> getGridImages() {
   List<GridImage> list = new ArrayList<GridImage>();
   List<ChannelData> l = parent.getSortedChannelData();
   Iterator<ChannelData> i = l.iterator();
   int index;
   GridImage image;
   // boolean[] rgb;
   ChannelData data;
   String label;
   boolean b = isRenderedImageRGB();
   if (!isModelRGB()) b = false;
   while (i.hasNext()) {
     data = i.next();
     index = data.getIndex();
     label = data.getChannelLabeling();
     // rgb = new boolean[3];
     if (parent.isChannelActive(index)) {
       /*
       if (b) {
       	rgb[0] = !parent.isChannelRed(index);
       	rgb[1] = !parent.isChannelGreen(index);
       	rgb[2] = !parent.isChannelBlue(index);
       	image = new GridImage(index, true, label, rgb);
       } else {
       	image = new GridImage(index, true, label);
       	image.setTextureData(gridImagesAsTextures.get(index));
       }
       */
       image = new GridImage(index, true, label);
       image.setTextureData(gridImagesAsTextures.get(index));
     } else {
       image = new GridImage(index, false, label);
     }
     list.add(image);
   }
   return list;
 }
  /**
   * Get the analysis results from the model and convert to the necessary array. data types using
   * the ROIStats wrapper then create the appropriate table data and summary statistics.
   */
  void displayAnalysisResults() {
    if (state == State.ANALYSING) return;
    this.ROIStats = model.getAnalysisResults();
    if (ROIStats == null || ROIStats.size() == 0) return;
    state = State.ANALYSING;
    channelSelection.setVisible(true);
    clearMaps();
    shapeStatsList = new TreeMap<Coord3D, Map<StatsType, Map>>(new Coord3D());
    pixelStats = new TreeMap<Coord3D, Map<Integer, Map<Point, Double>>>(new Coord3D());
    shapeMap = new TreeMap<Coord3D, ROIShape>(new Coord3D());
    minStats = new TreeMap<Coord3D, Map<Integer, Double>>(new Coord3D());
    maxStats = new TreeMap<Coord3D, Map<Integer, Double>>(new Coord3D());
    meanStats = new TreeMap<Coord3D, Map<Integer, Double>>(new Coord3D());
    sumStats = new TreeMap<Coord3D, Map<Integer, Double>>(new Coord3D());
    stdDevStats = new TreeMap<Coord3D, Map<Integer, Double>>(new Coord3D());

    Entry entry;
    Iterator j = ROIStats.entrySet().iterator();
    channelName = new TreeMap<Integer, String>();
    nameMap = new LinkedHashMap<String, Integer>();

    int minZ = Integer.MAX_VALUE, maxZ = Integer.MIN_VALUE;
    int minT = Integer.MAX_VALUE, maxT = Integer.MIN_VALUE;
    clearAllValues();
    Coord3D c3D;
    Map<StatsType, Map> shapeStats;
    ChannelData channelData;
    int channel;
    Iterator<ChannelData> i;
    List<ChannelData> metadata = model.getMetadata();
    while (j.hasNext()) {
      entry = (Entry) j.next();
      shape = (ROIShape) entry.getKey();
      c3D = shape.getCoord3D();
      minT = Math.min(minT, c3D.getTimePoint());
      maxT = Math.max(maxT, c3D.getTimePoint());
      minZ = Math.min(minZ, c3D.getZSection());
      maxZ = Math.max(maxZ, c3D.getZSection());

      shapeMap.put(c3D, shape);
      if (shape.getFigure() instanceof MeasureTextFigure) {
        state = State.READY;
        return;
      }

      shapeStats = AnalysisStatsWrapper.convertStats((Map) entry.getValue());
      shapeStatsList.put(c3D, shapeStats);

      minStats.put(c3D, shapeStats.get(StatsType.MIN));
      maxStats.put(c3D, shapeStats.get(StatsType.MAX));
      meanStats.put(c3D, shapeStats.get(StatsType.MEAN));
      sumStats.put(c3D, shapeStats.get(StatsType.SUM));
      stdDevStats.put(c3D, shapeStats.get(StatsType.STDDEV));
      pixelStats.put(c3D, shapeStats.get(StatsType.PIXEL_PLANEPOINT2D));

      /* really inefficient but hey.... quick hack just now till refactor */
      channelName.clear();
      nameMap.clear();
      channelColour.clear();

      i = metadata.iterator();
      List<String> names = new ArrayList<String>();
      String name;
      while (i.hasNext()) {
        channelData = i.next();
        channel = channelData.getIndex();
        if (model.isChannelActive(channel)) {
          name = channelData.getChannelLabeling();
          if (names.contains(name)) name += " " + channel;
          channelName.put(channel, name);
          nameMap.put(channelName.get(channel), channel);
          channelColour.put(channel, (Color) model.getActiveChannels().get(channel));
        }
      }
    }
    if (channelName.size() != channelColour.size() || nameMap.size() == 0) {
      createComboBox();
      List<String> names = channelSummaryModel.getRowNames();
      List<String> channelNames = new ArrayList<String>();
      Double data[][] = new Double[channelName.size()][names.size()];
      channelSummaryModel = new ChannelSummaryModel(names, channelNames, data);
      channelSummaryTable.setModel(channelSummaryModel);
      saveButton.setEnabled(false);
      showIntensityTable.setEnabled(false);
      if (intensityDialog != null) intensityDialog.setVisible(false);
      state = State.READY;
      return;
    }
    saveButton.setEnabled(true);
    showIntensityTable.setEnabled(true);
    maxZ = maxZ + 1;
    minZ = minZ + 1;
    maxT = maxT + 1;
    minT = minT + 1;

    createComboBox();
    Object[] nameColour = (Object[]) channelSelection.getSelectedItem();
    String string = (String) nameColour[1];
    selectedChannel = nameMap.get(string);
    zSlider.setMaximum(maxZ);
    zSlider.setMinimum(minZ);
    tSlider.setMaximum(maxT);
    tSlider.setMinimum(minT);
    zSlider.setVisible((maxZ != minZ));
    tSlider.setVisible((maxT != minT));
    tSlider.setValue(model.getCurrentView().getTimePoint() + 1);
    zSlider.setValue(model.getCurrentView().getZSection() + 1);
    coord = new Coord3D(zSlider.getValue() - 1, tSlider.getValue() - 1);
    shape = shapeMap.get(coord);
    populateData(coord, selectedChannel);
    saveButton.setEnabled(tableModel.getRowCount() > 0);
    state = State.READY;
  }