Skip to main content

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?)

Legal

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.

Topics / Projects

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.

AlphaComposites: Which Does What?
October 2009
Jar | Web Start
Demo Graphic

This is a very short article with a little hands-on demo of how the different AlphaComposite types interact.

This doesn't necessarily teach anything or present new ideas; it's just a quick guide to consult if you need it.

Angles: need GUI widget for angles?
May 2008
Jar | Web Start
Demo Graphic

Take a JSlider. Add a AngleSliderUI. Voila! You have a GUI widget for angles.

Comes in Aqua and non-Aqua flavors.

Buttons: New UIs
August 2009
Jar | Web Start
Demo Graphic

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 ButtonUIs, and provides around 10 UI's to choose from. (But you can make more if you want to...) Also each ButtonUI can be turned into a ComboBoxUI.

Colors: a Color Dialog
April 2007
Jar | Web Start
Demo Graphic

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...

Colors: a ColorPalette
January 2010
Jar | Web Start
Demo Graphic

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...)

Colors: a Good GUI for Selecting Colors
January 2010
Jar | Web Start
Demo Graphic

This jar includes all my color-related GUI components: the ColorPicker, the ColorWell, and the ColorPalette.

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).

Crossfades: What Is and Isn't Possible
June 2008
Jar | Web Start

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.

Customize Toolbar: Implementing Mac-Like Toolbars
June 2008
Jar | Web Start

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.

Event Dispatch Thread: Responding to Deadlocks
June 2008
Jar

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.)

Gradients: Avoiding Color Banding
March 2014
Jar | Web Start

This article explores the problem of color banding in linear gradients and presents a partial solution.

Gradients: Using TexturePaint for Gradients
November 2009
Jar | Web Start

This class uses a java.awt.TexturePaint to render a multiple-color linear gradient.

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.

Gradients: a GUI Widget to Design Them
May 2008
Jar | Web Start
Demo Graphic

This is a GUI component to arrange the distribution of colors for multicolor gradients. It is similar to a JSlider, but it supports multiple thumbs and maps each thumb to a Color.

(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.)

Gradients: a Halftone Gradient
November 2009
Jar | Web Start
Demo Graphic

This is a handy little gradient that resembles halftone print.

I came across this idea by accident while working on the TransformedTexturePaint class.

Graphics2D: Improving Performance
February 2009
Jar | Web Start

It turns out some Graphics2D operations are painfully inefficient -- and we can easily intercept and divert those methods!

This is becoming less of a problem now that Quartz is being phased out, but even without Quartz we can still make some improvements...

Graphics2D: Serializable Vector Graphics
December 2008
Jar | Web Start

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.

How to Inspect Runtime Properties
May 2008
Jar
Demo Graphic

This simple app lets you browse the JVM's UIManager's constants, SystemColors, and System.getProperties().

Have you ever forgotten how to access a generic warning icon? Which system properties access what? The difference between SystemColor.text and SystemColor.textText? This lets you preview all these properties.

Images: 3D Transforms and Transitions
April 2014
Jar | Web Start
Demo Graphic

This explores how to render BufferedImages through PerspectiveTransforms, and offers a few new 3D-based transitions.

Images: Accessing NSImages on Mac
June 2008
Jar
Demo Graphic

This shows how to access NSImages on Mac, and enumerates dozens of such images. Some are well documented, but some were identified through a brute-force search.

Images: BMPs and Thumbnails
June 2010
Jar | Web Start

This provides an efficient mechanism for creating BMP thumbnails, and a crude BMP decoder/encoder.

Images: Color Palette Reduction
February 2014
Jar | Web Start
Demo Graphic

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.)

Images: Managed Images
April 2007
Jar

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.

Images: Reading JPEG Thumbnails
March 2010
Jar | Web Start

Most JPEG files have embedded thumbnails. This features a light parser that fetches these thumbnails -- including some thumbnails JAI might miss -- and this new code is a fraction of the install size of JAI.

Images: Scaling Down
June 2010
Jar | Web Start
Demo Graphic

This improves the image quality and memory allocation when scaling large BufferedImages to thumbnails.

Images: Scaling JPEGs and PNGs
May 2011
Jar | Web Start

