public int getIndexOfPoint( String name ) { int i = 0; for( NamedPointWorld p : pointsWorld ) { if( p.getName().equals( name ) ) return i; ++i; } return -1; }
public Set< String > getNamesAsSet( ) { HashSet< String > namesSet = new HashSet< String >(); for( NamedPointWorld npw : pointsWorld ) { namesSet.add( npw.getName() ); } return namesSet; }
public NamedPointWorld get(String name) { Iterator<NamedPointWorld> i0; for(i0=pointsWorld.listIterator();i0.hasNext();) { NamedPointWorld p=i0.next(); if( p.getName().equals(name) ) return p; } return null; }
public void add(NamedPointWorld namedPointWorld) { synchronized (this) { String name = namedPointWorld.getName(); NamedPointWorld existing = get( name ); if( existing != null ) throw new RuntimeException( "Trying to add a point of name '" + name + "', but this NamedPointSet already has one." ); pointsWorld.add( namedPointWorld ); } }
boolean fineTune( NamedPointWorld p ) { int index = points.getIndexOfPoint( p.getName() ); return fineTune( p, index ); }
void delete(int i) { String name = points.get(i).getName(); YesNoCancelDialog d = new YesNoCancelDialog( IJ.getInstance(), "Really delete?", "Do you really want to delete the point \""+name+"\"?" ); if( d.yesPressed() ) { points.delete(i); dialog.recreatePointsPanel(); dialog.pack(); } }
String pointName = p.getName();
c.gridy = counter; c.anchor = GridBagConstraints.LINE_END; markButtons[counter] = b = new Button(p.getName()); b.addActionListener(this); buttonToIndex.put( b, counter );
void rename(int i) { NamedPointWorld npw = points.get(i); GenericDialog gd = new GenericDialog( "Rename Point" ); gd.addStringField( "Rename point to:", npw.getName() ); gd.showDialog(); if( gd.wasCanceled() ) return; String newName = gd.getNextString(); boolean result = points.renamePointTo( i, newName ); if( result ) { dialog.markButtons[i].setLabel( newName ); dialog.pack(); } else { IJ.error("Couldn't rename point: there already is one called \"" + newName + "\"" ); } }