protected void initSimulator(ForceSimulator fsim) {
      // make sure we have force items to work with
      TupleSet t = (TupleSet) m_vis.getGroup(m_group);
      t.addColumns(ANCHORITEM_SCHEMA);
      t.addColumns(FORCEITEM_SCHEMA);

      Iterator iter = m_vis.visibleItems(m_nodeGroup);
      while (iter.hasNext()) {
        VisualItem item = (VisualItem) iter.next();
        // get force item
        ForceItem fitem = (ForceItem) item.get(FORCEITEM);
        if (fitem == null) {
          fitem = new ForceItem();
          item.set(FORCEITEM, fitem);
        }
        fitem.location[0] = (float) item.getEndX();
        fitem.location[1] = (float) item.getEndY();
        fitem.mass = getMassValue(item);

        // get spring anchor
        ForceItem aitem = (ForceItem) item.get(ANCHORITEM);
        if (aitem == null) {
          aitem = new ForceItem();
          item.set(ANCHORITEM, aitem);
          aitem.location[0] = fitem.location[0];
          aitem.location[1] = fitem.location[1];
        }

        fsim.addItem(fitem);
        fsim.addSpring(fitem, aitem, 0);
      }
    }
  public void clear() {
    // System.err.println("run clear");
    ForceSimulator fsim = getForceSimulator();
    fsim.clear();

    // make sure we have force items to work with
    TupleSet t = (TupleSet) m_vis.getGroup(m_nodeGroup);

    Iterator iter = m_vis.visibleItems(m_nodeGroup);
    while (iter.hasNext()) {
      VisualItem item = (VisualItem) iter.next();
      if (!item.canGet(ANCHORITEM, ForceItem.class)) break;
      // get force item
      ForceItem fitem = (ForceItem) item.get(FORCEITEM);
      if (fitem != null) {
        fitem.location[0] = (float) item.getEndX();
        fitem.location[1] = (float) item.getEndY();
        fitem.mass = getMassValue(item);

        // get spring anchor
        ForceItem aitem = (ForceItem) item.get(ANCHORITEM);
        // only reset if an anchor exists
        if (aitem != null) {
          aitem.location[0] = fitem.location[0];
          aitem.location[1] = fitem.location[1];

          fsim.addItem(fitem);
          fsim.addSpring(fitem, aitem, 0);
        }
      }
    }
  }
 public void reset() {
   Iterator iter = m_vis.visibleItems(m_nodeGroup);
   while (iter.hasNext()) {
     VisualItem item = (VisualItem) iter.next();
     ForceItem aitem = (ForceItem) item.get(ANCHORITEM);
     if (aitem != null) {
       aitem.location[0] = (float) item.getEndX();
       aitem.location[1] = (float) item.getEndY();
     }
   }
   super.reset();
 }
 public double getSize(VisualItem item) {
   double y = item.getEndY();
   return 0.2 + y / 1400;
 }
    @Override
    //        public void itemPressed(VisualItem item, MouseEvent e) {
    public void itemClicked(VisualItem item, MouseEvent e) {
      // load (or unload) marked-up text into glasspane on rightclick
      // glasspane text is now loaded on mouseover instead

      // temp: zoom on selection
      if (SwingUtilities.isLeftMouseButton(e)) {
        if (item.canGetInt(DocumentGridTable.NODE_ID)) {
          int nodeId = item.getInt(DocumentGridTable.NODE_ID);
          boolean hasSelectFocus = item.getBoolean(SELECT_FOCUS);
          boolean hasWidthFocus = item.getBoolean(WIDTH_FOCUS);
          boolean hasHeightFocus = item.getBoolean(HEIGHT_FOCUS);
          if (hasSelectFocus) {
            // simply deselect the node
            resetGlyphFocus();
          } else {
            // clear all other node selections
            resetGlyphFocus();
            // select this node
            item.setBoolean(SELECT_FOCUS, true);
            item.setBoolean(WIDTH_FOCUS, true);
            item.setBoolean(HEIGHT_FOCUS, true);
          }

          // ensure that the layout has been reprocessed before loading glasspane
          documentGridLayout.categoricalLayout();

          m_vis.run(
              "init"); // init is needed to run here, since sizing is tightly-bound with our
                       // faux-fisheye zooming
          //                    m_vis.run("repaint");

          // appear the glasspane at appropriate size & location
          // get relative location of Visualization
          int xOffset = 0;
          int yOffset = 0;
          JComponent component = display;
          // recursively go through this Component's ancestors, summing offset information in order
          // to get the absolute position relative to window
          do {
            Point visLocation = component.getLocation();
            xOffset += visLocation.x;
            yOffset += visLocation.y;
          } while ((!component.getParent().getClass().equals(JRootPane.class))
              && (component = (JComponent) component.getParent()) != null);
          // debug
          //                    System.out.println("debug: " + this.getClass().getName() + ":
          // offsets: " + xOffset + ", " + yOffset);

          String attrIdStr =
              colorAttrName; // TODO make highlighting more general, not just based on color!

          // make sure that the clicked item is not temporarily ``disabled'' (ie, zoom state was not
          // immediately toggled by a glasspane-oriented class)
          if (disableNextZoomItem == null || disableNextZoomItem != item) {
            disableNextZoomItem = null;
            int x = (int) item.getEndX() + bufferPx + xOffset;
            int y = (int) item.getEndY() + bufferPx + yOffset;
            int w = (int) item.getDouble(WIDTH_END) - 2 * bufferPx;
            int h = (int) item.getDouble(HEIGHT_END) - 2 * bufferPx;
            // debug
            System.out.println(
                "debug: "
                    + this.getClass().getName()
                    + ": displaying sized glasspane at x="
                    + x
                    + ", y="
                    + y
                    + ", w="
                    + w
                    + ", h="
                    + h);
            glassPane.displaySizedPane((int) x, (int) y, (int) w, (int) h, item);

            AbstractDocument doc = glassPane.getAbstDoc();
            controller.writeDocTextWithHighlights(doc, nodeId, attrIdStr);

            glassPane.setBackgroundColor(new Color(docColorAction.getColor(item)));
          } else {
            disableNextZoomItem = null;
          }
        }
      }
    }