KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > awt > CategoryGraph2D


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

11 public abstract class CategoryGraph2D extends DoubleBufferedCanvas implements GraphDataListener {
12         /**
13         * Data model.
14         */

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

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

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

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

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

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

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

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