Exemplo n.º 1
0
 public Tree(String key, String value, TreeDisplay display) {
   this.left = null;
   this.right = null;
   this.key = key;
   this.value = value;
   this.display = display;
   display.displayMessage("[" + key + "] Created with value " + value, java.awt.Color.blue);
 }
Exemplo n.º 2
0
  public ObjectWrapper search(String key) {
    display.displayMessage("[" + this.key + "] Searching for " + key);
    if (key == null) {
      return new ObjectWrapper("null");
    }
    ;

    int res = key.compareTo(this.key);
    if (res == 0) {
      display.displayMessage("[" + this.key + "] Found " + key);
      return new ObjectWrapper(value);
    }
    if (res < 0) {
      return (left != null) ? left.search(key) : new ObjectWrapper("null");
    } else {
      return (right != null) ? right.search(key) : new ObjectWrapper("null");
    }
  }
Exemplo n.º 3
0
  public void insert(String key, String value, boolean AC) {
    int res = key.compareTo(this.key);
    if (res == 0) {
      // Same key --> Modify the current value
      display.displayMessage("[" + key + "] Replacing " + this.value + " with " + value);
      this.value = value;
    } else if (res < 0) {
      display.displayMessage("[" + key + "] trying left");
      // key < this.key --> store left
      if (left != null) {
        left.insert(key, value, AC);
      } else {
        display.displayMessage("[" + key + "] Creating left");
        // Create the new node
        try {
          left =
              org.objectweb.proactive.api.PAActiveObject.newActive(
                  this.getClass(), new Object[] {key, value, display});
        } catch (Exception e) {
          e.printStackTrace();
        }

        // Enabled Automatic Continuations
        if (AC) {
          try {
            org.objectweb.proactive.api.PAActiveObject.enableAC(
                org.objectweb.proactive.api.PAActiveObject.getStubOnThis());
          } catch (java.io.IOException e) {
            display.displayMessage("Automatic Continuations error!!!", java.awt.Color.red);
          }
        }
      }
    } else {
      display.displayMessage("[" + key + "] trying right");
      if (right != null) {
        right.insert(key, value, AC);
      } else {
        display.displayMessage("[" + key + "] Creating right");
        try {
          right =
              org.objectweb.proactive.api.PAActiveObject.newActive(
                  this.getClass(), new Object[] {key, value, display});
        } catch (Exception e) {
          e.printStackTrace();
        }

        // Enabled Automatic Continuations
        if (AC) {
          try {
            org.objectweb.proactive.api.PAActiveObject.enableAC(
                org.objectweb.proactive.api.PAActiveObject.getStubOnThis());
          } catch (java.io.IOException e) {
            display.displayMessage("Automatic Continuations error!!!", java.awt.Color.red);
          }
        }
      }
    }
  }
Exemplo n.º 4
0
 public void onCreate(Bundle savedInstanceState) {
   mapFragmentId = R.id.moveable_marker_map;
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_tree_move);
   setUpMapIfNeeded();
   showPositionOnMap();
   plotMarker.setDraggable(true);
   SegmentedButton buttons = (SegmentedButton) findViewById(R.id.basemap_controls);
   MapHelper.setUpBasemapControls(buttons, mMap);
 }
Exemplo n.º 5
0
 @Override
 public void run() {
   try {
     try {
       treeDisplay.start();
     } catch (IOException ex) {
       Logger.getLogger(DisplayThread.class.getName()).log(Level.SEVERE, null, ex);
     }
   } catch (LWJGLException ex) {
     Logger.getLogger(DisplayThread.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Exemplo n.º 6
0
 public void disableAC() {
   try {
     org.objectweb.proactive.api.PAActiveObject.disableAC(
         org.objectweb.proactive.api.PAActiveObject.getStubOnThis());
     if (right != null) {
       right.disableAC();
     }
     if (left != null) {
       left.disableAC();
     }
   } catch (java.io.IOException e) {
     display.displayMessage("Automatic Continuations error!!!", java.awt.Color.red);
   }
 }