Example usage for java.awt Graphics2D drawImage

List of usage examples for java.awt Graphics2D drawImage

Introduction

In this page you can find the example usage for java.awt Graphics2D drawImage.

Prototype

public abstract boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer);

Source Link

Document

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

Usage

From source file:org.apache.fop.afp.AFPGraphics2D.java

/**
 * Draws an AWT image into a BufferedImage using an AWT Graphics2D implementation
 *
 * @param img the AWT image/*from   w  ww.  j a va2  s.  com*/
 * @param bufferedImage the AWT buffered image
 * @param width the image width
 * @param height the image height
 * @param observer the image observer
 * @return true if the image was drawn
 */
private boolean drawBufferedImage(Image img, BufferedImage bufferedImage, int width, int height,
        ImageObserver observer) {

    java.awt.Graphics2D g2d = bufferedImage.createGraphics();
    try {
        g2d.setComposite(AlphaComposite.SrcOver);

        Color color = new Color(1, 1, 1, 0);
        g2d.setBackground(color);
        g2d.setPaint(color);

        g2d.fillRect(0, 0, width, height);

        int imageWidth = bufferedImage.getWidth();
        int imageHeight = bufferedImage.getHeight();
        Rectangle clipRect = new Rectangle(0, 0, imageWidth, imageHeight);
        g2d.clip(clipRect);

        g2d.setComposite(gc.getComposite());

        return g2d.drawImage(img, 0, 0, imageWidth, imageHeight, observer);
    } finally {
        g2d.dispose(); //drawn so dispose immediately to free system resource
    }
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.fileutils.ExportUtils.java

public static void drawLinkInfo(GrowingLayer growingLayer, MapPNode mapPnode, double unitWidth,
        Graphics2D graphics, String dataFilesPrefix) {
    int width = (int) unitWidth;
    for (int x = 0; x < growingLayer.getXSize(); x++) {
        for (int y = 0; y < growingLayer.getYSize(); y++) {
            try {
                if (growingLayer.getUnit(x, y) != null) {
                    String[] mappedData = growingLayer.getUnit(x, y).getMappedInputNames();
                    if (mappedData != null) {
                        boolean hasValidLink = false;
                        for (String element : mappedData) {
                            if (new File(dataFilesPrefix + element).exists()) {
                                hasValidLink = true;
                                break;
                            }// w w  w  .  ja  va 2 s  . c o  m
                        }
                        if (hasValidLink) {
                            try {
                                BufferedImage icon = ImageIO.read(new FileInputStream(ExportUtils.class
                                        .getResource(RESOURCE_PATH_ICONS + "note.png").getFile()));
                                // icon = scaleImageByHeight(icon, (int) (unitWidth - 2));
                                int iconHeight = (int) (unitWidth * 0.7);
                                int iconWidth = (int) ((double) iconHeight / (double) icon.getHeight()
                                        * icon.getWidth());
                                int restWidth = (width - iconWidth) / 2;
                                int restHeight = (width - iconHeight) / 2;
                                graphics.drawImage(icon, x * width + restWidth, y * width + restHeight,
                                        iconWidth, iconHeight, null);
                            } catch (FileNotFoundException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                }
            } catch (LayerAccessException e) {
                // should not happen
                e.printStackTrace();
            }

        }
    }
}

From source file:net.rptools.maptool.client.functions.InputFunction.java

/**
 * Gets icon from the asset manager. Code copied and modified from
 * EditTokenDialog.java/*from   w w  w .j  a  v  a2s .co m*/
 */
private ImageIcon getIcon(String id, int size, ImageObserver io) {
    // Extract the MD5Key from the URL
    if (id == null)
        return null;
    MD5Key assetID = new MD5Key(id);

    // Get the base image && find the new size for the icon
    BufferedImage assetImage = ImageManager.getImage(assetID, io);

    // Resize
    if (assetImage.getWidth() > size || assetImage.getHeight() > size) {
        Dimension dim = new Dimension(assetImage.getWidth(), assetImage.getWidth());
        if (dim.height < dim.width) {
            dim.height = (int) ((dim.height / (double) dim.width) * size);
            dim.width = size;
        } else {
            dim.width = (int) ((dim.width / (double) dim.height) * size);
            dim.height = size;
        }
        BufferedImage image = new BufferedImage(dim.width, dim.height, Transparency.BITMASK);
        Graphics2D g = image.createGraphics();
        g.drawImage(assetImage, 0, 0, dim.width, dim.height, null);
        assetImage = image;
    }
    return new ImageIcon(assetImage);
}

From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java

public boolean renderArea(Graphics2D g2, Rectangle2D dataArea) {

    g2.setPaint(plot.paint);//  w w w  .  jav a  2  s.  c om

    if (pass == 1) {
        if (image != null) {
            double x = dataArea.getX();
            double y = dataArea.getY();
            //there is a problem when using Graphics2D with affine transform 
            //and BufferedImage; using subclass of Image returned below.
            //rescaling needed because adding legend causes dataArea to change.
            Image scaledImage = image.getScaledInstance((int) dataArea.getWidth() - 1,
                    (int) dataArea.getHeight() - 1, Image.SCALE_DEFAULT);
            g2.drawImage(scaledImage, (int) x + 1, (int) y + 1, (int) dataArea.getWidth() - 1,
                    (int) dataArea.getHeight() - 1, this);
            //g2.translate(-1,-1);
            //g2.drawRect((int) x, (int) y, (int) dataArea.getWidth(),(int) dataArea.getHeight());
            //g2.translate(1,1);
        }
        return true;
    }

    final double parHStep, parVStep;
    double parHLower = plot.getDomainAxis().getRange().getLowerBound();
    double parHUpper = plot.getDomainAxis().getRange().getUpperBound();
    double parVLower = plot.getRangeAxis().getRange().getLowerBound();
    double parVUpper = plot.getRangeAxis().getRange().getUpperBound();

    parHStep = Math.abs(parHUpper - parHLower) / dataArea.getWidth();
    parVStep = Math.abs(parVUpper - parVLower) / dataArea.getHeight();

    image = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(),
            BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
    int[] data = dataBuffer.getData();

    final double parHStart = parHLower + parHStep / 2;
    final double parVStart = parVUpper - parVStep / 2;

    if (model instanceof ODE) {
        double step = stepSize; // stepSize and timeStep probably mean the same thing, one for discrete another for ODE
        double[] result = new double[model.getNVar()];

        for (int i = 0; i < (int) dataArea.getWidth(); i++) {
            for (int j = 0; j < (int) dataArea.getHeight(); j++) {

                parameters.put(firstParLabel, parHStart + i * parHStep);
                parameters.put(secondParLabel, parVStart - j * parVStep);

                int color;
                result = Lua.evaluateLyapunovExponentsODE(model, parameters, initialPoint, timePeriod,
                        stepSize);

                if (result == null) {
                    System.out.println("i: " + i + " j: " + j);
                    System.out.println("par1: " + parHStart + i * parHStep);
                    System.out.println("par2: " + parVStart + j * parVStep);
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                    return false;
                }

                int zer = 0;
                int pos = 0;
                int neg = 0;
                int nan = 0;
                for (int ii = 0; ii < result.length; ii++) {
                    if (Math.abs(result[ii]) == (1.0 / 0.0))
                        nan++;
                    else if (Math.abs(result[ii]) <= epsilon)
                        zer++;
                    else if (result[ii] > epsilon)
                        pos++;
                    else if (result[ii] < (-epsilon))
                        neg++;
                    else
                        nan++;
                }

                color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB();
                ExpsSigns es = new ExpsSigns(zer, pos, neg, nan);
                if (!signsSet.contains(es))
                    signsSet.add(es);

                data[i + j * (int) dataArea.getWidth()] = color;

                if (stopped == true)
                    return false;

                if (j == (int) dataArea.getHeight() - 1) {
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                }
            } //end for
        } //end for
    } //end if ODE
    else {
        for (int i = 0; i < (int) dataArea.getWidth(); i++) {
            for (int j = 0; j < (int) dataArea.getHeight(); j++) {

                parameters.put(firstParLabel, parHStart + i * parHStep);
                parameters.put(secondParLabel, parVStart - j * parVStep);

                double[] result;
                int color;

                result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations);

                if (result == null) {
                    System.out.println("i: " + i + " j: " + j);
                    System.out.println("par1: " + parHStart + i * parHStep);
                    System.out.println("par2: " + parVStart + j * parVStep);
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                    return false;
                }

                int zer = 0;
                int pos = 0;
                int neg = 0;
                int nan = 0;
                for (int ii = 0; ii < result.length; ii++) {
                    if (Math.abs(result[ii]) == (1.0 / 0.0))
                        nan++;
                    else if (Math.abs(result[ii]) <= epsilon)
                        zer++;
                    else if (result[ii] > epsilon)
                        pos++;
                    else if (result[ii] < (-epsilon))
                        neg++;
                    else
                        nan++;
                }

                color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB();
                ExpsSigns es = new ExpsSigns(zer, pos, neg, nan);
                if (!signsSet.contains(es))
                    signsSet.add(es);

                data[i + j * (int) dataArea.getWidth()] = color;

                if (stopped == true)
                    return false;

                if (j == (int) dataArea.getHeight() - 1)
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
            } //end for
        } //end for
    } //end else
    return true;
}

From source file:org.echocat.velma.dialogs.AboutDialog.java

@Nonnull
@Override//from ww  w.jav  a 2s .co  m
protected Container createContainer() {
    return new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            final Graphics2D g2d = (Graphics2D) g;
            final Dimension size = getSize();
            g2d.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR);
            g2d.setRenderingHint(KEY_RENDERING, VALUE_RENDER_QUALITY);
            g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
            final double sourceWidth = _backgroundImage.getWidth();
            final double sourceHeight = _backgroundImage.getHeight();
            final double targetWidth = size.getWidth();
            final double targetHeight = size.getHeight();
            final double relWidth = sourceWidth / targetWidth;
            final double relHeight = sourceHeight / targetHeight;
            final double width;
            final double height;
            final double x;
            final double y;
            if (relWidth > relHeight) {
                width = sourceWidth / relHeight;
                height = sourceHeight / relHeight;
                x = ((targetWidth - width) / 2);
                y = 0;
            } else {
                width = sourceWidth / relWidth;
                height = sourceHeight / relWidth;
                x = 0;
                y = ((targetHeight - height) / 2);
            }

            g2d.drawImage(_backgroundImage, (int) x, (int) y, (int) width, (int) height, this);
        }
    };
}

