예제 #1
0
파일: TDTree.java 프로젝트: CDargis/TDTree
  /**
   * Returns the closest point to @param p. Works recursively. Compares current point with p, then
   * checks which tree to explore sub-trees
   *
   * @param t
   * @param p
   * @param best
   * @param bestDistance
   * @param cd
   * @return Point nearest to p
   */
  private Point nearest(TreeNode t, Point p, Point best, double bestDistance, boolean cd) {
    if (p == null) return best;
    if (t == null) return best;
    nodesTouchedOnNearest++;
    // System.out.println(t.p.toString());

    double distance = squaredDistance(t.p, p);
    if (distance < bestDistance) {
      best = t.p;
      bestDistance = distance;
    }

    Point result;
    if (cd) {
      if (p.x() < t.p.x()) result = nearest(t.left, p, best, bestDistance, !cd);
      else if (p.x() > t.p.x()) result = nearest(t.right, p, best, bestDistance, !cd);
      else { // They must be equal, cut on y
        if (p.y() < t.p.y()) result = nearest(t.left, p, best, bestDistance, !cd);
        else result = nearest(t.right, p, best, bestDistance, !cd);
      }
    } else {
      if (p.y() < t.p.y()) result = nearest(t.left, p, best, bestDistance, !cd);
      else if (p.y() > t.p.y()) result = nearest(t.right, p, best, bestDistance, !cd);
      else { // They must be equal, cut on x
        if (p.x() < t.p.x()) result = nearest(t.left, p, best, bestDistance, !cd);
        else result = nearest(t.right, p, best, bestDistance, !cd);
      }
    }
    distance = squaredDistance(result, p);
    if (distance < bestDistance) {
      best = result;
      bestDistance = distance;
    }
    return best;
  }
예제 #2
0
  /**
   * Translate coordinates from one window into another. Optimized for XAWT - uses cached data when
   * possible. Preferable over pure XTranslateCoordinates.
   *
   * @return coordinates relative to dst, or null if error happened
   */
  static Point toOtherWindow(long src, long dst, int x, int y) {
    Point rpt = new Point(0, 0);

    // Check if both windows belong to XAWT - then no X calls are necessary

    XBaseWindow srcPeer = XToolkit.windowToXWindow(src);
    XBaseWindow dstPeer = XToolkit.windowToXWindow(dst);

    if (srcPeer != null && dstPeer != null) {
      // (x, y) is relative to src
      rpt.x = x + srcPeer.getAbsoluteX() - dstPeer.getAbsoluteX();
      rpt.y = y + srcPeer.getAbsoluteY() - dstPeer.getAbsoluteY();
    } else if (dstPeer != null && XlibUtil.isRoot(src, dstPeer.getScreenNumber())) {
      // from root into peer
      rpt.x = x - dstPeer.getAbsoluteX();
      rpt.y = y - dstPeer.getAbsoluteY();
    } else if (srcPeer != null && XlibUtil.isRoot(dst, srcPeer.getScreenNumber())) {
      // from peer into root
      rpt.x = x + srcPeer.getAbsoluteX();
      rpt.y = y + srcPeer.getAbsoluteY();
    } else {
      rpt = XlibUtil.translateCoordinates(src, dst, new Point(x, y));
    }
    return rpt;
  }
예제 #3
0
  public void drawOn(Page page) throws Exception {
    if (fill_shape) {
      page.setBrushColor(color[0], color[1], color[2]);
    } else {
      page.setPenColor(color[0], color[1], color[2]);
    }
    page.setPenWidth(width);
    page.setLinePattern(pattern);

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x += box_x;
      point.y += box_y;
    }

    if (fill_shape) {
      page.drawPath(points, 'f');
    } else {
      if (close_path) {
        page.drawPath(points, 's');
      } else {
        page.drawPath(points, 'S');
      }
    }

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x -= box_x;
      point.y -= box_y;
    }
  }
예제 #4
0
파일: TDTree.java 프로젝트: CDargis/TDTree
 // This method returns true of p lies in the rectangle outlined by sw, se, nw, ne
 private boolean subTreeInRange(Point sw, Point se, Point nw, Point ne, Point p) {
   if (sw.x() < p.x() && p.x() < se.x()) {
     if (sw.y() < p.y() && p.y() < nw.y()) {
       return true;
     }
   }
   return false;
 }
예제 #5
0
 public Point getLocation() {
   if (inEditMode) {
     tmpLoc.x = defLoc.x;
     tmpLoc.y = defLoc.y;
   } else {
     tmpLoc.x = curLoc.x;
     tmpLoc.y = curLoc.y;
   }
   return tmpLoc;
 }
