Examples of Rectangle2D


Examples of java.awt.geom.Rectangle2D

    double[] charW = new double[chars.length];

    for (int i = 0; i < chars.length; i++)
    {
      chars[i] = (char) ('a' + i);
      Rectangle2D rect = font.getStringBounds("" + chars[i], frc); //$NON-NLS-1$
      charW[i] = rect.getWidth();
    }

    System.out.println(TEST_STRING);
    final char[] string = TEST_STRING.toCharArray();
    System.out.println(computeWidth(font, frc, string));
View Full Code Here

Examples of java.awt.geom.Rectangle2D

    /** Prepare background **/
    g2.transform(AffineTransform.getScaleInstance(getZoom(), getZoom()));
    g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

    /** Prepare background **/
    final Rectangle2D pageArea = new Rectangle2D.Float(0, 0, outerW, outerH);
    /**
     * The border around the printable area is painted when the corresponding property is
     * set to true.
     */
    final Rectangle2D printingArea = new Rectangle2D.Float(innerX, innerY, innerW, innerH);

    /** Paint Page Shadow */
    final Rectangle2D southborder = new Rectangle2D.Float
        (getShadowSize(), outerH,
            outerW, getShadowSize());
    final Rectangle2D eastborder = new Rectangle2D.Float
        (outerW, getShadowSize(), getShadowSize(), outerH);

    g2.setPaint(UIManager.getColor("controlShadow")); //$NON-NLS-1$

    g2.fill(southborder);
    g2.fill(eastborder);

    if (isBorderPainted())
    {
      g2.setPaint(Color.gray);
      g2.draw(printingArea);
    }

    g2.setPaint(Color.white);
    g2.fill(pageArea);

    final Graphics2D g22 = (Graphics2D) g2.create();
    backend.draw(g22, new Rectangle2D.Double
        (0, 0, pageFormat.getWidth(), pageFormat.getHeight()));
    g22.dispose();
   
    final Rectangle2D transPageArea = new Rectangle2D.Float(0, 0, outerW, outerH);
    g2.setPaint(Color.black);
    g2.draw(transPageArea);


    g2.dispose();
View Full Code Here

Examples of java.awt.geom.Rectangle2D

        }

        public void mouseReleased(MouseEvent event) {
            if (getAction() != null ? getAction().isEnabled() : isEnabled()) {
                // do a hit test to make sure the mouse is being released inside the button
                Rectangle2D buttonRect = BorderlessImageToggleButton.this.getBounds();
                if (buttonRect.contains(event.getPoint())) {
                    BorderlessImageToggleButton.this.setBackground(BorderlessUtility.ON_MOUSE_OVER_BACKGROUND);
                }
            }
        }
View Full Code Here

Examples of java.awt.geom.Rectangle2D

            for (int i = 0; i < ticker.length; i++) {
                int channel = 224 - 128 / (i + 1);
                g2.setColor(new Color(channel, channel, channel, alphaLevel));
                g2.fill(ticker[i]);
               
                Rectangle2D bounds = ticker[i].getBounds2D();
                if (bounds.getMaxY() > maxY)
                    maxY = bounds.getMaxY();
            }
           
            if (text != null && text.length() > 0) {
                FontRenderContext context = g2.getFontRenderContext();
                TextLayout layout = new TextLayout(text, getFont(), context);
                Rectangle2D bounds = layout.getBounds();
                g2.setColor(getForeground());
                layout.draw(g2, (float) (width - bounds.getWidth()) / 2,
                        (float) (maxY + layout.getLeading() + 2 * layout.getAscent()));
            }
        }
    }
View Full Code Here

