public void selectMapElement(MapElement mapElement){
  if (mapElement == null) {
    tree.setSelectionPath(null);
    return;
  }
  DefaultMutableTreeNode treeNode=null;
  if (mapElement instanceof Landmark) {
    int n=landmarksNode.getChildCount();
    for (int i=0; i < n; ++i) {
      DefaultMutableTreeNode dmtn=(DefaultMutableTreeNode)landmarksNode.getChildAt(i);
      if ((MapElement)dmtn.getUserObject() == mapElement) {
        treeNode=dmtn;
        break;
      }
    }
    if (treeNode != null) {
      tree.setSelectionPath(new TreePath(new Object[]{rootNode,landmarksNode,treeNode}));
    }
  }
 else   if (mapElement instanceof Tool) {
    int n=toolsNode.getChildCount();
    for (int i=0; i < n; ++i) {
      DefaultMutableTreeNode dmtn=(DefaultMutableTreeNode)toolsNode.getChildAt(i);
      if ((MapElement)dmtn.getUserObject() == mapElement) {
        treeNode=dmtn;
        break;
      }
    }
    if (treeNode != null) {
      tree.setSelectionPath(new TreePath(new Object[]{rootNode,toolsNode,treeNode}));
    }
  }
 else   if (mapElement instanceof LineSet) {
    int n=lineSetsNode.getChildCount();
    for (int i=0; i < n; ++i) {
      DefaultMutableTreeNode dmtn=(DefaultMutableTreeNode)lineSetsNode.getChildAt(i);
      if ((MapElement)dmtn.getUserObject() == mapElement) {
        treeNode=dmtn;
        break;
      }
    }
    if (treeNode != null) {
      tree.setSelectionPath(new TreePath(new Object[]{rootNode,lineSetsNode,treeNode}));
    }
  }
}

public void selectMapElement ( MapElement mapElement ) { if ( mapElement == null ) { tree . setSelectionPath ( null ) ; return ; } DefaultMutableTreeNode treeNode = null ; if ( mapElement instanceof Landmark ) { int n = landmarksNode . getChildCount ( ) ; for ( int i = 0 ; i < n ; ++ i ) { DefaultMutableTreeNode dmtn = ( DefaultMutableTreeNode ) landmarksNode . getChildAt ( i ) ; if ( ( MapElement ) dmtn . getUserObject ( ) == mapElement ) { treeNode = dmtn ; break ; } } if ( treeNode != null ) { tree . setSelectionPath ( new TreePath ( new Object [ ] { rootNode , landmarksNode , treeNode } ) ) ; } } else if ( mapElement instanceof Tool ) { int n = toolsNode . getChildCount ( ) ; for ( int i = 0 ; i < n ; ++ i ) { DefaultMutableTreeNode dmtn = ( DefaultMutableTreeNode ) toolsNode . getChildAt ( i ) ; if ( ( MapElement ) dmtn . getUserObject ( ) == mapElement ) { treeNode = dmtn ; break ; } } if ( treeNode != null ) { tree . setSelectionPath ( new TreePath ( new Object [ ] { rootNode , toolsNode , treeNode } ) ) ; } } else if ( mapElement instanceof LineSet ) { int n = lineSetsNode . getChildCount ( ) ; for ( int i = 0 ; i < n ; ++ i ) { DefaultMutableTreeNode dmtn = ( DefaultMutableTreeNode ) lineSetsNode . getChildAt ( i ) ; if ( ( MapElement ) dmtn . getUserObject ( ) == mapElement ) { treeNode = dmtn ; break ; } } if ( treeNode != null ) { tree . setSelectionPath ( new TreePath ( new Object [ ] { rootNode , lineSetsNode , treeNode } ) ) ; } } }
select the map element to display