예제 #6
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   super.reshape(x, y, w, h);
 }
예제 #7
0
 /** NOTE: the connection from java to matlab */
 public RCvalue java2Matlab() throws EvalException {
   if (rc == null) {
     if (poly != null) {
       Value[] v = new Value[poly.degree()];
       for (int i = 0; i < v.length; i++) {
         Point pt = poly.point(i);
         assert pt.type() == CohoDouble.type
             : "The result type is not CohoDouble, it is " + pt.type();
         //					if(pt.type()!=CohoDouble.type){
         //					throw new RuntimeException("The result type is not CohoDouble, it is "+pt.type() );
         //					}
         v[i] =
             RCvalue.factory()
                 .create(
                     new Value[] {
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.x()).doubleValue()), null),
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.y()).doubleValue()), null)
                     },
                     false);
       }
       rc = (RCvalue) (RCvalue.factory().create(v, true));
     } else { // empty polygon
       rc = (RCvalue) (RCvalue.factory().create(new Value[0], true));
     }
   }
   return (rc);
 }
 protected RelativePoint getPointToShowResults() {
   final int selectedRow = myTree.getSelectionRows()[0];
   final Rectangle rowBounds = myTree.getRowBounds(selectedRow);
   final Point location = rowBounds.getLocation();
   location.x += rowBounds.width;
   return new RelativePoint(myTree, location);
 }
예제 #9
0
 private void centerOnScreen(Frame frame) {
   Point point = frame.getLocationOnScreen();
   Dimension dimension = frame.getSize();
   Dimension dimension1 = getSize();
   point.x += (dimension.width - dimension1.width) / 2;
   point.y += (dimension.height - dimension1.height) / 2;
   Dimension dimension2 = Toolkit.getDefaultToolkit().getScreenSize();
   if (point.x < 0
       || point.y < 0
       || point.x + dimension1.width > dimension2.width
       || point.y + dimension1.height > dimension2.height) {
     point.x = (dimension2.width - dimension1.width) / 2;
     point.y = (dimension2.height - dimension1.height) / 2;
   }
   setLocation(point.x, point.y);
 }
예제 #10
0
 public void scaleBy(double factor) throws Exception {
   for (int i = 0; i < points.size(); i++) {
     Point point = points.get(i);
     point.x *= factor;
     point.y *= factor;
   }
 }
예제 #11
0
파일: TDTree.java 프로젝트: CDargis/TDTree
  // Private method for deleting a node. Called from the public delete method. Works recursively
  // Method works by recursively deleting a node, and then once backing out of the recursion all
  // data members are updated for each node
  private boolean delete(TreeNode t, Point p, boolean cd) {
    boolean status = false;
    // Base case, not found so return false
    if (t == null) return false;
    if (t.p.equals(p)) { // Found the node, now delete it
      if (t.right != null) {
        TreeNode min = findMin(t.right, cd);
        swapData(t, min);
        status = delete(min, min.p, min.cd);
      } else if (t.left != null) {
        TreeNode min = findMin(t.left, cd);
        swapData(t, min);
        t.right = t.left;
        t.left = null;
        status = delete(min, min.p, min.cd);
      } else { // At a leaf, remove the node
        size--;
        status = deleteFromParent(t);
      }
    } else if (cd) {
      if (p.x() < t.p.x()) status = delete(t.left, p, !cd);
      else if (p.x() > t.p.x()) status = delete(t.right, p, !cd);
      else { // They must be equal, cut on y
        if (p.y() < t.p.y()) status = delete(t.left, p, !cd);
        else status = delete(t.right, p, !cd);
      }
    } else {
      if (p.y() < t.p.y()) status = delete(t.left, p, !cd);
      else if (p.y() > t.p.y()) status = delete(t.right, p, !cd);
      else { // They must be equal, cut on x
        if (p.x() < t.p.x()) status = delete(t.left, p, !cd);
        else status = delete(t.right, p, !cd);
      }
    }
    // Backing out of recursion, need to update data members
    updateMinMaxOnDeleteAndRebuild(t);
    t.height = maxHeight(t.left, t.right) + 1;

    // Check if becoming unbalanced
    if (unbalanced(t)) {
      Point[] points = collectSatanSpawn(t);
      TDTree newSubTree = new TDTree(points, cd);
      swapDataMembers(t, newSubTree.root);
    }
    return status;
  } // End private delete method
  public void updatePosition() {
    Point position = new Point(spaceOccupied.x, spaceOccupied.y);

    // Insert random behavior.  During
    // each update, a sprite has about
    // one chance in 10 of making a
    // random change to its
    // motionVector.  When a change
    // occurs, the motionVector
    // coordinate values are forced to
    // fall between -7 and 7.  This
    // puts a cap on the maximum speed
    // for a sprite.
    if (rand.nextInt() % 10 == 0) {
      Point randomOffset = new Point(rand.nextInt() % 3, rand.nextInt() % 3);
      motionVector.x += randomOffset.x;
      if (motionVector.x >= 7) motionVector.x -= 7;
      if (motionVector.x <= -7) motionVector.x += 7;
      motionVector.y += randomOffset.y;
      if (motionVector.y >= 7) motionVector.y -= 7;
      if (motionVector.y <= -7) motionVector.y += 7;
    } // end if

    // Move the sprite on the screen
    position.translate(motionVector.x, motionVector.y);

    // Bounce off the walls
    boolean bounceRequired = false;
    Point tempMotionVector = new Point(motionVector.x, motionVector.y);

    // Handle walls in x-dimension
    if (position.x < bounds.x) {
      bounceRequired = true;
      position.x = bounds.x;
      // reverse direction in x
      tempMotionVector.x = -tempMotionVector.x;
    } else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width)) {
      bounceRequired = true;
      position.x = bounds.x + bounds.width - spaceOccupied.width;
      // reverse direction in x
      tempMotionVector.x = -tempMotionVector.x;
    } // end else if

    // Handle walls in y-dimension
    if (position.y < bounds.y) {
      bounceRequired = true;
      position.y = bounds.y;
      tempMotionVector.y = -tempMotionVector.y;
    } else if ((position.y + spaceOccupied.height) > (bounds.y + bounds.height)) {
      bounceRequired = true;
      position.y = bounds.y + bounds.height - spaceOccupied.height;
      tempMotionVector.y = -tempMotionVector.y;
    } // end else if

    if (bounceRequired)
      // save new motionVector
      setMotionVector(tempMotionVector);
    // update spaceOccupied
    setSpaceOccupied(position);
  } // end updatePosition()
