Esempio n. 1
1
  public void unregisterKeyStroke(KeyStroke ks, JComponent c) {

    // component may have already been removed from the hierarchy, we
    // need to look up the container using the componentKeyStrokeMap.

    ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c, ks);

    Container topContainer = componentKeyStrokeMap.get(ckp);

    if (topContainer == null) { // never heard of this pairing, so bail
      return;
    }

    Hashtable keyMap = containerMap.get(topContainer);
    if (keyMap == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    Object tmp = keyMap.get(ks);
    if (tmp == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    if (tmp instanceof JComponent && tmp == c) {
      keyMap.remove(ks); // remove the KeyStroke from the Map
      // System.out.println("removed a stroke" + ks);
    } else if (tmp
        instanceof Vector) { // this means there is more than one component reg for this key
      Vector v = (Vector) tmp;
      v.removeElement(c);
      if (v.isEmpty()) {
        keyMap.remove(ks); // remove the KeyStroke from the Map
        // System.out.println("removed a ks vector");
      }
    }

    if (keyMap.isEmpty()) { // if no more bindings in this table
      containerMap.remove(topContainer); // remove table to enable GC
      // System.out.println("removed a container");
    }

    componentKeyStrokeMap.remove(ckp);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).unregisterAccelerator(ks);
    }
  }
Esempio n. 2
0
 /**
  * Detach the DataSet from the class. Data associated with the DataSet will nolonger be plotted.
  *
  * @param d The DataSet to detach.
  */
 public void detachDataSet(DataSet d) {
   if (d != null) {
     if (d.xaxis != null) d.xaxis.detachDataSet(d);
     if (d.yaxis != null) d.yaxis.detachDataSet(d);
     dataset.removeElement(d);
   }
 }
Esempio n. 3
0
  /**
   * Detach a previously attached Axis.
   *
   * @param the Axis to dettach.
   */
  public void detachAxis(Axis a) {

    if (a != null) {
      a.detachAll();
      a.g2d = null;
      axis.removeElement(a);
    }
  }
Esempio n. 4
0
 public void unregisterMenuBar(JMenuBar mb) {
   Container topContainer = getTopAncestor(mb);
   if (topContainer == null) {
     return;
   }
   Hashtable keyMap = containerMap.get(topContainer);
   if (keyMap != null) {
     Vector v = (Vector) keyMap.get(JMenuBar.class);
     if (v != null) {
       v.removeElement(mb);
       if (v.isEmpty()) {
         keyMap.remove(JMenuBar.class);
         if (keyMap.isEmpty()) {
           // remove table to enable GC
           containerMap.remove(topContainer);
         }
       }
     }
   }
 }