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

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

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

Rectangle.intersect介绍

[英]Computes the intersection of this Rectangle with the specified Rectangle. Returns a new Rectangle that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.
[中]计算此Rectangle与指定Rectangle的交集。返回表示两个矩形相交的新Rectangle。如果两个矩形不相交,结果将是一个空矩形。

代码示例

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

/**
 * Checks that the provided <code>dimensions</code> when intersected with the source region used
 * by the provided {@link ImageReadParam} instance does not result in an empty {@link
 * Rectangle}.
 *
 * <p>Input parameters cannot be null.
 *
 * @param readParameters an instance of {@link ImageReadParam} for which we want to check the
 *     source region element.
 * @param dimensions an instance of {@link Rectangle} to use for the check.
 * @return <code>true</code> if the intersection is not empty, <code>false</code> otherwise.
 */
public static final boolean checkEmptySourceRegion(
    final ImageReadParam readParameters, final Rectangle dimensions) {
  Utilities.ensureNonNull("readDimension", dimensions);
  Utilities.ensureNonNull("readP", readParameters);
  final Rectangle sourceRegion = readParameters.getSourceRegion();
  Rectangle.intersect(sourceRegion, dimensions, sourceRegion);
  if (sourceRegion.isEmpty()) return true;
  readParameters.setSourceRegion(sourceRegion);
  return false;
}

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

/**
 * Checks that the provided {@code dimensions} when intersected with the source region used by
 * the provided {@link ImageReadParam} instance does not result in an empty {@link Rectangle}.
 * Finally, in case the region intersection is not empty, set it as new source region for the
 * provided {@link ImageReadParam}.
 *
 * <p>Input parameters cannot be null.
 *
 * @param readParameters an instance of {@link ImageReadParam} for which we want to check the
 *     source region element.
 * @param dimensions an instance of {@link Rectangle} to use for the check.
 * @return {@code true} if the intersection is not empty, {@code false} otherwise.
 */
public static boolean checkEmptySourceRegion(
    final ImageReadParam readParameters, final Rectangle dimensions) {
  Utilities.ensureNonNull("readDimension", dimensions);
  Utilities.ensureNonNull("readP", readParameters);
  final Rectangle sourceRegion = readParameters.getSourceRegion();
  Rectangle.intersect(sourceRegion, dimensions, sourceRegion);
  if (sourceRegion.isEmpty()) {
    return true;
  }
  readParameters.setSourceRegion(sourceRegion);
  return false;
}

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

Rectangle r1 = new Rectangle(x,y,width,height);
Rectangle r2 = new Rectangle(other.getX(),other.getY(),other.getWidth(),other.getHeight());

return r1.intersect(r2);

代码示例来源:origin: senbox-org/s2tbx

/**
 * Gets the intersection area for the given rectangle and this cell.
 *
 * @param rectangle The rectangle to test
 * @return A <code>java.awt.Rectangle</code> if the intersection area between this cell and the given rectangle
 * has positive width and height, <code>null</code> otherwise.
 */
public Rectangle intersection(Rectangle rectangle) {
  Rectangle result = new Rectangle();
  Rectangle.intersect(new Rectangle(cellStartPixelX + cellOffsetX, cellStartPixelY + cellOffsetY, cellPixelWidth - cellOffsetX, cellPixelHeight - cellOffsetY),
            rectangle,
            result);
  return (result.width > 0 && result.height > 0) ? result : null;
}

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

