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

package project;

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import javax.swing.JLabel;
import javax.swing.plaf.basic.BasicLabelUI;

public class APPClasePantallasUI extends BasicLabelUI
{

    public APPClasePantallasUI(int incrementoX, int incrementoY)
    {
        this.incrementoX = 0;
        this.incrementoY = 0;
        this.incrementoX = incrementoX;
        this.incrementoY = incrementoY;
    }

    protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY)
    {
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        int accChar = l.getDisplayedMnemonic();
        g.setColor(l.getForeground());
        java.awt.geom.Rectangle2D rect = l.getFont().getStringBounds(s, g2.getFontRenderContext());
        comenzarRotar(g);
        rotar(g, s, textX, textY);
        terminarRotar(g);
    }

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

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

    public void rotar(Graphics s, String textoDelTema, int posxDelTexto, int posyDelTexto)
    {
        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() + incrementoX, (int)invertedZero.getY() + incrementoY);
    }

    private Point2D invertedZero;
    private Point2D zeroPoint;
    private AffineTransform transform;
    private Graphics2D g2;
    private AffineTransform oldTransform;
    private int incrementoX;
    private int incrementoY;
}