<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Andrew E. Bruno &#187; Java</title>
	<atom:link href="http://left.subtree.org/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://left.subtree.org</link>
	<description>A sourceful of secrets</description>
	<lastBuildDate>Tue, 07 Feb 2012 12:25:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='left.subtree.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e14c799c6e8030a8abefcb495c0b0e17?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Andrew E. Bruno &#187; Java</title>
		<link>http://left.subtree.org</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://left.subtree.org/osd.xml" title="Andrew E. Bruno" />
	<atom:link rel='hub' href='http://left.subtree.org/?pushpress=hub'/>
		<item>
		<title>passtab &#8211; store passwords in your wallet</title>
		<link>http://left.subtree.org/2011/07/01/passtab-store-passwords-in-your-wallet/</link>
		<comments>http://left.subtree.org/2011/07/01/passtab-store-passwords-in-your-wallet/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 04:15:21 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[passtab]]></category>
		<category><![CDATA[passwords]]></category>

		<guid isPermaLink="false">http://left.subtree.org/?p=334</guid>
		<description><![CDATA[Here&#8217;s a quote from Bruce Schneier that essentially sums up the motivation for this post: We&#8217;re all good at securing small pieces of paper. I recommend that people write their passwords down on a small piece of paper, and keep it with their other valuable small pieces of paper: in their wallet. I recently read [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=334&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quote from <a href="http://www.schneier.com/blog/archives/2005/06/write_down_your.html">Bruce Schneier</a> that essentially sums up the motivation for this post:</p>
<blockquote><p>
We&#8217;re all good at securing small pieces of paper. I recommend that people write<br />
their passwords down on a small piece of paper, and keep it with their other<br />
valuable small pieces of paper: in their wallet.
</p></blockquote>
<p>I recently read an excellent <a href="http://blog.jgc.org/2010/12/write-your-passwords-down.html">blog post</a> by John Graham-Cumming in which he presents a elegant system for writing down your passwords using a <a href="http://en.wikipedia.org/wiki/Tabula_recta">Tabula Recta</a>. I was inspired by this concept so I created a tool called <a href="https://github.com/aebruno/passtab">passtab</a> which aims to provide a light-weight system for managing passwords based on his idea. This post is about the general usage of passtab and presents some of the password management capabilities. This is not your grandmothers password manager so if you&#8217;re looking for a nice GUI point and click application that&#8217;s easy to use you can stop reading right here. This is for hardcore folks who enjoy looking up their passwords in archaic <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Tabula_recta">tablets</a> invented by ancient cryptographers with last names like <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Johannes_Trithemius">Trithemius</a>. For the impatient, you can grab a copy of the latest version on <a href="https://github.com/aebruno/passtab/archives/master">github</a>.  </p>
<p><strong>Introducing passtab</strong></p>
<p><a href="https://github.com/aebruno/passtab">passtab</a> is a light-weight system for managing passwords using a Tabula Recta. passtab has two main features: 1. generating random Tabula Recta&#8217;s in PDF format for printing and storing in your wallet 2. fetching passwords from the Tabula Recta (password managment). These features are independent and you can use passtab to only generate PDFs or optionally make use of the password management features. One unique benefit is the ability to have both an electronic and paper copy of your passwords. You can download the binary release of passtab at github <a href="https://github.com/aebruno/passtab/archives/master">here</a>. Unpack the distribution and run <code>./bin/passtab --help</code> for a list of options. If the startup shell script doesn&#8217;t work you can run <code>java -jar lib/passtab-uber.jar --help</code>. The following sections illustrate some use cases of passtab.</p>
<p><strong>Generate a random Tabula Recta in PDF</strong></p>
<p>passtab can generate random Tabula Recta&#8217;s in PDF format. </p>
<p><pre class="brush: plain;">
$ ./bin/passtab --format pdf --output passtab.pdf
Jun 12, 2011 11:16:29 AM org.qnot.passtab.PassTab generate
INFO: Generating a random Tabula Recta (might take a while)...
$ ls *.pdf
passtab.pdf
</pre></p>
<p>Here&#8217;s an <a href='http://qnot.files.wordpress.com/2011/06/passtab.pdf'>example PDF</a> generated from passtab. You can now print this PDF out and store in your wallet!</p>
<p><strong>How to use the Tabula Recta</strong></p>
<p>Here&#8217;s a simple example (taken directly from the <a href="https://github.com/aebruno/passtab/blob/master/README">README</a>), suppose we have the following Tabula Recta:</p>
<pre>

    | A B C D E F G H I J K L M N
  --|----------------------------
  A | _ u } I ` } R ) a &lt; L : a A
  B | - o ( : p # O % . _ ; ' j L
  C | w c ( c y 2 h y ~ N O * &gt; w
  D | o : R m L % V , d H r Y B j
  E | 9 , &lt; 0 J p a o ) O w 0 w #
  F | C j i } i z 2 $ O R 5 @ T I
  G | Q - E m 8 N c / + u W Y V &gt;
  H | , y } U Y i j i q w q c - 4
  I | K j W H e ; I ? E 7 H v 2 +
  J | g * 7 4 E } a h Y z &lt; " : w
  K | . _ } I / J k 1 a D ^ ; p K
  L | ` &lt; A L c z } } I P ? 4 y T
  M | F D &lt; 8 &lt; 0 R B t 9 X o B 2
  N | I r O E m o a + Y W w ; : 7
