/*****************************************************************************
 ******************************************************************************
 ***                          ZoomGraphics.java                             ***
 ***                                                                        ***
 ***   This file is part of WEBSPN 3.3                                      ***
 ***                                                                        ***
 ***   Copyright 1997/98 University of Catania - Engineering Faculty        ***
 ***                                                                        ***
 ***   Developed by:                        Supervisor:                     ***
 ***        Francesco MARLETTA                  Ing. Antonio PULIAFITO      ***
 ***        Filippo ASCIA                       (ap@iit.unict.it)           ***
 ***                                                                        ***
 ******************************************************************************
 *****************************************************************************/
package webSPN;

// Class that performs zoomed draws

import java.awt.*;
import java.awt.image.*;

public class ZoomGraphics extends Graphics {
    private Graphics output;
    private float zoomFactor;
    private int Xoffset;
    private int Yoffset;
    private Font theFont;
    private Color theColor;

    //----------------------------------------------------------------------------
    // class constructors
    //----------------------------------------------------------------------------
    public ZoomGraphics(Graphics g) {
        output = g;
        zoomFactor = (float) 1.0;
        Xoffset = 0;
        Yoffset = 0;
    }

    public ZoomGraphics(Graphics g, int zoom) {
        output = g;
        zoomFactor = zoom / (float) 100.0;
        Xoffset = 0;
        Yoffset = 0;
    }

    // this constructor set also an offset for drawing
    public ZoomGraphics(Graphics g, int zoom, int dx, int dy) {
        output = g;
        zoomFactor = zoom / (float) 100;
        Xoffset = dx;
        Yoffset = dy;
    }

    //----------------------------------------------------------------------------
    // set the zoom factor
    //----------------------------------------------------------------------------
    public void setZoomFactor(int zoom) {
        zoomFactor = zoom / (float) 100;
    }

    //----------------------------------------------------------------------------
    // retrieve the zoom factor
    //----------------------------------------------------------------------------
    public int getZoomFactor() {
        return Math.round(zoomFactor * 100);
    }

    //----------------------------------------------------------------------------
    // set the draw offset
    //----------------------------------------------------------------------------
    public void translate(int dX, int dY) {
        Xoffset = dX;
        Yoffset = dY;
    }

    //----------------------------------------------------------------------------
    // retrieve the draw offset
    //----------------------------------------------------------------------------
    public Point getOffset() {
        return new Point(Xoffset, Yoffset);
    }

    //----------------------------------------------------------------------------
    // Graphics class method: setFont
    //----------------------------------------------------------------------------
    public void setFont(Font font) {
        theFont = font;
        output.setFont(new Font(theFont.getName(), theFont.getStyle(),
          Math.round(theFont.getSize() * zoomFactor)));
    }

    //----------------------------------------------------------------------------
    // Graphics class method: getFont
    //----------------------------------------------------------------------------
    public Font getFont() {
        return theFont;
    }

    //----------------------------------------------------------------------------
    // Graphics class method: getFontMetrics
    //----------------------------------------------------------------------------
    /* FM: Questo metodo appartiene adesso anche alla classe Graphics, quindi non
     