java.awt.Polygon.intersects()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(215)

本文整理了Java中java.awt.Polygon.intersects()方法的一些代码示例,展示了Polygon.intersects()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.intersects()方法的具体详情如下:
包路径:java.awt.Polygon
类名称:Polygon
方法名:intersects

Polygon.intersects介绍

暂无

代码示例

代码示例来源:origin: org.softsmithy.lib/lib-core

/**
 * Tests if the interior of this Star intersects the interior of a
 * specified Rectangle2D.
 *
 * @param r  a specified Rectangle2D
 * @return   true if this Star and the interior of the specified
 *      Rectangle2D intersect each other; false otherwise.
 * @see      #intersects(double, double, double, double)
 */
public boolean intersects(Rectangle2D r) {
  return fPolygon.intersects(r);
}

代码示例来源:origin: vasl-developers/vasl

public boolean isTouchedBy(Rectangle rect) {
  return hexBorder.intersects(rect);
}

代码示例来源:origin: org.softsmithy.lib/softsmithy-lib-awt

/**
 * Tests if the interior of this Star intersects the interior of a
 * specified Rectangle2D.
 *
 * @param r  a specified Rectangle2D
 * @return   true if this Star and the interior of the specified
 *      Rectangle2D intersect each other; false otherwise.
 * @see      #intersects(double, double, double, double)
 */
@Override
public boolean intersects(Rectangle2D r) {
  return fPolygon.intersects(r);
}

代码示例来源:origin: org.softsmithy.lib/softsmithy-lib-awt

/**
 * Tests if the interior of this Star intersects the interior of a
 * specified set of rectangular coordinates.
 *
 * @param x  x-coordinate of the top-left corner of the specified rectangular area
 * @param y  y-coordinate of the top-left corner of the specified rectangular area
 * @param w  the width of the specified rectangular area
 * @param h  the height of the specified rectangular area
 * @return   true if the interior of this Star and the interior of the
 *      specified set of rectangular coordinates intersect each other; false
 *      otherwise.
 * @see      java.awt.geom.Area
 */

@Override
public boolean intersects(double x, double y, double w, double h) {
  return fPolygon.intersects(x, y, w, h);
}

代码示例来源:origin: org.softsmithy.lib/lib-core

/**
 * Tests if the interior of this Star intersects the interior of a
 * specified set of rectangular coordinates.
 *
 * @param x  x-coordinate of the top-left corner of the specified rectangular area
 * @param y  y-coordinate of the top-left corner of the specified rectangular area
 * @param w  the width of the specified rectangular area
 * @param h  the height of the specified rectangular area
 * @return   true if the interior of this Star and the interior of the
 *      specified set of rectangular coordinates intersect each other; false
 *      otherwise.
 * @see      java.awt.geom.Area
 */

public boolean intersects(double x, double y, double w, double h) {
  return fPolygon.intersects(x, y, w, h);
}

代码示例来源:origin: stackoverflow.com

public ArrayList<Polygon> getNeighbourList(Polygon center, ArrayList<Polygon> possibleNeighbourList){
  // result list
  ArrayList realNeighbourList = new ArrayList();
  for(Polygon p : possibleNeighbourList){
    // check if current polygon is a neighbour of the center polygon by using the spatial relation touches or intersects
    if(center.intersects(p)){
      realNeighbourList.add(p);
    }
  }
  return realNeighbourList;
}

代码示例来源:origin: Audiveris/audiveris

@Override
public boolean intersects (Rectangle rect)
{
  return getPolygon().intersects(rect);
}

代码示例来源:origin: aseldawy/spatialhadoop2

@Override
public boolean isIntersected(Shape s) {
 Rectangle2D mbr = super.getBounds2D();
 return super.intersects(mbr.getMinX(), mbr.getMinY(),
   mbr.getWidth(), mbr.getHeight());
}

代码示例来源:origin: sc.fiji/TrakEM2_

@Override
  synchronized public boolean isRoughlyInside(final Layer layer, final Rectangle r) {
    final Polygon[] pols = getSubPerimeters(layer); // in world coords
    if (null == pols) return false;
    for (final Polygon pol : pols) {
      if (pol.intersects(r)) return true;
    }
    return false;
  }
}

