Exemplo n.º 1
0
 @Override
 public boolean isInBounds(Bounds bounds) {
   // TODO there is no float polygon, so I have to think about s.th. else (or leave it the way it
   // is now)
   int x[] = new int[nodes.length];
   int y[] = new int[nodes.length];
   int i = 0;
   for (Node node : nodes) {
     x[i] = (int) (node.getPos().getLongitude() * 1000); // 1000 is a random factor, can be changed
     i++;
   }
   i = 0;
   for (Node node : nodes) {
     y[i] = (int) (node.getPos().getLatitude() * 1000);
     i++;
   }
   Polygon area = new Polygon(x, y, nodes.length);
   Rectangle2D.Double box =
       new Rectangle2D.Double(
           bounds.getLeft() * 1000 - 1,
           bounds.getTop() * 1000 - 1,
           bounds.getWidth() * 1000 + 1,
           bounds.getHeight() * 1000 + 1);
   boolean inside = false;
   for (Node node : nodes) {
     if (node.isInBounds(bounds)) {
       inside = true;
     }
   }
   return inside || area.contains(box) || area.intersects(box);
 }