예제 #13
0
  /* カーソル移動 */
  public void move_cursor(Object.DIRECTION dir) {
    int nx = select_point.x + Object.DirectionVector[dir.ordinal()][0];
    int ny = select_point.y + Object.DirectionVector[dir.ordinal()][1];

    if (inner(nx, ny)) {
      select_point.x = nx;
      select_point.y = ny;
    }
  }
예제 #14
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   if (!inEditMode) {
     if ((h != nHeight) || (h < rHeight)) {
       adjustFont(w, h);
     }
   }
   super.reshape(x, y, w, h);
 }
예제 #15
0
파일: TDTree.java 프로젝트: CDargis/TDTree
 // Recursive method for determining if a point is in the tree
 // This function works very similar to the insert method
 private boolean contains(TreeNode t, Point p, boolean even) {
   if (p == null) return false;
   if (t == null) return false;
   if (t.p.equals(p)) return true; // Found the point, return true
   if (even) {
     if (p.x() < t.p.x()) return contains(t.left, p, !even);
     else if (p.x() > t.p.x()) return contains(t.right, p, !even);
     else { // They must be equal, cut on y
       if (p.y() < t.p.y()) return contains(t.left, p, !even);
       else return contains(t.right, p, !even);
     }
   } else {
     if (p.y() < t.p.y()) return contains(t.left, p, !even);
     else if (p.y() > t.p.y()) return contains(t.right, p, !even);
     else { // They must be equal, cut on x
       if (p.x() < t.p.x()) return contains(t.left, p, !even);
       else return contains(t.right, p, !even);
     }
   }
 } // End contains method
예제 #16
0
 public void setSizeRatio(double x, double y) {
   xRatio = x;
   yRatio = y;
   if (x > 1.0) xRatio = x - 1.0;
   if (y > 1.0) yRatio = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * xRatio);
   curLoc.y = (int) ((double) defLoc.y * yRatio);
   curDim.width = (int) ((double) defDim.width * xRatio);
   curDim.height = (int) ((double) defDim.height * yRatio);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
 }
예제 #17
0
  /** Constrains a point to the current grid. */
  protected Point constrainPoint(Point p) {
    // constrain to view size
    Dimension size = getSize();
    // p.x = Math.min(size.width, Math.max(1, p.x));
    // p.y = Math.min(size.height, Math.max(1, p.y));
    p.x = Geom.range(1, size.width, p.x);
    p.y = Geom.range(1, size.height, p.y);

    if (fConstrainer != null) {
      return fConstrainer.constrainPoint(p);
    }
    return p;
  }