Need to scale megapixel JPEGs on-the-fly without loading them entirely into memory? This might just do the trick.

Images: Studying MediaTracker
April 2007
Jar

I never did trust MediaTracker. (Why does it require a java.awt.Component to tell if an image is loaded?)

Here I wrote my own class that converts abstract java.awt.Images into BufferedImages.

Implementing [Fake] Modal Dialogs in Full-Screen Mode
April 2011

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.

Implementing a JThrobber
March 2014
Jar | Web Start
Demo Graphic

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).

JOptionPane: Making an Alternative
June 2008
Jar | Web Start
Demo Graphic

I find the JOptionPane hard to work with sometimes. If you want a really polished dialog -- with a help button, the right spacing, the right controls to escape, etc. -- you might just want to make a new model.

Really: check out the javadocs for this one. There's a lot of research/explanation in there.

Jars: Building Concise Jars
January 2009
Jar

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 javac command to figure that out for me.

Layouts: Designing an Inspector
June 2009
Jar | Web Start
Demo Graphic

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).

ListUIs: Adding decorations to cells
June 2012
Jar | Web Start
Demo Graphic

This demonstrates a new ListUI to add decorations to JList cells. The demo emulates Apple's music file icons.

Lists: An Observable List for UIs
July 2012
Jar

This article presents a java.util.List implementation designed with UI interaction in mind. This includes thread safety, efficiency, and listeners.

Mouse Click Events: Adding Wiggle Room
February 2011
Jar | Web Start

This triggers mouseClicked events even if the mouse moves a few pixels between click and release.

Movies: Writing MOV Files Without QuickTime
June 2008
Jar

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.

Navigation: Bread Crumbs
January 2014
Jar | Web Start
Demo Graphic

A Swing implementation of collapsible bread crumbs.

Panels: Collapsible Sections
March 2014
Jar | Web Start

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.

Panels: Refreshes and Transitions
March 2014
Jar | Web Start

This panel builds on the Transition architecture to let certain refreshes occur with a transition.

Panels: an Improved PanelUI
March 2014
Jar | Web Start
Demo Graphic

This explores a new PanelUI to spruce up panels. This achieves a variety of looks, including a textured plastic look (shown to the right), a simple faded drop shadow, a modern recessed subpanel with a light bevel shadow, and a hand-torn edge.

The edges are the most important part, and they are achieved with a separate javax.swing.Border that can be used independently of this UI.

Performance: Constructing Arrays and Images
April 2014
Jar | Web Start

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).

Performance: Studying Math
May 2009
Jar | Web Start

The java.lang.Math class was designed with accuracy in mind.

But if you're dealing with graphics: you can probably fudge on some accuracy in exchange for speed. What methods can be improved?

Performance: Studying the PixelGrabber
April 2007
Jar

Can we improve on the java.awt.PixelGrabber?

If you're only working with a BufferedImage and not an abstract Image: you might be able to really improve performance with the ARGBPixelGrabber.

Preferences: Aqua-Like Preferences
November 2008
Jar | Web Start
Demo Graphic

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.).

Print Dialogs: Laying Out Tiles
November 2008
Jar | Web Start
Demo Graphic

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.)

Screen Capture: Recording Java Apps
June 2008
Jar

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 RepaintManager to only capture the areas of interest.

Also this jar can export this animation as a MOV file (using JPEG moving encoding). All 100% Java.

Shapes: A ComponentUI to Create and Edit Shapes
March 2014
Jar | Web Start

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.

Shapes: Calculating Bounds
May 2007
Jar | Web Start

How do you get the bounds of a shape? A GeneralPath or Path2D may return a larger rectangle than necessary. The Area class is accurate, but painfully slow. This demonstrates the ShapeBounds class, which is accurate and near instant.

Shapes: Clipping to a Rectangle
April 2007
Jar | Web Start
Demo Graphic

What's the most common shape we need to clip to? A Rectangle.

But if we use Areas our performance will tank. This demonstrates a simple model that iterates over a path exactly once to get the clipped shape.

(This does not use Sutherland-Hodgman clipping algorithm or the Weiler-Atherton clipping algorithm.)

