// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) space 
// Source File Name:   XAxis.java

package lt.monarch.charts;

import java.awt.*;

// Referenced classes of package lt.monarch.charts:
//            Axis, AxisMapper

public class XAxis extends Axis
{

    public XAxis(AxisMapper axismapper)
    {
        super(axismapper);
    }

    public void draw(Graphics g, Rectangle rectangle)
    {
        g.setColor(Color.black);
        g.drawLine(rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y);
        g.setFont(super.font);
        FontMetrics fontmetrics = g.getFontMetrics();
        int i = fontmetrics.stringWidth(" ");
        String s = "";
        for (int j = 0; j < super.mapper.labelCount(); j++)
            s = s + " " + super.mapper.label(j) + " ";

        int k = (int)Math.floor((double)fontmetrics.stringWidth(s) / (double)rectangle.width) + 1;
        int l = super.label == null ? 0 : k;
        for (int i1 = k / 2; i1 < super.mapper.labelCount() - l; i1 += k)
        {
            String s1 = super.mapper.label(i1);
            int j1 = mapLabel(rectangle, i1);
            g.drawString(s1, j1 - fontmetrics.stringWidth(s1) / 2, rectangle.y + fontmetrics.getHeight() + i);
            g.drawLine(j1, rectangle.y, j1, rectangle.y + i);
        }

        if (super.label != null)
            g.drawString(super.label, (rectangle.width + rectangle.x) - fontmetrics.stringWidth(super.label), rectangle.y + fontmetrics.getHeight() + i);
    }

    public int height(Graphics g)
    {
        FontMetrics fontmetrics = g.getFontMetrics(super.font);
        return fontmetrics.getHeight();
    }

    public int map(Rectangle rectangle, Object obj)
    {
        return super.mapper.map(rectangle.width, obj) + rectangle.x;
    }

    public int mapLabel(Rectangle rectangle, int i)
    {
        return super.mapper.mapLabel(rectangle.width, i) + rectangle.x;
    }
}
