/**
   * <code>init</code> - wait for instance to become displayable, determine appropriate font
   * metrics, and render the JGo navigator, and slot widgets
   *
   * <p>These functions are not done in the constructor to avoid: "Cannot measure text until a
   * JGoView exists and is part of a visible window". called by componentShown method on the JFrame
   * JGoView.setVisible( true) must be completed -- use SwingWorker in constructor
   */
  public final void init() {
    // wait for NavigatorView instance to become displayable
    if (!ViewGenerics.displayableWait(NavigatorView.this)) {
      closeView(this);
      return;
    }
    this.computeFontMetrics(this);

    jGoDocument = jGoView.getDocument();
    jGoDocument.addDocumentListener(createDocListener());
    renderInitialNode();

    NavigatorViewLayout layout = new NavigatorViewLayout(jGoDocument, startTimeMSecs);
    layout.performLayout();

    MDIInternalFrame contentFilterFrame = viewSet.getContentSpecWindow();
    int contentFilterMaxY =
        (int) (contentFilterFrame.getLocation().getY() + contentFilterFrame.getSize().getHeight());
    int delta =
        Math.min(
            ViewConstants.INTERNAL_FRAME_X_DELTA_DIV_4
                * ((PartialPlanViewSet) viewSet).getNavigatorFrameCnt(),
            (int)
                (PlanWorks.getPlanWorks().getSize().getHeight()
                    - contentFilterMaxY
                    - (ViewConstants.MDI_FRAME_DECORATION_HEIGHT * 2)));
    navigatorFrame.setLocation(
        (ViewConstants.INTERNAL_FRAME_X_DELTA / 2) + delta, contentFilterMaxY + delta);

    //     Rectangle documentBounds = jGoView.getDocument().computeBounds();
    //     jGoView.getDocument().setDocumentSize( (int) documentBounds.getWidth() +
    //                                            (ViewConstants.TIMELINE_VIEW_X_INIT * 2),
    //                                            (int) documentBounds.getHeight() +
    //                                            (ViewConstants.TIMELINE_VIEW_Y_INIT * 2));
    int maxViewWidth = (int) jGoView.getDocumentSize().getWidth();
    int maxViewHeight = (int) jGoView.getDocumentSize().getHeight();

    //     navigatorFrame.setSize
    //       ( maxViewWidth + ViewConstants.MDI_FRAME_DECORATION_WIDTH,
    //         maxViewHeight + ViewConstants.MDI_FRAME_DECORATION_HEIGHT);

    expandViewFrame(navigatorFrame, maxViewWidth, maxViewHeight);

    long stopTimeMSecs = System.currentTimeMillis();
    System.err.println(
        "   ... "
            + ViewConstants.NAVIGATOR_VIEW
            + " elapsed time: "
            + (stopTimeMSecs - startTimeMSecs)
            + " msecs.");
    startTimeMSecs = 0L;
    isLayoutNeeded = false;
    focusNode = null;
    // print out info for created nodes
    // iterateOverJGoDocument(); // slower - many more nodes to go thru
    // iterateOverNodes();
  } // end init
  private void commonConstructor() {
    System.err.println("Render Navigator View ...");
    this.startTimeMSecs = System.currentTimeMillis();
    // isDebugPrint = true;
    isDebugPrint = false;
    // timelineColorMap = createTimelineColorMap();
    highlightPathNodesList = null;
    this.setName(navigatorFrame.getTitle());
    viewName = ViewConstants.NAVIGATOR_VIEW;

    navLinkMap = new HashMap();
    entityNavNodeMap = new HashMap();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    jGoView = new NavigatorJGoView(this);
    jGoView.addViewListener(createViewListener());
    jGoView.setBackground(ViewConstants.VIEW_BACKGROUND_COLOR);
    add(jGoView, BorderLayout.NORTH);
    jGoView.validate();
    jGoView.setVisible(true);
    this.setVisible(true);
    // SwingUtilities.invokeLater( runInit);
    final SwingWorker worker =
        new SwingWorker() {
          public Object construct() {
            init();
            return null;
          }
        };
    worker.start();
  } // end commonConstructor
  /**
   * <code>VariableQueryView</code> - constructor
   *
   * @param variableList - <code>List</code> -
   * @param query - <code>String</code> -
   * @param planSequence - <code>ViewableObject</code> -
   * @param stepString - <code>String</code> -
   * @param viewSet - <code>ViewSet</code> -
   * @param sequenceQueryWindow - <code>JPanel</code> -
   * @param variableQueryFrame - <code>MDIInternalFrame</code> -
   * @param startTimeMSecs - <code>long</code> -
   * @param viewListener - <code>ViewListener</code> -
   */
  public VariableQueryView(
      final List variableList,
      final String query,
      final ViewableObject planSequence,
      final String stepString,
      final ViewSet viewSet,
      final JPanel sequenceQueryWindow,
      final MDIInternalFrame variableQueryFrame,
      final long startTimeMSecs,
      final ViewListener viewListener) {
    super((PwPlanningSequence) planSequence, (SequenceViewSet) viewSet);
    this.variableList = variableList;
    Collections.sort(
        variableList,
        new VariableQueryComparatorAscending(ViewConstants.DB_TRANSACTION_STEP_NUM_HEADER));
    this.query = query;
    this.planSequence = (PwPlanningSequence) planSequence;
    stepNumber = Integer.parseInt(stepString);
    this.viewSet = (SequenceViewSet) viewSet;
    this.sequenceQueryWindow = (SequenceQueryWindow) sequenceQueryWindow;
    viewFrame = variableQueryFrame;
    // for PWTestHelper.findComponentByName
    setName(variableQueryFrame.getTitle());
    this.startTimeMSecs = startTimeMSecs;
    if (viewListener != null) {
      addViewListener(viewListener);
    }

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    SwingUtilities.invokeLater(runInit);
  } // end constructor