// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   PaintedScrambleBoard.java

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class PaintedScrambleBoard extends ScrambleSettings
    implements MouseListener
{

    PaintedScrambleBoard(Scramble scramble)
    {
        border = 2;
        god = scramble;
        addMouseListener(this);
        setVisible(true);
    }

    void place(char c, Point point)
    {
        boardChars[point.x][point.y] = c;
        int i = getSize().width;
        int j = getSize().height;
        Graphics g = getGraphics();
        if(g != null)
        {
            g.setClip((i / 15) * point.x, (j / 15) * point.y, i / 15, j / 15);
            update(g);
        }
    }

    public void paint(Graphics g)
    {
        int i = getSize().width;
        int j = getSize().height;
        FontMetrics fontmetrics = g.getFontMetrics();
        g.setColor(ScrambleSettings.boardColor);
        g.fill3DRect(0, 0, i - 1 - border * 2, j - 1, true);
        for(int k = 0; k < 15; k++)
        {
            for(int l = 0; l < 15; l++)
            {
                g.setColor(ScrambleSettings.colorArray[boardLayout[l][k]]);
                g.fill3DRect(border + (i / 15) * l, border + (j / 15) * k, i / 15 - border, j / 15 - border, false);
                if((new Point(l, k)).equals(startSquare))
                {
                    g.setColor(ScrambleSettings.colorArray[5]);
                    g.translate((i / 15) * l + 4, (j / 15) * k + 2);
                    g.fillPolygon(starX, starY, 10);
                    g.translate(-4 - (i / 15) * l, -2 - (j / 15) * k);
                }
                String s = String.valueOf(boardChars[l][k]);
                if(!s.equals(" "))
                {
                    g.setColor(ScrambleSettings.tileColor);
                    g.fill3DRect(border + 1 + (i / 15) * l, border + 1 + (j / 15) * k, i / 15 - border - 2, j / 15 - border - 2, true);
                    g.setColor(Color.black);
                    g.drawString(s, (i / 15) * l + (i / 15 - fontmetrics.stringWidth(s)) / 2 + 1, (j / 15) * k + (j / 15 - fontmetrics.getHeight()) / 2 + fontmetrics.getAscent() + 1);
                }
            }

        }

        setVisible(true);
    }

    public void update(Graphics g)
    {
        int i = getSize().width;
        int j = getSize().height;
        Rectangle rectangle = g.getClipBounds();
        int k = rectangle.x / (i / 15);
        int l = rectangle.y / (j / 15);
        FontMetrics fontmetrics = g.getFontMetrics();
        g.setColor(ScrambleSettings.colorArray[boardLayout[k][l]]);
        g.fill3DRect(border + (i / 15) * k, border + (j / 15) * l, i / 15 - border, j / 15 - border, false);
        if((new Point(k, l)).equals(startSquare))
        {
            g.setColor(ScrambleSettings.colorArray[5]);
            g.translate((i / 15) * k + 4, (j / 15) * l + 2);
            g.fillPolygon(starX, starY, 10);
            g.translate(-4 - (i / 15) * k, -2 - (j / 15) * l);
        }
        String s = String.valueOf(boardChars[k][l]);
        if(!s.equals(" "))
        {
            g.setColor(ScrambleSettings.tileColor);
            g.fill3DRect(border + 1 + (i / 15) * k, border + 1 + (j / 15) * l, i / 15 - border - 2, j / 15 - border - 2, true);
            g.setColor(Color.black);
            g.drawString(s, (i / 15) * k + (i / 15 - fontmetrics.stringWidth(s)) / 2 + 1, (j / 15) * l + (j / 15 - fontmetrics.getHeight()) / 2 + fontmetrics.getAscent() + 1);
        }
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
        int i = mouseevent.getX() / 26;
        int j = mouseevent.getY() / 23;
        if(i >= 0 && i <= 14 && j >= 0 && j <= 14)
            god.gotSomething(new Point(i, j));
    }

    public void mouseClicked(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
    }

    public void mouseExited(MouseEvent mouseevent)
    {
    }

    public void mousePressed(MouseEvent mouseevent)
    {
    }

    Point choice;
    Scramble god;
    int border;
    int starX[] = {
        9, 12, 18, 13, 17, 9, 1, 5, 0, 6
    };
    int starY[] = {
        0, 6, 6, 10, 18, 12, 18, 10, 6, 6
    };
    char boardChars[][] = {
        {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
            ' ', ' ', ' ', ' ', ' '
        }
    };
}
