1 7 package org.ejtools.graph.renderer; 8 9 import java.awt.BorderLayout ; 10 import java.awt.LayoutManager ; 11 import java.util.Iterator ; 12 import java.util.Vector ; 13 14 import javax.swing.JComponent ; 15 import javax.swing.JPanel ; 16 17 import org.ejtools.graph.DefaultGraphElement; 18 import org.ejtools.graph.GraphElement; 19 import org.ejtools.graph.GraphRenderer; 20 21 26 public class JPanelGraphRenderer extends JPanel implements GraphRenderer 27 { 28 29 protected GraphElement element = null; 30 31 protected Vector renderers = new Vector (); 32 33 34 39 public JPanelGraphRenderer(LayoutManager layout) 40 { 41 super(layout); 42 this.element = new DefaultGraphElement(); 43 } 44 45 46 47 public JPanelGraphRenderer() 48 { 49 this(new BorderLayout ()); 50 } 51 52 53 58 public void addRenderer(GraphRenderer renderer) 59 { 60 renderer.setGraphElement(this.element); 61 this.renderers.add(renderer); 62 this.add((JComponent ) renderer); 63 } 64 65 66 69 public void setGraphElement(GraphElement element) 70 { 71 this.element = element; 72 for (Iterator it = this.renderers.iterator(); it.hasNext(); ) 73 { 74 ((GraphRenderer) it.next()).setGraphElement(this.element); 75 } 76 } 77 78 79 82 public void setHorizontalScale(double multiplier) 83 { 84 for (Iterator it = this.renderers.iterator(); it.hasNext(); ) 85 { 86 ((GraphRenderer) it.next()).setHorizontalScale(multiplier); 87 } 88 } 89 90 91 94 public void setHorizontalScaling(int type) 95 { 96 for (Iterator it = this.renderers.iterator(); it.hasNext(); ) 97 { 98 ((GraphRenderer) it.next()).setHorizontalScaling(type); 99 } 100 } 101 102 103 106 public void setVerticalScale(double multiplier) 107 { 108 for (Iterator it = this.renderers.iterator(); it.hasNext(); ) 109 { 110 ((GraphRenderer) it.next()).setVerticalScale(multiplier); 111 } 112 } 113 114 115 118 public void setVerticalScaling(int type) 119 { 120 for (Iterator it = this.renderers.iterator(); it.hasNext(); ) 121 { 122 ((GraphRenderer) it.next()).setVerticalScaling(type); 123 } 124 } 125 } 126 | Popular Tags |