KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > swing > JCategoryGraph2D


1 package JSci.swing;
2
3 import java.awt.*;
4 import JSci.awt.*;
5
6 /**
7 * The JCategoryGraph2D superclass provides an abstract encapsulation
8 * of 2D category graphs.
9 * @version 1.2
10 * @author Mark Hale
11 */

12 public abstract class JCategoryGraph2D extends JDoubleBufferedComponent implements GraphDataListener {
13         /**
14         * Data model.
15         */

16         protected CategoryGraph2DModel model;
17         /**
18         * Origin.
19         */

20         protected Point origin=new Point();
21         /**
22         * Padding.
23         */

24         protected final int scalePad=5;
25         protected final int axisPad=25;
26         protected int leftAxisPad;
27         /**
28         * Constructs a 2D category graph.
29         */

30         public JCategoryGraph2D(CategoryGraph2DModel cgm) {
31                 model=cgm;
32                 model.addGraphDataListener(this);
33         }
34         /**
35         * Sets the data plotted by this graph to the specified data.
36         */

37         public final void setModel(CategoryGraph2DModel cgm) {
38                 model.removeGraphDataListener(this);
39                 model=cgm;
40                 model.addGraphDataListener(this);
41                 dataChanged(new GraphDataEvent(model));
42         }
43         /**
44         * Returns the model used by this graph.
45         */

46         public final CategoryGraph2DModel getModel() {
47                 return model;
48         }
49         public abstract void dataChanged(GraphDataEvent e);
50         /**
51         * Returns the preferred size of this component.
52         */

53         public Dimension getPreferredSize() {
54                 return getMinimumSize();
55         }
56         /**
57         * Returns the minimum size of this component.
58         */

59         public Dimension getMinimumSize() {
60                 return new Dimension(170, 170);
61         }
62 }
63
64
Popular Tags