Shapes: Creating an Alternative to the Area Class
August 2010
Jar

This project branches off the Area class and optimizes parts of its performance. The underlying algorithms are not changed, but (in some cases) the performance is considerably improved.

Shapes: Implementing a Freehand Pencil Tool
June 2010
Jar

If the user drags the mouse over a JComponent, then you can collect a series of points. This project takes those points and replaces the line segments with attractive bezier curves.

This is one of three ShapeCreationPanelUIs.

Shapes: Measuring Length
February 2009
Jar | Web Start

An uninteresting but very useful class that deals with measuring shapes.

Shapes: Parametric Equations (and Spirals!)
March 2010
Jar | Web Start
Demo Graphic

This is a two-fold article:
1. This presents the ParametricPathIterator to convert parametric equations into java.awt.Shapes.
2. As a proof of concept: this presents the Spiral2D.

Shapes: an Introduction
March 2010

This covers some nitty gritty details about java.awt.Shapes that I refer to (or take for granted) in other shape-related articles.

There is nothing to download here. Just read the article if you're interested.

Sliders: Creating a Slider with Multiple Thumbs
January 2015
Jar | Web Start
Demo Graphic

This is a GUI component that mimicks the javax.swing.JSlider, except it supports an arbitrary number of thumbs. There are currently three UI implementations for this component: one for Apple, one for Windows, and one for Metal.

What happens when thumbs intersect/overlap? There are 3 enums for that: NUDGE_OTHER, STOP_AGAINST, and JUMP_OVER_OTHER.

Slideshows: Transitions & SWFs
April 2007
Jar | Web Start
Demo Graphic

A fun set of transitions defined with a simple vector-graphics-ish architecture.

The demo includes a player and minimal Flash export.

Strokes: a Bristle Stroke
May 2008
Jar | Web Start
Demo Graphic

A stroke based on splattering lots of tiny shapes along a path.

Strokes: a Brush Stroke
April 2007
Jar | Web Start
Demo Graphic

A stroke based on rendering several smaller strokes in parallel along a path.

Strokes: a Calligraphy Stroke
May 2009
Jar | Web Start
Demo Graphic

A stroke that resembles a nib at a fixed angle.

Strokes: a Charcoal Stroke
December 2008
Jar | Web Start
Demo Graphic

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 BasicStrokes and CalligraphyStrokes.

Text: Effects and Block Shadows
February 2011
Jar | Web Start
Demo Graphic

Create some fun text effects using block shadows.

Text: Formatting Source Code in Swing
December 2015
Jar | Web Start
Demo Graphic

This article discusses how to set up a JTextPane to render Java source code with stylized font attributes and line numbers.

Text: Handwriting Text Effect
Nov 2014
Jar

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.

Text: Managing a Console in Swing
March 2015
Jar

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.

Text: Prompts and Search Fields
December 2009
Jar | Web Start
Demo Graphic

This article has 2 goals:
1. Display a gray prompt over a JTextField if it doesn't have the focus.
2. Implement a RoundTextFieldUI (with an optional magnifying glass).

Text: Searching JTextComponents
December 2009
Jar | Web Start
Demo Graphic

This discusses different GUIs for the user to search for a string in a JTextComponent.

This includes the common search dialog, the model Safari uses and the model Firefox uses.

Text: Swivel Animations
Mar 2012
Jar | Web Start

This animation idly skims over a series of text boxes by panning and zooming at interesting angles.

Text: Text Height and GUI Layout
June 2008
Jar

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.

TexturePaints and AffineTransforms
June 2008
Jar | Web Start

This discusses/demos a class that combines these two elements.

Thumbnails: Formatting Thumbnails
August 2012
Jar | Web Start
Demo Graphic

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.

TreeUIs: Adding Decorations to Cells
May 2012
Jar | Web Start
Demo Graphic

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.

Windows: Adding a Window Menu
November 2008
Jar
Demo Graphic

This article discusses and emulates the "Window" menu found on Macs.

Windows: Dragging Made Easy
April 2007
Jar

Sometimes you want to be able to click and drag a window, palette, dialog etc.

 
 
Close
loading
Please Confirm
Close