All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.examples.viewer.commands.generic.ZoomIn Maven / Gradle / Ivy

There is a newer version: 7.15.25
Show newest version
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2017 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
 @LICENSE@
 *
 * ---------------
 * ZoomIn.java
 * ---------------
 */

package org.jpedal.examples.viewer.commands.generic;

import org.jpedal.PdfDecoderInt;
import org.jpedal.examples.viewer.Commands;
import org.jpedal.examples.viewer.gui.GUI;
import org.jpedal.gui.GUIFactory;

/**
 * Takes an Image Snapshot of the Selected Area
 */
public class ZoomIn {

    private static final int[] scalingValues = {25, 50, 75, 100, 125, 150, 200, 250, 500, 750, 1000};

    public static boolean execute(final Object[] args, final GUIFactory currentGUI, final PdfDecoderInt decode_pdf) {

        if (args == null) {
            float scaling = 100 * currentGUI.getScaling();
            scaling = (int) (decode_pdf.getDPIFactory().removeScaling(scaling) + 0.5f);

            if (scaling < scalingValues[0]) {
                ((GUI) currentGUI).setSelectedComboItem(Commands.SCALING, String.valueOf(scalingValues[0]));
            } else {
                int scalingToUse = -1;
                for (int i = 0; i != scalingValues.length - 1; i++) {
                    if (scaling >= scalingValues[i] && scaling < scalingValues[i + 1]) {
                        scalingToUse = i + 1;
                        break;
                    }
                }
                if (scalingToUse != -1) {
                    ((GUI) currentGUI).setSelectedComboItem(Commands.SCALING, String.valueOf(scalingValues[scalingToUse]));
                }
            }
        }

        return false;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy