private void checkNeuronAllocation() {
   if (chip.getNumCells() == 0) {
     return;
   }
   if (neurons == null || neurons.getNumCells() != chip.getNumCells()) {
     neurons = new Neurons(this);
   }
 }
 public void annotate(GLAutoDrawable drawable) {
   if (showStateAtMouse == false || neurons == null) {
     return;
   }
   Point p = chip.getCanvas().getMousePixel();
   if (!chip.getCanvas().wasMousePixelInsideChipBounds()) {
     return;
   }
   neurons.display(drawable, p);
 }
 @Override
 public synchronized EventPacket<?> filterPacket(EventPacket<?> in) {
   checkOutputPacketEventType(in);
   checkNeuronAllocation();
   OutputEventIterator outItr = out.outputIterator();
   for (Object o : in) {
     TypedEvent e = (TypedEvent) o;
     if (neurons.stimulate(e)) {
       TypedEvent oe = (TypedEvent) outItr.nextOutput();
       oe.copyFrom(e);
     }
   }
   return out;
 }
 @Override
 public synchronized void resetFilter() {
   if (neurons != null) {
     neurons.initialize(this);
   }
 }
 public synchronized void doClearState() {
   if (neurons != null) {
     neurons.reset();
   }
 }
 public synchronized void doLoadState() {
   checkNeuronAllocation();
   if (neurons != null) {
     neurons.loadState(this);
   }
 }
 public synchronized void doSaveState() {
   if (neurons != null) {
     neurons.saveState();
   }
 }