From source file:ClipImage.java

public void drawDemo(Graphics2D g2) {

    if (newBufferedImage) {
        x = Math.random() * w;// w  ww  .j av a 2 s  .  co m
        y = Math.random() * h;
        ew = (Math.random() * w) / 2;
        eh = (Math.random() * h) / 2;
    }
    x += ix;
    y += iy;
    ew += iw;
    eh += ih;
    if (ew > w / 2) {
        ew = w / 2;
        iw = Math.random() * -w / 16 - 1;
    }
    if (ew < w / 8) {
        ew = w / 8;
        iw = Math.random() * w / 16 + 1;
    }
    if (eh > h / 2) {
        eh = h / 2;
        ih = Math.random() * -h / 16 - 1;
    }
    if (eh < h / 8) {
        eh = h / 8;
        ih = Math.random() * h / 16 + 1;
    }
    if ((x + ew) > w) {
        x = (w - ew) - 1;
        ix = Math.random() * -w / 32 - 1;
    }
    if (x < 0) {
        x = 2;
        ix = Math.random() * w / 32 + 1;
    }
    if ((y + eh) > h) {
        y = (h - eh) - 2;
        iy = Math.random() * -h / 32 - 1;
    }
    if (y < 0) {
        y = 2;
        iy = Math.random() * h / 32 + 1;
    }

    ellipse.setFrame(x, y, ew, eh);
    g2.setClip(ellipse);

    rect.setRect(x + 5, y + 5, ew - 10, eh - 10);
    g2.clip(rect);

    g2.drawImage(img, 0, 0, w, h, this);

    p.reset();
    p.moveTo(-w / 2.0f, -h / 8.0f);
    p.lineTo(+w / 2.0f, -h / 8.0f);
    p.lineTo(-w / 4.0f, +h / 2.0f);
    p.lineTo(+0.0f, -h / 2.0f);
    p.lineTo(+w / 4.0f, +h / 2.0f);
    p.closePath();

    at.setToIdentity();
    at.translate(w * .5f, h * .5f);
    g2.transform(at);
    g2.setStroke(bs);
    g2.setPaint(redBlend);
    g2.draw(p);

    at.setToIdentity();
    g2.setTransform(at);

    g2.setPaint(greenBlend);

    for (int yy = 0; yy < h; yy += 50) {
        for (int xx = 0, i = 0; xx < w; i++, xx += 50) {
            switch (i) {
            case 0:
                arc.setArc(xx, yy, 25, 25, 45, 270, Arc2D.PIE);
                g2.fill(arc);
                break;
            case 1:
                ellipse.setFrame(xx, yy, 25, 25);
                g2.fill(ellipse);
                break;
            case 2:
                roundRect.setRoundRect(xx, yy, 25, 25, 4, 4);
                g2.fill(roundRect);
                break;
            case 3:
                rect.setRect(xx, yy, 25, 25);
                g2.fill(rect);
                i = -1;
            }

        }
    }
}

