/*
    Copyright M-Gate Labs 2007
*/

/**
 <p>
 <b>A Renderable Edge</b>
 </p>
 */

package com.mgatelabs.swftools.exploit.conversion;

import com.mgatelabs.swftools.support.swf.objects.FFill;
import com.mgatelabs.swftools.support.swf.objects.FLine;

import java.awt.geom.GeneralPath;

public class REdge extends RBase {
    private long startX;
    private long startY;
    private long deltaX;
    private long deltaY;
    private long endX;
    private long endY;

    public REdge(FFill fill, FLine line, long startX, long startY, long deltaX, long deltaY) {
        super(EDGE, fill, line);

        this.startX = startX;
        this.startY = startY;
        endX = startX + deltaX;
        endY = startY + deltaY;
        deltaX = deltaX;
        deltaY = deltaY;
    }

    public long getStartX() {
        return startX;
    }

    public long getEndX() {
        return endX;
    }

    public long getStartY() {
        return startY;
    }

    public long getEndY() {
        return endY;
    }

    public GeneralPath getPath() {
        GeneralPath aPath = new GeneralPath();
        aPath.moveTo(startX / 20.0f, startY / 20.0f);
        aPath.lineTo(endX / 20.0f, endY / 20.0f);
        return aPath;
    }

    public void flip() {
        super.flip();
        long tempA = startX;
        long tempB = startY;
        startX = endX;
        startY = endY;
        endX = tempA;
        endY = tempB;
    }

    public String toString() {
        String result = "";
        if (getType() == CURVE) {

        } else {
            result = "X " + (getStartX() / 20.0f);
            result += " Y " + (getStartY() / 20.0f);
            result += ",X " + (getEndX() / 20.0f);
            result += " Y " + (getEndY() / 20.0f);
        }
        return result;
    }
}