Ejemplo n.º 1
0
 public void toggleShowMeasurements() {
   if (showMeasurements.isSelected()) {
     measurements.setStructures(currentNucId, currentStructureIdx);
     measurements.setObjects(list.getSelectedValues());
     this.container.add(measurements);
   } else this.container.remove(measurements);
   core.refreshDisplay();
 }
Ejemplo n.º 2
0
 public void invertSelection() {
   int[] sel = this.list.getSelectedIndices();
   int[] newSel = new int[listModel.getSize() - sel.length];
   int idx = 0;
   int lastIdx = -1;
   for (int i : sel) {
     for (int i2 = lastIdx + 1; i2 < i; i2++) newSel[idx++] = i2;
     lastIdx = i;
   }
   for (int i2 = lastIdx + 1; i2 < listModel.getSize(); i2++) newSel[idx++] = i2;
   list.setSelectedIndices(newSel);
 }
Ejemplo n.º 3
0
  /** Initializes this dialog properly */
  private void completeInitialization() {
    // title of archives list
    jPanel1.setBorder(
        new javax.swing.border.TitledBorder(
            new javax.swing.border.EtchedBorder(),
            NbBundle.getBundle(HistoryModel.class).getString("CTL_Archives")));

    historyData = JarPackagerOption.singleton().historyData();
    historyList.setModel(historyData);
    updateControlStates();
    // testing
    JarContent jc = new JarContent();
    jc.filteredContent();
  }
Ejemplo n.º 4
0
 protected HashMap<Integer, ArrayList<Object3DGui>> getSplitSelection() {
   System.out.println(
       "get split selection: currenChannels==null?" + (this.currentChannels == null));
   if (this.currentChannels == null) return new HashMap<Integer, ArrayList<Object3DGui>>(0);
   HashMap<Integer, ArrayList<Object3DGui>> res =
       new HashMap<Integer, ArrayList<Object3DGui>>(this.currentChannels.length);
   for (ObjectStructure ass : currentChannels) res.put(ass.getIdx(), new ArrayList<Object3DGui>());
   for (Object o : list.getSelectedValues()) {
     Object3DGui o3D = (Object3DGui) (o);
     int idx = o3D.getChannel().getIdx();
     res.get(idx).add(o3D);
   }
   return res;
 }
Ejemplo n.º 5
0
 public void setStructures(ObjectId id, Object[] selectedChannels) {
   // System.out.println("Set Structures: cell"+id+ " sel channels
   // length"+selectedChannels.length);
   this.currentNucId = id;
   this.currentChannels = new ObjectStructure[selectedChannels.length];
   currentStructureIdx = new int[selectedChannels.length];
   for (int i = 0; i < selectedChannels.length; i++) {
     currentChannels[i] = (ObjectStructure) selectedChannels[i];
     currentStructureIdx[i] = currentChannels[i].getIdx();
   }
   setSortKeys();
   populateObjects();
   if (showMeasurements.isSelected()) {
     measurements.setStructures(id, currentStructureIdx);
     measurements.setObjects(list.getSelectedValues());
   }
 }
Ejemplo n.º 6
0
 /** Restores currently selected archive */
 boolean restoreArchive() {
   String archivePath = (String) historyList.getSelectedValue();
   if (archivePath == null) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 NbBundle.getBundle(HistoryPanel.class).getString("MSG_NoSelection"),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   HistoryModel.HistoryEntry foundEntry = historyData.getEntry(archivePath);
   File contentFile = new File(foundEntry.contentPath);
   // return if content not found
   if (!contentFile.exists()) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 MessageFormat.format(
                     NbBundle.getBundle(HistoryPanel.class).getString("FMT_NotExist"),
                     new Object[] {archivePath}),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   // read jar content, if it's possible
   JarContent jc = null;
   try {
     ObjectInputStream ois =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(contentFile)));
     try {
       jc = new JarContent();
       jc.readContent(ois);
     } finally {
       ois.close();
     }
   } catch (IOException exc) {
     exc.printStackTrace();
     return false;
   } catch (ClassNotFoundException exc) {
     exc.printStackTrace();
     return false;
   }
   // set the content if everything goes well
   PackagingView.getPackagingView().setJarContent(jc);
   return true;
 }
