/*
 * @(#)ViewZoomToFactorAction.java  1.0  2008-09-20
 * 
 * Copyright (c) 2008 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

package ch.randelshofer.pdf.action;

import ch.randelshofer.pdf.*;
import com.sun.pdfview.PDFPage;
import java.awt.Dimension;
import java.awt.event.ActionEvent;

/**
 * ViewZoomToFactorAction.
 *
 * @author Werner Randelshofer
 * @version 1.0 2008-09
 */
public class ViewZoomToFactorAction extends AbstractJPDFFilePanelAction {
    public static String ID = "view.zoom.toFactor";

    private double scaleFactor;

    public ViewZoomToFactorAction(JPDFFilePanel pdfPanel, double zoomFactor) {
        super(pdfPanel, ID);
        this.scaleFactor = zoomFactor;
    }

    public void actionPerformed(ActionEvent e) {
        JPDFPagePanel pp = pdfPanel.getPagePanel();
        pp.setPreferredZoomFactor(scaleFactor);
//pp.setZoomPolicy(ZoomPolicy.FIT_FACTOR);
    }

    @Override
    protected void updateAction() {
        setEnabled(pdfPanel.getPDF() != null);
    }
}
