1 25 package org.jrobin.demo.graph; 26 27 import javax.swing.*; 28 import java.awt.*; 29 30 import org.jrobin.graph.RrdGraph; 31 32 37 public class SwingDemoPanel extends JPanel 38 { 39 private RrdGraph graph; 40 private int width, height; 41 42 SwingDemoPanel( RrdGraph graph ) 43 { 44 this.graph = graph; 45 } 46 47 public void paintComponent( Graphics g ) 48 { 49 try 50 { 51 graph.specifyImageSize(true); 54 graph.renderImage( (Graphics2D) g, width, height ); 55 56 } 57 catch ( Exception e ) { 58 e.printStackTrace(); 59 } 60 } 61 62 void setGraphDimension(Dimension d) { 63 width = d.width; 64 height = d.height; 65 repaint(); 66 } 67 } 68 | Popular Tags |