/*
 * @(#)ViewRotatePageAction.java  1.0  2009-11-22
 * 
 * Copyright (c) 2009 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.event.ActionEvent;

/**
 * ViewRotatePageAction.
 *
 * @author Werner Randelshofer
 * @version 1.0 2009-11-22 Created.
 */
public class ViewRotatePageAction extends AbstractJPDFFilePanelAction {
    public static String ID = "view.rotatePage";

    public ViewRotatePageAction(JPDFFilePanel pdfPanel) {
        super(pdfPanel, ID);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        PDFPage page = pdfPanel.getPagePanel().getPage();
        page.setRotation((page.getRotation()+90)%360);
        JPDFPagePanel panel = pdfPanel.getPagePanel();
        panel.updatePreferredSize();
             panel.revalidate();
             panel.repaint();
             pdfPanel.getThumbnailsPanel().repaintThumbnail(pdfPanel.getCurrentPageNumber());


    }

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