예제 #18
0
 public void setEditMode(boolean s) {
   twin.setEditMode(s);
   setOpaque(s);
   if (s) {
     addMouseListener(ml);
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     defDim = getPreferredSize();
     curDim.width = defDim.width;
     curDim.height = defDim.height;
   } else removeMouseListener(ml);
   inEditMode = s;
 }
예제 #19
0
 public void setSizeRatio(double x, double y) {
   double rx = x;
   double ry = y;
   if (rx > 1.0) rx = x - 1.0;
   if (ry > 1.0) ry = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * rx);
   curLoc.y = (int) ((double) defLoc.y * ry);
   curDim.width = (int) ((double) defDim.width * rx);
   curDim.height = (int) ((double) defDim.height * ry);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
   twin.setSizeRatio(x, y);
 }
예제 #20
0
    private void ensureInBounds() {
      if (bounds == null) {
        bounds = new Rect(0, 0, width, height);
      }

      float xMin = bounds.x + radius;
      float xMax = bounds.w + bounds.x - radius;
      float yMin = bounds.y + radius;
      float yMax = (bounds.h + bounds.y) - radius;
      if (pos.x < xMin) {
        pos.x = xMin;

        vel.x *= COLLISION_SCALE;
      } else if (pos.x > xMax) {
        pos.x = xMax;

        vel.x *= COLLISION_SCALE;
      }

      if (pos.y < yMin) {
        pos.y = yMin;
        vel.y *= COLLISION_SCALE;
      } else if (pos.y > yMax) {
        pos.y = yMax;
        vel.y *= COLLISION_SCALE;
      }

      Float p1 = new Float(pos.x);
      Float p2 = new Float(pos.y);
      Float v1 = new Float(vel.x);
      Float v2 = new Float(vel.y);

      // If anything is NaN -- make new Point and Velocity
      if (p1.isNaN(p1) || p2.isNaN(p2) || v1.isNaN(v1) || v2.isNaN(v2)) {
        pos = new Point(random(width), random(height)); // Place new point randomly
        vel = new Vector(0.0f, 0.0f); // Start it out with no movement
      }
    }
  /**
   * Returns the component in the currently selected path which contains sourcePoint.
   *
   * @param source The component in whose coordinate space sourcePoint is given
   * @param sourcePoint The point which is being tested
   * @return The component in the currently selected path which contains sourcePoint (relative to
   *     the source component's coordinate space. If sourcePoint is not inside a component on the
   *     currently selected path, null is returned.
   */
  public Component componentForPoint(Component source, Point sourcePoint) {
    int screenX, screenY;
    Point p = sourcePoint;
    int i, c, j, d;
    Component mc;
    Rectangle r2;
    int cWidth, cHeight;
    MenuElement menuElement;
    MenuElement subElements[];
    Vector<MenuElement> tmp;
    int selectionSize;

    SwingUtilities.convertPointToScreen(p, source);

    screenX = p.x;
    screenY = p.y;

    tmp = (Vector<MenuElement>) selection.clone();
    selectionSize = tmp.size();
    for (i = selectionSize - 1; i >= 0; i--) {
      menuElement = (MenuElement) tmp.elementAt(i);
      subElements = menuElement.getSubElements();

      for (j = 0, d = subElements.length; j < d; j++) {
        if (subElements[j] == null) continue;
        mc = subElements[j].getComponent();
        if (!mc.isShowing()) continue;
        if (mc instanceof JComponent) {
          cWidth = mc.getWidth();
          cHeight = mc.getHeight();
        } else {
          r2 = mc.getBounds();
          cWidth = r2.width;
          cHeight = r2.height;
        }
        p.x = screenX;
        p.y = screenY;
        SwingUtilities.convertPointFromScreen(p, mc);

        /**
         * Return the deepest component on the selection path in whose bounds the event's point
         * occurs
         */
        if (p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight) {
          return mc;
        }
      }
    }
    return null;
  }
  /**
   * Calls the given treeNode.
   *
   * @param treeNode the <tt>TreeNode</tt> to call
   */
  private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) {
    if (!(treeNode instanceof ContactNode)) return;

    UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor();

    Point location = new Point(button.getX(), button.getY() + button.getHeight());

    SwingUtilities.convertPointToScreen(location, treeContactList);

    location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;
    location.x += 8;
    location.y -= 8;

    CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location);
  }
