/**
 *  Nothing very special about the Grid turtle.  It just draws a grid of 
 *  lines on the display.
 */

import java.awt.*;
import javax.swing.*;
import com.otherwise.jurtle.Turtle;

public class Grid extends Turtle
{


    /**
     *  Main entry point to the code.  Hides the turtle and draws the grid.
     */
    public void runTurtle()
    {
        hideTurtle();

        Dimension size = getDisplaySize();

        for ( int i = 0; i <= size.width; i += 10 )
        {
            moveTo( i, 0 );
            setPosition( i, size.height );
        }
        for ( int i = 0; i < size.height; i += 10 )
        {
            moveTo( 0, i );
            setPosition( size.width, i );
        }
    }


    /**
     *  A helper method that moves the turtle without drawing anything.
     */
    private void moveTo( int x, int y )
    {
        boolean penWasDown = isPenDown();
        penUp();
        setPosition( x, y );
        if ( penWasDown )
            penDown();
    }


}
