// Carnegie Mellon University
//   Information Networking Institute and
//   School of Computer Science
//
// Master Thesis: A Monitoring Tool for Overlay Network
// By: TungFai Chan and Annie Cheng
//
// File: NodeGraphPanel.java
// Path: userInterfaces/
// Description: Panel extends from JPanel adapts for graph drawing


package userInterfaces;

import userInterfaces.componentManagers.*;

import java.awt.*;
import javax.swing.*;

public class NodeGraphPanel extends JPanel {

    final static public int NEIGHBOR_TYPE = 0;
    final static public int ROUTING_TYPE = 1;

    GraphManager graphManager = null;
    int graphType;

    public NodeGraphPanel(int type) {
        super();
        super.setVisible(true);
        graphType = type;
    }

    public void attach(GraphManager gPainter) {
        if (graphManager == null)
            graphManager = gPainter;
    }

    public void detach() {
        graphManager = null;
    }

    public void paint(Graphics g) {

        if (graphManager != null) {
            g.clearRect(0, 0, this.getWidth(), this.getHeight());
            graphManager.drawGraph(g, graphType);
        }


    }

}