X-Git-Url: http://git.megacz.com/?p=eltron.git;a=blobdiff_plain;f=src%2Fcom%2Fmegacz%2Feltron%2FMailingLabel.java;fp=src%2Fcom%2Fmegacz%2Feltron%2FMailingLabel.java;h=641abd7c1cef54d36d8c0e10f3b8d70dfdab24d6;hp=0000000000000000000000000000000000000000;hb=61e6074f12446ccf9f6b5a41996e3c8b8f8e2f3a;hpb=0178b34d5fde3c1cfbc18ae48ec1798b28a1af21 diff --git a/src/com/megacz/eltron/MailingLabel.java b/src/com/megacz/eltron/MailingLabel.java new file mode 100644 index 0000000..641abd7 --- /dev/null +++ b/src/com/megacz/eltron/MailingLabel.java @@ -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