代码示例来源:origin: stackoverflow.com

Polygon givenPolygon = getInputPolygon();

// open source and get data with JDBC
Connection c = DriverManager.getConnection(src);
Statement s = c.createStatement();
ResultSet results = s.executeQuery("SELECT * FROM " + table);

// open dest and copy/filter with jackcess
Database destDB = Database.open(dest);
destDB.copyTable(table, results, new ImportFilter() {
  @Override
  public List<Column> filterColumns(List<Column> cols,
                   ResultSetMetaData metadata)
  throws SQLException, IOException {
    // get all columns
    return cols;
  }

  @Override
  public Object[] filterRow(Object[] row) throws SQLException,
  IOException {
    byte[] blob = row[1]; // or whatever your schema requires
    Polygon p = new Polygon(blob);
    if givenPolygon.intersects(p)
      return row;
    return null;
  }
});

代码示例来源:origin: triplea-game/triplea

protected static void draw(final Rectangle bounds, final Graphics2D graphics, final MapData mapData,
   final Territory territory, final Paint territoryPaint) {
  final List<Polygon> polys = mapData.getPolygons(territory);
  for (final Polygon polygon : polys) {
   if (!polygon.intersects(bounds) && !polygon.contains(bounds)) {
    continue;
   }

   final Polygon translatedPolygon = Util.translatePolygon(polygon, -bounds.x, -bounds.y);
   graphics.setPaint(territoryPaint);
   graphics.fillPolygon(translatedPolygon);
   graphics.setColor(Color.BLACK);
   graphics.drawPolygon(translatedPolygon);
  }
 }
}

代码示例来源:origin: RPTools/maptool

