/*
* NCSA Data To Knowledge (D2K) Project
* Automated Learning Group
* National Center for Supercomputing Applications
* University of Illinois at Urbana-Champaign
* 605 E. Springfield, Champaign, IL 61820
*
* d2k@ncsa.uiuc.edu
*
* Copyright 2003, Board of Trustees of the University of Illinois,
* All Rights Reserved
*
* NCSA Data To Knowledge (D2K) software, source code, binary code, and Java-byte
* code including D2K modules and D2K itineraries (hereafter, Software) is
* copyrighted by the Board of Trustees of the University of Illinois (UI),
* and ownership remains with the UI.
*
* Prior to receiving this Software Source Code, You must have agreed to a
* non-exclusive, non-transferable, restricted License of Software with UI for
* limited Research Use and/or Internal Business Use. The terms of that License
* control the use of this Software Source Code. For the sake of convenience,
* certain provisions of that License are stated here. However, in the event
* of any real or perceived differences between the terms of the License and the
* statements made herein, the License controls.
*
* You may not distribute the Software including the Binary Code and this Source
* Code to third parties.
*
* You may make Derivative Works. You are encouraged to provide information to
* UI regarding Derivative Works and your experience with Software. However, if
* You make any Derivative Work based on or derived from the Software, then You
* will: (1) clearly notify users that such Derivative Work is a modified version
* and uses or is derived from the original NCSA Data To Knowledge (D2K)
* developed at UI, and include specific language in that notice as provided for
* in the License, and (2) acknowledge via citation and provide UI with a copy of
* any report or publication using the Software or Derivative Work.
*
* If You wish to make Commercial Use of the Software or Derivative Works, then
* You should contact the UI, c/o NCSA, to negotiate an appropriate license for
* such Commercial Use. Commercial Use includes sale, lease, license,
* distribution or otherwise making the Software or Derivative Works available to
* third parties, which includes, but is not limited to, integration of all or
* part of the Software or Derivative Work into a product for sale or license by
* or on behalf of You to third parties.
*
* UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
* PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE UI
* SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USERS OF THIS SOFTWARE.
*
* By using or copying this Software, You agree to abide by the copyright law
* and all other applicable laws of the U.S. including, but not limited to,
* export control laws, and the terms of the License. UI shall have the right
* to terminate its license with You immediately upon Your breach of, or
* non-compliance with, any of its terms. You may be held legally responsible
* for any copyright infringement that is caused or encouraged by Your failure
* to abide by the terms of the License.
*/
package ncsa.d2k.modules.core.vis.widgets;
import javax.swing.JPanel;
import java.awt.*;
import ncsa.d2k.modules.core.datatype.table.*;
import ncsa.d2k.modules.core.datatype.table.basic.*;
/**
A Chart is similar to a Graph, but it does not plot
data points. Aggregate values are shown, such as in
a BarChart or PieChart.
*/
public abstract class Chart extends JPanel {
// Legend
double legendleftoffset, legendtopoffset;
double legendwidth, legendheight;
// Offset from left
double leftoffset;
// Offset from right
double rightoffset;
// Offset from top
double topoffset;
// Offset from bottom
double bottomoffset;
// Empty space
int smallspace = 5;
int largespace = 10;
double samplecolorsize = 8;
// the data
DataSet set;
GraphSettings settings;
Table table;
int bins;
// dimensions of the chart
double graphwidth, graphheight;
int gridsize;
// labels to show
String title, xlabel, ylabel;
// Font
Font font;
FontMetrics metrics;
int fontheight, fontascent;
// color generation
/*Color[] colors = {
new Color(253, 204, 138), new Color(148, 212, 161),
new Color(153, 185, 216), new Color(189, 163, 177),
new Color(213, 213, 157), new Color(193, 70, 72),
new Color( 29, 136, 161), new Color(187, 116, 130),
new Color(200, 143, 93), new Color(127, 162, 133)
};*/
Color[] colors = {new Color(71, 74, 98), new Color(191, 191, 115),
new Color(111, 142, 116), new Color(178, 198, 181),
new Color(153, 185, 216), new Color(96, 93, 71),
new Color(146, 205, 163), new Color(203, 84, 84),
new Color(217, 183, 170), new Color(140, 54, 57),
new Color(203, 136, 76)
};
abstract public void initOffsets();
abstract public void resize();
public Chart(Table t, DataSet d, GraphSettings g) {
table = t;
set = d;
settings = g;
bins = table.getNumRows();
}
/**
Get a color.
*/
public Color getColor(int i) {
return colors[i % colors.length];
}
}