// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:15
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   APPButtonUI.java

package project;

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import javax.swing.AbstractButton;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicGraphicsUtils;

public class APPButtonUI extends BasicButtonUI
{

    public APPButtonUI()
    {
        buttonPressed = false;
        f1 = new Font("Berdana", 0, 9);
        f2 = new Font("Berdana", 0, 14);
    }

    protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String s)
    {
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        int accChar = b.getDisplayedMnemonicIndex();
        if(!b.isEnabled())
        {
            g.setColor(Color.gray);
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 1, textRect.y + 15);
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 2, textRect.y + 16);
            g.setColor(new Color(222, 222, 236));
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x, textRect.y + 14);
        } else
        if(!buttonPressed)
        {
            g.setColor(new Color(39, 46, 128));
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 1, textRect.y + 15);
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 2, textRect.y + 16);
            g.setColor(b.getForeground());
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x, textRect.y + 14);
        } else
        {
            g.setColor(new Color(39, 46, 128));
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 1 + 2, textRect.y + 15 + 2);
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 2 + 2, textRect.y + 16 + 2);
            g.setColor(b.getForeground());
            BasicGraphicsUtils.drawString(g, s, accChar, textRect.x + 2, textRect.y + 14 + 2);
        }
        buttonPressed = false;
    }

    protected void paintButtonPressed(Graphics g, AbstractButton b)
    {
        buttonPressed = true;
    }

    public void comenzarRotar(Graphics s)
    {
        g2 = (Graphics2D)s;
        oldTransform = new AffineTransform(g2.getTransform());
        transform = g2.getTransform();
        transform.concatenate(AffineTransform.getRotateInstance(3.1415926535897931D));
        g2.setTransform(transform);
    }

    public void terminarRotar(Graphics s)
    {
        g2.setTransform(oldTransform);
        s.setFont(f1);
    }

    public void rotar(Graphics s, String textoDelTema, int posxDelTexto, int posyDelTexto)
    {
        s.setFont(f2);
        zeroPoint = new java.awt.geom.Point2D.Float(posxDelTexto, posyDelTexto);
        zeroPoint = oldTransform.transform(zeroPoint, zeroPoint);
        invertedZero = new java.awt.geom.Point2D.Float();
        try
        {
            invertedZero = transform.inverseTransform(zeroPoint, invertedZero);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        g2.drawString(textoDelTema, (int)invertedZero.getX(), (int)invertedZero.getY() + 25);
    }

    private boolean buttonPressed;
    private Point2D invertedZero;
    private Point2D zeroPoint;
    private AffineTransform transform;
    private Graphics2D g2;
    private AffineTransform oldTransform;
    private Font f1;
    private Font f2;
}