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

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

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

Polygon.getBounds介绍

[英]Gets the bounding box of this Polygon. The bounding box is the smallest Rectangle whose sides are parallel to the x and y axes of the coordinate space, and can completely contain the Polygon.
[中]获取此Polygon的边界框。边界框是最小的矩形,其边平行于坐标空间的x轴和y轴,可以完全包含Polygon

代码示例

代码示例来源:origin: haraldk/TwelveMonkeys

/**
 * Read in a polygon. The input stream should be positioned at the first byte
 * of the polygon.
 *
 * @param pStream the stream to read from
 * @param pBounds the bounds rectangle to read into
 *
 * @return the polygon
 *
 * @throws IOException if an I/O error occurs while reading the image.
 */
private Polygon readPoly(DataInput pStream, Rectangle pBounds) throws IOException {
  // Get polygon data size
  int size = pStream.readUnsignedShort();
  // Get poly bounds
  readRectangle(pStream, pBounds);
  // Initialize the point array to the right size
  int points = (size - 10) / 4;
  // Get the rest of the polygon points
  Polygon polygon = new Polygon();
  for (int i = 0; i < points; i++) {
    int y = getYPtCoord(pStream.readShort());
    int x = getXPtCoord(pStream.readShort());
    polygon.addPoint(x, y);
  }
  if (!pBounds.contains(polygon.getBounds())) {
    processWarningOccurred("Bad poly, contains point(s) out of bounds " + pBounds + ": " + polygon);
  }
  return polygon;
}

代码示例来源:origin: geotools/geotools

rasterSpaceROI = rectangleToPolygon(finalRasterArea);
if (rasterSpaceROI == null || rasterSpaceROI.getBounds().isEmpty())
  if (finalRasterArea.isEmpty())
    throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

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

/**
 * Gets the bounding box of this Star. The bounding box is the smallest
 * rectangle whose sides are parallel to the x and y axes of the coordinate
 * space, and can completely contain the Star.
 * @return a Rectangle that defines the bounds of this Star.
 * @see #getBounds2D()
 */
public Rectangle getBounds() {
  return fPolygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see edu.indiana.extreme.xbaya.graph.gui.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

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

/**
 * Gets the bounding box of this Star. The bounding box is the smallest
 * rectangle whose sides are parallel to the x and y axes of the coordinate
 * space, and can completely contain the Star.
 * @return a Rectangle that defines the bounds of this Star.
 * @see #getBounds2D()
 */
@Override
public Rectangle getBounds() {
  return fPolygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see org.apache.airavata.xbaya.ui.graph.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

/**
 * @see edu.indiana.extreme.xbaya.graph.gui.NodeGUI#getBounds()
 */
@Override
protected Rectangle getBounds() {
  return this.polygon.getBounds();
}

代码示例来源:origin: MegaMek/megamek

public CursorSprite(BoardView1 boardView1, final Color color) {
  super(boardView1);
  this.color = color;
  bounds = new Rectangle(BoardView1.hexPoly.getBounds().width + 1,
      BoardView1.hexPoly.getBounds().height + 1);
  image = null;
  // start offscreen
  setOffScreen();
}

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

@Override
public Rectangle getBounds ()
{
  return getPolygon().getBounds(); // This is always a fresh copy of rectangle
}

代码示例来源:origin: edu.stanford.protege/org.coode.owlviz

/**
 * Gets the size of the <code>Node</code>.
 * @return A <code>Dimension</code> containing the width and height
 * of the <code>Node</code>.
 */
public Dimension getSize()
{
  return triangle.getBounds().getSize();
}

代码示例来源:origin: MegaMek/megamek

@Override
public Rectangle getBounds() {
  bounds = new Rectangle(BoardView1.hexPoly.getBounds().width + 1,
      BoardView1.hexPoly.getBounds().height + 1);
  bounds.setLocation(bv.getHexLocation(hexLoc));
  return bounds;
}

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

Polygon shape = new Polygon();
shape.addPoint(...);
....
Rectangle bounds = shape.getBounds();
AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(angle), bounds.width / 2, bounds.height / 2);

Path2D path = (shape instanceof Path2D) ? (Path2D)shape : new GeneralPath(shape);
Shape rotated = path.createTransformedShape( transform );
System.out.println(rotated.getBounds());

代码示例来源:origin: MegaMek/megamek

@Override
public Rectangle getBounds() {
  if (true) {
    makePoly();
  }
  // set bounds
  bounds = new Rectangle(flyOverPoly.getBounds());
  bounds.setSize(bounds.getSize().width + 1, bounds.getSize().height + 1);
  return bounds;
}

代码示例来源:origin: de.biomedical-imaging.ij/ij_blob

public static ImagePlus generateBlobImage(Blob b){
  Rectangle r = b.getOuterContour().getBounds();
  r.setBounds(r.x, r.y, (int)r.getWidth()+1, (int)r.getHeight()+1);
  ImagePlus help = NewImage.createByteImage("", r.width+2, r.height+2, 1, NewImage.FILL_WHITE);
  ImageProcessor ip = help.getProcessor();
  b.draw(ip, Blob.DRAW_HOLES, -(r.x-1), -(r.y-1));
  help.setProcessor(ip);
  return help;
}

代码示例来源:origin: MegaMek/megamek

@Override
public Rectangle getBounds() {
  makePoly();
  // set bounds
  bounds = new Rectangle(c3Poly.getBounds());
  bounds.setSize(bounds.getSize().width + 1,
      bounds.getSize().height + 1);
  // move poly to upper right of image
  c3Poly.translate(-bounds.getLocation().x, -bounds.getLocation().y);
  image = null;
  return bounds;
}

相关文章