/*
 * EventType.java
 *
 * Created on April 29, 2005, 2:28 PM
 */

package DDMT.core.misc;

import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.JLabel;
import java.awt.Component;
import javax.swing.JList;
import java.awt.Color;

/**
 *
 * @author  jk3
 * @description This class models one event that has occured in the system, such
 *as a message being passed.
 */
public interface EventType {
    
    /** Compare two events **/
    abstract public int Compare( EventType event );
    
    /** Get the time for the event **/
    abstract public double getTime();
    
    /** Print this event **/
    abstract public String print();
    
    /** Check if this event has to do with a specific node **/
    abstract public boolean involves( int number );
    
    /** Check if this event happened in a specific time period **/
    abstract public boolean happenedDuring( double startTime, double endTime);
    
     /**
     *Cell renderer for the list.  Shows two strings seperated by a two-way arrow.
     */
    public class EventCellRenderer extends JPanel implements ListCellRenderer {
        
        //the center label
        JLabel center;
        
        /**
         *Method to create a new cell renderer
         */
        public EventCellRenderer() 
        {
            setLayout( new java.awt.BorderLayout());
            center = new JLabel();
            center.setOpaque(true);
            center.setBackground(Color.WHITE);
            add(center);
            
        }
      
        /**
         *Method to get one component of the cell renderer
         */
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) 
        {
            center.setText( ((EventType)value).print() );
            
            return this;
        }
    }
}


