/* * [CMPApplet.java] * * Summary: Generate HTML to invoke a stanrdard CMP Applet. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2009-04-28 initial version * 1.1 2009-04-28 put Java version up front */ package com.mindprod.htmlmacros.macro; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.Tools; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Generate HTML to invoke a stanrdard CMP Applet. * * @author Roedy Green, Canadian Mind Products * @version 1.1 2009-04-28 put Java version up front * @see com.mindprod.htmlmacros.macro.CurrCon * @since 2009 */ public final class CMPApplet extends Macro { /** * suffix for a tag */ private static final String TAG_TAIL = ">\n"; /** * how to use the macro, nothing to do with signed/unsigned. Java figures that out from the jar. */ private static final String USAGE = "\ntry "; // TODO: implement the * * @return expanded macro HTML */ private String expandWithHTML4( String pk, String className, int width, int height, String jdk, String params ) { final FastCat sb = new FastCat( 20 ); sb.append( "" ); return sb.toString(); } /** * @param pk last leg of package * @param className main-Class without package or .class * @param width width of Applet window * @param height height of Applet window * @param jdk JDK version required e.g. "1.6" without trailing + * @param params additonal parms e.g. * * @return expanded macro HTML */ private String expandWithHTML5( String pk, String className, int width, int height, String jdk, String params ) { // generate something like this // // // // // Applet failed to run. No Java plug-in was found. // final FastCat sb = new FastCat( 36 ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( params ); sb.append( "Applet failed to run. No Java ", jdk, " or later plug-in found.\n" ); sb.append( "\n" ); return sb.toString(); } /** * Generate an Applet invocation for a CMP standard Applet where the jar is in the /applet directory. *

* * * @param parms show currency amount level. * @param quiet true if want output suppressed. * @param verbose @return expanded macro HTML */ public String expandMacro( String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { out.print( "A" ); } if ( !( 5 <= parms.length && parms.length <= 6 ) ) { throw new IllegalArgumentException( USAGE ); } try { int p = 0; final String jdk = parms[ p++ ]; if ( jdk.indexOf( '.' ) < 0 ) { throw new IllegalArgumentException( USAGE ); } String pk = parms[ p++ ]; if ( pk.indexOf( '.' ) >= 0 ) { throw new IllegalArgumentException( USAGE ); } String className = parms[ p++ ]; if ( className.indexOf( '.' ) >= 0 ) { throw new IllegalArgumentException( USAGE ); } final int width = Integer.parseInt( parms[ p++ ] ); final int height = Integer.parseInt( parms[ p++ ] ); final String params = parms.length > p ? parms[ p ] : ""; if ( configuration.isUsingHTML5( fileBeingDistributed ) ) { return expandWithHTML5( pk, className, width, height, jdk, params ); } else { return expandWithHTML4( pk, className, width, height, jdk, params ); } } catch ( NumberFormatException e ) { throw new IllegalArgumentException( USAGE ); } } }