/* * [ArrowNonets.java] * * Summary: Displays nonets of arrows of various types. One shot. * * Copyright: (c) 1999-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 2011-10-03 initial version */ package com.mindprod.entities; import com.mindprod.common18.BigDate; import com.mindprod.fastcat.FastCat; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import static java.lang.System.*; /** * Displays nonets of arrows of various types. One shot. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-10-03 initial version * @since 2011-02-10 */ public final class ArrowNonets { /** * where we put the generated HTML for inclusion on the website */ private static final String NONET_OUTPUT_FILE = "entityarrownonets.htmlfrag"; private static final String DO_NOT_EDIT = "\n"; /** * converts awkward characters to HTML entities. output appears in entitiesarrownonets.html * * @param args names of files to process, dirs, files, -s, *.*, no wildcards. */ public static void main( String[] args ) { final FastCat sb = new FastCat( 25 ); sb.append( DO_NOT_EDIT + "" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n\n
ways of making arrows
Ways of " + "Making Arrows
AppearanceHTML tags
\n" ); final Nonet angleArrows = new Nonet( new String[] { " ", "∧", " ", "<", "—", ">", " ", "∨", " " } ); sb.append( angleArrows.grid( "arrow appearance", "behold", false ) ); sb.append( "\n" ); sb.append( angleArrows.grid( "HTML entities", "htmlentity", true ) ); sb.append( "
\n" ); final Nonet singleArrows = new Nonet( new String[] { "↖", "↑", "↗", "←", "↔", "→", "↙", "↓", "↘" } ); sb.append( singleArrows.grid( "arrow appearance", "behold", false ) ); sb.append( "\n" ); sb.append( singleArrows.grid( "HTML entities", "htmlentity", true ) ); sb.append( "
\n" ); final Nonet doubleArrows = new Nonet( new String[] { " ", "⇑", " ", "⇐", "⇔", "⇒", " ", "⇓", " " } ); sb.append( doubleArrows.grid( "arrow appearance", "behold", false ) ); sb.append( "\n" ); sb.append( doubleArrows.grid( "HTML entities", "htmlentity", true ) ); sb.append( "
\n" ); sb.append( "\n" ); final String result = sb.toString(); try { HunkIO.writeEntireFile( new File( NONET_OUTPUT_FILE ), result ); out.println( NONET_OUTPUT_FILE + " generated" ); } catch ( IOException e ) { err.println( "Could not write " + NONET_OUTPUT_FILE ); } } // end main } // end ArrowNonets /** * which 9 chars used to describe a grid of arrows */ class Nonet { /** * entity for an arrow for arrow */ private final String[] nonets; /** * constructor to build a grid of 9 arrow chars * * @param nonets entities for 9 arrow chars, top to bottom, left to right */ Nonet( String[] nonets ) { assert nonets != null && nonets.length == 9 : "must have 9 entries in a Nonet. "; for ( String entity : nonets ) { assert entity.startsWith( "&" ) : "Missing & no start of entity " + entity; assert entity.endsWith( ";" ) : "Missing semicolon on end of entity " + entity; } this.nonets = nonets; } /** * build HTML to display a 3x3 grid of arrow chars */ String grid( final String summary, final String cssClass, boolean visibleEntities ) { final FastCat sb = new FastCat( 60 ); sb.append( "\n" ); sb.append( "" ); for ( int i = 0; i < 9; i++ ) { if ( i % 3 == 0 ) { sb.append( "" ); } sb.append( "\n" ); if ( i % 3 == 2 ) { sb.append( "\n" ); } } sb.append( "
" ); sb.append( summary ); // not visible sb.append( "
" ); if ( visibleEntities ) { String entity = nonets[ i ]; if ( !entity.equals( " " ) ) { sb.append( EntifyStrings.entifyHTML( entity ) ); // convert & to & on start } } else { sb.append( nonets[ i ] ); } sb.append( "
\n" ); return sb.toString(); } }