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

org.jpedal.examples.viewer.objects.ClientExternalHandler 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@
 *
 * ---------------
 * ClientExternalHandler.java
 * ---------------
 */
package org.jpedal.examples.viewer.objects;

import org.jpedal.external.AdditonalHandler;
import org.jpedal.external.AnnotationHandler;
import org.jpedal.external.JPedalActionHandler;
import org.jpedal.external.Options;
import org.jpedal.io.Speech;

/**
 * Additional handlers used in Client
 *
 * @author markee
 */
public abstract class ClientExternalHandler implements AdditonalHandler {


    AnnotationHandler annotationHandler; // =new ExampleAnnotationHandler();

    // [AWI] Used when the UI is ready for Keyboard input (used for touchscreens with virtual keyboards).

    private JPedalActionHandler keyboardHandler;

    private Speech speech;

    @Override
    public Object getExternalHandler(final int type) {

        switch (type) {
            
            /* [AWI] Used when the UI is ready for Keyboard input (used for touchscreens with virtual keyboards). */
            case Options.KeyboardReadyHandler:
                return keyboardHandler;

            case Options.SpeechEngine:
                return speech;

            case Options.UniqueAnnotationHandler:
                return annotationHandler;

            default:
                throw new IllegalArgumentException("Unknown type=" + type);

        }
    }

    @Override
    public void addExternalHandler(final Object newHandler, final int type) {

        switch (type) {

            case Options.UniqueAnnotationHandler:
                annotationHandler = (AnnotationHandler) newHandler;
                break;
            
             /* [AWI] Used when the UI is ready for Keyboard input (used for touchscreens with virtual keyboards). */
            case Options.KeyboardReadyHandler:
                if (newHandler instanceof JPedalActionHandler) {
                    keyboardHandler = (JPedalActionHandler) newHandler;
                }
                break;

            case Options.SpeechEngine:
                if (newHandler instanceof Speech) {
                    speech = (Speech) newHandler;
                }
                break;

            default:
                throw new IllegalArgumentException("Unknown type=" + type);

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy