@Override public Object getValueAt(final int rowIndex, final int columnIndex) { switch (columnIndex) { case 0: return rowIndex + 1; case 1: return contents.get(rowIndex).getName(); } return null; }
@Override public void contentRemoved(final Content arg0) { final String name = arg0.getName(); synchronized (ht_pt_meshes) { for (final Iterator<Map.Entry<ProjectThing,String>> it = ht_pt_meshes.entrySet().iterator(); it.hasNext(); ) { if (name.equals(it.next().getValue())) { it.remove(); break; } } } } @Override
private void sortByName() { final TreeMap<String, Content> m = new TreeMap<String, Content>(); for (final Content c : contents) { m.put(c.getName(), c); } // Swap this.contents = new ArrayList<Content>(m.values()); fireTableDataChanged(); }
void saveContent(final PrintWriter out, final Content c) { out.println("BeginContent"); out.println("name = " + c.getName()); for (final ContentInstant ci : c.getInstants().values()) saveContentInstant(out, ci); out.println("EndContent"); }
@Override public String getToolTipText(final MouseEvent me) { return ((ContentTableModel)getModel()).contents .get(ContentTable.this.rowAtPoint(me.getPoint())).getName(); } }
@Override public void actionPerformed(final ActionEvent e) { String s = regex.getText(); if (0 == s.length()) return; if (!s.startsWith("^")) s = "^.*" + s; if (!s.endsWith("$")) s = s + ".*$"; Pattern pattern = null; try { pattern = Pattern.compile(s); } catch (final PatternSyntaxException pse) { JOptionPane.showMessageDialog(univ.getWindow(), "Error parsing the regular expression:\n" + pse.getMessage()); return; } for (final Content c : new ArrayList<Content>(getOrderedContents(univ))) { if (pattern.matcher(c.getName()).matches()) { univ.removeContent(c.getName()); Utils.log("Removed " + c.getName()); } } } };
@Override public void contentAdded(final Content c) { updateMenus(); if (c == null) return; final String name = c.getName(); final JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); item.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (item.getState()) executer.select(name); else executer.select(null); } }); selectMenu.add(item); }
@Override public void contentSelected(final Content c) { if (c == null) return; final String contentName = c.getName(); final Path selectedPath = getPathFrom3DViewerName(contentName); if (plugin != null && selectedPath != null) plugin.selectPath(selectedPath, false); }
@Override public void mouseMoved(final MouseEvent e) { final Content c = picker.getPickedContent(e.getX(), e.getY()); if (c != null) IJ.showStatus(c.getName()); else IJ.showStatus(""); } });
public void delete(final Content c) { if (!checkSel(c)) return; univ.removeContent(c.getName()); record(DELETE); }
@Override public void contentRemoved(final Content c) { updateMenus(); if (c == null) return; for (int i = 0; i < selectMenu.getItemCount(); i++) { final JMenuItem item = selectMenu.getItem(i); if (item.getText().equals(c.getName())) { selectMenu.remove(i); return; } } }
public void showContent(final Content c, final boolean b) { if (!checkSel(c)) return; c.setVisible(b); record( SHOW_CONTENT, c.getName(), ""+b ); if (!b) univ.clearSelection(); }
public static void delete() { final Image3DUniverse univ = getUniv(); if (univ != null && univ.getSelected() != null) { univ.removeContent(univ.getSelected().getName()); } }
public void updatePreview() { final String name = getNameForContent(); if (content != null) univ.removeContent(content.getName()); final Primitive prim = getPrimitive(); if (prim != null) content = univ.addCustomMesh(prim, name); } }
@Override public Content call() { try { // 1 - Create content final Callable<Content> c = createMesh(pt, displ, resample); if (null == c) return null; final Content content = c.call(); if (null == content) return null; final String title = content.getName(); // 2 - Remove from universe any content of the same title if (universe.contains(title)) { universe.removeContent(title); } // 3 - Add to universe, and wait universe.addContentLater(content).get(); return content; } catch (final Exception e) { IJError.print(e); return null; } } });
static public void writeDXF(final Collection contents, final Writer w) throws IOException { w.write("0\nSECTION\n2\nENTITIES\n"); // header of file for (final Iterator it = contents.iterator(); it.hasNext();) { final Content ob = (Content) it.next(); CustomMesh cmesh = null; if (ob.getContent() instanceof CustomMeshNode) { final CustomMeshNode cmeshnode = (CustomMeshNode) ob.getContent(); cmesh = cmeshnode.getMesh(); } else if (ob.getContent() instanceof MeshGroup) { final MeshGroup mg = (MeshGroup) ob.getContent(); cmesh = mg.getMesh(); } else continue; final List triangles = cmesh.getMesh(); final String title = ob.getName().replaceAll(" ", "_").replaceAll("#", "--"); final Mtl mat = new Mtl(1 - ob.getTransparency(), cmesh.getColor()); writeTrianglesDXF(w, triangles, title, "" + mat.getAsSingle()); } w.append("0\nENDSEC\n0\nEOF\n"); // TRAILER of the file }
public void initRegistration() { // Select the contents used for registration final Collection contents = univ.getContents(); if (contents.size() < 2) { IJ.error("At least two bodies are required for " + " registration"); return; } final String[] conts = new String[contents.size()]; int i = 0; for (final Iterator it = contents.iterator(); it.hasNext();) conts[i++] = ((Content) it.next()).getName(); final GenericDialog gd = new GenericDialog("Registration"); gd.addChoice("template", conts, conts[0]); gd.addChoice("model", conts, conts[1]); gd.addCheckbox("allow scaling", true); openDialogs.add(gd); gd.showDialog(); openDialogs.remove(gd); if (gd.wasCanceled()) return; templ = univ.getContent(gd.getNextChoice()); model = univ.getContent(gd.getNextChoice()); final boolean scaling = gd.getNextBoolean(); // Select the landmarks of the template selectLandmarkSet(templ, "LS_MODEL"); }
/** Returns true on success. */ private boolean addContentToScene(final Content c) { synchronized (lock) { final String name = c.getName(); if (contents.containsKey(name)) { IJ.log("Mesh named '" + name + "' exists already"); return false; } // update start and end time int st = startTime; int e = endTime; if (c.getStartTime() < startTime) st = c.getStartTime(); if (c.getEndTime() > endTime) e = c.getEndTime(); updateStartAndEndTime(st, e); this.scene.addChild(c); this.contents.put(name, c); this.recalculateGlobalMinMax(c); c.setPointListDialog(plDialog); c.showTimepoint(currentTimepoint, true); } return true; }
public void resetTransform(final Content c) { if (!checkSel(c)) return; if (c.isLocked()) { IJ.error(c.getName() + " is locked"); return; } univ.fireTransformationStarted(); c.setTransform(new Transform3D()); univ.fireTransformationFinished(); record(RESET_TRANSFORM); }
public void contentProperties(final Content c) { if (!checkSel(c)) return; final Point3d min = new Point3d(); final Point3d max = new Point3d(); final Point3d center = new Point3d(); c.getContent().getMin(min); c.getContent().getMax(max); c.getContent().getCenter(center); final TextWindow tw = new TextWindow(c.getName(), " \tx\ty\tz", "min\t" + (float) min.x + "\t" + (float) min.y + "\t" + (float) min.z + "\n" + "max\t" + (float) max.x + "\t" + (float) max.y + "\t" + (float) max.z + "\n" + "cog\t" + (float) center.x + "\t" + (float) center.y + "\t" + (float) center.z + "\n\n" + "volume\t" + c.getContent().getVolume(), 512, 512); }