01: package JSci.swing;
02:
03: import java.awt.*;
04: import JSci.awt.*;
05:
06: /**
07: * The JCategoryGraph2D superclass provides an abstract encapsulation
08: * of 2D category graphs.
09: * @version 1.2
10: * @author Mark Hale
11: */
12: public abstract class JCategoryGraph2D extends JDoubleBufferedComponent
13: implements GraphDataListener {
14: /**
15: * Data model.
16: */
17: protected CategoryGraph2DModel model;
18: /**
19: * Origin.
20: */
21: protected Point origin = new Point();
22: /**
23: * Padding.
24: */
25: protected final int scalePad = 5;
26: protected final int axisPad = 25;
27: protected int leftAxisPad;
28:
29: /**
30: * Constructs a 2D category graph.
31: */
32: public JCategoryGraph2D(CategoryGraph2DModel cgm) {
33: model = cgm;
34: model.addGraphDataListener(this );
35: }
36:
37: /**
38: * Sets the data plotted by this graph to the specified data.
39: */
40: public final void setModel(CategoryGraph2DModel cgm) {
41: model.removeGraphDataListener(this );
42: model = cgm;
43: model.addGraphDataListener(this );
44: dataChanged(new GraphDataEvent(model));
45: }
46:
47: /**
48: * Returns the model used by this graph.
49: */
50: public final CategoryGraph2DModel getModel() {
51: return model;
52: }
53:
54: public abstract void dataChanged(GraphDataEvent e);
55:
56: /**
57: * Returns the preferred size of this component.
58: */
59: public Dimension getPreferredSize() {
60: return getMinimumSize();
61: }
62:
63: /**
64: * Returns the minimum size of this component.
65: */
66: public Dimension getMinimumSize() {
67: return new Dimension(170, 170);
68: }
69: }
|