Package java.awt

Examples of java.awt.Graphics


        // due to an issue with ImageIO and mixed signed code
        // we are now using good oldfashioned ImageIcon to load
        // images and the paint it on top of a new BufferedImage
        Image img = new ImageIcon(url).getImage();
        BufferedImage bufferedImage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
        Graphics g = bufferedImage.getGraphics();
        g.drawImage(img, 0, 0, null);
        g.dispose();

        return bufferedImage;
    }
View Full Code Here


    final AffineTransform tx = AffineTransform.getTranslateInstance(dx1 - transx, dy1 - transy);
    tx.scale(scalex, scaley);

    final BufferedImage mask = new BufferedImage(img.getWidth(observer), img.getHeight(observer),
        BufferedImage.TYPE_BYTE_BINARY);
    final Graphics g = mask.getGraphics();
    g.fillRect(sx1, sy1, (int) swidth, (int) sheight);
    drawImage(img, mask, tx, null, observer);
    g.dispose();
    return true;
  }
View Full Code Here

                w = (int) (h * imageRatio);
        }
       
        BufferedImage bi = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
       
        Graphics g = bi.createGraphics();
        DcSwingUtilities.setRenderingHint(g);
        g.drawImage(image, 0, 0, w, h, null);
        g.dispose();
       
        bi.flush();
//        image.flush();
       
        return bi;
View Full Code Here

            return new byte[0];
        }

        ImageFormatter imageFormatter = formatter.makeClone();

        Graphics graphics = createGraphics(imageFormatter,
                proj.getWidth(),
                proj.getHeight());

        if (graphics == null) {
            return new byte[0];
        }

        ((Proj) proj).drawBackground((Graphics2D) graphics, background);

        if (Debug.debugging("imageserver")) {
            Debug.output("ImageServer: considering " + layers.length
                    + " for image...");
        }

        if (layers != null) {
            for (int i = layers.length - 1; i >= 0; i--) {
                if ((includedLayerMask & (0x00000001 << i)) != 0) {
                    if (Debug.debugging("imageserver")) {
                        Debug.output("ImageServer: image request adding layer graphics from : "
                                + layers[i].getName());
                    }

                    layers[i].renderDataForProjection(proj, graphics);
                } else {
                    if (Debug.debugging("imageserver")) {
                        Debug.output("ImageServer: skipping layer graphics from : "
                                + layers[i].getName());
                    }
                }
            }
        } else {
            if (Debug.debugging("imageserver")) {
                Debug.output("ImageServer: no layers available");
            }
        }

        byte[] formattedImage = getFormattedImage(imageFormatter,
                scaledWidth,
                scaledHeight);
        graphics.dispose();
        return formattedImage;
    }
View Full Code Here

        while (currentSize > 1) {
            if (delta <= nextPow2) {
                if (currentSize != endSize) {
                    BufferedImage tmpImage = new BufferedImage(endSize,
                            endSize, BufferedImage.TYPE_INT_RGB);
                    Graphics g = tmpImage.getGraphics();
                    ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                            RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                    g.drawImage(currentImage, 0, 0, tmpImage.getWidth(),
                            tmpImage.getHeight(), null);
                    currentImage = tmpImage;
                }
                return currentImage;
            } else {
                BufferedImage tmpImage = new BufferedImage(currentSize >> 1,
                        currentSize >> 1, BufferedImage.TYPE_INT_RGB);
                Graphics g = tmpImage.getGraphics();
                ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                g.drawImage(currentImage, 0, 0, tmpImage.getWidth(),
                        tmpImage.getHeight(), null);
                currentImage = tmpImage;
                currentSize = currentImage.getWidth(null);
                delta = currentSize - endSize;
                nextPow2 = currentSize >> 1;
View Full Code Here

    }

    private ImageIcon getTextAccentToggleButtonImage(int width, int height,
                                                     Font f, String s) {
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.getGraphics();
        g.setFont(f);
        g.setColor(Color.black);
        FontMetrics fm = g.getFontMetrics();

        int stringWidth = fm.stringWidth(s);
        int stringHeight = f.getSize() - 2;
        g.drawString(s, (width - stringWidth) / 2, height - (height - stringHeight) / 2);
        return new ImageIcon(bi);
    }
View Full Code Here

        if (width == -1)
            width = proj.getWidth();
        if (height == -1)
            height = proj.getHeight();

        Graphics graphics = getGraphics(width, height);

        if (!needToScale) {
            if (Debug.debugging("formatter")) {
                Debug.output("AIF: don't need to scale, painting normally.");
            }
View Full Code Here

     */
    public Graphics getGraphics(int width, int height, int imageType) {
        bufferedImage = new BufferedImage(width, height, imageType);

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Graphics g = ge.createGraphics(bufferedImage);
        g.setClip(0, 0, width, height);
        return g;
    }
View Full Code Here

        int height = 256;
        int width = 256;

        BufferedImage bigImage = new BufferedImage(width * 6, height * 6, BufferedImage.TYPE_INT_RGB);
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Graphics g = ge.createGraphics(bigImage);
        Toolkit tk = Toolkit.getDefaultToolkit();

        for (int x = 0; x < 6; x++) {
            for (int y = 0; y < 6; y++) {
                int[] pixels = decompressSubframe(x, y, colortable);

                java.awt.Image bitmap = tk.createImage(new MemoryImageSource(width, height, pixels, 0, width));

                g.drawImage(bitmap, x * 256, y * 256, null);
            }
        }

        JLabel picture = new JLabel(new ImageIcon(bigImage));
        JFrame frame = com.bbn.openmap.util.PaletteHelper.getPaletteWindow(picture,
View Full Code Here

                if (Debug.debugging("shape"))
                    Debug.output("ShapeLayer.paint(): " + omg.size() + " omg"
                            + " shadow=" + shadowX + "," + shadowY);

                if (shadowX != 0 || shadowY != 0) {
                    Graphics shadowG = g.create();
                    shadowG.translate(shadowX, shadowY);
                    omg.render(shadowG);
                } else {
                    omg.render(g);
                }
View Full Code Here

TOP

Related Classes of java.awt.Graphics

Copyright © 2018 www.massapicom. 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.