1 7 package org.ejtools.graph.renderer; 8 9 import java.awt.GridBagConstraints ; 10 import java.text.DecimalFormat ; 11 import java.text.SimpleDateFormat ; 12 13 import javax.swing.JComponent ; 14 15 import org.ejtools.graph.Axis; 16 import org.ejtools.graph.GraphElement; 17 import org.ejtools.graph.GraphRenderer; 18 import org.ejtools.graph.LabelElement; 19 20 25 public class TriAxisLayoutRenderer extends GridBagLayoutRenderer 26 { 27 28 public TriAxisLayoutRenderer() 29 { 30 super(); 31 32 GridBagConstraints constraints = new GridBagConstraints (); 33 34 GraphRenderer rd = new GridGraphRenderer(new SimpleDateFormat ("HH:mm:ss"), new DecimalFormat ("0")); 35 constraints.gridx = 1; 36 constraints.gridy = 1; 37 constraints.fill = GridBagConstraints.BOTH; 38 constraints.weightx = 1.0; 39 constraints.weighty = 1.0; 40 this.addRenderer(rd, constraints); 41 42 Axis axis = new HorizontalAxis(new SimpleDateFormat ("HH:mm:ss"), Axis.BOTTOM); 43 constraints.gridx = 1; 44 constraints.gridy = 2; 45 constraints.fill = GridBagConstraints.HORIZONTAL; 46 constraints.weightx = 0.0; 47 constraints.weighty = 0.0; 48 this.addRenderer(axis, constraints); 49 50 axis = new VerticalAxis(new DecimalFormat ("0"), Axis.LEFT); 51 constraints.gridx = 0; 52 constraints.gridy = 1; 53 constraints.fill = GridBagConstraints.VERTICAL; 54 constraints.weightx = 0.0; 55 constraints.weighty = 0.0; 56 this.addRenderer(axis, constraints); 57 58 axis = new VerticalAxis(new DecimalFormat ("0"), Axis.RIGHT); 59 constraints.gridx = 2; 60 constraints.gridy = 1; 61 constraints.fill = GridBagConstraints.VERTICAL; 62 constraints.weightx = 0.0; 63 constraints.weighty = 0.0; 64 this.addRenderer(axis, constraints); 65 } 66 67 68 71 public void setGraphElement(GraphElement element) 72 { 73 super.setGraphElement(element); 74 75 if (element instanceof LabelElement) 76 { 77 JComponent component = ((LabelElement) this.element).getComponent(); 78 79 GridBagConstraints constraints = new GridBagConstraints (); 80 constraints.gridx = 0; 81 constraints.gridy = 0; 82 constraints.gridwidth = 3; 83 constraints.fill = GridBagConstraints.HORIZONTAL; 84 constraints.weightx = 0.0; 85 constraints.weighty = 0.0; 86 this.add(component, constraints); 87 } 88 } 89 } 90 | Popular Tags |