package cnp.ew.displayer;
import java.awt.*;
import cnp.ew.lightweight.*;

public class CpEdgeBorderDisplayer extends CpAbstractBorderDisplayer
{
    public Color borderColor=Color.black;
    public Color leftBorderColor;
    public Color rightBorderColor;
    public Color topBorderColor;
    public Color bottomBorderColor;
    public int leftBorderThickness=0;
    public int rightBorderThickness=0;
    public int topBorderThickness=0;
    public int bottomBorderThickness=0;

    public CpEdgeBorderDisplayer()
    {
        this(0, 0, 0, 0);
    }

    public CpEdgeBorderDisplayer(int leftThickness, int topThickness, int rightThickness, int bottomThickness)
    {
        leftBorderThickness = leftThickness;
        topBorderThickness = topThickness;
        rightBorderThickness = rightThickness;
        bottomBorderThickness = bottomThickness;
    }

    void paintBordersIn(CpLightweightComponent c, Graphics g, int x, int y, int w, int h)
    {

        if (leftBorderThickness > 0) {
            drawBorder(g, x, y, leftBorderThickness, h, leftBorderColor);
        }

        if (rightBorderThickness > 0) {
            drawBorder(g, x + w - rightBorderThickness, y, rightBorderThickness, h, rightBorderColor);
        }

        if (topBorderThickness > 0) {
            drawBorder(g, x, y, w, topBorderThickness, topBorderColor);
        }
        if (bottomBorderThickness > 0) {
            drawBorder(g, x, y + h - bottomBorderThickness, w, bottomBorderThickness, bottomBorderColor);
        }
    }

    public void drawBorder(Graphics g, int x, int y, int w, int h, Color possibleBorderColor)
    {
        if (possibleBorderColor != null) {
            g.setColor(possibleBorderColor);
        } else {
            g.setColor(borderColor);
        }

        g.fillRect(x, y, w, h);
    }


	public int getLeftBorderThickness(CpLightweightComponent c)
	{
	    return leftBorderThickness;
	}

	public int getRightBorderThickness(CpLightweightComponent c)
	{
	    return rightBorderThickness;
	}

	public int getTopBorderThickness(CpLightweightComponent c)
	{
	    return topBorderThickness;
	}

	public int getBottomBorderThickness(CpLightweightComponent c)
	{
	    return bottomBorderThickness;
	}

}