</pre>
<p></p>
<p>And suppose we want to get our password for logging into webmail at acme.com. We decide to use the first and last letter of the domain name as the start row/column of the password and we want a password 8 characters in length. So we start at the intersection of &#8216;A&#8217; and &#8216;E&#8217; and read off 8 characters diagonally resulting in the password: <code>'#h,)RWc</code></p>
<p>Defining a scheme for selecting the starting row/column for a given password is completely up to the user and can be as simple or as complex as one desires. The direction for reading the password is also up to the user to define (left, right, diagonally, etc.). See John Graham-Cumming&#8217;s excellent <a href="http://blog.jgc.org/2010/12/write-your-passwords-down.html">blog post</a> for more examples. </p>
<p>This method is slightly more complex than just writing down your passwords on a sheet of paper but the added complexity offers some advantages:</p>
<ol>
<li>Can store <i>all</i> your passwords on a single sheet of paper</li>
<li>If someone steals this sheet of paper they&#8217;ll have a harder time figuring out what your passwords are</li>
<li>Allows you to use strong random passwords</li>
<li>If you want to change your passwords just re-generate a new Tabula Recta. Your scheme for selecting passwords can stay the same</li>
</ol>
<p>passtab makes no assumptions about how passwords are read nor does it know anything about your scheme (unless you configure it). Now that you don&#8217;t have to remember long random passwords anymore what <i>do</i> you need to remember when using a Tabula Recta? Well first, you need to come up with a method for finding the starting position for a given password. In the example above this can be as simple as using characters from a domain/host name. But the beauty is you can be as creative as you want. A scheme that works for most of your passwords would probably be ideal but you can certainly generate multiple Tabula Recta&#8217;s if you like. Once you have a way of coming up with a starting location you need to define a method for reading off the password. In passtab this is called a <code>sequence</code>. In the example above we simply read 8 characters diagonally. But again you can be creative here. You could read 8 characters diagonally skipping every 3rd character, etc. Lastly, you&#8217;ll need to remember what to do if you hit the edge of the Tabula Recta before the end of the password. For example, if you start at Z:Z and want to read 8 characters diagonally you can&#8217;t because you reached the end of the Tabula Recta. In passtab this is called a <code>collision</code>. In this case we could just continue reading following the edge.</p>
<p>Using the Tabula Recta allows you to make use of long secure random passwords and only have to remember three simple things. You also have <i>all</i> your passwords on a single sheet of paper that fits in your wallet.</p>
<p><strong>Custom Alphabets</strong></p>
<p>In passtab, a Tabula Recta consists of two alphabets. The header alphabet and the data alphabet. The header alphabet is used for the row and column heading of the Tabula Recta and forms the basis for finding the starting location of the passwords. The data alphabet is used to generate the contents of the Tabula Recta and passtab will randomly pick characters from this alphabet using a cryptographically secure random number generator. By default, passtab uses a header alphabet of <code>0-9A-Z</code> and a data alphabet consisting of all printable ASCII characters. It&#8217;s important to keep in mind that the data alphabet directly effects the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Password_strength#Entropy_as_a_measure_of_password_strength">entropy</a> of your passwords. passtab allows you to customize these alphabets allowing you to generate any kind of Tabula Recta, for example:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -b A,B,C,D -a 'a,b,c,d,1,2,3,4,!,@,#'
Jun 12, 2011 10:24:26 PM org.qnot.passtab.PassTab generate
INFO: Generating a random Tabula Recta (might take a while)...
  A B C D 
A d 1 @ 4 
B c 4 @ 2 
C b 3 3 ! 
D 1 a @ 4 
</pre></p>
<p>Here&#8217;s a Tabula Recta using greek symbols as the header alphabet (here&#8217;s the <a href='http://qnot.files.wordpress.com/2011/06/passtab-greek.pdf'>example PDF</a>):</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -b 'Σ,Τ,Π,ρ,ϋ,ψ' -a 'a,b,c,d,1,2,3,4,!,@,#'
Jun 12, 2011 11:26:00 PM org.qnot.passtab.PassTab generate
INFO: Generating a random Tabula Recta (might take a while)...
  Σ Τ Π ρ ϋ ψ 
