Package java.awt

Examples of java.awt.Graphics2D


            return;
        }

        if (!(image instanceof BufferedImage)) {
            sourceImage = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2D = sourceImage.createGraphics();
            g2D.drawImage(image, 0, 0, this);
        } else {
            sourceImage = (BufferedImage) image;
        }

        width = sourceImage.getWidth();
View Full Code Here


    /**
     * @see com.bbn.openmap.omGraphics.awt.ShapeDecoration#draw(Graphics,
     *      Point2D[], boolean)
     */
    public void draw(Graphics g, Point2D[] points, boolean complete) {
        Graphics2D g2D = (Graphics2D) g;
        setGraphics(g2D);
        // we just need to draw the poly line
        for (int i = 0; i < points.length - 1; i++)
            g2D.drawLine((int) points[i].getX(),
                    (int) points[i].getY(),
                    (int) points[i + 1].getX(),
                    (int) points[i + 1].getY());
        restoreGraphics(g2D);
    }
View Full Code Here

        if (!visible)
            return;
        if (badprojection)
            return;
        g.setColor(Color.red);
        Graphics2D g2d = (Graphics2D) g;
        if (selected)
            g2d.setPaint(selectPaint);
        else
            g2d.setPaint(linePaint);
        AffineTransform saveAT = g2d.getTransform();
        // Perform transformation
        g2d.transform(at);
        // Render
        g2d.drawGlyphVector(gv, 0, 0);
        g.setColor(Color.blue);
        /*
         * if (path != null) { Stroke st = g2d.getStroke();
         * g2d.setStroke(new BasicStroke(.3f)); g2d.draw(path);
         * g2d.setStroke(st); }
         */
        // Restore original transform
        g2d.setTransform(saveAT);
    }
View Full Code Here

            if (da != null) {
                tmpDA = part.getRenderingAttributes();
                part.setRenderingAttributes(da);
            }

            Graphics2D g2 = (Graphics2D) g.create();
            part.render(g2, width, height);
            g2.dispose();

            if (da != null) {
                part.setRenderingAttributes(tmpDA);
                tmpDA = null;
            }
View Full Code Here

     * IconPart geometries.
     */
    public static ImageIcon getIcon(int width, int height, IconPart geometry,
                                    DrawingAttributes appDA) {
        ImageIcon icon = createImageIcon(width, height);
        Graphics2D g = (Graphics2D) icon.getImage().getGraphics();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        geometry.render(g, width, height, appDA);
        return icon;
    }
View Full Code Here

            if (bufferedMapImage == null || bufferedRenderingImage == null) {
                createBuffers(w, h);
            }

            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Graphics2D g = (Graphics2D) ge.createGraphics(bufferedMapImage);
            g.setClip(0, 0, w, h);
            Border border = mb.getBorder();
            mb.setBorder(null);
            mb.paintAll(g);
            mb.setBorder(border);

            oX = x;
            oY = y;

            isPanning = true;

        } else {
            if (bufferedMapImage != null && bufferedRenderingImage != null) {
                Graphics2D gr2d = (Graphics2D) bufferedRenderingImage.getGraphics();
                /*
                 * Drawing original image whithout transparence and in the
                 * initial position
                 */
                if (leaveShadow) {
                    gr2d.drawImage(bufferedMapImage, 0, 0, null);
                } else {
                    gr2d.setPaint(mb.getBckgrnd());
                    gr2d.fillRect(0, 0, mb.getWidth(), mb.getHeight());
                }

                /*
                 * Drawing image whith transparence and in the mouse position
                 * minus origianl mouse click position
                 */
                gr2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opaqueness));
                gr2d.drawImage(bufferedMapImage, x - oX, y - oY, null);

                ((Graphics2D) mb.getGraphics()).drawImage(bufferedRenderingImage, 0, 0, null);
            }
        }
        super.mouseDragged(arg0);
View Full Code Here

     * @param pt1 the anchor point.
     * @param pt2 the current (mouse) position.
     * @param graphics a java.awt.Graphics object to render into.
     */
    public void paintLine(LatLonPoint pt1, LatLonPoint pt2, Graphics graphics) {
        Graphics2D g = (Graphics2D) graphics;
        g.setXORMode(java.awt.Color.lightGray);
        g.setColor(java.awt.Color.darkGray);
        if (pt1 != null && pt2 != null) {
            // the line connecting the segments
            OMLine cLine = new OMLine(pt1.getLatitude(), pt1.getLongitude(), pt2.getLatitude(), pt2.getLongitude(), lineType);
            // get the map projection
            Projection proj = theMap.getProjection();
View Full Code Here

     * @param graphics a java.awt.Graphics object to render into.
     */
    public void paintCircle(LatLonPoint pt1, LatLonPoint pt2, Graphics graphics) {
        // do all this only if want to display the rubberband circle
        if (displayCircle) {
            Graphics2D g = (Graphics2D) graphics;
            g.setXORMode(java.awt.Color.lightGray);
            g.setColor(java.awt.Color.darkGray);
            if (pt1 != null && pt2 != null) {
                // first convert degrees to radians
                float radphi1 = ProjMath.degToRad(pt1.getLatitude());
                float radlambda0 = ProjMath.degToRad(pt1.getLongitude());
                float radphi = ProjMath.degToRad(pt2.getLatitude());
View Full Code Here

        BufferedImage bufferedImage = null;
        if (list != null && layer != null) {
            int w = layer.getProjection().getWidth();
            int h = layer.getProjection().getHeight();
            bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2d = (Graphics2D) bufferedImage.getGraphics();
            super.setRenderingHints(g2d);
            long startPaint = System.currentTimeMillis();
            list.render(g2d);
            long endPaint = System.currentTimeMillis();
            if (Debug.debugging("policy")) {
View Full Code Here

        }
    }

    protected void renderString(Graphics g, String string, int x, int y) {
        if (g instanceof Graphics2D) {
            Graphics2D g2 = (Graphics2D) g;
            if (getTextMatteColor() != null) {
                FontRenderContext context = g2.getFontRenderContext();
                GlyphVector glyphVector = g2.getFont()
                        .createGlyphVector(context, string);
                Shape outline = glyphVector.getOutline();
                g2.translate(x, y);
                g2.setStroke(getTextMatteStroke());
                g2.setColor(getTextMatteColor());
                g2.draw(outline);
                g2.translate(-x, -y);

                g2.setColor(getLineColor());
            }
        }
        g.drawString(string, x, y);
    }
View Full Code Here

TOP

Related Classes of java.awt.Graphics2D

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.