Program: 180035
Project: 180035
Buggy source:
/** 
 * This constructor requires a Frame and a desired size
 */
public MapPlot(MDialog frame,int width,int height,DataSet data,Vector polys,JList varList){
  super(frame);
  this.polys=polys;
  this.data=data;
  border=20;
  if (varList.getSelectedIndices().length > 0)   this.displayVar=varList.getSelectedIndices()[0];
 else   this.displayVar=-1;
  allVarList=varList;
  frame.setTitle("String_Node_Str" + data.setName + "String_Node_Str");
  int xMin=((MyPoly)polys.elementAt(0)).xpoints[0];
  int xMax=((MyPoly)polys.elementAt(0)).xpoints[0];
  int yMin=((MyPoly)polys.elementAt(0)).ypoints[0];
  int yMax=((MyPoly)polys.elementAt(0)).ypoints[0];
  for (int i=0; i < polys.size(); i++) {
    MyPoly p=(MyPoly)polys.elementAt(i);
    Rectangle box=p.getBounds();
    xMin=Math.min(box.x,xMin);
    xMax=Math.max(box.x + box.width,xMax);
    yMin=Math.min(box.y,yMin);
    yMax=Math.max(box.y + box.height,yMax);
  }
  setCoordinates(xMin,yMin,xMax,yMax,1);
  ratio=(double)(xMax - xMin) / (double)(yMax - yMin);
  p=new JPanel(new FlowLayout());
  Varlist=new JComboBox();
  Varlist.addItem("String_Node_Str");
  for (int j=0; j < data.k; j++) {
    Varlist.addItem(data.getName(j));
  }
  Varlist.setSelectedIndex(this.displayVar + 1);
  Varlist.setSize(200,(Varlist.getSize()).height);
  Varlist.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  p.add(Varlist);
  if (RService.hasR()) {
    try {
      RConnection c=new RConnection();
      double[] reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      double[] greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      double[] blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      terrain=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       terrain[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      heat=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       heat[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      topo=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       topo[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      c.close();
    }
 catch (    RserveException rse) {
      System.out.println("String_Node_Str" + rse.getMessage());
    }
catch (    REXPMismatchException mme) {
      System.out.println("String_Node_Str" + mme.getMessage());
    }
  }
  Collist=new JComboBox();
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  if (RService.hasR()) {
    Collist.addItem("String_Node_Str");
    Collist.addItem("String_Node_Str");
    Collist.addItem("String_Node_Str");
  }
  Collist.setSize(200,(Varlist.getSize()).height);
  p.add(Collist);
  Collist.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  ColMap=new JComboBox();
  ColMap.addItem("String_Node_Str");
  ColMap.addItem("String_Node_Str");
  ColMap.addItem("String_Node_Str");
  p.add(ColMap);
  ColMap.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  JCheckBox cbInvert=new JCheckBox("String_Node_Str",inverted);
  cbInvert.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      inverted=!inverted;
      updateMap();
    }
  }
);
  p.add(cbInvert);
  p.add(new JLabel("String_Node_Str"));
  minField=new JTextField(5);
  minField.addActionListener(this);
  minField.setActionCommand("String_Node_Str");
  p.add(minField);
  p.add(new JLabel("String_Node_Str"));
  maxField=new JTextField(5);
  maxField.addActionListener(this);
  maxField.setActionCommand("String_Node_Str");
  p.add(maxField);
  p.setPreferredSize(new Dimension(frame.getWidth(),frame.getHeight()));
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(p,BorderLayout.NORTH);
  frame.getContentPane().add(this,BorderLayout.CENTER);
  frame.pack();
  System.out.println(p.getMinimumSize() + "String_Node_Str" + p.getPreferredSize()+ "String_Node_Str"+ p.getSize()+ "String_Node_Str"+ maxField.getY()+ "String_Node_Str"+ maxField.getHeight());
  p.setPreferredSize(new Dimension(frame.getWidth(),2 + maxField.getY() + maxField.getHeight()));
  frame.pack();
  frame.setVisible(true);
  Varlist.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  Collist.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  ColMap.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  cbInvert.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  maxField.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  minField.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  match=new int[polys.size()];
  boolean[] recMatch=new boolean[data.n];
  int pid=0;
  while (!data.isPolyID(pid))   pid++;
  double[] ids=data.getRawNumbers(pid);
  for (int i=0; i < polys.size(); i++) {
    MyPoly P=(MyPoly)polys.elementAt(i);
    int j=0;
    while (j < ids.length && (int)ids[j] != P.Id) {
      if ((int)ids[j] != P.Id)       j++;
    }
    if (j < ids.length) {
      match[i]=j;
      recMatch[j]=true;
    }
 else {
      P.Id=-1;
      match[i]=-1;
      System.out.println("String_Node_Str" + P.Id + "String_Node_Str");
    }
  }
  for (int i=0; i < data.n; i++)   if (!recMatch[i])   System.out.println("String_Node_Str" + i + "String_Node_Str");
  this.enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
  this.enableEvents(AWTEvent.MOUSE_EVENT_MASK);
  this.enableEvents(AWTEvent.ITEM_EVENT_MASK);
  this.enableEvents(AWTEvent.WINDOW_EVENT_MASK);
  this.enableEvents(AWTEvent.KEY_EVENT_MASK);
  this.requestFocus();
}

Fixed version (ground truth):
/** 
 * This constructor requires a Frame and a desired size
 */
