Package tst.print

Source Code of tst.print.TestLinePrinter

package tst.print;
import java.util.Calendar;

import tcg.print.EColor;
import tcg.print.ETextStyle;
import tcg.print.ILinePrinter;
import tcg.print.IPrintable;
import tcg.print.PrintableFactory;
import tcg.print.JavaLinePrinter;



public class TestLinePrinter {

  /**
   * @param args
   */
  public static void main(String[] args)
  {
    String printer_name = "PrintServer1";
   
    ILinePrinter printer = new JavaLinePrinter(printer_name);
    if (!printer.ping())
    {
      System.out.println("Java printer " + printer_name
                + " is not available.");
      return;
    }
   
    //initialize the calendar instance. in Unix it often throws exception because of
    //unknown locale
    try
    {
      Calendar.getInstance();
    }
    catch(Exception ex)
    {
      //ignore
    }
   
    IPrintable printable = PrintableFactory.createPrintable("OKI");
    printable.append(Calendar.getInstance().getTime().toString() + ": Hello world! köyden ağaçtan\n");
    try
    {
      printer.print(printable);
    }
    catch(RuntimeException re)
    {
      System.out.println("Exception: " + re.getMessage());
    }
   
    printable.clear();
    printable.append(Calendar.getInstance().getTime().toString() + ": abcdefghijklmnop\ndfssdfgsdgs\nssasdfdsf\n");
    try
    {
      printer.print(printable);
    }
    catch(RuntimeException re)
    {
      System.out.println("Exception: " + re.getMessage());
    }
   
    printable.clear();
    printable.append(Calendar.getInstance().getTime().toString() + ": \u65e5\u672c\u8a9e\u6587\u5b57\u5217\n");
    try
    {
      printer.print(printable);
    }
    catch(RuntimeException re)
    {
      System.out.println("Exception: " + re.getMessage());
    }
   
    printable.clear();
    printable.append(Calendar.getInstance().getTime().toString() + ": ");
    printable.append(" BOLD ", new ETextStyle[]{ ETextStyle.BOLD }, null );
    printable.append(" ITALIC ", new ETextStyle[]{ ETextStyle.ITALIC }, null );
    printable.append(" BOLD-ITALIC ", new ETextStyle[]{ ETextStyle.BOLD, ETextStyle.ITALIC }, null );
    printable.append(" UNDERLINE ", new ETextStyle[]{ ETextStyle.UNDERLINE }, null );
    printable.append(" STRIKETHROUGH ", new ETextStyle[]{ ETextStyle.STRIKETHROUGH }, null );
    printable.append(" SUPERSCRIPT ", new ETextStyle[]{ ETextStyle.SUPERSCRIPT }, null );
    printable.append(" SUBSCRIPT ", new ETextStyle[]{ ETextStyle.SUBSCRIPT }, null );
    printable.append("\n");
    try
    {
      printer.print(printable);
    }
    catch(RuntimeException re)
    {
      System.out.println("Exception: " + re.getMessage());
    }
   
    printable.clear();
    printable.append(Calendar.getInstance().getTime().toString() + ": ");
    printable.append(" DARK_GRAY ", null, EColor.DARK_GRAY );
    printable.append(" GRAY ", null, EColor.GRAY );
    printable.append(" LIGHT_GRAY ", null, EColor.LIGHT_GRAY );
    printable.append(" WHITE ", null, EColor.WHITE );
    printable.append(" MAGENTA ", null, EColor.MAGENTA );
    printable.append(" RED ", null, EColor.RED );
    printable.append(" PINK ", null, EColor.PINK );
    printable.append(" ORANGE ", null, EColor.ORANGE );
    printable.append(" YELLOW ", null, EColor.YELLOW );
    printable.append(" GREEN ", null, EColor.GREEN );
    printable.append(" CYAN ", null, EColor.CYAN );
    printable.append(" BLUE ", null, EColor.BLUE );
    printable.append("\n");
    try
    {
      printer.print(printable);
    }
    catch(RuntimeException re)
    {
      System.out.println("Exception: " + re.getMessage());
    }
   
  }

}
TOP

Related Classes of tst.print.TestLinePrinter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.