/* * [Widen.java] * * Summary: Makes table contain half as many rows and twice as many columns my moving bottom half of table to top right. * * Copyright: (c) 1998-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 1998-01-01 initial version. */ package com.mindprod.reorg; import java.io.IOException; import static java.lang.System.*; /** * Makes table contain half as many rows and twice as many columns my moving bottom half of table to top right. *

* Widen.java * Widen an HTML table, * command line is empty * Makes table contain half as many rows and twice as many columns my moving bottom half of table to top right. * Must manually strip stuff ahead and after table. * Must manually strip
* Must manually strip * no fancy etc. Just in upper or lower case. * It can't handle any grammatical errors in your HTML. * Input from E:\temp\in.html * Output to E:\temp\out.html all tags in lower case. * * @author Roedy Green, Canadian Mind Products * @version 1.0 1998-01-01 initial version. * @since 1998 */ public final class Widen extends Common { private static final int FIRST_COPYRIGHT_YEAR = 1998; /** * non-displaying copyright. */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 1998-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; /** * main * * @param args which cols you want in output table in order, 0-based * * @throws java.io.IOException if any problem reading or writing the html */ @SuppressWarnings( { "UnnecessaryLocalVariable" } ) public static void main( String[] args ) throws IOException { // get entire table into a string. final String[][] matrix = getMatrix( IN_FILENAME ); final int rows = rows( matrix ); final int cols = cols( matrix ); displayRowAndColCounts( "input", rows, cols ); trimMatrix( matrix ); final int nrows = ( rows + 1 ) / 2; final int ncols = cols * 2; displayRowAndColCounts( "widened output", nrows, ncols ); // create new matrix with desired new columns. String[][] grid = new String[ nrows ][ ncols ]; // copy top left to top left. for ( int row = 0; row < nrows; row++ ) { for ( int col = 0; col < cols; col++ ) { out.println( row + " " + col ); grid[ row ][ col ] = ( row >= rows || col >= cols ) ? "" : matrix[ row ][ col ]; } // end for col } // end for for row out.println( "..." ); // copy bottom right to top right for ( int row = nrows; row < rows; row++ ) { for ( int col = 0; col < cols; col++ ) { out.println( row + " " + col ); grid[ row - nrows ][ col + cols ] = ( row >= rows || col >= cols ) ? "" : matrix[ row ][ col ]; } // end for col } // end for row writeMatrix( grid, OUT_FILENAME ); } // end main }