java.awt.Rectangle.createIntersection()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(142)

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

Rectangle.createIntersection介绍

暂无

代码示例

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

.createIntersection(wall_rectangle);

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

public void checkCollision() {
   Rectangle player_rectangle = new Rectangle(player.getX(),
       player.getY(), 32, 32);
   for (Wall wall : walls) {
     Rectangle wall_rectangle = new Rectangle(wall.getX(), wall.getY(),
         32, 32);
     if (player_rectangle.intersects(wall_rectangle)) {
       Rectangle intersection = (Rectangle) player_rectangle
           .createIntersection(wall_rectangle);
       if (player.xspeed < 0 && player.x >= intersection.x) {
         player.x += intersection.getWidth();
       } 
       if (player.xspeed > 0 && player.x <= intersection.x) {
         player.x -= intersection.getWidth();
       }
       if (player.yspeed < 0 && player.y >= intersection.y) {
         player.y += intersection.getHeight();
       }
       if (player.yspeed > 0 && player.y <= intersection.y) {
         player.y -= intersection.getHeight();
       }
       Print(Integer.toString(intersection.width) + ", "
           + Integer.toString(intersection.height));
     }
   }
 }

代码示例来源:origin: pentaho/pentaho-reporting

/**
 * Replays the command on the given WmfFile.
 *
 * @param file the meta file.
 */
public void replay( final WmfFile file ) {
 final MfDcState state = file.getCurrentState();
 final Rectangle rect = state.getClipRegion();
 final Rectangle2D rec2 = rect.createIntersection( getScaledIntersectClipRect() );
 state.setClipRegion( new Rectangle( (int) rec2.getX(),
  (int) rec2.getY(),
  (int) rec2.getWidth(),
  (int) rec2.getHeight() ) );
}

代码示例来源:origin: net.sf.squirrel-sql.plugins/graph

private boolean isRectangleOccupied(Point leftUp, Point rightDown, TableFrameController toExclude)
{
 Vector<TableFrameController> tblCtrls = _tableFramesModel.getTblCtrls();
 for (int i = 0; i < tblCtrls.size(); i++)
 {
   TableFrameController tfc = tblCtrls.get(i);
   if (tfc.equals(toExclude))
   {
    continue;
   }
   Rectangle rectTfc = tfc.getFrame().getBounds();
   Rectangle rectParam = new Rectangle(leftUp.x - BORDER_X, leftUp.y - BORDER_Y, rightDown.x - leftUp.x + BORDER_X, rightDown.y - leftUp.y + BORDER_Y);
   Rectangle2D interSect = rectParam.createIntersection(rectTfc);
   if (0 < interSect.getWidth() && 0 < interSect.getHeight())
   {
    return true;
   }
 }
 return false;
}

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

GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Rectangle2D intBounds = bounds.createIntersection(parentBounds);
float perArea = (float) ((intBounds.getWidth() * intBounds.getHeight()) / (parentBounds.width * parentBounds.height));
if (perArea > maxArea) {

代码示例来源:origin: nroduit/Weasis

private void refreshZoomWin() {
  Point loc = getLocation();
  if (loc.x == -1 && loc.y == -1) {
    centerZoomWin();
    return;
  }
  Rectangle rect = view2d.getBounds();
  rect.x = 0;
  rect.y = 0;
  Rectangle2D r = rect.createIntersection(getBounds());
  if (r.getWidth() < 25.0 || r.getHeight() < 25.0) {
    centerZoomWin();
  }
}

代码示例来源:origin: lbalazscs/Pixelitor

public static boolean selectionIsOK(Composition comp) {
  Selection selection = comp.getSelection();
  if (selection == null) {
    return true;
  }
  Rectangle canvasSize = comp.getCanvasImBounds();
  // increase the width/height because of rounding errors
  canvasSize = new Rectangle(0, 0, canvasSize.width + 1, canvasSize.height + 1);
  Rectangle2D shapeBounds = selection.getShapeBounds2D();
  if (shapeBounds.isEmpty()) {
    System.out.println("\nConsistencyChecks::selectionIsOK: empty shape = " + shapeBounds);
    return false;
  }
  // In principle the selection must be fully inside the canvas,
  // but this is hard to check since
  // canvasSize.contains(shapeBounds)
  // doesn't work (the bounds are not necessarily the smallest)
  // so check that it is not fully outside
  boolean ok = !canvasSize.createIntersection(shapeBounds).isEmpty();
  if (!ok) {
    System.out.println("\nConsistencyChecks::selectionIsOK: no intersection: "
      + "canvasSize = " + canvasSize
        + ", shapeBounds = " + shapeBounds);
  }
  return ok;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

private void doPaintChildren( Graphics g ) {
  super.paintChildren(g);
  int xOff = imagePanel.getX();
  int yOff = imagePanel.getY();
  g.setColor(Color.BLACK);
  int w = imagePanel.getWidth(),
    h = imagePanel.getHeight();
  drawCross( g, xOff - 1, yOff -1);
  drawCross( g, xOff - 1, yOff + h + 1);
  drawCross( g, xOff + w + 1, yOff -1);
  drawCross( g, xOff + w + 1, yOff + h + 1);
  Rectangle2D clip = new Rectangle2D.Float( xOff, yOff, w, h);
  Rectangle visible = getVisibleRect();
  if (visible != null) {
    clip = visible.createIntersection(clip);
  }
  g.setClip( clip);
  paintPanel(g, xOff, yOff);
}

代码示例来源:origin: lbalazscs/Pixelitor

Rectangle2D canvasImgIntersection = canvasBounds.createIntersection(imVisiblePart);
Path2D darkAreaClip = new Path2D.Double(Path2D.WIND_EVEN_ODD);
darkAreaClip.append(canvasImgIntersection, false);

代码示例来源:origin: org.exbin.deltahex/deltahex-swing

Rectangle hexRect = paintDataCache.codeSectionRectangle;
if (showHeader) {
  g.setClip(clipBounds.createIntersection(new Rectangle(hexRect.x, 0, hexRect.width, hexRect.y)));
  painter.paintHeader(g);
g.setClip(clipBounds.createIntersection(new Rectangle(0, hexRect.y, hexRect.x + hexRect.width, hexRect.height)));
painter.paintBackground(g);
if (showLineNumbers) {
  painter.paintLineNumbers(g);
  g.setClip(clipBounds.createIntersection(new Rectangle(hexRect.x, hexRect.y, hexRect.width, hexRect.height)));

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

rectClipUser = clip.getBounds();
m_g2D.clip(rectClip.createIntersection(rectClipUser));

相关文章