/* * [RenderAsIframe.java] * * Summary: Renders a string of tokens into an HTML iframe, usually representing Java source code. * * 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.jdisplay.Footprint; import com.mindprod.jdisplay.Geometry; import static java.lang.System.*; /** * Renders a string of tokens into an HTML iframe, usually representing Java source code. *

* Used by com.mindprod.htmlmacros.jdisplay to expand short snippets in HTML as an iframe. * * @author Roedy Green, Canadian Mind Products * @version 1.7 2009-04-12 shorter style names, improved highlighting. * @since 2007 */ final class RenderAsIframe { /** * true if want extra debugging output */ private static final boolean DEBUGGING = false; /** * expand a tokens to CSS-style HTML * * @param snippetName name of the snippet. * @param footprint the geometry of the snippet. * * @return the HTML to render this via an iframe. */ static String expand( Footprint footprint, String snippetName ) { // HTML version won't exactly match Applet version because: // 1. Applet uses 1.5 instead of double spacing. // 2. fence chars are not handled identically. // 3. slight diffs in style sheet vs TokenFonts. if ( DEBUGGING ) { out.println( snippetName + " " + footprint ); } final int width = footprint.actualAPPLET_WIDTH + ( footprint.hasVScroll ? Geometry.SCROLLED_FAT_WIDTH_PX : Geometry.UNSCROLLED_FAT_WIDTH_PX ); final int height = footprint.actualAPPLET_HEIGHT + ( footprint.hasHScroll ? Geometry.SCROLLED_FAT_HEIGHT_PX : Geometry.UNSCROLLED_FAT_HEIGHT_PX ); final boolean scrolling = ( footprint.hasHScroll || footprint.hasVScroll ); // If box is too big, frame will shrink leaving space below. // with auto, if box is too small, will grow scroll bars. // Put iframe in a <div sandwich since class on the inline // is ignored. final FastCat sb = new FastCat( 13 ); sb.append( "" ); return sb.toString(); } }