gt:     if (!vertexList.contains(startVertex)) {
context: package org.simonwells.monkeypuzzle;
  
  /*
   * TreeSearchPanel.java
   *
   * Created on 31 March 2004, 09:18
   */
  
  /**
   *
   * @author  growe
   */
  import java.awt.*;
  import java.awt.event.*;
  import java.util.*;
  import java.awt.geom.*;
  import javax.swing.*;
  
  public class TreeSearchPanel extends FullPanel
  {
    SearchFrame searchFrame;
    boolean selectedSomething;
    
    /** Creates a new instance of TreeSearchPanel */
    public TreeSearchPanel()
    {
    }
    
    public void setSearchFrame(SearchFrame s)
    { searchFrame = s; }
    
    /**
     * Draw vertices on top of the edge structure
     */
    public void drawNodes(Graphics2D gg)
    {
      Enumeration nodeList = argument.getBreadthFirstTraversal().elements();
      // Run through the traversal and draw each vertex
      // using an Ellipse2D
      // The draw point has been determined previously in
      // calcNodeCoords()
      while (nodeList.hasMoreElements()) { 
        TreeVertex vertex = (TreeVertex)nodeList.nextElement();
        // Don't draw virtual nodes
        if (vertex.isVirtual())
        	continue;
        
        // If tree is incomplete and we're on the top layer, skip it
        if (argument.isMultiRoots() && vertex.getLayer() == 0)
        	continue;
        
        Point corner = vertex.getDrawPoint();
        Shape node = new Ellipse2D.Float(corner.x, corner.y,
  				       NODE_DIAM, NODE_DIAM);
        vertex.setShape(node, this);
        
        // Fill the interior of the node with vertex's fillPaint
        gg.setPaint(vertex.fillPaint);
        gg.fill(node);
        
        // Draw the outline with vertex's outlinePaint; bold if selected
        gg.setPaint(vertex.outlinePaint);
        if (vertex.isSelected()) {
          gg.setStroke(selectStroke);
        } else {
          gg.setStroke(solidStroke);
        }
        gg.draw(node);
        
        // Draw the short label on top of the vertex
        gg.setPaint(vertex.textPaint);
        String shortLabelString = new String(vertex.getShortLabel());
        if (shortLabelString.length() == 1) {
          gg.setFont(labelFont1);
          gg.drawString(shortLabelString,
            corner.x + NODE_DIAM/4, corner.y + 3*NODE_DIAM/4);
        } else if (shortLabelString.length() == 2) {
          gg.setFont(labelFont2);
          gg.drawString(shortLabelString,
            corner.x + NODE_DIAM/5, corner.y + 3*NODE_DIAM/4);
        }
      }
    }
  
    /**
     * Draws the edge structure of the tree
     */
    public void drawEdges(Graphics2D gg)
    {
      gg.setPaint(Color.black);
      Enumeration nodeList = argument.getBreadthFirstTraversal().elements();
      // For each vertex...
      while (nodeList.hasMoreElements()) {
        // Get its edge list...
        TreeVertex vertex = (TreeVertex)nodeList.nextElement();
        Enumeration edges = vertex.getEdgeList().elements();
        // For each edge in the list...
        while (edges.hasMoreElements()) {
          TreeEdge edge = (TreeEdge)edges.nextElement();
          // If we have several vertices on layer 0, only draw
          // edges for layers below that
          if (!(argument.isMultiRoots() && vertex.getLayer() == 0)) {
            // If the edge has been selected with the mouse,
            // use a thick line
            if (edge.isSelected()) {
              gg.setStroke(selectStroke);
            }
            gg.draw(edge.getShape(this));
            // If we used a thick line, reset the stroke to normal
            // line for next edge.
            if (edge.isSelected()) {
              gg.setStroke(solidStroke);
            }
            TreeVertex edgeSource = edge.getDestVertex();
          }
        }
      }
    }
  
    public java.awt.image.BufferedImage getJpegImage()
    {
      return null;
    }
    
    public boolean addFreeVertex()
    {
      argument.addFreeVertex(null, null, 0, this);
      displayFrame.controlFrame.updateDisplays(true); 
      return true;
    }
    
    public void selectVertexEdge(MouseEvent e)
    {
      double x = e.getX();
      double y = e.getY();
      selectedSomething = false;
      startVertex = getSelectedVertex(x, y, displayFrame.getMainDiagramPanel(), 
        displayFrame.getFreeVertexPanel());
      if (startVertex == null)  { // No vertex selected
        // See if an edge was selected. If not, see if a subtree
        // was selected.
        canCreateEdge = false;
        if (testEdgeShapes(e) != null)
        {
          selectedSomething = true;
        }
  //      refreshDisplay();
        return;
      } else {
        selectedSomething = true;
      }
      if (startVertex.isVirtual())
        return;
      if (startVertex.getHasParent()) {
        if (startVertex.isRefutation()) {
            displayFrame.controlFrame.setMessageLabelText("Refutations cannot be used as premises " +
              "in the current version of Araucaria");
        } else {
            displayFrame.controlFrame.setMessageLabelText("Premise is already supporting a conclusion");
          }
        canCreateEdge = false;
  //      refreshDisplay();
        return;
      } else {
        // Allow mouse to be dragged to select other vertex
        canCreateEdge = true;
        initDragCoords(x, y);
      }
    }
    
    /*
     * Creates a line of width EDGE_SELECT_WIDTH for each edge
     * and tests if mouse click was in that Shape's boundary.
     * Returns the edge if one was selected, null otherwise.
     */
    public TreeEdge testEdgeShapes(MouseEvent event) 
    {
      if (argument == null || argument.getTree() == null) return null;
      double x = event.getX(); 
      double y = event.getY();
      BasicStroke edgeWidth = new BasicStroke(EDGE_SELECT_WIDTH);
      if (argument.getBreadthFirstTraversal() == null) return null;
      Enumeration nodeList = argument.getBreadthFirstTraversal().elements();
      while (nodeList.hasMoreElements()) {
        TreeVertex vertex = (TreeVertex)nodeList.nextElement();
        if (argument.isMultiRoots() && vertex.getLayer() == 0)
        	continue;
        Enumeration edges = vertex.getEdgeList().elements();
        while (edges.hasMoreElements()) {
          TreeEdge edge = (TreeEdge)edges.nextElement();
          Shape shape = edge.getShape(this);
          Shape wideEdge = edgeWidth.createStrokedShape(shape);
          TreeVertex child = edge.getDestVertex();
          if (wideEdge.contains(x, y)) {
            edge.setSelected(!edge.isSelected());
            return edge;
          }
        }
      }
      return null;
    }
    
    public void addNewEdge()
    {
      if (!canCreateEdge) {
  //      refreshDisplay();
        return;
      }
      canCreateEdge = false;
      Vector vertexList = argument.getTree().getVertexList();
      boolean addNewEdge = false;
  