KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > graph > renderer > JPanelGraphRenderer


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.graph.renderer;
8
9 import java.awt.BorderLayout JavaDoc;
10 import java.awt.LayoutManager JavaDoc;
11 import java.util.Iterator JavaDoc;
12 import java.util.Vector JavaDoc;
13
14 import javax.swing.JComponent JavaDoc;
15 import javax.swing.JPanel JavaDoc;
16
17 import org.ejtools.graph.DefaultGraphElement;
18 import org.ejtools.graph.GraphElement;
19 import org.ejtools.graph.GraphRenderer;
20
21 /**
22  * @author Laurent Etiemble
23  * @version $Revision: 1.7 $
24  * @todo Javadoc to complete
25  */

26 public class JPanelGraphRenderer extends JPanel JavaDoc implements GraphRenderer
27 {
28    /** Description of the Field */
29    protected GraphElement element = null;
30    /** Description of the Field */
31    protected Vector JavaDoc renderers = new Vector JavaDoc();
32
33
34    /**
35     * Constructor for JPanelGraph.
36     *
37     * @param layout
38     */

39    public JPanelGraphRenderer(LayoutManager JavaDoc layout)
40    {
41       super(layout);
42       this.element = new DefaultGraphElement();
43    }
44
45
46    /** Constructor for Graph. */
47    public JPanelGraphRenderer()
48    {
49       this(new BorderLayout JavaDoc());
50    }
51
52
53    /**
54     * Sets the renderer attribute of the Graph object
55     *
56     * @param renderer The new renderer value
57     */

58    public void addRenderer(GraphRenderer renderer)
59    {
60       renderer.setGraphElement(this.element);
61       this.renderers.add(renderer);
62       this.add((JComponent JavaDoc) renderer);
63    }
64
65
66    /**
67     * @param element The new graphElement value
68     */

69    public void setGraphElement(GraphElement element)
70    {
71       this.element = element;
72       for (Iterator JavaDoc it = this.renderers.iterator(); it.hasNext(); )
73       {
74          ((GraphRenderer) it.next()).setGraphElement(this.element);
75       }
76    }
77
78
79    /**
80     * @param multiplier The new horizontalScale value
81     */

82    public void setHorizontalScale(double multiplier)
83    {
84       for (Iterator JavaDoc it = this.renderers.iterator(); it.hasNext(); )
85       {
86          ((GraphRenderer) it.next()).setHorizontalScale(multiplier);
87       }
88    }
89
90
91    /**
92     * @param type The new horizontalScaling value
93     */

94    public void setHorizontalScaling(int type)
95    {
96       for (Iterator JavaDoc it = this.renderers.iterator(); it.hasNext(); )
97       {
98          ((GraphRenderer) it.next()).setHorizontalScaling(type);
99       }
100    }
101
102
103    /**
104     * @param multiplier The new verticalScale value
105     */

106    public void setVerticalScale(double multiplier)
107    {
108       for (Iterator JavaDoc it = this.renderers.iterator(); it.hasNext(); )
109       {
110          ((GraphRenderer) it.next()).setVerticalScale(multiplier);
111       }
112    }
113
114
115    /**
116     * @param type The new verticalScaling value
117     */

118    public void setVerticalScaling(int type)
119    {
120       for (Iterator JavaDoc it = this.renderers.iterator(); it.hasNext(); )
121       {
122          ((GraphRenderer) it.next()).setVerticalScaling(type);
123       }
124    }
125 }
126
Popular Tags