Rectangle.intersect(finalRasterArea, sourceGridRange, finalRasterArea);
if (finalRasterArea.isEmpty()) {
  throw new EmptyIntersectionException(
    Rectangle.intersect(bounds, sourceGridRange, bounds);
    if (bounds.isEmpty())
      throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

bounds.x = screenBounds.x + (screenBounds.width - bounds.width) / 2;
bounds.y = screenBounds.y + (screenBounds.height - bounds.height) / 2;
Rectangle.intersect(screenBounds, bounds, bounds);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

bounds.x = screenBounds.x + (screenBounds.width - bounds.width) / 2;
bounds.y = screenBounds.y + (screenBounds.height - bounds.height) / 3;
Rectangle.intersect(screenBounds, bounds, bounds);

代码示例来源:origin: markiewb/nb-codeoutline

Rectangle.intersect(lineClip, clip, lineClip);
g.setClip(lineClip);
lh.paintLayeredHighlights(g, line.getStartOffset(), line.getEndOffset() - 1, allocation, host, this);

代码示例来源:origin: org.geotools/gt-coverage

/**
 * Checks that the provided {@code dimensions} when intersected with the source region used by 
 * the provided {@link ImageReadParam} instance does not result in an empty {@link Rectangle}.
 * Finally, in case the region intersection is not empty, set it as new source region for the 
 * provided {@link ImageReadParam}.  
 * <p>
 * Input parameters cannot be null.
 * 
 * @param readParameters an instance of {@link ImageReadParam} for which we want to check 
 *          the source region element.
 * @param dimensions an instance of {@link Rectangle} to use for the check.
 * @return {@code true} if the intersection is not empty, {@code false} otherwise.
 */
public static boolean checkEmptySourceRegion(final ImageReadParam readParameters, 
    final Rectangle dimensions) {
  Utilities.ensureNonNull("readDimension", dimensions);
  Utilities.ensureNonNull("readP", readParameters);
  final Rectangle sourceRegion = readParameters.getSourceRegion();
  Rectangle.intersect(sourceRegion, dimensions, sourceRegion);
  if (sourceRegion.isEmpty()) {
    return true;
  }
  readParameters.setSourceRegion(sourceRegion);
  return false;
}

代码示例来源:origin: org.geotools/gt-coverage

/**
 * Checks that the provided <code>dimensions</code> when intersected with
 * the source region used by the provided {@link ImageReadParam} instance
 * does not result in an empty {@link Rectangle}.
 * 
 * <p>
 * Input parameters cannot be null.
 * 
 * @param readParameters
 *            an instance of {@link ImageReadParam} for which we want to
 *            check the source region element.
 * @param dimensions
 *            an instance of {@link Rectangle} to use for the check.
 * @return <code>true</code> if the intersection is not empty,
 *         <code>false</code> otherwise.
 */
public final static boolean checkEmptySourceRegion(final ImageReadParam readParameters,
    final Rectangle dimensions) {
    Utilities.ensureNonNull("readDimension", dimensions);
    Utilities.ensureNonNull("readP", readParameters);
  final Rectangle sourceRegion = readParameters.getSourceRegion();
  Rectangle.intersect(sourceRegion, dimensions, sourceRegion);
  if (sourceRegion.isEmpty())
    return true;
  readParameters.setSourceRegion(sourceRegion);
  return false;
}

代码示例来源:origin: google/sagetv

currEffectClip.intersect(currEffectClip, op.destRect, currEffectClip);
currEffectClip.intersect(currEffectClip, op.destRect, currEffectClip);
if (baseClip != null)
 currEffectClip.intersect(currEffectClip, baseClip, currEffectClip);

代码示例来源:origin: google/sagetv

MathUtils.transformRectCoords(intRectd, currXform, intRectd);
if (currEffectClip != null)
 intRectd.intersect(intRectd, currEffectClip, intRectd);
if (ANIM_DEBUG) System.out.println("Clearing the graphics area for the YUV video image surface");
usedHiResSurf = true;

代码示例来源:origin: google/sagetv

java.awt.Rectangle.intersect(currRenderRect, rootComp.getBounds(), currRenderRect);
currentlyScrolling = hasScrollAnimsStill;

代码示例来源:origin: google/sagetv

MathUtils.transformRectCoords(cr, currXform, cr);
if (currEffectClip != null)
 cr.intersect(cr, currEffectClip, cr);
if (cr.getWidth() <= 0 || cr.getHeight() <= 0)
 return;

代码示例来源:origin: org.geotools/gt-coverage

Rectangle.intersect(finalRasterArea, sourceGridRange, finalRasterArea);
if(finalRasterArea.isEmpty())
  throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));
    Rectangle.intersect(bounds, sourceGridRange, bounds);
    if(bounds.isEmpty())
      throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

相关文章