Ejemplo n.º 7
0
 @Override
 public void valueChanged(ListSelectionEvent lse) {
   if (lse.getValueIsAdjusting()) {
     return;
   }
   if (populatingObjects || selectingObject || !showObjects.isSelected()) {
     return;
   }
   selectingObject = true;
   if (measurements != null && showMeasurements.isSelected())
     measurements.setObjects(list.getSelectedValues());
   try {
     showRois3D();
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   selectingObject = false;
 }
Ejemplo n.º 8
0
 public void populateObjects() {
   try {
     this.listModel.removeAllElements();
     if (currentChannels == null) {
       return;
     }
     this.populatingObjects = true;
     ArrayList<Integer> selection = null;
     if (showSelection != null && showSelection.isSelected()) selection = new ArrayList<Integer>();
     int currentIdx = 0;
     for (ObjectStructure ass : currentChannels) {
       Object3D[] os = ass.getObjects();
       if (os != null) {
         Object3DGui[] osg = new Object3DGui[os.length];
         for (int i = 0; i < os.length; i++) osg[i] = new Object3DGui(os[i], ass);
         if (layout instanceof ObjectManagerLayout
             && currentChannels.length == 1
             && !((ObjectManagerLayout) layout).getSortKey().equals("idx"))
           this.sort(((ObjectManagerLayout) layout).getSortKey(), osg, ass.getIdx());
         // System.out.println("populating objects.. nb objects:"+os.length);
         for (Object3DGui o3D : osg) {
           this.listModel.addElement(o3D);
           if (selection != null && o3D.isInSelection()) selection.add(currentIdx);
           currentIdx++;
         }
         // if (selection!=null) System.out.println("populating objects.. selection
         // size:"+selection.size());
       } // else System.out.println("no objects int channel:"+ass.getChannelName());
     }
     if (selection != null && !selection.isEmpty()) {
       int[] sel = new int[selection.size()];
       int i = 0;
       for (int idx : selection) sel[i++] = idx;
       list.setSelectedIndices(sel);
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   this.populatingObjects = false;
 }
Ejemplo n.º 9
0
 protected void initPanels() {
   BasicDBObject usr = Core.mongoConnector.getUser();
   splitDist = new DoubleParameter("Dist", "splitMinDistObj", 5d, DoubleParameter.nfDEC1);
   splitDist.dbGet(usr);
   splitRad = new DoubleParameter("Rad", "splitRadObj", 2d, DoubleParameter.nfDEC1);
   splitRad.dbGet(usr);
   ObjectManagerLayout lay = new ObjectManagerLayout(this);
   showObjects = lay.showROIs;
   showObjects.setSelected(true);
   splitDist.addToContainer(lay.splitDistPanel);
   showMeasurements = lay.viewMeasurements;
   measurements = new MeasurementDisplayer();
   this.listModel = new DefaultListModel();
   this.list = lay.list;
   this.list.setModel(listModel);
   this.list.setCellRenderer(new LCRenderer());
   this.list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   this.list.setLayoutOrientation(JList.VERTICAL);
   listSelectionModel = list.getSelectionModel();
   listSelectionModel.addListSelectionListener(this);
   this.layout = lay;
 }
Ejemplo n.º 10
0
 /** Updates the state of buttons according to the current selection */
 private void updateControlStates() {
   int[] selItems = historyList.getSelectedIndices();
   removeButton.setEnabled(selItems.length > 0);
 }
Ejemplo n.º 11
0
 public void selectAll() {
   list.setSelectionInterval(0, list.getModel().getSize() - 1);
 }