Buggy code:
public class OrbitSetController extends DefaultController implements PropertyChangeListener { private final OrbitSource colorSource ; private final OrbitSet orbits ; private final OrbitSet allOrbits ; private Direction lastOrbit = null ; private boolean mOneAtATime = true ; private boolean showLastOrbit = false ; double xMax = 0.0 ; double yMax = 0.0 ; private final Map orbitDots = new HashMap ( ) ; private static class OrbitState { double dotX ; double dotY ; int dotXint ; int dotYint ; } public OrbitSetController ( OrbitSet orbits , OrbitSet allOrbits , OrbitSource colorSource , boolean showLastOrbit ) { } private synchronized void recalculateDots ( ) { orbits . retainAll ( allOrbits ) ; Symmetry symmetry = allOrbits . getSymmetry ( ) ; AlgebraicField field = symmetry . getField ( ) ; RealVector test = new RealVector ( 0.1 , 0.1 , 1.0 ) ; if ( symmetry instanceof OctahedralSymmetry ) test = new RealVector ( 2.0 , 1.0 , 4.0 ) ; else if ( symmetry instanceof DodecagonalSymmetry ) test = new RealVector ( 10.0 , 1.0 , 1.0 ) ; orbitDots . clear ( ) ; for ( Iterator dirs = allOrbits . iterator ( ) ; dirs . hasNext ( ) ; ) { Direction dir = ( ( Direction ) ( dirs . next ( ) ) ) ; if ( ( lastOrbit ) == null ) { lastOrbit = dir ; } OrbitSetController . OrbitState orbit = new OrbitSetController . OrbitState ( ) ; orbitDots . put ( dir , orbit ) ; Axis axis = dir . getAxis ( test ) ; int [ ] v = axis . normal ( ) ; double z = field . evaluateNumber ( field . getVectorComponent ( v , 2 ) ) ; orbit . dotX = field . evaluateNumber ( field . getVectorComponent ( v , 0 ) ) ; orbit . dotX = ( orbit . dotX ) // z ; orbit . dotY = field . evaluateNumber ( field . getVectorComponent ( v , 1 ) ) ; orbit . dotY = ( orbit . dotY ) // z ; { double temp = orbit . dotX ; orbit . dotX = orbit . dotY ; orbit . dotY = temp ; } if ( ( orbit . dotY ) > ( yMax ) ) yMax = orbit . dotY ; if ( ( orbit . dotX ) > ( xMax ) ) xMax = orbit . dotX ; } <START_BUG> if ( ! ( allOrbits . contains ( lastOrbit ) ) ) { <END_BUG> if ( ! ( orbits . isEmpty ( ) ) ) lastOrbit = ( ( Direction ) ( orbits . last ( ) ) ) ; else if ( ! ( orbitDots . isEmpty ( ) ) ) lastOrbit = ( ( Direction ) ( orbitDots . keySet ( ) . iterator ( ) . next ( ) ) ) ; else lastOrbit = null ; } properties ( ) . firePropertyChange ( "selectedOrbit" , null , ( ( lastOrbit ) == null ? null : lastOrbit . getName ( ) ) ) ; } public void doAction ( String action , ActionEvent e ) throws Exception { } public void propertyChange ( PropertyChangeEvent evt ) { } void toggleOrbit ( Direction dir ) { } public Controller getSubController ( String name ) { } public String getProperty ( String string ) { } public void setProperty ( String cmd , Object value ) { } private static final int RADIUS = 12 ; private static final int INNER_RADIUS = 5 ; private static final int OUTER_RADIUS = 19 ; private static final int DIAM = 2 * ( OrbitSetController . RADIUS ) ; private static int TOP = 30 ; private static int LEFT = OrbitSetController . TOP ; public void repaintGraphics ( String panelName , Graphics graphics , Dimension size ) { } Direction pickDirection ( MouseEvent click ) { } public MouseTool getMouseTool ( ) { } public String [ ] getCommandList ( String listName ) { } }

Fix:
if ( ( ( lastOrbit ) == null ) || ( ! ( allOrbits . contains ( lastOrbit ) ) ) ) {