From source file:dk.dma.msinm.web.OsmStaticMap.java

public BufferedImage createBaseMap(MapImageCtx ctx) {
    BufferedImage image = new BufferedImage(ctx.width, ctx.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    int startX = (int) Math.floor(ctx.centerX - (ctx.width / ctx.tileSize) / 2.0);
    int startY = (int) Math.floor(ctx.centerY - (ctx.height / ctx.tileSize) / 2.0);
    int endX = (int) Math.ceil(ctx.centerX + (ctx.width / ctx.tileSize) / 2.0);
    int endY = (int) Math.ceil(ctx.centerY + (ctx.height / ctx.tileSize) / 2.0);
    ctx.offsetX = -Math.floor((ctx.centerX - Math.floor(ctx.centerX)) * ctx.tileSize);
    ctx.offsetY = -Math.floor((ctx.centerY - Math.floor(ctx.centerY)) * ctx.tileSize);
    ctx.offsetX += Math.floor(ctx.width / 2.0);
    ctx.offsetY += Math.floor(ctx.height / 2.0);
    ctx.offsetX += Math.floor(startX - Math.floor(ctx.centerX)) * ctx.tileSize;
    ctx.offsetY += Math.floor(startY - Math.floor(ctx.centerY)) * ctx.tileSize;

    for (int x = startX; x <= endX; x++) {
        for (int y = startY; y <= endY; y++) {
            String url = String.format(OSM_URL, ctx.zoom, x, y);
            log.info("Fetching " + url);
            try {
                BufferedImage tileImage = fetchTile(url);
                double destX = (x - startX) * ctx.tileSize + ctx.offsetX;
                double destY = (y - startY) * ctx.tileSize + ctx.offsetY;
                g2.drawImage(tileImage, (int) destX, (int) destY, ctx.tileSize, ctx.tileSize, null);
                image.flush();/* ww  w .  j a v a 2 s.c om*/
            } catch (Exception e) {
                log.warn("Failed loading image " + url);
            }
        }
    }
    return image;
}

From source file:ClipImage.java

public void drawDemo(Graphics2D g2) {
    if (newBufferedImage) {
        x = Math.random() * w;/*  w  w  w .  ja v a  2s .  c  o m*/
        y = Math.random() * h;
        ew = (Math.random() * w) / 2;
        eh = (Math.random() * h) / 2;
    }
    x += ix;
    y += iy;
    ew += iw;
    eh += ih;
    if (ew > w / 2) {
        ew = w / 2;
        iw = Math.random() * -w / 16 - 1;
    }
    if (ew < w / 8) {
        ew = w / 8;
        iw = Math.random() * w / 16 + 1;
    }
    if (eh > h / 2) {
        eh = h / 2;
        ih = Math.random() * -h / 16 - 1;
    }
    if (eh < h / 8) {
        eh = h / 8;
        ih = Math.random() * h / 16 + 1;
    }
    if ((x + ew) > w) {
        x = (w - ew) - 1;
        ix = Math.random() * -w / 32 - 1;
    }
    if (x < 0) {
        x = 2;
        ix = Math.random() * w / 32 + 1;
    }
    if ((y + eh) > h) {
        y = (h - eh) - 2;
        iy = Math.random() * -h / 32 - 1;
    }
    if (y < 0) {
        y = 2;
        iy = Math.random() * h / 32 + 1;
    }

    ellipse.setFrame(x, y, ew, eh);
    g2.setClip(ellipse);

    rect.setRect(x + 5, y + 5, ew - 10, eh - 10);
    g2.clip(rect);

    g2.drawImage(img, 0, 0, w, h, this);

    p.reset();
    p.moveTo(-w / 2.0f, -h / 8.0f);
    p.lineTo(+w / 2.0f, -h / 8.0f);
    p.lineTo(-w / 4.0f, +h / 2.0f);
    p.lineTo(+0.0f, -h / 2.0f);
    p.lineTo(+w / 4.0f, +h / 2.0f);
    p.closePath();

    at.setToIdentity();
    at.translate(w * .5f, h * .5f);
    g2.transform(at);
    g2.setStroke(bs);
    g2.setPaint(redBlend);
    g2.draw(p);

    at.setToIdentity();
    g2.setTransform(at);

    g2.setPaint(greenBlend);

    for (int yy = 0; yy < h; yy += 50) {
        for (int xx = 0, i = 0; xx < w; i++, xx += 50) {
            switch (i) {
            case 0:
                arc.setArc(xx, yy, 25, 25, 45, 270, Arc2D.PIE);
                g2.fill(arc);
                break;
            case 1:
                ellipse.setFrame(xx, yy, 25, 25);
                g2.fill(ellipse);
                break;
            case 2:
                roundRect.setRoundRect(xx, yy, 25, 25, 4, 4);
                g2.fill(roundRect);
                break;
            case 3:
                rect.setRect(xx, yy, 25, 25);
                g2.fill(rect);
                i = -1;
            }

        }
    }
}

From source file:gg.msn.ui.panel.MainPanel.java

@Override
public void paint(Graphics g) {
    super.paint(g);
    try {/*from www .  j  ava2 s .c  o m*/
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        //render per utenti Facebook
        if (ChatClientView.protocol.equals(ChatClientView.FACEBOOK_PROTOCOL)) {
            final FacebookUser user = (FacebookUser) value;
            int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2);

            //name string
            g2.setFont(list.getFont());
            g2.drawString(user.name, WHITE_SPACE + IMAGE_LATE + 3, textY);

            //status string
            //                g2.setFont(list.getFont());
            //                g2.drawString(user.status, WHITE_SPACE + IMAGE_LATE + 3, textY);

            //icon
            ImageIcon icon = user.portrait;
            //log.debug("icon [" + icon + "]");
            //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING));
            g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE,
                    IMAGE_LATE, null);
            //                 g2.setColor(Color.WHITE);
            //                g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, ARC_SIZE, ARC_SIZE);
            //                g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+1) / 2), IMAGE_LATE+1, IMAGE_LATE+1, ARC_SIZE, ARC_SIZE);
            //                g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+2) / 2), IMAGE_LATE+2, IMAGE_LATE+2, ARC_SIZE, ARC_SIZE);
            //render per utenti Client
            //                log.debug("user status [" + user.status + "]");
            //                log.debug("user online status [" + user.onlineStatus + "]");
            if (StringUtils.equals(user.status, FacebookUser.STATUS_ONLINE)) {
                g2.setColor(Color.GREEN);
                g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2),
                        STATUS_ICON_WIDTH, STATUS_ICON_WIDTH);
            } else {
                g2.setColor(Color.GRAY);
                g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2),
                        STATUS_ICON_WIDTH, STATUS_ICON_WIDTH);
            }

        } else {
            g2.setFont(list.getFont());
            int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2);

            Client client = (Client) value;
            //                setText((client).getNick());
            ImageIcon icon = null;
            try {
                new ImageIcon(client.getImage());
            } catch (Exception e) {
                //                    log.debug("immgine non presente");
                icon = ThemeManager.getTheme().get(ThemeManager.USER_ICON);
            }
            g2.drawString(client.getNick(), WHITE_SPACE + IMAGE_LATE + 3, textY);
            //log.debug("icon [" + icon + "]");
            //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING));
            g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE,
                    IMAGE_LATE, null);

            //                setFont(list.getFont());
            //                setIcon(scaledIcon);
        }
    } catch (Exception e) {
        log.warn(e);
    }

}

