Examples of Graphics2D


Examples of java.awt.Graphics2D

        Document doc = XMLUtil.documentFromFile(xhtml);
        Graphics2DRenderer renderer = new Graphics2DRenderer();
        renderer.setDocument(doc, new File(xhtml).toURI().toURL().toString());

        BufferedImage buff = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
        Graphics2D g = (Graphics2D) buff.getGraphics();

        Dimension dim = new Dimension(width, height);
        renderer.layout(g, dim);
        renderer.render(g);
View Full Code Here

Examples of java.awt.Graphics2D

    return preferredSize;
  }

  public void draw(final Graphics2D g2, final Rectangle2D bounds)
  {
    final Graphics2D gr2 = (Graphics2D) g2.create();
    try
    {
      gr2.clip(bounds);
      barcode.draw(gr2, (int) bounds.getX(), (int) bounds.getY());
    }
    catch (OutputException e)
    {
      logger.error("Unable to draw barcode element", e);
    }
    finally
    {
      gr2.dispose();
    }

  }
View Full Code Here

Examples of java.awt.Graphics2D

    final float innerX = (float) pageFormat.getImageableX();
    final float innerY = (float) pageFormat.getImageableY();
    final float innerW = (float) pageFormat.getImageableWidth();
    final float innerH = (float) pageFormat.getImageableHeight();

    final Graphics2D g2 = (Graphics2D) graphics.create();
    //double paperBorder = paperBorderPixel * zoomFactor;

    /** 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);

View Full Code Here

Examples of java.awt.Graphics2D

            int width  = getWidth();
            int height = getHeight();
           
            double maxY = 0.0;
           
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHints(hints);
           
            g2.setColor(new Color(255, 255, 255, (int) (alphaLevel * shield)));
            g2.fillRect(0, 0, getWidth(), getHeight());
           
            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
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.