/* * [RenderWithApplet.java] * * Summary: Renders a string of tokens, usually representing Java source code with the JDisplay 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.7 2009-04-12 shorter style names, improved highlighting. */ package com.mindprod.jdisplayaux; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.Tools; import com.mindprod.jdisplay.Footprint; import java.io.File; import static com.mindprod.htmlmacros.macro.Global.configuration; /** * Renders a string of tokens, usually representing Java source code with the JDisplay Applet. *

* Used by com.mindprod.htmlmacros.jdisplay to expand long * snippets via an Applet that reads the ser file. * * @author Roedy Green, Canadian Mind Products * @version 1.7 2009-04-12 shorter style names, improved highlighting. * @since 2009 */ final class RenderWithApplet { /** * expand a tokens to CSS-style HTML * * @param footprint geometry of the snippet * @param snippetFilename unqualified snippetFilename of the snippet. * @param fileBeingDistributed file we are inserting <applet tags * * @return the equivalent markup HTML */ static String expand( Footprint footprint, String snippetFilename, File fileBeingDistributed ) { int width = footprint.actualAPPLET_WIDTH; int height = footprint.actualAPPLET_HEIGHT; boolean hasBar = footprint.hasBar; if ( configuration.isUsingHTML5( fileBeingDistributed ) ) { return expandUsingHTML5( snippetFilename, fileBeingDistributed, width, height, hasBar ); } else { return expandUsingHTML4( snippetFilename, fileBeingDistributed, width, height, hasBar ); } } private static String expandUsingHTML4( final String snippetFilename, final File fileBeingProcessed, final int width, final int height, final boolean hasBar ) { final FastCat sb = new FastCat( 16 ); sb.append( "\n" ); sb.append( "\n" ); // figures out by itself if it needs scroll bars by examining footprint in *.ser file. sb.append( "view\n" ); return sb.toString(); } private static String expandUsingHTML5( final String snippetFilename, final File fileBeingDistributed, final int width, final int height, final boolean hasBar ) { final FastCat sb = new FastCat( 24 ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "view\n" ); return sb.toString(); } }