Σ 1 2 1 d d c 
Τ 1 2 b b @ c 
Π 1 # c 3 2 @ 
ρ 4 2 d 2 @ 3 
ϋ 2 3 b 1 ! b 
ψ d @ # c ! a
</pre></p>
<p><b>Password Management</b></p>
<p>So this is all well and great, but in reality it can be a huge pain to have to look up your webmail password in a Tabula Recta that&#8217;s on a sheet of paper in your wallet <i>every time you login</i>. For this reason, passtab has some optional features to help read passwords from the Tabula Recta. This allows you to have both a hard copy of the Tabula Recta in your wallet and an electronic version stored on your hard drive for quick access to your passwords. This obviously comes with some security considerations and care must be taken to protect the passtab database as you would any ssh private key for example. If someone got a hold of the passtab database file they could brute force your Tabula Recta. I ended up creating an encrypted thumb drive and store my passtab configuration and database files on it. You could also use gpg to encrypt it or any other method to protect it from the bad guys. This next section discusses the password management features of passtab.</p>
<p>First some definitions:</p>
<ul>
<li><strong>Direction</strong>: a <code>direction</code> to move on the Tabula Recta. Valid values are <code>N,S,E,W,NE,NW,SE,SW</code></li>
<li><strong>Sequence Item</strong>: a <code>sequence item</code> consists of a <code>length</code> and <code>direction</code>. For example, <code>12:SE</code> would mean move 12 characters in the SE direction (diagonally)</li>
<li><strong>Sequence</strong>: a <code>sequence</code> is a list of <code>sequence items</code>. This allows you to define arbitrary sequences for reading passwords. For example, <code>4:SE,3:N,1:S</code> would mean read 4 characters SE (diagonally) followed by 3 characters N (up) followed by 1 character S (down)</li>
<li><strong>Collision</strong>: a <code>collision</code> defines what directions to move if we hit the edge of the Tabula Recta before the end of the password. You can define more than one direction and they will be tried in order. For example, N,NE,E,SE,S,SW,W,NW would mean if we hit a wall try those directions in order until we&#8217;re able to move again</li>
</ul>
<p><strong>Generate a Tabula Recta in PDF and save to a passtab database</strong></p>
<p>passtab can generate a Tabula Recta in PDF along with storing it in a passtab database. The passtab database is stored in <a href="http://json.org/">JSON</a> format and can be easily accessed outside of passtab (any language that can read JSON files). Again, you&#8217;ll want to store that JSON file someplace safe. For example:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab --dbsave --name mypasstab
Jun 12, 2011 10:48:33 PM org.qnot.passtab.PassTab generate
INFO: Generating a random Tabula Recta (might take a while)...
$ ls mypasstab.*
mypasstab.json  mypasstab.pdf
</pre></p>
<p><strong>Reading passwords from the passtab database</strong></p>
<p>Once we&#8217;ve created our passtab database we can now fetch passwords by telling passtab the starting location and the sequence to read. For example, suppose we want to read a password starting at row &#8216;B&#8217; and column &#8216;N&#8217; and we want a password 10 characters in length reading diagonally:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -i mypasstab.json --getpass B:N --sequence 9:SE
o6,ZzH{e$@
</pre></p>
<p>Copy the password to the clipboard using xclip:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -i mypasstab.json --getpass B:N --sequence 9:SE --chomp | xclip
</pre></p>
<p>We used <code>9:SE</code> as our sequence because passtab includes the character at the start location in the password. If we didn&#8217;t want to include this character we can optionally skip it like so:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -i mypasstab.json --getpass B:N --sequence 10:SE --skipstart
6,ZzH{e$@_
</pre></p>
<p>Define a list of directions to try in the event of a collision. This will try the directions N,S,E,W in order until we can move again. Here we start at Z:Z and can&#8217;t move SE (diagonally) so we try N (up) which works so we move N (up) until we hit another collision:</p>
<p><pre class="brush: plain;">
$ ./bin/passtab -i mypasstab.json --getpass Z:Z --sequence 9:SE --collision N,S,E,W
a((vy&amp;0bV&amp;
</pre></p>
<p><strong>Conclusion</strong></p>
<p>This post introduced a new tool called passtab for managing passwords using a Tabula Recta. I&#8217;m sure it has plenty of bugs so use at your own risk and if by chance you find it somewhat useful I&#8217;d be very interested in any feedback.   </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=334&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2011/07/01/passtab-store-passwords-in-your-wallet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating executable jars with Maven</title>
		<link>http://left.subtree.org/2008/01/24/creating-executable-jars-with-maven/</link>
		<comments>http://left.subtree.org/2008/01/24/creating-executable-jars-with-maven/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 04:53:16 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2008/01/24/creating-executable-jars-with-maven/</guid>
		<description><![CDATA[After wrestling with Maven assemblies for while I finally figured out how to build executable jars. The Maven assembly plugin allows you to define ways to package up your project for distribution by creating various assembly descriptor files. Here&#8217;s a quick example of a Maven assembly for building an executable jar (uberjar). For this example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=18&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After wrestling with <a href="http://maven.apache.org/plugins/maven-assembly-plugin/">Maven assemblies</a> for while I finally figured out how to build executable jars. The Maven assembly plugin allows you to define ways to package up your project for distribution by creating various assembly descriptor files. Here&#8217;s a quick example of a Maven assembly for building an executable jar (uberjar). For this example we&#8217;ll create a brand new project from scratch but it should be easy to see how to integrate into an existing project.</p>
<p>First step lets create a test project:</p>
<p><pre class="brush: plain;">
$ mvn archetype:create -DgroupId=org.qnot.example -DartifactId=hello-world
$ cd hello-world
</pre></p>
<p>Next add a few dependencies to the project. In this example we&#8217;ll add a few libraries from jakarta commons. The &lt;dependencies/&gt; section in the pom.xml should now look like this:</p>
<p><pre class="brush: xml;">
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;commons-cli&lt;/groupId&gt;
      &lt;artifactId&gt;commons-cli&lt;/artifactId&gt;
      &lt;version&gt;1.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;commons-lang&lt;/groupId&gt;
      &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
      &lt;version&gt;2.3&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
</pre></p>
<p>Create a META-INF/ directory to store the MANIFEST.MF file which defines the main class in the executable jar.</p>
<p><pre class="brush: plain;">
$ mkdir -p src/main/resources/META-INF/
$ echo 'Main-Class: org.qnot.example.App' &gt; MANIFEST.MF 
</pre></p>
<p>Create a src/assemble directory to store the assembly descriptor files</p>
<p><pre class="brush: plain;">
$ mkdir src/assemble
</pre></p>
<p>Next we&#8217;ll create the actual assembly descriptor file which defines how to package up the jar. Create the file src/assemble/exe.xml with the following xml:</p>
<p><pre class="brush: xml;">
&lt;assembly&gt;
  &lt;id&gt;exe&lt;/id&gt;
  &lt;formats&gt;
    &lt;format&gt;jar&lt;/format&gt;
  &lt;/formats&gt;
  &lt;includeBaseDirectory&gt;false&lt;/includeBaseDirectory&gt;
  &lt;dependencySets&gt;
    &lt;dependencySet&gt;
      &lt;outputDirectory&gt;&lt;/outputDirectory&gt;
      &lt;outputFileNameMapping&gt;&lt;/outputFileNameMapping&gt;
      &lt;unpack&gt;true&lt;/unpack&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;includes&gt;
        &lt;include&gt;commons-lang:commons-lang&lt;/include&gt;
        &lt;include&gt;commons-cli:commons-cli&lt;/include&gt;
      &lt;/includes&gt;
    &lt;/dependencySet&gt;
  &lt;/dependencySets&gt;
  &lt;fileSets&gt;
    &lt;fileSet&gt;
      &lt;directory&gt;target/classes&lt;/directory&gt;
      &lt;outputDirectory&gt;&lt;/outputDirectory&gt;
    &lt;/fileSet&gt;
  &lt;/fileSets&gt;
&lt;/assembly&gt;
</pre></p>
<p>Inside the <code>&lt;dependecySets/&gt;</code> is where you can add all the libraries you&#8217;d like to include in the uberjar. These must also be defined in your pom.</p>
<p>Finally, add the maven-assembly-plugin to the pom:<br />
<pre class="brush: xml;">
  &lt;build&gt;
    &lt;finalName&gt;hello-world&lt;/finalName&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;descriptors&gt;
            &lt;descriptor&gt;src/assemble/exe.xml&lt;/descriptor&gt;
          &lt;/descriptors&gt;
          &lt;archive&gt;
            &lt;manifestFile&gt;src/main/resources/META-INF/MANIFEST.MF&lt;/manifestFile&gt;
          &lt;/archive&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
</pre></p>
<p>To run the assembly and build the executable jar:</p>
<p><pre class="brush: plain;">
$ mvn assembly:assembly
$ java -jar target/hello-world-exe.jar
Hello World! 
</pre></p>
<p>I tested the hello-world example using the latest Maven release (2.0.8) and maven-assembly-plugin-2.2-beta-1. If you run into any issues try and update your Maven plugins by running:</p>
<p><pre class="brush: plain;">
$ mvn -U compile
</pre></p>
<p>You can download the example hello-world project <a href="http://www.qnot.org/code/hello-world.tar.gz">here</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=18&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2008/01/24/creating-executable-jars-with-maven/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
		<item>
		<title>Rotate Labels JFreeChart</title>
		<link>http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/</link>
		<comments>http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 03:06:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/</guid>
		<description><![CDATA[When creating a chart that has rather long labels for the x-axis it is sometimes desirable to rotate them a bit so they fit on the plot. The method to use is setCategoryLabelPositions(..) on the CategoryAxis class. Here&#8217;s a quick example: And the code..<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=17&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When creating a chart that has rather long labels for the x-axis it is sometimes desirable to rotate them a bit so they fit on the plot. The method to use is <code>setCategoryLabelPositions(..)</code> on the <code>CategoryAxis</code> class. Here&#8217;s a quick example:</p>
<p><img src="http://qnot.files.wordpress.com/2007/08/rotate_labels.png?w=700" alt="" title="rotate_labels"   class="aligncenter size-full wp-image-172" /></p>
<p>And the code..</p>
<p><pre class="brush: java; highlight: [38];">
import java.io.File;
import java.io.IOException;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.ChartColor;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.data.category.DefaultCategoryDataset;

public class RotateLabels {
    public static void main(String[] args) {
        DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
        dataSet.addValue(51, &quot;series&quot;, &quot;Colonel Forbin&quot;);
        dataSet.addValue(92, &quot;series&quot;, &quot;The Lizards&quot;);
        dataSet.addValue(33, &quot;series&quot;, &quot;Wilson&quot;);
        dataSet.addValue(77, &quot;series&quot;, &quot;Rutherford the Brave&quot;);
        dataSet.addValue(37, &quot;series&quot;, &quot;The Unit Monster&quot;);
        dataSet.addValue(97, &quot;series&quot;, &quot;The Famous Mockingbird&quot;);
        dataSet.addValue(67, &quot;series&quot;, &quot;Poster Nutbag&quot;);

        JFreeChart chart = ChartFactory.createBarChart(
            &quot;Gamehendge&quot;,
            null,
            null,
            dataSet,
            PlotOrientation.VERTICAL,
            false,
            false,
            false
        );

        CategoryPlot plot = (CategoryPlot)chart.getPlot();
        CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
        xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

        chart.setBackgroundPaint(ChartColor.WHITE);
        try {
            ChartUtilities.saveChartAsPNG(new File(&quot;chart.png&quot;), chart, 400, 300);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=17&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>

		<media:content url="http://qnot.files.wordpress.com/2007/08/rotate_labels.png" medium="image">
			<media:title type="html">rotate_labels</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL bigint types and iBATIS</title>
		<link>http://left.subtree.org/2007/07/16/mysql-bigint-types-and-ibatis/</link>
		<comments>http://left.subtree.org/2007/07/16/mysql-bigint-types-and-ibatis/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 21:22:37 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/07/16/mysql-bigint-types-and-ibatis/</guid>
		<description><![CDATA[One nuance I recently ran into while using iBATIS was inserting data into MySQL bigint unsigned columns. iBATIS doesn&#8217;t seem to have a way to handle BigInteger data types and throws an exception when attempting to do an insert. Fetching data out seemed to work OK because if iBATIS doesn&#8217;t know how to handle a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=15&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One nuance I recently ran into while using <a href="http://ibatis.apache.org/">iBATIS</a> was inserting data into <a href="http://www.mysql.com/">MySQL</a> bigint unsigned columns. iBATIS doesn&#8217;t seem to have a way to handle BigInteger data types and throws an exception when attempting to do an insert. Fetching data out seemed to work OK because if iBATIS doesn&#8217;t know how to handle a certain type it just returns a java.lang.Object. The way to go about inserting BigInteger types is to set up a type handler. Here&#8217;s an example type handler for BigInteger types:</p>
<p><pre class="brush: java;">
package org.qnot.util;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.sql.Types;

import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;

public class BigIntegerTypeHandler implements TypeHandlerCallback {

    public Object getResult(ResultGetter getter) throws SQLException {
        if(getter.wasNull()) {
            return null;
        }

        Object o = getter.getObject();
        if(o instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal)o;
            return bd.toBigInteger();
        } else if(o instanceof BigInteger) {
            return (BigInteger)o;
        } else {
            return o;
        }
    }

    public void setParameter(ParameterSetter setter, Object parameter)
            throws SQLException {
        if (parameter == null) {
            setter.setNull(Types.BIGINT);
        } else {
            BigInteger i = (BigInteger) parameter;
            setter.setBigDecimal(new BigDecimal(i));
        }
    }

    public Object valueOf(String s) {
        return s;
    }
}
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=15&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/07/16/mysql-bigint-types-and-ibatis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting MIF to XML &#8211; Java Version</title>
		<link>http://left.subtree.org/2007/01/31/converting-mif-to-xml-java-version/</link>
		<comments>http://left.subtree.org/2007/01/31/converting-mif-to-xml-java-version/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 03:57:01 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/01/31/converting-mif-to-xml-java-version/</guid>
		<description><![CDATA[In my previous post I discussed a tool called mif2xml for converting MIF files to an intermediate XML dialect. In this post I&#8217;ll talk about the Java port of mif2xml called mif2xml-j which you can download here including just the executable jar. JFlex is a lexical analyzer generator for Java and is the library I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=7&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://left.subtree.org/2007/01/25/converting-mif-to-xml/">previous post</a> I discussed a tool called <code>mif2xml</code> for converting MIF files to an intermediate XML dialect. In this post I&#8217;ll talk about the Java port of <code>mif2xml</code> called <code>mif2xml-j</code> which you can download <a href="https://github.com/aebruno/mif2xml-j">here</a> including just the <a href="#">executable jar</a>.</p>
<p><a href="http://www.jflex.de/">JFlex</a> is a lexical analyzer generator for Java and is the library I chose to use for creating the MIF lexer. The first step was to get JFlex integrated into my build environment. For this project I decided to use <a href="http://ant.apache.org/">ant</a> but integrating JFlex into another build environment <span id="more-7"></span>should be straightforward. I created the following directory structure:</p>
<p><pre class="brush: plain; light: true;">
--/
  |-- src/main/jflex/               - JFlex lexical specifications
  |-- src/main/resources/MANIFEST   - Defines main class for executable jar
  |-- src/main/java/                - Java source
  |-- lib/                          - 3rd party libraries (JFlex.jar)
  |-- build.xml                     - Ant build file
</pre></p>
<p>JFlex comes bundled with a <code>JFlexAntTask</code> which provides a very convenient <code>&lt;jflex/&gt;</code> task. Here&#8217;s a snippet of the ant build file I created which shows how to set it up:<br />
<pre class="brush: xml;">
&lt;property name=&quot;src&quot;   location=&quot;${basedir}/src/main/java&quot; /&gt;
&lt;property name=&quot;lib&quot; location=&quot;${basedir}/lib&quot; /&gt;
&lt;property name=&quot;scanner-file&quot; value=&quot;${basedir}/src/main/jflex/mif.jflex&quot; /&gt;

&lt;path id=&quot;classpath&quot;&gt;
    &lt;pathelement location=&quot;${build}&quot; /&gt;
    &lt;fileset dir=&quot;${lib}&quot;&gt;
        &lt;include name=&quot;*.jar&quot; /&gt;
    &lt;/fileset&gt;
&lt;/path&gt;

&lt;taskdef classpathref=&quot;classpath&quot; classname=&quot;JFlex.anttask.JFlexTask&quot; name=&quot;jflex&quot; /&gt;

&lt;target name=&quot;jflex&quot; description=&quot;Generate the MIF lexer&quot;&gt;
    &lt;echo message=&quot;Generating the MIF Lexer&quot; /&gt;
    &lt;jflex file=&quot;${scanner-file}&quot; destdir=&quot;${src}&quot; /&gt;
&lt;/target&gt;
</pre></p>
<p>I found writing the lexical specification in JFlex and flex to be very similar. JFlex has a great <a href="http://www.jflex.de/manual.html">user manual</a> which contains a lot of useful info. Here&#8217;s the <code>mif.jflex</code> file:</p>
<p><pre class="brush: cpp;">
/*
 * Copyright 2007 Andrew Bruno &lt;aeb@qnot.org&gt;
 * Licensed under the Apache License, Version 2.0
 */

package org.qnot.mif2xml;
import java.util.Stack;

%%

%{
  private Stack&lt;Tag&gt; tags = new Stack&lt;Tag&gt;();
  private StringBuffer data = new StringBuffer();
  private StringBuffer facet = new StringBuffer();
%}

%line
%char
%standalone
%class  MifLexer
%xstate DATA
%xstate STR
%xstate FACET

ID=[A-Za-z][A-Za-z0-9]*
TAG=&quot;&lt;&quot;{ID}&quot; &quot;
TAG_END=&quot;&gt;&quot;
NONNEWLINE=[^\r|\n|\r\n]
NEWLINE=[\r|\n|\r\n]
WHITE_SPACE_CHAR=[ \n\t]

%%

&lt;YYINITIAL&gt; { 
   {TAG}   {
        Tag tag = new Tag();
        tag.setName(yytext().substring(1, yytext().length()-1));
        tags.push(tag);
        tag.writeStart();
        data = new StringBuffer();
        yybegin(DATA);
    }

    {TAG_END}   {
        if(!tags.empty()) {
            Tag tag = (Tag)tags.pop();
            tag.writeEnd();
        }
    }

    ^&quot;=&quot;[a-zA-Z][a-zA-Z0-9]*{NEWLINE} {
        facet = new StringBuffer();
        facet.append(yytext());
        yybegin(FACET);
    }

    {WHITE_SPACE_CHAR}+   {  /* eat up whitespace */ }
    {NONNEWLINE}          {  /* eat up everything else  */ }
}

&lt;DATA&gt; {
    {NEWLINE}  {
        if(!tags.empty()) {
            Tag tag = (Tag)tags.pop();
            tag.setValue(data.toString());
            tags.push(tag);
        }
        yybegin(YYINITIAL);
    }
    &quot;`&quot;  {  yybegin(STR); }
    {TAG_END}  {
        if(!tags.empty()) {
            Tag tag = (Tag)tags.pop();
            String value = tag.getValue();

            String dataStr = data.toString();
            if(dataStr != null &amp;&amp; dataStr.length() &gt; 0) {
                value = dataStr;
            }

            if(value != null) {
                value = value.replaceAll(&quot;^\\s+&quot;, &quot;&quot;);
                value = value.replaceAll(&quot;\\s+$&quot;, &quot;&quot;);
            }

            tag.setValue(value);
            tag.writeEnd();
        }
        yybegin(YYINITIAL);
    }
    [^\n|\r|\r\n|`|&gt;] {
        data.append(yytext());
    }
}

&lt;STR&gt; {
    &quot;'&quot;  {
        if(!tags.empty()) {
            Tag tag = (Tag)tags.pop();
            if(tag.getValue() == null || tag.getValue().length() == 0) {
                tag.setValue(&quot;`'&quot;);
            }
            tags.push(tag);
        }
        yybegin(YYINITIAL);
    }
    [^']*  {
        if(!tags.empty()) {
            Tag tag = (Tag)tags.pop();
            StringBuffer buf = new StringBuffer();
            buf.append(&quot;`&quot;);
            buf.append(yytext());
            buf.append(&quot;'&quot;);
            tag.setValue(buf.toString());
            tags.push(tag);
        }
    }
}

&lt;FACET&gt; {
    ^&quot;=EndInset&quot;{NEWLINE} {
        facet.append(yytext());
        Tag.writeFacet(facet.toString());
        yybegin(YYINITIAL);
    }

    .*{NEWLINE} {
        facet.append(yytext());
    }
}
</pre></p>
<p>I created a simple <code>Tag</code> class to encapsulate a MIF XML tag and handle writing out each tag. The <code>MifLexer</code> keeps a stack of <code>Tag</code> instances while it&#8217;s processing the input file:</p>
<p><pre class="brush: java;">
/*
 * Copyright 2007 Andrew Bruno &lt;aeb@qnot.org&gt;
 * Licensed under the Apache License, Version 2.0
 */

package org.qnot.mif2xml;

public class Tag {
    private String name;
    private String value;

    public String getName() {
        return this.name;
    }

    public String getValue() {
        return this.value;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void writeEnd() {
        if(value != null &amp;&amp; value.length() &gt; 0) {
            System.out.print(escape(value) + &quot;&lt;/&quot; + name + &quot;&gt;&quot;);
        } else {
            System.out.print(&quot;&lt;/&quot; + name + &quot;&gt;&quot;);
        }
    }

    public void writeStart() {
        System.out.print(&quot;&lt;&quot; + name + &quot;&gt;&quot; );
    }

    public static void writeFacet(String facet) {
        System.out.print(&quot;&lt;_facet&gt;&lt;![CDATA[&quot;);
        System.out.print(facet);
        System.out.print(&quot;]]&gt;&lt;/_facet&gt;&quot;);
    }

    private String escape(String str) {
        str = str.replaceAll(&quot;&amp;&quot;, &quot;&amp;amp;&quot;);
        str = str.replaceAll(&quot;\&quot;&quot;, &quot;&amp;quot;&quot;);
        str = str.replaceAll(&quot;&gt;&quot;, &quot;&amp;gt;&quot;);
        str = str.replaceAll(&quot;&lt;&quot;, &quot;&amp;lt;&quot;);
        str = str.replaceAll(&quot;^\\s+&quot;, &quot;&quot;);
        str = str.replaceAll(&quot;\\s+$&quot;, &quot;&quot;);

        return str;
    }
}
</pre></p>
<p>There&#8217;s a separate <code>Main</code> class which creates a new instance of the <code>MifLexer</code> class for processing the file passed in on the command line. I&#8217;d like to eventually extend this class so that it handles command line options and possibly even runs some XSLT&#8217;s over the generated MIF XML.</p>
<p><pre class="brush: java;">
/*
 * Copyright 2007 Andrew Bruno &lt;aeb@qnot.org&gt;
 * Licensed under the Apache License, Version 2.0
 */

package org.qnot.mif2xml;

import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class Main {
    public static void main(String[] args) {
        if(args.length != 1) {
            System.err.println(&quot;Usage : mif2xml &lt;inputfile&gt;&quot;);
            System.exit(1);
        }

        try {
            MifLexer scanner = new MifLexer(new FileReader(args[0]));
            System.out.print(&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;&lt;mif&gt;&quot;);
            scanner.yylex();
            System.out.print(&quot;&lt;/mif&gt;&quot;);
        } catch(FileNotFoundException e) {
            System.out.println(&quot;File not found : &quot;+args[0]);
        } catch(IOException e) {
            System.out.println(&quot;I/O error scanning file '&quot;+args[0]+&quot;': &quot;+e.getMessage());
        } catch(Exception e) {
            System.out.println(&quot;Unexpected exception: &quot; + e.getMessage());
            e.printStackTrace();
        }
    }
}
</pre></p>
<p>To run the code download the <a href="#">executable jar</a> and run<br />
<pre class="brush: plain; light: true;">
$ java -jar mif2xml-0.1.jar myfile.mif
</pre></p>
<p>The MIF XML will be printed to stdout.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=7&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/01/31/converting-mif-to-xml-java-version/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Sparklines with JFreeChart</title>
		<link>http://left.subtree.org/2007/01/15/creating-sparklines-with-jfreechart/</link>
		<comments>http://left.subtree.org/2007/01/15/creating-sparklines-with-jfreechart/#comments</comments>
		<pubDate>Mon, 15 Jan 2007 08:05:01 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/01/14/creating-sparklines-with-jfreechart/</guid>
		<description><![CDATA[Sparklines are very small charts usually displayed along side some text and help quickly compare time series data. They are usually rendered without any axis, labels, or tick marks and appear as just a simple line. Sparklines were developed by Edward Tufte and further explained here. JFreeChart does not have any built in classes for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=4&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Sparkline">Sparklines</a> are very small charts usually displayed along side some text and help quickly compare time series data. They are usually rendered without any axis, labels, or tick marks and appear as just a simple line. Sparklines were developed by <a href="http://www.edwardtufte.com/">Edward Tufte</a> and further explained <a href="http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&amp;topic_id=1">here</a>.</p>
<p><a href="http://www.jfree.org/jfreechart/">JFreeChart</a> does not have any built in classes for creating sparklines but are easily created by adjusting a few settings in the basic charting classes. Here&#8217;s a few quick examples of some sparklines generated using JFreeChart:</p>
<table style="border:none;">
<tr>
<td style="border:none;"><span style="font-size:medium;">Foo 90</span></td>
<td style="border:none;"><img src="http://qnot.files.wordpress.com/2007/01/sparkline.png?w=700" alt="" title="sparkline"   class="alignnone size-full wp-image-195" /></td>
</tr>
<tr>
<td style="border:none;"><span style="font-size:medium;">Bar 34</span></td>
<td style="border:none;"><img src="http://qnot.files.wordpress.com/2007/01/sparkline1.png?w=700" alt="" title="sparkline1"   class="alignnone size-full wp-image-196" /></td>
</tr>
<tr>
<td style="border:none;"><span style="font-size:medium;">Baz 54</span></td>
<td style="border:none;"><img src="http://qnot.files.wordpress.com/2007/01/sparkline2.png?w=700" alt="" title="sparkline2"   class="alignnone size-full wp-image-197" /></td>
</tr>
</table>
<p>To create sparklines using JFreeChart you just need to turn off the display of labels, tickmarks, lines, etc. on the domain/range axis as well as the XYPlot.</p>
<p>Here&#8217;s a complete example:</p>
<p><pre class="brush: java; highlight: [43,44,45,46,47,48,51,52,53,54,55,56,62,63,64,65]; wrap-lines: false;">
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickUnit;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.RectangleInsets;

public class Sparkline {
    public static void main(String[] args) {
        TimeSeriesCollection dataSet = new TimeSeriesCollection();
        Day day = new Day();
        TimeSeries data = new TimeSeries(&quot;Sparkline&quot;, day.getClass());

        // XXX add real data here
        Random r = new Random();
        Calendar c = Calendar.getInstance();
        for(int i = 0; i &lt; 100; i++) {
            int val = r.nextInt(100);
            if(val &lt; 50)
                val += 50;
            c.add(Calendar.DATE, 7);
            Date date = c.getTime();
            data.add(new Day(date), val);
        }

        dataSet.addSeries(data);

        // The sparkline is created by setting a bunch of the visible properties
        // on the domain, range axis and the XYPlot to false
        DateAxis x = new DateAxis();
        x.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1));
        x.setTickLabelsVisible(false);
        x.setTickMarksVisible(false);
        x.setAxisLineVisible(false);
        x.setNegativeArrowVisible(false);
        x.setPositiveArrowVisible(false);
        x.setVisible(false);

        NumberAxis y = new NumberAxis();
        y.setTickLabelsVisible(false);
        y.setTickMarksVisible(false);
        y.setAxisLineVisible(false);
        y.setNegativeArrowVisible(false);
        y.setPositiveArrowVisible(false);
        y.setVisible(false);

        XYPlot plot = new XYPlot();
        plot.setInsets(new RectangleInsets(-1, -1, 0, 0));
        plot.setDataset(dataSet);
        plot.setDomainAxis(x);
        plot.setDomainGridlinesVisible(false);
        plot.setDomainCrosshairVisible(false);
        plot.setRangeGridlinesVisible(false);
        plot.setRangeCrosshairVisible(false);
        plot.setRangeAxis(y);
        plot.setRenderer(new StandardXYItemRenderer(
                StandardXYItemRenderer.LINES));

        JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
                plot, false);
        chart.setBorderVisible(false);

        try {
            ChartUtilities.saveChartAsPNG(new File(&quot;sparkline.png&quot;), chart,
                    100, 30);
        } catch(IOException e) {
            System.err.println(&quot;Failed to render chart as png: &quot;
                    + e.getMessage());
            e.printStackTrace();
        }
    }
}
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=4&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/01/15/creating-sparklines-with-jfreechart/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>

		<media:content url="http://qnot.files.wordpress.com/2007/01/sparkline.png" medium="image">
			<media:title type="html">sparkline</media:title>
		</media:content>

		<media:content url="http://qnot.files.wordpress.com/2007/01/sparkline1.png" medium="image">
			<media:title type="html">sparkline1</media:title>
		</media:content>

		<media:content url="http://qnot.files.wordpress.com/2007/01/sparkline2.png" medium="image">
			<media:title type="html">sparkline2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
