Pie Chart Demo, Java 1.0.2

A classic textbook example, PieDialdraws a pie chart of radial sectors, specified by arrays of colors and starting angles.

PieControl extends PieDial, so that it can be reshaped in response to mouse inputs. Drags on a radial separating segments shifts the radial, thus changing the relative sizes of those segments.

This PieDemo appletshows it in use.

Also see PieDemo for Java 1.1 plus, same functionality with the newer event model. You cannot run applets

You cannot drag a sector boundary across another one, but you can use one to "push" others along.
By dragging some segment down to zero size, further drag motion will rotate the entire pie. Backing away while in the same drag then restores the closed segment.

Other responses could be programmed, for example Click to divide a segment in two, when pre-enabled by some other control. We would need a new color for it.

Geometry measures angles in degrees, zero degrees right at "plus X" or "East" and ninety degrees up at "plus Y" or "North" increasing counter-clockwise, with sectors specified in counter-clockwise order, although the first start can be any value. We always use this ZERO_EAST_DEG_CCW system internally, because it is used by the Java AWT.

Navigation and surveying measures angles in degrees, zero degrees "North" and ninety degrees "East" increasing clockwise, with sectors specified in clockwise order, although the first start can be any value. If the caller specifies this ZERO_NORTH_DEG_CW system, we convert their angles to the internal system, and convert back when reporting.

For applications that prefer either radians or percent to degrees, simply multiply all angles by a conversion constant.

PieControlextends PieDial, making it able to resize sectors in response to mouse drags, and report such changes as Action events.

Other Java..

Also see a bar chart.

This software is provided free of charge with no support. Email me at mhirsch@ipdinc.com if you do have a problem, and I will try to help, but I cannot promise to.

My employer, Integrated Performance Decisions is ISO 9001 certified, and has expertise in Java, X/Motif, Windows, Lotus Notes, and the experience that comes from a diverse client base. Can we help you too?

Legalities

Except for all sections which are identified as the work, and copyright, of others, this work is Copyright (C) 1998 by Morris Hirsch. All rights reserved, except as granted here.

Redistribution and use in source and binary forms, with or without modification, for any purpose, are permitted, except as may be restricted by original copyright holders, provided that the following conditions are met:

DISCLAIMER

This software is provided free of charge with no support.
This software is provided in source format; You are advised to examine it and understand it, before putting it to use.
This software uses only algorithms and coding techniques that are available to the public in the open literature. You are however, advised to make your own determination of legality, for your intended use.
This software is provided by the Author and Contributors ``AS IS'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose, are disclaimed.
In no event shall the Author or Contributors, or their Agents, be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Please also visit my home page.

Email me at mhirsch@ipdinc.com