#!/usr/bin/env python

# encoding: utf-8

'''
@author: Jiadong Lin, Xi'an Jiaotong University, Leiden University

@contact: jiadong324@gmail.com

@time: 2020/3/2
'''

class Segment():

    def __init__(self, x_start, y_start, length, forward, seg_id):
        self._xStart = x_start
        self._yStart = y_start
        self._length = length
        self._forward = forward
        self._segId = seg_id
        if forward:
            self._xEnd = self._xStart + (self._length - 1)
        else:
            self._xEnd = self._xStart - (self._length - 1)
        self._yEnd = self._yStart + (length - 1)

    def setxEnd(self, xEnd):
        self._xEnd = xEnd

    def setyEnd(self, yEnd):
        self._yEnd = yEnd

    def setLength(self, length):
        self._length = length

    def setxStart(self, xStart):
        self._xStart = xStart

    def setyStart(self, yStart):
        self._yStart = yStart

    def setForward(self, forward):
        self._forward = forward

    def setSegId(self, segId):
        self._segId = segId

    def toString(self):
        # coordS = "[" + str(self._xStart) + "," + str(self._yStart) + "]"
        # coordE = "[" + str(self._xEnd) + "," + str(self._yEnd) + "]"
        # return self._segId + "-" + coordS + "-" + coordE + "-" + self._forward + " " + self.length

        return str(self._xStart) + '\t' + str(self._xEnd) + '\t' + str(self._yStart) + '\t' + str(self._yEnd) + '\t' \
               + str(self._forward)

    def xStart(self):
        return self._xStart

    def yStart(self):
        return self._yStart

    def xEnd(self):
        return self._xEnd

    def yEnd(self):
        return self._yEnd

    def segId(self):
        return self._segId

    def length(self):
        return abs(self._xEnd - self._xStart)

    def Id(self):
        return self._segId

    def forward(self):
        return self._forward