예제 #23
0
파일: TDTree.java 프로젝트: CDargis/TDTree
  private boolean boxOverlaps(TreeNode t, Point sw, Point ne) {
    Point nw = new Point(sw.x(), ne.y());
    Point se = new Point(ne.x(), sw.y());

    Point myNw = new Point(t.minX.p.x(), t.maxY.p.y());
    Point mySe = new Point(t.maxX.p.x(), t.minY.p.y());

    if (myNw.x() >= nw.x() || myNw.y() >= nw.y() || mySe.x() <= se.x() || mySe.y() <= se.y()) {
      return true;
    }
    return false;
  }
예제 #24
0
파일: TDTree.java 프로젝트: CDargis/TDTree
  // Works the exact same way as rangeSize(). Simply checks if sub-tree possibly contains points in
  // query
  private void rangeQuery(Point sw, Point ne, Collection<Point> result, TreeNode t) {
    if (t == null) return;

    if (subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minY.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxY.p)) {
      rangeQuery(sw, ne, result, t.left);
      rangeQuery(sw, ne, result, t.right);
    } else return;

    if (inRange(sw, ne, t.p)) result.add(t.p);
  }
예제 #25
0
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      Point p = evt.getPoint();
      if (evt.getSource() != table) {
        p.x -= table.getX();
        p.y -= table.getY();
      }

      int row = table.rowAtPoint(p);
      int column = table.columnAtPoint(p);
      if (column == 0 && row != -1) {
        VFSDirectoryEntryTableModel.Entry entry =
            (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0);
        if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) {
          table.toggleExpanded(row);
          return;
        }
      }

      if (GUIUtilities.isMiddleButton(evt.getModifiers())) {
        if (row == -1) /* nothing */ ;
        else if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row);
        else table.getSelectionModel().setSelectionInterval(row, row);
      } else if (GUIUtilities.isPopupTrigger(evt)) {
        if (popup != null && popup.isVisible()) {
          popup.setVisible(false);
          popup = null;
          return;
        }

        if (row == -1) showFilePopup(null, table, evt.getPoint());
        else {
          if (!table.getSelectionModel().isSelectedIndex(row))
            table.getSelectionModel().setSelectionInterval(row, row);
          showFilePopup(getSelectedFiles(), table, evt.getPoint());
        }
      }
    } // }}}
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Dimension asz = this.getSize();

    if (fullRefresh) {
      g2.clearRect(0, 0, asz.width, asz.height);
      fullRefresh = false;
    }
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    big.setColor(Color.black);
    offset.x = (int) (asz.width - iw) / 2;
    offset.y = (int) (asz.height - ih) / 2;
    big.drawImage(img, 0, 0, this);
    big.setPaint(Color.red);
    if ((rect.width > 0) && (rect.height > 0)) big.draw(rect);
    if (selected == 1) shadeExt(big, 0, 0, 0, 64);
    else if (selected == 2) {
      shadeExt(big, 0, 0, 0, 255);
      selected = 1;
    }
    g2.drawImage(bi, offset.x, offset.y, this);
  }
예제 #27
0
 public void setEditMode(boolean s) {
   if (s) {
     addMouseListener(ml);
     setOpaque(s);
     if (font != null) {
       setFont(font);
       fontH = font.getSize();
       rHeight = fontH;
     }
     defDim = getPreferredSize();
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     curDim.width = defDim.width;
     curDim.height = defDim.height;
     xRatio = 1.0;
     yRatio = 1.0;
   } else {
     removeMouseListener(ml);
     if ((bg != null) || (isActive < 1)) setOpaque(true);
     else setOpaque(false);
   }
   inEditMode = s;
 }
예제 #28
0
파일: TDTree.java 프로젝트: CDargis/TDTree
  // Private method for calculating range size. Works by checking if two rectangles overlap each
  // other
  // If the two overlap (range query and range of points in sub-tree), keep searching. If not return
  // 0
  private int rangeSize(Point sw, Point ne, TreeNode t) {
    if (t == null) return 0; // Fell out of tree
    int count = 0;
    if (subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minY.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxY.p)) {

      count += rangeSize(sw, ne, t.left);
      count += rangeSize(sw, ne, t.right);
    } else return 0; // If there is no overlap, return 0

    if (inRange(sw, ne, t.p)) { // Add current node to count if within range
      count++;
    }

    return count;
  }
예제 #29
0
 public Point getDefLoc() {
   tmpLoc.x = defLoc.x;
   tmpLoc.y = defLoc.y;
   return tmpLoc;
 }
예제 #30
0
 public void setDefLoc(int x, int y) {
   defLoc.x = x;
   defLoc.y = y;
 }