public MapPlot(MDialog frame,int width,int height,DataSet data,Vector polys,JList varList){
  super(frame);
  this.polys=polys;
  this.data=data;
  border=20;
  if (varList.getSelectedIndices().length > 0)   this.displayVar=varList.getSelectedIndices()[0];
 else   this.displayVar=-1;
  allVarList=varList;
  setName("String_Node_Str" + data.setName + "String_Node_Str");
  int xMin=((MyPoly)polys.elementAt(0)).xpoints[0];
  int xMax=((MyPoly)polys.elementAt(0)).xpoints[0];
  int yMin=((MyPoly)polys.elementAt(0)).ypoints[0];
  int yMax=((MyPoly)polys.elementAt(0)).ypoints[0];
  for (int i=0; i < polys.size(); i++) {
    MyPoly p=(MyPoly)polys.elementAt(i);
    Rectangle box=p.getBounds();
    xMin=Math.min(box.x,xMin);
    xMax=Math.max(box.x + box.width,xMax);
    yMin=Math.min(box.y,yMin);
    yMax=Math.max(box.y + box.height,yMax);
  }
  setCoordinates(xMin,yMin,xMax,yMax,1);
  ratio=(double)(xMax - xMin) / (double)(yMax - yMin);
  p=new JPanel(new FlowLayout());
  Varlist=new JComboBox();
  Varlist.addItem("String_Node_Str");
  for (int j=0; j < data.k; j++) {
    Varlist.addItem(data.getName(j));
  }
  Varlist.setSelectedIndex(this.displayVar + 1);
  Varlist.setSize(200,(Varlist.getSize()).height);
  Varlist.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  p.add(Varlist);
  if (RService.hasR()) {
    try {
      RConnection c=new RConnection();
      double[] reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      double[] greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      double[] blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      terrain=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       terrain[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      heat=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       heat[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      reds=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      greens=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      blues=c.eval("String_Node_Str" + (polys.size()) + "String_Node_Str").asDoubles();
      topo=new Color[polys.size()];
      for (int i=0; i < polys.size(); i++)       topo[i]=new Color((float)(reds[i] / 255),(float)(greens[i] / 255),(float)(blues[i] / 255));
      c.close();
    }
 catch (    RserveException rse) {
      System.out.println("String_Node_Str" + rse.getMessage());
    }
catch (    REXPMismatchException mme) {
      System.out.println("String_Node_Str" + mme.getMessage());
    }
  }
  Collist=new JComboBox();
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  Collist.addItem("String_Node_Str");
  if (RService.hasR()) {
    Collist.addItem("String_Node_Str");
    Collist.addItem("String_Node_Str");
    Collist.addItem("String_Node_Str");
  }
  Collist.setSize(200,(Varlist.getSize()).height);
  p.add(Collist);
  Collist.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  ColMap=new JComboBox();
  ColMap.addItem("String_Node_Str");
  ColMap.addItem("String_Node_Str");
  ColMap.addItem("String_Node_Str");
  p.add(ColMap);
  ColMap.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      updateMap();
    }
  }
);
  JCheckBox cbInvert=new JCheckBox("String_Node_Str",inverted);
  cbInvert.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      inverted=!inverted;
      updateMap();
    }
  }
);
  p.add(cbInvert);
  p.add(new JLabel("String_Node_Str"));
  minField=new JTextField(5);
  minField.addActionListener(this);
  minField.setActionCommand("String_Node_Str");
  p.add(minField);
  p.add(new JLabel("String_Node_Str"));
  maxField=new JTextField(5);
  maxField.addActionListener(this);
  maxField.setActionCommand("String_Node_Str");
  p.add(maxField);
  p.setPreferredSize(new Dimension(frame.getWidth(),frame.getHeight()));
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(p,BorderLayout.NORTH);
  frame.getContentPane().add(this,BorderLayout.CENTER);
  frame.pack();
  System.out.println(p.getMinimumSize() + "String_Node_Str" + p.getPreferredSize()+ "String_Node_Str"+ p.getSize()+ "String_Node_Str"+ maxField.getY()+ "String_Node_Str"+ maxField.getHeight());
  p.setPreferredSize(new Dimension(frame.getWidth(),2 + maxField.getY() + maxField.getHeight()));
  frame.pack();
  frame.setVisible(true);
  Varlist.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  Collist.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  ColMap.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  cbInvert.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  maxField.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  minField.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      processKeyEvent(e);
    }
  }
);
  match=new int[polys.size()];
  boolean[] recMatch=new boolean[data.n];
  int pid=0;
  while (!data.isPolyID(pid))   pid++;
  double[] ids=data.getRawNumbers(pid);
  for (int i=0; i < polys.size(); i++) {
    MyPoly P=(MyPoly)polys.elementAt(i);
    int j=0;
    while (j < ids.length && (int)ids[j] != P.Id) {
      if ((int)ids[j] != P.Id)       j++;
    }
    if (j < ids.length) {
      match[i]=j;
      recMatch[j]=true;
    }
 else {
      P.Id=-1;
      match[i]=-1;
      System.out.println("String_Node_Str" + P.Id + "String_Node_Str");
    }
  }
  for (int i=0; i < data.n; i++)   if (!recMatch[i])   System.out.println("String_Node_Str" + i + "String_Node_Str");
  this.enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
  this.enableEvents(AWTEvent.MOUSE_EVENT_MASK);
  this.enableEvents(AWTEvent.ITEM_EVENT_MASK);
  this.enableEvents(AWTEvent.WINDOW_EVENT_MASK);
  this.enableEvents(AWTEvent.KEY_EVENT_MASK);
  this.requestFocus();
}