// 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:   PaintedLetters.java

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

public class PaintedLetters extends ScrambleSettings
    implements MouseListener
{

    void setPlayer(int i)
    {
        player = i;
    }

    PaintedLetters(Scramble scramble)
    {
        lhBackTopN = 4;
        lhLeftSideN = 7;
        lhBaseN = 4;
        lhFrontTopN = 4;
        lhFrontBottomN = 4;
        border = 2;
        hand = ' ';
        god = scramble;
        addMouseListener(this);
        setVisible(false);
    }

    void setLetter(char c, int i)
    {
        letters[player][i] = c;
        int j = getSize().width;
        int k = getSize().height;
        if(getGraphics() != null)
        {
            Graphics g = getGraphics();
            g.setClip((j / 15) * i + 20, k / 3 - 4, j / 15, k / 3 - 4);
            update(g);
        }
    }

    void removeTileAt(int i)
    {
        setLetter(' ', i);
    }

    void pickUp(char c)
    {
        hand = c;
        int i = getSize().width;
        int j = getSize().height;
        if(getGraphics() != null)
        {
            Graphics g = getGraphics();
            g.setClip((i / 15) * 14, j / 3 - 1, i / 15, j / 3 + 1);
            update(g);
        }
    }

    void putDown()
    {
        pickUp(' ');
    }

    public void paint(Graphics g)
    {
        g.translate(5, 20);
        int i = getSize().width;
        int j = getSize().height;
        FontMetrics fontmetrics = g.getFontMetrics();
        g.setColor(ScrambleSettings.letterHolderColor);
        g.fillPolygon(lhBaseX, lhBaseY, lhBaseN);
        g.setColor(ScrambleSettings.letterHolderColor.brighter());
        g.fillPolygon(lhLeftSideX, lhLeftSideY, lhLeftSideN);
        g.setColor(ScrambleSettings.letterHolderColor.brighter().brighter());
        g.fillPolygon(lhBackTopX, lhBackTopY, lhBackTopN);
        g.setColor(ScrambleSettings.letterHolderColor.darker());
        g.fillPolygon(lhFrontBottomX, lhFrontBottomY, lhFrontBottomN);
        g.translate(-5, -20);
        g.translate(20, -4);
        for(int k = 0; k < 7; k++)
        {
            String s = String.valueOf(letters[player][k]);
            if(!s.equals(" "))
            {
                g.setColor(ScrambleSettings.tileColor);
                g.fill3DRect(border + 1 + (i / 15) * k, border + 1 + j / 3, i / 15 - border - 2, j / 3 - border - 2, true);
                g.setColor(Color.black);
                g.drawString(s, (i / 15) * k + (i / 15 - fontmetrics.stringWidth(s)) / 2 + 1, j / 3 + (j / 3 - fontmetrics.getHeight()) / 2 + fontmetrics.getAscent() + 1);
            }
        }

        g.translate(-20, 0);
        String s1 = String.valueOf(hand);
        if(!s1.equals(" "))
        {
            g.setColor(ScrambleSettings.tileColor);
            g.fill3DRect(border + 1 + (i / 15) * 14, border + 1 + j / 3, i / 15 - border - 2, j / 3 - border - 2, true);
            g.setColor(Color.black);
            g.drawString(s1, (i / 15) * 14 + (i / 15 - fontmetrics.stringWidth(s1)) / 2 + 1, j / 3 + (j / 3 - fontmetrics.getHeight()) / 2 + fontmetrics.getAscent() + 1);
        }
        g.translate(0, 4);
        g.translate(5, 20);
        g.setColor(ScrambleSettings.letterHolderColor.brighter().brighter());
        g.fillPolygon(lhFrontTopX, lhFrontTopY, lhFrontTopN);
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
        int i = (mouseevent.getX() - 20) / 26;
        int j = (mouseevent.getY() + 4) / 26;
        if(i >= 0 && i <= 7 && j == 1)
            god.gotSomething(new Point(15, i));
        if(i == 14 && j == 1)
            god.gotSomething(new Point(15, 7));
    }

    public void mouseClicked(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
    }

    public void mouseExited(MouseEvent mouseevent)
    {
    }

    public void mousePressed(MouseEvent mouseevent)
    {
    }

    char letters[][] = {
        {
            ' ', ' ', ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' '
        }, {
            ' ', ' ', ' ', ' ', ' ', ' ', ' '
        }
    };
    int lhBackTopX[] = {
        2, 202, 208, 8
    };
    int lhBackTopY[] = {
        6, 6, 8, 8
    };
    int lhBackTopN;
    int lhLeftSideX[] = {
        2, 4, 12, 18, 14, 10, 8
    };
    int lhLeftSideY[] = {
        6, 30, 34, 28, 24, 26, 8
    };
    int lhLeftSideN;
    int lhBaseX[] = {
        8, 208, 210, 10
    };
    int lhBaseY[] = {
        8, 8, 26, 26
    };
    int lhBaseN;
    int lhFrontTopX[] = {
        14, 214, 218, 18
    };
    int lhFrontTopY[] = {
        24, 24, 28, 28
    };
    int lhFrontTopN;
    int lhFrontBottomX[] = {
        18, 218, 212, 12
    };
    int lhFrontBottomY[] = {
        28, 28, 34, 34
    };
    int lhFrontBottomN;
    int border;
    char hand;
    Scramble god;
    int player;
}
