Example usage for com.lowagie.text.pdf PdfTransition PdfTransition

List of usage examples for com.lowagie.text.pdf PdfTransition PdfTransition

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfTransition PdfTransition.

Prototype

public PdfTransition(int type, int duration) 

Source Link

Document

Constructs a Transition.

Usage

From source file:org.pdfsam.console.business.pdf.handlers.SlideShowCmdExecutor.java

License:Open Source License

/**
 * sets the transitions on the stamper setting the default value if no transition has been set for the page.
 * @param defaultTransition//from w  w w  .j a  v a 2 s. c o m
 * @param totalPages
 * @param transitions
 */
private void setTransitionsWithDefault(Transitions transitions, int totalPages) {
    LOG.debug("Setting transitions with a default value.");
    Transition[] trans = transitions.getTransitions();

    Hashtable transitionsMap = new Hashtable(0);
    if (trans != null) {
        transitionsMap = new Hashtable(trans.length);
        for (int i = 0; i < trans.length; i++) {
            transitionsMap.put(new Integer(trans[i].getPageNumber()), trans[i]);
        }
    }

    for (int j = 1; j <= totalPages; j++) {
        Object rawTransition = transitionsMap.get(new Integer(j));
        if (rawTransition != null) {
            Transition transition = (Transition) rawTransition;
            pdfStamper.setDuration(transition.getDuration(), transition.getPageNumber());
            pdfStamper.setTransition(new PdfTransition(getITextTransition(transition.getTransition()),
                    transition.getTransitionDuration()), transition.getPageNumber());
        } else {
            pdfStamper.setDuration(transitions.getDefaultTransition().getDuration(), j);
            pdfStamper.setTransition(
                    new PdfTransition(getITextTransition(transitions.getDefaultTransition().getTransition()),
                            transitions.getDefaultTransition().getTransitionDuration()),
                    j);
        }
        setPercentageOfWorkDone(((j) * WorkDoneDataModel.MAX_PERGENTAGE) / totalPages);
    }
}

From source file:org.pdfsam.console.business.pdf.handlers.SlideShowCmdExecutor.java

License:Open Source License

/**
 * sets the transitions on the stamper when no default transition is set
 * @param defaultTransition//from ww w  . j a  v  a2  s .c  o  m
 * @param transitions
 */
private void setTransitionsWithoutDefault(Transitions transitions) {
    LOG.debug("Setting transitions without a default value.");
    Transition[] trans = transitions.getTransitions();
    if (trans != null && trans.length > 0) {
        for (int i = 0; i < trans.length; i++) {
            pdfStamper.setDuration(trans[i].getDuration(), trans[i].getPageNumber());
            pdfStamper.setTransition(new PdfTransition(getITextTransition(trans[i].getTransition()),
                    trans[i].getTransitionDuration()), trans[i].getPageNumber());
            setPercentageOfWorkDone(((i + 1) * WorkDoneDataModel.MAX_PERGENTAGE) / trans.length);
        }
    } else {
        LOG.warn("No transition to set.");
    }
}

From source file:org.sejda.impl.itext.component.PdfStamperHandler.java

License:Apache License

/**
 * Applies the given transition to the given page.
 * /*from  w ww  . jav  a  2s  . c  o  m*/
 * @param page
 * @param transition
 */
public void setTransitionOnStamper(Integer page, PdfPageTransition transition) {
    Integer transitionStyle = getTransition(transition.getStyle());
    if (transitionStyle != null) {
        stamper.setDuration(transition.getDisplayDuration(), page);
        stamper.setTransition(new PdfTransition(transitionStyle, transition.getTransitionDuration()), page);
    } else {
        LOG.warn("Transition {} not applied to page {}. Not supported by iText.", transition.getStyle(), page);
    }
}