/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER OR
* CONTRIBUTORS 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.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* A simple bar chart demo
* @author Sami Shaio
* @modified 06/21/00 Daniel Peek : refactored, comments
*/
@SuppressWarnings("serial")
private int orientation;
private int columns;
private int values[];
private int styles[];
public void init() {
getSettings();
for (int i = 0; i < columns; i++) {
parseValue(i);
parseLabel(i);
parseStyle(i);
parseColor(i);
}
}
private void getSettings() {
title = "Chart";
}
columns = 5;
} else {
}
scale = 10;
} else {
}
} else {
}
}
private void parseValue(int i) {
try {
} catch (NumberFormatException e) {
values[i] = 0;
} catch (NullPointerException e) {
values[i] = 0;
}
}
private void parseLabel(int i) {
labels[i] = "";
} else {
}
}
private void parseStyle(int i) {
} else {
}
}
private void parseColor(int i) {
} else {
}
} else {
}
}
// draw the title centered at the bottom of the bar graph
// draw the bars and their titles
if (orientation == HORIZONTAL) {
paintHorizontal(g);
} else { // VERTICAL
paintVertical(g);
}
}
for (int i = 0; i < columns; i++) {
// set the X coordinate for this bar and label and center it
// set the Y coordinate for this bar and label
// draw the label
// draw the shadow
// draw the bar
}
} else { // SOLID
}
// draw the value at the end of the bar
}
}
int barWidth = maxLabelWidth;
for (int i = 0; i < columns; i++) {
// X coordinate for this label and bar (centered)
// Y coordinate for this label and bar
// draw the label
// draw the shadow
// draw the bar
}
} else {
}
// draw the value on top of the bar
}
}
return "Title: Bar Chart \n"
+ "Author: Sami Shaio \n"
+ "A simple bar chart demo.";
}
{ "title", "string", "The title of bar graph. Default is 'Chart'" },
{ "scale", "int", "The scale of the bar graph. Default is 10." },
{ "orientation", "{VERTICAL, HORIZONTAL}",
"The orienation of the bar graph. Default is VERTICAL." },
{ "c#", "int", "Subsitute a number for #. "
{ "c#_label", "string", "The label for bar #. "
+ "Default is an empty label." },
{ "c#_style", "{SOLID, STRIPED}", "The style of bar #. "
+ "Default is SOLID." },
{ "c#_color", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, "
+ "WHITE, YELLOW, GRAY, DARKGRAY}",
"The color of bar #. Default is GRAY." }
};
return info;
}
}