import java.awt.Component;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.util.Hashtable;
import java.util.Enumeration;
import java.awt.Color;

/**
*  Special utils are gathered here for the test classes to work.				<br>
 * Copied some of the sampleUtils from oracle								    <br>
 * This is necessary for the info text. This makes the info text more readable. <br>
 * This is used to draw the dialog text in visual search test.				    <br>
 * If you're interested writing dialog using this util see more info at vsearch <br>
 * classe's ghostWriter() funcion.											    <br>
 * @author Toni 															    
  ********************************************************************************/

public class peblUtils {

    private static float defaultFontSize = (float)20.0;
    
    private static final FontRenderContext DEFAULT_FRC = 
                                new FontRenderContext(null, false, false);
                
    /**
     * Return the default FontRenderContext from the graphics environment.
     */
    public static FontRenderContext getDefaultFontRenderContext() {

        // fake right now - figure out where to get real default info
        return DEFAULT_FRC;
    }

    private static final Hashtable map = new Hashtable();
    static {
        map.put(TextAttribute.SIZE, new Float(defaultFontSize));
    }

    private static final String TEXT_ARG = "-text";

    /**
     * Return the index in args of the String argument.  If argument is
     * not found return -1.
     */
    public static int getIndexOfArgument(String[] args, String argument) {

        for (int i=0; i < args.length; i++) {
            
            if (args[i].equals(argument)) {
                return i;
            }
        }

        return -1;
    }

    /**
     * Use the hash table
     */
    public static AttributedCharacterIterator getText(String str) {

        AttributedString string = new AttributedString(str,map);
 
        return string.getIterator();
    }

} 