From source file:org.gumtree.vis.awt.CompositePanel.java

@Override
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
    if (pageIndex != 0) {
        return NO_SUCH_PAGE;
    }//ww w.j a  v  a  2  s  .c  o m
    Graphics2D g2 = (Graphics2D) g;
    double x = pf.getImageableX();
    double y = pf.getImageableY();
    double w = pf.getImageableWidth();
    double h = pf.getImageableHeight();
    double screenWidth = getWidth();
    double screenHeight = getHeight();
    double widthRatio = w / screenWidth;
    double heightRatio = h / screenHeight;
    double overallRatio = 1;
    overallRatio = widthRatio < heightRatio ? widthRatio : heightRatio;
    //        Rectangle2D printArea = new Rectangle2D.Double(x, y, screenWidth * overallRatio, 
    //              screenHeight * overallRatio);
    BufferedImage image = getImage();
    g2.drawImage(image, (int) x, (int) y, (int) (screenWidth * overallRatio),
            (int) (screenHeight * overallRatio), null);
    //        draw(g2, printArea, x, y);
    g2.dispose();
    return PAGE_EXISTS;

    //        XYPlot plot = (XYPlot) getChart().getPlot();
    //        Font domainFont = plot.getDomainAxis().getLabelFont();
    //        int domainSize = domainFont.getSize();
    //        Font rangeFont = plot.getRangeAxis().getLabelFont();
    //        int rangeSize = rangeFont.getSize();
    //        Font titleFont = getChart().getTitle().getFont();
    //        int titleSize = titleFont.getSize();
    //        Font domainScaleFont = plot.getDomainAxis().getTickLabelFont();
    //        int domainScaleSize = domainScaleFont.getSize();
    //        Font rangeScaleFont = plot.getRangeAxis().getTickLabelFont();
    //        int rangeScaleSize = rangeScaleFont.getSize();
    //        plot.getDomainAxis().setLabelFont(domainFont.deriveFont(
    //              (float) (domainSize * overallRatio)));
    //        plot.getRangeAxis().setLabelFont(rangeFont.deriveFont(
    //              (float) (rangeSize * overallRatio)));
    //        getChart().getTitle().setFont(titleFont.deriveFont(
    //              (float) (titleSize * overallRatio)));
    //        plot.getDomainAxis().setTickLabelFont(domainScaleFont.deriveFont(
    //              (float) (domainScaleSize * overallRatio)));
    //        plot.getRangeAxis().setTickLabelFont(rangeScaleFont.deriveFont(
    //              (float) (rangeScaleSize * overallRatio)));
    //        
    //        Rectangle2D chartArea = (Rectangle2D) printArea.clone();
    //        getChart().getPadding().trim(chartArea);
    //        AxisUtilities.trimTitle(chartArea, g2, getChart().getTitle(), getChart().getTitle().getPosition());
    //        
    //        Axis scaleAxis = null;
    //        Font scaleAxisFont = null;
    //        int scaleAxisFontSize = 0;
    //        for (Object object : getChart().getSubtitles()) {
    //           Title title = (Title) object;
    //           if (title instanceof PaintScaleLegend) {
    //              scaleAxis = ((PaintScaleLegend) title).getAxis();
    //              scaleAxisFont = scaleAxis.getTickLabelFont();
    //              scaleAxisFontSize = scaleAxisFont.getSize();
    //              scaleAxis.setTickLabelFont(scaleAxisFont.deriveFont(
    //                    (float) (scaleAxisFontSize * overallRatio)));
    //           }
    //           AxisUtilities.trimTitle(chartArea, g2, title, title.getPosition());
    //        }
    //        AxisSpace axisSpace = AxisUtilities.calculateAxisSpace(
    //              getChart().getXYPlot(), g2, chartArea);
    //        Rectangle2D dataArea = axisSpace.shrink(chartArea, null);
    //        getChart().getXYPlot().getInsets().trim(dataArea);
    //        getChart().getXYPlot().getAxisOffset().trim(dataArea);
    //        
    ////        Rectangle2D screenArea = getScreenDataArea();
    ////        Rectangle2D visibleArea = getVisibleRect();
    ////        Rectangle2D printScreenArea = new Rectangle2D.Double(screenArea.getMinX() * overallRatio + x, 
    ////              screenArea.getMinY() * overallRatio + y, 
    ////              printArea.getWidth() - visibleArea.getWidth() + screenArea.getWidth(), 
    ////              printArea.getHeight() - visibleArea.getHeight() + screenArea.getHeight());
    //
    //        getChart().draw(g2, printArea, getAnchor(), null);
    //        ChartMaskingUtilities.drawMasks(g2, dataArea, 
    //              getMasks(), null, getChart(), overallRatio);
    //        plot.getDomainAxis().setLabelFont(domainFont);
    //        plot.getRangeAxis().setLabelFont(rangeFont);
    //        getChart().getTitle().setFont(titleFont);
    //        plot.getDomainAxis().setTickLabelFont(domainScaleFont);
    //        plot.getRangeAxis().setTickLabelFont(rangeScaleFont);
    //        if (scaleAxis != null) {
    //           scaleAxis.setTickLabelFont(scaleAxisFont);
    //        }
    //        return PAGE_EXISTS;
}