Examples of java.awt.geom.Rectangle2D

    {
      return;
    }

    graphics2D.setColor(Color.RED);
    final Rectangle2D dataArea = getDataAreaOffset();
    final EntityCollection entityCollection = chartRenderingInfo.getEntityCollection();
    for (int i = 0; i < entityCollection.getEntityCount(); i++)
    {
      final ChartEntity chartEntity = entityCollection.getEntity(i);
      if (chartEntity instanceof XYItemEntity ||
          chartEntity instanceof CategoryItemEntity ||
          chartEntity instanceof PieSectionEntity)
      {
        final Area a = new Area(chartEntity.getArea());
        if (buggyDrawArea)
        {
          a.transform(AffineTransform.getTranslateInstance(dataArea.getX(), dataArea.getY()));
        }
        a.intersect(new Area(dataArea));
        graphics2D.draw(a);
      }
      else
View Full Code Here

Examples of java.awt.geom.Rectangle2D

  {
    if (chartRenderingInfo == null)
    {
      return null;
    }
    final Rectangle2D dataArea = getDataAreaOffset();
    final Rectangle2D otherArea = new Rectangle2D.Double();

    if ((ObjectUtilities.equal(bounds, this.bounds)) == false)
    {
      final BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
      final Graphics2D graphics = image.createGraphics();
View Full Code Here

Examples of java.awt.geom.Rectangle2D

              (float) (ellipse2D.getCenterY() + dataArea.getY()), (float) (ellipse2D.getWidth() / 2));
        }
      }
      else if (area instanceof Rectangle2D)
      {
        final Rectangle2D rect = (Rectangle2D) area;
        return (new RectangleImageMapEntry((float) (rect.getX() + dataArea.getX()),
            (float) (rect.getY() + dataArea.getY()),
            (float) (rect.getX() + rect.getWidth()),
            (float) (rect.getY() + rect.getHeight())));
      }
    }
    else
    {
      if (area instanceof Ellipse2D)
      {
        final Ellipse2D ellipse2D = (Ellipse2D) area;
        if (ellipse2D.getWidth() == ellipse2D.getHeight())
        {
          return new CircleImageMapEntry((float) (ellipse2D.getCenterX()),
              (float) (ellipse2D.getCenterY()), (float) (ellipse2D.getWidth() / 2));
        }
      }
      else if (area instanceof Rectangle2D)
      {
        final Rectangle2D rect = (Rectangle2D) area;
        return (new RectangleImageMapEntry((float) (rect.getX()),
            (float) (rect.getY()),
            (float) (rect.getX() + rect.getWidth()),
            (float) (rect.getY() + rect.getHeight())));
      }
    }

    final Area a = new Area(area);
    if (buggyDrawArea)
View Full Code Here

Examples of java.awt.geom.Rectangle2D

    // The code below may be weird, but at least it is predictable weird.
    final ExtendedBaselineInfo baselineInfo = renderableText.getBaselineInfo();
    final long baseline = baselineInfo.getBaseline(baselineInfo.getDominantBaseline());

    final FontMetrics fm = g2.getFontMetrics();
    final Rectangle2D rect = fm.getMaxCharBounds(g2);
    final long awtBaseLine = StrictGeomUtility.toInternalValue(-rect.getY());

    final GlyphList gs = renderableText.getGlyphs();
    if (metaData.isFeatureSupported(OutputProcessorFeature.FAST_FONTRENDERING) &&
        isNormalTextSpacing(renderableText))
    {
View Full Code Here

Examples of java.awt.geom.Rectangle2D

    double width = 0;
    if (fontSize > 0)
    {
      final float scale = 1000 / fontSize;
      final Font font = this.font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
      final Rectangle2D stringBounds = font.getStringBounds(s, getFontRenderContext());
      width = stringBounds.getWidth() / scale;
    }
    if (s.length() > 1)
    {
      final float adv = ((float) width - lastBaseFont.getWidthPoint(s, fontSize)) / (s.length() - 1);
      cb.setCharacterSpacing(adv);
View Full Code Here

Examples of java.awt.geom.Rectangle2D

  /**
   * @see Graphics#clipRect(int, int, int, int)
   */
  public void clipRect(final int x, final int y, final int width, final int height)
  {
    final Rectangle2D rect = new Rectangle2D.Double(x, y, width, height);
    clip(rect);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.