本文整理了Java中java.awt.Rectangle.isEmpty
方法的一些代码示例,展示了Rectangle.isEmpty
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.isEmpty
方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:isEmpty
[英]Determines whether or not this Rectangle
is empty. A Rectangle
is empty if its width or its height is less than or equal to zero.
[中]确定此Rectangle
是否为空。如果Rectangle
的宽度或高度小于或等于零,则其为空。
代码示例来源:origin: runelite/runelite
@Override
public Rectangle getBounds()
{
final Rectangle bounds = super.getBounds();
final Rectangle parent = getParentBounds(client.getWidget(widgetInfo));
if (parent.isEmpty())
{
return bounds;
}
int x = bounds.x;
int y = bounds.y;
x = Math.max(parent.x, x);
y = Math.max(parent.y, y);
x = Math.min((int)parent.getMaxX() - bounds.width, x);
y = Math.min((int)parent.getMaxY() - bounds.height, y);
bounds.setLocation(x, y);
return bounds;
}
代码示例来源:origin: runelite/runelite
@Override
public Dimension render(Graphics2D graphics)
{
final Widget widget = client.getWidget(widgetInfo);
final Rectangle bounds = super.getBounds();
final Rectangle parent = getParentBounds(widget);
if (parent.isEmpty())
{
return null;
}
int x = bounds.x;
int y = bounds.y;
x = Math.max(parent.x, x);
y = Math.max(parent.y, y);
x = Math.min((int)parent.getMaxX() - bounds.width, x);
y = Math.min((int)parent.getMaxY() - bounds.height, y);
bounds.setLocation(x, y);
widget.setOriginalX(0);
widget.setOriginalY(0);
widget.setRelativeX(bounds.x - parent.x);
widget.setRelativeY(bounds.y - parent.y);
return new Dimension(widget.getWidth(), widget.getHeight());
}
代码示例来源:origin: runelite/runelite
final Rectangle bounds = overlay.getBounds();
if (bounds.isEmpty())
代码示例来源:origin: geotools/geotools
private void doSetScreenArea(Rectangle screenArea) {
if (screenArea == null || screenArea.isEmpty()) {
this.screenArea = new Rectangle();
} else {
this.screenArea = new Rectangle(screenArea);
}
setTransforms(false);
}
代码示例来源:origin: geotools/geotools
/**
* Checks if the view port bounds are empty (undefined). This will be {@code true} if either or
* both of the world bounds and screen bounds are empty.
*
* @return {@code true} if empty
*/
public boolean isEmpty() {
lock.readLock().lock();
try {
return screenArea.isEmpty() || bounds.isEmpty();
} finally {
lock.readLock().unlock();
}
}
代码示例来源:origin: apache/cloudstack
public boolean add(Rectangle rect) {
if (bound.isEmpty()) {
assert (rectList.size() == 0);
bound.x = rect.x;
bound.y = rect.y;
bound.width = rect.width;
bound.height = rect.height;
rectList.add(rect);
return true;
}
Rectangle rcInflated = new Rectangle(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2);
if (!bound.intersects(rcInflated))
return false;
for (Rectangle r : rectList) {
if (r.intersects(rcInflated)) {
if (!r.contains(rect)) {
enlargeBound(rect);
rectList.add(rect);
return true;
}
}
}
return false;
}
代码示例来源:origin: geotools/geotools
if (!(r == null || r.isEmpty())) {
int dx = 0;
int dy = 0;
代码示例来源:origin: nguyenq/tess4j
/**
* Sets image to be processed.
*
* @param xsize width of image
* @param ysize height of image
* @param buf pixel data
* @param rect the bounding rectangle defines the region of the image to be
* recognized. A rectangle of zero dimension or <code>null</code> indicates
* the whole image.
* @param bpp bits per pixel, represents the bit depth of the image, with 1
* for binary bitmap, 8 for gray, and 24 for color RGB.
*/
protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) {
int bytespp = bpp / 8;
int bytespl = (int) Math.ceil(xsize * bpp / 8.0);
TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl);
if (rect != null && !rect.isEmpty()) {
TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height);
}
}
代码示例来源:origin: nguyenq/tess4j
/**
* Sets image to be processed.
*
* @param xsize width of image
* @param ysize height of image
* @param buf pixel data
* @param rect the bounding rectangle defines the region of the image to be
* recognized. A rectangle of zero dimension or <code>null</code> indicates
* the whole image.
* @param bpp bits per pixel, represents the bit depth of the image, with 1
* for binary bitmap, 8 for gray, and 24 for color RGB.
*/
protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) {
int bytespp = bpp / 8;
int bytespl = (int) Math.ceil(xsize * bpp / 8.0);
api.TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl);
if (rect != null && !rect.isEmpty()) {
api.TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height);
}
}
代码示例来源:origin: geotools/geotools
/** {@inheritDoc} */
@Override
public void moveImage(int dx, int dy) {
drawingLock.lock();
try {
if (isShowing() && !getVisibleRect().isEmpty()) {
imageOrigin.translate(dx, dy);
baseImageMoved.set(true);
repaint();
onImageMoved();
}
} finally {
drawingLock.unlock();
}
}
代码示例来源:origin: geotools/geotools
if (screenArea.isEmpty()) {
screenToWorld = worldToScreen = null;
hasCenteringTransforms = false;
代码示例来源: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
private boolean renewCachedCoverage(DirectPosition centrePos) {
final Rectangle queryRect = createQueryGridEnvelope(centrePos);
if (queryRect.isEmpty()) {
return false;
}
final GridCoverage2DReader reader = sourceRef.get();
GeneralParameterValue parameter =
new Parameter(
AbstractGridFormat.READ_GRIDGEOMETRY2D,
new GridGeometry2D(
new GridEnvelope2D(queryRect),
reader.getOriginalGridToWorld(PixelInCell.CELL_CENTER),
reader.getCoordinateReferenceSystem()));
try {
cachedCoverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] {parameter});
return cachedCoverage != null;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源: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: geotools/geotools
final Rectangle imageBounds = binaryImage.getBounds();
final Rectangle overlapArea = imageBounds.intersection(tileBounds);
if (overlapArea.isEmpty()) {
return false;
代码示例来源:origin: geotools/geotools
viewport.setMatchingAspectRatio(true);
Rectangle rect = getVisibleRect();
if (!rect.isEmpty()) {
viewport.setScreenArea(rect);
代码示例来源:origin: geotools/geotools
@Test
public void fullCtor() {
MapViewport vp = new MapViewport(WORLD_1_1, true);
assertTrue(vp.isEmpty());
assertTrue(vp.isMatchingAspectRatio());
assertTrue(vp.getScreenArea().isEmpty());
assertTrue(WORLD_1_1.boundsEquals2D(vp.getBounds(), TOL));
}
代码示例来源:origin: geotools/geotools
@Test
public void booleanCtor() {
MapViewport vp = new MapViewport(true);
assertTrue(vp.isEmpty());
assertTrue(vp.isMatchingAspectRatio());
assertTrue(vp.getBounds().isEmpty());
assertTrue(vp.getScreenArea().isEmpty());
}
代码示例来源:origin: geotools/geotools
@Test
public void boundsCtor() {
MapViewport vp = new MapViewport(WORLD_1_1);
assertTrue(vp.isEmpty());
assertFalse(vp.isMatchingAspectRatio());
assertTrue(vp.getScreenArea().isEmpty());
assertTrue(WORLD_1_1.boundsEquals2D(vp.getBounds(), TOL));
}
代码示例来源:origin: geotools/geotools
@Test
public void defaultCtor() {
MapViewport vp = new MapViewport();
assertFalse(vp.isMatchingAspectRatio());
assertTrue(vp.isEmpty());
assertTrue(vp.getBounds().isEmpty());
assertTrue(vp.getScreenArea().isEmpty());
assertNull(vp.getCoordinateReferenceSystem());
}
内容来源于网络,如有侵权,请联系作者删除!