08.01.07
robobait: Prefuse histograms
I’ve recently been working on showing histograms using the Prefuse framework. I released five files today to help with that:
- BarRenderer.java — renders x,y coordinates as a bar that goes from x,0 to x,y
- HistogramTable.java — a Decorator that takes a Prefuse Table object and creates another Table (as a subclass) that has two columns for every column of the source: one column to define the range of a bin and one that says how many objects are in that range.
- HistogramGraph.java — a JComponent subclass which displays a graph for a bin/count pair of a HistogramTable.
- HistogramFrame.java — a JFrame subclass which lets you switch between all the data columns in a histogram and also lets you reset the bin count on the fly.
- HistogramTableTest.java — JUnit4 tests for HistogramTable.
Known bugs:
- There is a bug somewhere that manifests itself in HistogramGraph. If you select “Species Name” and then “Petal Width”, the first two x-axis labels are species names instead of numbers. I’ve looked at this enough to decide that it is quite possibly a Prefuse bug, and that it was not worth my time to try to fix it.
- I only recognize two types of column, numeric and string. I don’t distinguish between ints, floats, and doubles. Everything else is a string.
- I haven’t tested with boolean columns. I suspect that it will treat them as strings, and so it might just happen to do the right thing.
- I haven’t tested with derived columns. It might accidentally work, but I don’t know.
I encourage people to give me feedback on these. While I’ve done a lot of coding, I am relatively new to Java, so am quite willing to believe that I did something in a suboptimal way.
Administrative note: I’ve made a new category “robobait” for postings whose purpose is primarily to alert search engines to the existence of some other page. These are likely to be less interesting to human beings.
I’m also going to put “robobait” at the beginning of posting titles for robobait postings.