/*
 * @(#)ViewZoomIncreaseAction.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.JPDFPagePanel;
import ch.randelshofer.pdf.JPDFFilePanel;
import ch.randelshofer.pdf.ZoomPolicy;
import com.sun.pdfview.PDFPage;
import java.awt.Dimension;
import java.awt.event.ActionEvent;

/**
 * ViewZoomIncreaseAction.
 *
 * @author Werner Randelshofer
 * @version 1.0 2008-09
 */
public class ViewZoomIncreaseAction extends AbstractJPDFFilePanelAction {
    public static String INCREASE_ID = "view.zoom.increase";
    public static String DECREASE_ID = "view.zoom.decrease";
private double scaleFactor;
    
    public ViewZoomIncreaseAction(JPDFFilePanel pdfPanel, double scaleFactor) {
        super(pdfPanel, (scaleFactor >= 1) ? INCREASE_ID : DECREASE_ID);
        this.scaleFactor = scaleFactor;
    }

    public void actionPerformed(ActionEvent e) {
new Throwable().printStackTrace();
        JPDFPagePanel pp = pdfPanel.getPagePanel();
  
        pp.setPreferredZoomFactor(pp.getZoomFactor()*scaleFactor);
pdfPanel.setZoomPolicy(ZoomPolicy.FIXED_SIZE);
    }

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