package id.ac.itb.sigit.pengenalanpola;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Sigit on 22/09/2015.
 */
public class CharDef {
    private String character;
    private String chainCode;
    private String dirChainCode;
    private String relChainCode;
    private List<String> subChainCode=new ArrayList<>();

    public String getCharacter() {
        return character;
    }

    public void setCharacter(String character) {
        this.character = character;
    }

    public String getChainCode() {
        return chainCode;
    }

    public void setChainCode(String chainCode) {
        this.chainCode = chainCode;
    }

    public List<String> getSubChainCode() {
        return subChainCode;
    }

    public String getDirChainCode() {
        return dirChainCode;
    }

    public String getRelChainCode() {
        return relChainCode;
    }

    public void calcDirChainCode(){
        dirChainCode = "";

        for(int i=1; i < chainCode.length(); i++){
            int a = Integer.parseInt(chainCode.charAt(i) + "");
            int b = Integer.parseInt(chainCode.charAt(i - 1) + "");

            if(a == b){

            }else if(a < b){
                dirChainCode = dirChainCode + "-";
            }else{
                dirChainCode = dirChainCode + "+";
            }
        }
    }

    public void calcRelChainCode(){
        relChainCode = "";

        for(int i=1; i < chainCode.length(); i++){
            int a = Integer.parseInt(chainCode.charAt(i) + "");
            int b = Integer.parseInt(chainCode.charAt(i - 1) + "");

            if(a < b){
                relChainCode = relChainCode + (a - b + 8);
            }else{
                relChainCode = relChainCode + (a - b);
            }
        }
    }

}

@@ -1599,24 +1599,55 @@
        if(a 
+== b)%7B%0A%0A            %7Delse if(a 
 %3C b)%7B%0A      

Remove 0 from Relative Chain Code