package com.algomagic.atn; import att.grappa.*; import java.util.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; public class Visualization extends JFrame implements VisualizationConstants { private Properties _properties; private VisualizationPanel[] _visPanels; private ControlPanel _controls; private ProgressPanel _progress; private String[] _names = new String[2]; private Collection[] _policies = new Collection[2]; public void setName( String name, int side ) { _names[side] = name; } public void setPolicies( Collection pol, int side ) { _policies[side] = pol; } public void setAutoRaise( boolean state ) { _visPanels[LEFT_SIDE].setAutoRaise( state ); if( _visPanels[RIGHT_SIDE] != null ) { _visPanels[RIGHT_SIDE].setAutoRaise( state ); } } public Visualization( String log1, String log2 ) { addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent we ) { Window w = we.getWindow( ); w.setVisible( false ); w.dispose( ); System.exit( 0 ); } }); loadProperties( ); initializeFrame( log2 != null ); LogParser parser = null; try { parser = (LogParser)Class.forName( _properties.getProperty( PARSER_PROP, PARSER_DEFAULT ) ).newInstance( ); } catch( Exception e ) { e.printStackTrace( ); System.exit( 1 ); } java.util.List updates = parser.parse( this, log1, log2 ); updates = _visPanels[LEFT_SIDE].initialize( updates ); _visPanels[LEFT_SIDE].addCredentials( _policies[LEFT_SIDE], 2 ); _visPanels[LEFT_SIDE].setName( _names[LEFT_SIDE] ); // System.out.println( _policies[LEFT_SIDE] ); // System.out.println( _policies[RIGHT_SIDE] ); if( log2 != null ) { updates = _visPanels[RIGHT_SIDE].initialize( updates ); _visPanels[RIGHT_SIDE].addCredentials( _policies[RIGHT_SIDE], 2 ); _visPanels[RIGHT_SIDE].setName( _names[RIGHT_SIDE] ); } java.util.List l = new ArrayList( ); for( Iterator i = updates.iterator( ); i.hasNext( ); ) { Update u = (Update)i.next( ); PanelUpdate pu = null;; if( u.getSide( ) == LEFT_SIDE ) { pu = _visPanels[LEFT_SIDE].apply( u ); } else if( log2 != null ) { pu = _visPanels[RIGHT_SIDE].apply( u ); } if( !pu.isEmpty( ) ) { l.add( pu ); } } // _visPanels[LEFT_SIDE].reset( updates ); // if( log2 != null ) { // _visPanels[RIGHT_SIDE].reset( updates ); // } PlayBackController pbc = new PlayBackController( l, _properties ); pbc.addObserver( _progress ); pbc.addObserver( _visPanels[LEFT_SIDE] ); _visPanels[LEFT_SIDE].hideGraph( ); if( log2 != null ) { pbc.addObserver( _visPanels[RIGHT_SIDE] ); _visPanels[RIGHT_SIDE].hideGraph( ); } _progress.setMax( l.size( ) ); _controls.addObserver( pbc ); // // Object[] o = getKeyListeners( ); // for( int i = 0; o != null && i []" ); System.exit( 1 ); } } }