private static boolean hasIntegerBounds(Rectangle2D rt) { if (rt == null || rt.isEmpty()) { return true; } // check bounds double minx = rt.getMinX(); double miny = rt.getMinY(); double maxx = rt.getMaxX(); double maxy = rt.getMaxY(); return (minx % 1 == 0) && (miny % 1 == 0) && (maxx % 1 == 0) && (maxy % 1 == 0); }
/** * Utility method to create a ReferencedEnvelope from a Java2D Rectangle class, supporting empty * rectangles. * * @param rectangle The Java2D Rectangle object * @return ReferencedEnvelope,<br> * results in a null/an empty envelope, if input rectangle was empty */ public static ReferencedEnvelope create(Rectangle2D rectangle, CoordinateReferenceSystem crs) { if (rectangle.isEmpty()) { return new ReferencedEnvelope(crs); } else { return new ReferencedEnvelope(rectangle, crs); } } }
/** * Calculate vertical bounds common to all rendered glyphs. * * @param tableData * @param glyphIndex the table index that has glyphs. * @return an array with two elements: min lower bound (but max 0), and max upper bound (but min * 0). */ double[] getYBounds(Object[][] tableData, int glyphIndex) { double minY = 0; double maxY = 0; for (Object[] aTableData : tableData) { GeneralPath path = (GeneralPath) aTableData[glyphIndex]; Rectangle2D bounds2D = path.getBounds2D(); if (bounds2D.isEmpty()) { continue; } minY = Math.min(minY, bounds2D.getMinY()); maxY = Math.max(maxY, bounds2D.getMaxY()); } return new double[]{minY, maxY}; } }
/** * If, for any reason, a font size of 0 is provided to the renderer, resulting bounds will * become empty and this will ruin most geometric computations dealing with spacing and * orientations. Enlarge the envelope a tiny bit * * @param bounds */ void normalizeBounds(Rectangle2D bounds) { if (bounds == null) { bounds = new Rectangle2D.Float(-1, -1, 2, 2); } else if (bounds.isEmpty()) { bounds.setRect(bounds.getCenterX() - 1, bounds.getCenterY() - 1, 2, 2); } }
if (bounds2D.isEmpty())
clip.intersect(new Area(transformedBox)); Rectangle2D clipRect = clip.getBounds2D(); if (clipRect.isEmpty())
(float) finalRaster2Model.getTranslateY(), interpolation); if (finalLayout.isEmpty()) { if (LOGGER.isLoggable(java.util.logging.Level.INFO)) LOGGER.info(
GeneralPath path = descendantFont.getPath(code); tab[index][4] = path; if (!path.getBounds2D().isEmpty())
private Object[][] getGlyphs(PDType3Font font) throws IOException { Object[][] glyphs = new Object[256][4]; for (int index = 0; index <= 255; index++) { glyphs[index][0] = index; if (font.getEncoding().contains(index)) { glyphs[index][1] = font.getEncoding().getName(index); glyphs[index][2] = font.toUnicode(index); if (fontBBox.toGeneralPath().getBounds2D().isEmpty()) { glyphs[index][3] = NO_GLYPH; } else { glyphs[index][3] = renderType3Glyph(font, index); } totalAvailableGlyph++; } else { glyphs[index][1] = NO_GLYPH; glyphs[index][2] = NO_GLYPH; glyphs[index][3] = NO_GLYPH; } } return glyphs; }
(float) finalRaster2Model.getTranslateY(), nearest); if (finalLayout.isEmpty()) { if (LOGGER.isLoggable(java.util.logging.Level.FINE)) LOGGER.fine(
(float) finalRaster2Model.getTranslateY(), interpolation); if (finalLayout.isEmpty()) { if (LOGGER.isLoggable(java.util.logging.Level.INFO)) LOGGER.info(
if (!path.getBounds2D().isEmpty())
(float) finalRaster2Model.getTranslateY(), interpolation); if (finalLayout.isEmpty()) { if (LOGGER.isLoggable(java.util.logging.Level.FINE)) LOGGER.fine(
public static boolean floatRectsIntersect(java.awt.geom.Rectangle2D r1, float x, float y, float w, float h) { if (r1.isEmpty() || w <= 0 || h <= 0) { return false; } double x0 = r1.getX(); double y0 = r1.getY(); return ((x + w) - x0 > EPSILON) && ((y + h) - y0 > EPSILON) && ((x0 + r1.getWidth()) - x > EPSILON) && ((y0 + r1.getHeight()) - y > EPSILON); }
/** * Creates a bounds with the same shape as the rectangle provided. * * @param aBounds rectangle to be copied */ public PBounds(final Rectangle2D aBounds) { this(aBounds.getX(), aBounds.getY(), aBounds.getWidth(), aBounds.getHeight()); isEmpty = aBounds.isEmpty(); }
(float) finalRasterTransformation.getTranslateY(), interpolation); if (finalLayout.isEmpty()) { if (LOGGER.isLoggable(java.util.logging.Level.FINE)) LOGGER.fine(
/** * {@inheritDoc} */ public void setWorldByResolution(Rectangle2D bounds, double xres, double yres) { if (bounds == null || bounds.isEmpty()) { throw new IllegalArgumentException("bounds cannot be null or empty"); } if (xres < EPS || yres < EPS) { throw new IllegalArgumentException("xres and yres but must be greater than 0"); } doSetWorld(bounds, xres, yres); }
/** * Tests that the conversion of different bound types to ReferencedEnvelope does not lose the * emptiness property * * @throws Exception */ @Test public void testEmptyEnvelopeConversion() throws Exception { // conversion of an empty OGC envelope should stay empty GeneralEnvelope ge = new GeneralEnvelope(new double[] {0, 0}, new double[] {-1, -1}); assertTrue(ge.isEmpty()); assertTrue(ReferencedEnvelope.create(ge, ge.getCoordinateReferenceSystem()).isEmpty()); assertTrue(ReferencedEnvelope.reference(ge).isEmpty()); // conversion of an empty Java Rectangle 2D should stay empty Rectangle2D r2d = new Rectangle2D.Double(0, 0, -1, -1); assertTrue(r2d.isEmpty()); assertTrue(ReferencedEnvelope.create(r2d, null).isEmpty()); // conversion of an empty ReferencedEnvelope should stay empty ReferencedEnvelope re = new ReferencedEnvelope(); assertTrue(re.isEmpty()); assertTrue(ReferencedEnvelope.create(re).isEmpty()); assertTrue(ReferencedEnvelope.create(re, re.getCoordinateReferenceSystem()).isEmpty()); assertTrue(ReferencedEnvelope.reference(re).isEmpty()); } }
/** * If, for any reason, a font size of 0 is provided to the renderer, resulting bounds * will become empty and this will ruin most geometric computations dealing with spacing * and orientations. Enlarge the envelope a tiny bit * @param bounds */ void normalizeBounds(Rectangle2D bounds) { if(bounds.isEmpty()) { bounds.setRect(bounds.getCenterX() -1 , bounds.getCenterY() -1, 2, 2); } }