if (targetArea.contains(oa) || targetArea.intersects(oa)) {
  thePoint.put("x", entry.get("x"));
  thePoint.put("y", entry.get("y"));

代码示例来源:origin: triplea-game/triplea

@Override
public void draw(final Rectangle bounds, final GameData data, final Graphics2D graphics, final MapData mapData,
  final AffineTransform unscaled, final AffineTransform scaled) {
 final Territory territory = data.getMap().getTerritory(territoryName);
 final List<Polygon> polys = mapData.getPolygons(territory);
 graphics.setColor(Color.BLACK);
 for (final Polygon polygon : polys) {
  if (!polygon.intersects(bounds) && !polygon.contains(bounds)) {
   continue;
  }
  graphics.drawPolygon(Util.translatePolygon(polygon, -bounds.x, -bounds.y));
 }
}

代码示例来源:origin: triplea-game/triplea

@Override
public void draw(final Rectangle bounds, final GameData data, final Graphics2D graphics, final MapData mapData,
  final AffineTransform unscaled, final AffineTransform scaled) {
 final Territory territory = data.getMap().getTerritory(territoryName);
 final List<Polygon> polys = mapData.getPolygons(territory);
 graphics.setColor(Color.BLACK);
 for (final Polygon polygon : polys) {
  if (!polygon.intersects(bounds) && !polygon.contains(bounds)) {
   continue;
  }
  graphics.drawPolygon(Util.translatePolygon(polygon, -bounds.x, -bounds.y));
 }
}

代码示例来源:origin: triplea-game/triplea

@Override
public void draw(final Rectangle bounds, final GameData data, final Graphics2D graphics, final MapData mapData,
  final AffineTransform unscaled, final AffineTransform scaled) {
 final Territory territory = data.getMap().getTerritory(territoryName);
 final List<Polygon> polys = mapData.getPolygons(territory);
 graphics.setColor(color);
 for (final Polygon polygon : polys) {
  if (!polygon.intersects(bounds) && !polygon.contains(bounds)) {
   continue;
  }
  final Polygon translatedPolygon = Util.translatePolygon(polygon, -bounds.x, -bounds.y);
  if (operation == Operation.FILL) {
   graphics.fillPolygon(translatedPolygon);
  } else {
   graphics.drawPolygon(translatedPolygon);
  }
 }
}

代码示例来源:origin: Audiveris/audiveris

if (!getPolygon().intersects(thatFatBox)) {
  return false;

代码示例来源:origin: sc.fiji/TrakEM2_

/** Link the Patch objects that lay underneath the bounding box of this Displayable, so that they cannot be dragged independently.
 *  @return whether the locking state changed. */
public boolean linkPatches() {
  // find the patches that don't lay under other profiles of this profile's linking group, and make sure they are unlinked. This will unlink any Patch objects under this Profile:
  unlinkAll(Patch.class);
  // scan the Display and link Patch objects that lay under this Profile's bounding box:
  // catch all displayables of the current Layer
  final ArrayList<Displayable> al = layer.getDisplayables(Patch.class);
  // this bounding box:
  final Polygon perimeter = getPerimeter(); //displaced by this object's position!
  if (null == perimeter) return false; // happens when a profile with zero points is deleted
  // for each Patch, check if it underlays this profile's bounding box
  Rectangle box = new Rectangle();
  boolean must_lock = false;
  for (final Displayable displ : al) {
    // stupid java, Polygon cannot test for intersection with another Polygon !! //if (perimeter.intersects(displ.getPerimeter())) // TODO do it yourself: check if a Displayable intersects another Displayable
    if (perimeter.intersects(displ.getBoundingBox(box))) {
      // Link the patch
      this.link(displ);
      if (displ.locked) must_lock = true;
    }
  }
  // set the locked flag to this and all linked ones
  if (must_lock && !locked) {
    setLocked(true);
    return true;
  }
  return false;
}

代码示例来源:origin: vasl-developers/vasl

/**
 * Maps all ground level elevation from one level to another within a given shape.
 *
 * @parameter fromElevation original ground level elevation to replace
 * @parameter toTerrain new ground level elevation
 */
public boolean changeAllGroundLevel(int fromElevation, int toElevation, Shape s) {
  boolean changed = false;
  // change the map grid
  for (int i = 0; i < map.getGridWidth(); i++) {
    for (int j = 0; j < map.getGridHeight(); j++) {
      if (map.getGridElevation(i, j) == fromElevation && s.contains((double) i, (double) j)) {
        map.setGridElevation(toElevation, i, j);
        changed = true;
      }
    }
  }
  // change the base height of the hex grid
  for (int col = 0; col < map.getWidth(); col++) {
    for (int row = 0; row < map.getHeight() + (col % 2); row++) {
      Hex[][] hexGrid = map.getHexGrid();
      if (hexGrid[col][row].getBaseHeight() == fromElevation &&
          hexGrid[col][row].getHexBorder().intersects(s.getBounds())) {
        hexGrid[col][row].setBaseHeight(toElevation);
        changed = true;
      }
    }
  }
  return changed;
}

代码示例来源:origin: Audiveris/audiveris

/**
 * Look up for a potential rest interleaved between the given stemmed chords
 *
 * @param left  the chord on the left of the area
 * @param right the chord on the right of the area
 * @return the rest found, or null otherwise
 */
public RestInter lookupRest (AbstractChordInter left,
               AbstractChordInter right)
{
  // Define the area limited by the left and right chords with their stems
  // and check for intersection with a rest note
  Polygon polygon = new Polygon();
  polygon.addPoint(left.getHeadLocation().x, left.getHeadLocation().y);
  polygon.addPoint(left.getTailLocation().x, left.getTailLocation().y);
  polygon.addPoint(right.getTailLocation().x, right.getTailLocation().y);
  polygon.addPoint(right.getHeadLocation().x, right.getHeadLocation().y);
  for (RestChordInter restChord : getRestChords()) {
    for (Inter inter : restChord.getMembers()) {
      Rectangle box = inter.getBounds();
      if (polygon.intersects(box.x, box.y, box.width, box.height)) {
        return (RestInter) inter;
      }
    }
  }
  return null;
}

代码示例来源:origin: vasl-developers/vasl

if (hexGrid[col][row].getHexBorder().intersects(s.getBounds())) {

相关文章