updates
[eltron.git] / src / com / megacz / eltron / MailingLabel.java
diff --git a/src/com/megacz/eltron/MailingLabel.java b/src/com/megacz/eltron/MailingLabel.java
new file mode 100644 (file)
index 0000000..641abd7
--- /dev/null
@@ -0,0 +1,45 @@
+package com.megacz.eltron;
+
+import org.ibex.util.*;
+import org.ibex.graphics.*;
+import java.io.*;
+import java.util.*;
+import gnu.io.*;
+import java.awt.image.*;
+import java.awt.*;
+import java.io.*;
+import java.awt.Color;
+import java.awt.Font;
+
+/** stupid little program to print out mailing labels from a text file */
+public class MailingLabel {
+
+    public static void main(String[] args) throws Exception {
+        System.setProperty("java.awt.headless", "true");
+        BufferedImage img = new BufferedImage(1200, 800, BufferedImage.TYPE_INT_RGB);
+        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+        boolean indent = false;
+        Font f = new Font("sansserif", 0, 50);
+        FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f);
+        Graphics g = img.getGraphics();
+        g.setFont(f);
+        g.setColor(Color.white);
+        g.fillRect(0, 0, img.getWidth(null), img.getHeight(null));
+        g.setColor(Color.black);
+
+        int yp = 200;
+        for(String s = br.readLine(); s!=null; s = br.readLine()) {
+            if (s.trim().equals("")) indent = true;
+
+            if (indent) s = "      "+s;
+            g.drawString(s, 100, yp);
+            yp += fm.getHeight();
+        }
+        int[] data = new int[img.getWidth(null) * img.getHeight(null)];
+        for(int x=0; x<img.getWidth(null); x++)
+            for(int y=0; y<img.getHeight(null); y++)
+                data[x+y*img.getWidth(null)] = img.getRGB(x, y);
+        Eltron.print(data, img.getWidth(null), img.getHeight(null));
+    }
+
+}