Esempio n. 1
0
 public static void main(String[] args) throws Exception {
   String cmd = args[0].intern();
   if (cmd == "render") {
     PosixArgs opt = PosixArgs.getopt(args, 1, "aw:f:s:");
     boolean aa = false;
     String font = "SansSerif";
     int width = 100, size = 10;
     for (char c : opt.parsed()) {
       if (c == 'a') {
         aa = true;
       } else if (c == 'f') {
         font = opt.arg;
       } else if (c == 'w') {
         width = Integer.parseInt(opt.arg);
       } else if (c == 's') {
         size = Integer.parseInt(opt.arg);
       }
     }
     Foundry f = new Foundry(font, size);
     f.aa = aa;
     Text t = f.renderwrap(opt.rest[0], width);
     java.io.OutputStream out = new java.io.FileOutputStream(opt.rest[1]);
     javax.imageio.ImageIO.write(t.img, "PNG", out);
     out.close();
   }
 }
Esempio n. 2
0
 public static void cmdline(String[] args) {
   PosixArgs opt = PosixArgs.getopt(args, "hdPU:r:A:u:C:m:");
   if (opt == null) {
     usage(System.err);
     System.exit(1);
   }
   for (char c : opt.parsed()) {
     switch (c) {
       case 'h':
         usage(System.out);
         System.exit(0);
         break;
       case 'd':
         dbtext = true;
         break;
       case 'P':
         profile = true;
         break;
       case 'r':
         resdir = opt.arg;
         break;
       case 'A':
         int p = opt.rest[0].indexOf(':');
         if (p >= 0) {
           authserv = opt.arg.substring(0, p);
           authport = Integer.parseInt(opt.arg.substring(p + 1));
         } else {
           authserv = opt.arg;
         }
         break;
       case 'U':
         try {
           resurl = new URL(opt.arg);
         } catch (java.net.MalformedURLException e) {
           System.err.println(e);
           System.exit(1);
         }
         break;
       case 'u':
         authuser = opt.arg;
         break;
       case 'C':
         authck = Utils.hex2byte(opt.arg);
         break;
       case 'm':
         authmech = opt.arg;
     }
   }
   if (opt.rest.length > 0) {
     int p = opt.rest[0].indexOf(':');
     if (p >= 0) {
       defserv = opt.rest[0].substring(0, p);
       mainport = Integer.parseInt(opt.rest[0].substring(p + 1));
     } else {
       defserv = opt.rest[0];
     }
   }
 }