The javagraphics project is a collection of small stand-alone projects from a shared codebase written by Jeremy Wood. Most (but not all) of these subprojects are discussed in articles at javagraphics.blogspot.com.
Feel free to email me with feedback or suggestions for future projects.
The original incentive for this collection of projects had to do with my day job: there were several components/ideas I wanted to explore, but not enough hours in the workday. Like all companies: we were under time constraints, and my bosses couldn't afford to give me R&D time just because I had a hunch. But they didn't mind if I chipped away at these ideas on nights and weekends and made the results open source. Some of these hunches paid off, and large portions of this codebase ended up integrated into our products at work. (In fact the company president mentioned one project -- movie encoding -- ended up being one of the most crucial internal enhancements between major releases; it improved efficiency, stability, and let us add audio ducking.) As this codebase grew I also added projects of personal interest, and projects related to contract work. (You'll receive a discounted bid if you let me write an article about a project!)
Along the way I also abandoned a few projects, but I couldn't bring myself to completely delete some of them. Here is a scrapped list of projects. (Maybe someone on the internet will find these unfinished/deprecated projects helpful someday?)
Everything in the
com.bric codebase is released here under a Modified BSD license. If
you require another license: feel free to ask. Note a few projects may involve code from another party:
in that case separate licensing may apply (double-check inside the jar you download to be sure). The
licensing information is embedded in each jar distributed here.
Each topic is available as a stand-alone download with the source code included. My target audience is a developer who wants a specific widget, but does not want to download a 10 MB library of the entire codebase.
This is a very short article with a little hands-on demo of how the different
This doesn't necessarily teach anything or present new ideas; it's just a quick guide to consult if you need it.
Comes in Aqua and non-Aqua flavors.
Sure the buttons in Apple's Tech Note 2196 are great, but they're so... black-box-ish. And they're only available on Macs.
This article sets up a new framework for
This is a Photoshop-style color choosing dialog.
You can pull some parts of it apart for customization, but out-of-the-box it offers a great interface if you're dealing with a power user.
Of course: all dialogs are at least slightly evil, and they should be used with care...
This is an isolated GUI component from this article.
This app shows the progression of several different concepts for ColorPalettes. (Hopefully each one is an improvement over the previous...)
I'm not going to argue that this will meet your needs and save the world; but it includes a lot of useful tools and it might help (save the world).
As far as I can tell: there's not a good (efficient) way to crossfade two translucent images in Java2D.
(Crossfading opaque images? That's easy. But not translucent ones.)
This article focuses on discussion and not a downloadable end result.
In lots of Apple's software there's a handy menu option called "Customize Toolbar" that lets users drag and drop components in a toolbar. It's functional and great eye candy.
This article presents a similar mechanism for Java. A single thumbnail doesn't do justice to this feature, but if you go to the article you'll see a screencast.
What can you do when your event dispatch thread is blocked?
For starters: this article mentions how to automatically detect this situation and get great console output to help pinpoint the problem. Also this delves into a very murky partial solution. (It has worked multiple times for me, but it uses unsafe deprecated black magic.)
This article explores the problem of color banding in linear gradients and presents a partial solution.
This class uses a
This was mostly an experiment I put together for this article. As of this writing I'd only recommend using this if you can't use the MultipleGradientPaint in Java 1.6 or its earlier incarnations in the batik project.
This is functional, though. And if you're stuck in an earlier Java version: it's a very small class to add if you need it.
This is a GUI component to arrange the distribution of colors for multicolor gradients. It is similar to a
(By default it also leans heavily on some existing color GUI widgets I wrote, but you can replace those with your own components if you want to.)
This is a handy little gradient that resembles halftone print.
I came across this idea by accident while working on the
It turns out some
This is becoming less of a problem now that Quartz is being phased out, but even without Quartz we can still make some improvements...
This has been a real life-saver when I'm trying to debug our graphics-rich desktop apps at work.
Whenever something isn't rendering right this lets you see the stack trace of each graphic instruction.
This simple app lets you browse the JVM's
Have you ever forgotten how to access a generic warning icon? Which system properties access what? The difference between
This explores how to render
This shows how to access
This provides an efficient mechanism for creating BMP thumbnails, and a crude BMP decoder/encoder.
This is a crash course in a pure-Java implementation of color reduction for images (aka "image quantization"). This provides a median cut color reduction algorithm and a few different levels of error diffusion to help reduce images from millions of colors to a few hundred.
(This is a prerequisite for writing a gif encoder.)
There used to be a way to completely ruin your graphics performance.
This problem can still occur on Mac if you're use the Quartz rendering engine, but more and more that is being phased out so this is less of a problem than it used to be.
Most JPEG files have embedded thumbnails. This features a light parser that fetches these thumbnails -- including some thumbnails
This improves the image quality and memory allocation when scaling large
Need to scale megapixel JPEGs on-the-fly without loading them entirely into memory? This might just do the trick.
I never did trust MediaTracker. (Why does it require a
Here I wrote my own class that converts abstract
We needed to display modal dialogs in full-screen mode. On Mac this proved to be in impossible using normal JDialogs, so we had to come up with an alternative solution.
This introduces a new component for showing asynchronous indeterminate feedback.
They're vector-based, so while they're originally designed to be less than 20x20 pixels: they scale well if you need them to. The article/demo app also include some fun non-standard alternative UIs (that were fun to design, but I don't necessarily recommend).
I find the
Really: check out the javadocs for this one. There's a lot of research/explanation in there.
If I used an ant script or Eclipse's built-in jar-exporting widget: I'd need to specify up front the classes I want to put into a jar.
This class uses the
This article examines the notion of a well-designed inspector.
It uses this interface to layout the components, and it presents a few implementations of that interface (with varying degrees of success/hackery).
This demonstrates a new ListUI to add decorations to JList cells. The demo emulates Apple's music file icons.
This article presents a
This triggers mouseClicked events even if the mouse moves a few pixels between click and release.
This article presents a class that can write a .mov file as a series of images and PCM audio.
This movie uses a combination of JPG/PNG and WAV encoding, which is very poor compression. But this format is not subject to nasty patent/royalty issues.
A Swing implementation of collapsible bread crumbs.
A Swing implementation of a vertical series of collapsible panels. Panel heights are determined with vertical weights, and as the user toggles the visibility of panels: the UI is animated.
This panel builds on the Transition architecture to let certain refreshes occur with a transition.
This explores a new
The edges are the most important part, and they are achieved with a separate
This examines the cost of constructing arrays and BufferedImages, vs caching and reusing existing arrays.
This is intended to be used for highly repetitive tasks (such as batch image processing or rendering work).
But if you're dealing with graphics: you can probably fudge on some accuracy in exchange for speed. What methods can be improved?
Can we improve on the
If you're only working with a
This emulates two types of preferences on Mac: several rows of preferences (like the System Preferences) or one row of preferences (like Mail, Safari, etc.).
This introduces an object to lay out several graphic objects on a sheet of paper, and a dialog to preview and edit this layout.
(Oh: and it prints.)
The Robot class can capture parts of your screen as an image, but it can be slow to process so many pixels. This article ties into the
Also this jar can export this animation as a MOV file (using JPEG moving encoding). All 100% Java.
This is a UI component that lets the user define shapes. There are currently 3 unique UIs to define shapes (each with its own strengths and weaknesses). There are a couple of different UIs that can be applied to this, and I haven't yet written up a blog article on the subject.
How do you get the bounds of a shape? A
What's the most common shape we need to clip to? A
But if we use
(This does not use Sutherland-Hodgman clipping algorithm or the Weiler-Atherton clipping algorithm.)
This project branches off the
If the user drags the mouse over a
This is one of three ShapeCreationPanelUIs.
An uninteresting but very useful class that deals with measuring shapes.
This is a two-fold article:
This covers some nitty gritty details about
There is nothing to download here. Just read the article if you're interested.
This is a GUI component that mimicks the
What happens when thumbs intersect/overlap? There are 3 enums for that: NUDGE_OTHER, STOP_AGAINST, and JUMP_OVER_OTHER.
A fun set of transitions defined with a simple vector-graphics-ish architecture.
The demo includes a player and minimal Flash export.
A stroke based on splattering lots of tiny shapes along a path.
A stroke based on rendering several smaller strokes in parallel along a path.
A stroke that resembles a nib at a fixed angle.
A stroke with grooves in the edges that resembles charcoal on pavement.
This stroke is actually a filter than can modify any shape, but the only current suitable examples are
Create some fun text effects using block shadows.
This article discusses how to set up a
This visual effect draws text over time similar to how human would. Unlike a simple wipe-left transition (which would work with any font), this requires specially formatted font-like shape data. The current implementation is modeled after the public domain font Comic Neue.
This discusses options for presenting a console-like Swing component.
The class I end up developing is the BasicConsole: a thread-safe JTextArea that highlights multiple PrintStreams in different colors and offers modest support for tab-formatted tables.
This article has 2 goals:
This discusses different GUIs for the user to search for a string in a
This includes the common search dialog, the model Safari uses and the model Firefox uses.
This animation idly skims over a series of text boxes by panning and zooming at interesting angles.
This walks through how to find the preferred height of a block of text, and provides a GUI component to display text with a fixed width.
This discusses/demos a class that combines these two elements.
This presents a simple model to decorate thumbnails.
Each thumbnail is rendered as a series of consecutive layers, including shadows and borders. The thumbnail is created by passing a source image (as a File, URL, or Image) and a maximum dimension size for the formatted thumbnail.
This new TreeUI adds icons on the right side of a tree that can serve as indicators or buttons. This uses a combination of advanced TreeCellRenderers and MouseListeners, so these decorations do not actually exist in the Swing hierarchy.
This article discusses and emulates the "Window" menu found on Macs.
Sometimes you want to be able to click and drag a window, palette, dialog etc.