

//
// Core Program for TETDM 
// ShrinkData.java Version 1.00
// Copyright(C) 2018- TETDM CORE MEMBER ALL RIGHTS RESERVED.
// This program is provided under the license.
//

package source;


import java.io.*;
import java.text.*;
import java.util.*;



public class ShrinkData
{
    String toolName;
    String condition;
    String objectWord;
    String example;
    int shrunkNumber;
    
    boolean originalFocusSegments[];
    
    String message;
    
    ShrinkData()
    {
        toolName = "";
        condition = "";
        objectWord = "";
        example = "";
        shrunkNumber = 0;
        message = "";
    }
    
    ShrinkData(String toolName, String condition, String objectWord, String example, int shrunkNumber, boolean focusSegments[])
    {
        this.toolName = toolName;
        this.condition = condition;
        this.objectWord = objectWord;
        this.example = example;
        this.shrunkNumber = shrunkNumber;
        
        originalFocusSegments = focusSegments;
        
        createMessage(true);
    }
    
    void createInvertionData(int shrunkNumber, boolean focusSegments[])
    {
        String nameSplit[] = toolName.split(" ");
        if(nameSplit[0].equals("[NOT]"))
            toolName = nameSplit[1];
        else
            toolName = "[NOT] "+toolName;
        this.shrunkNumber = shrunkNumber;
        
        originalFocusSegments = focusSegments;
        
        createMessage(true);
    }
    
    void createMessage(boolean japanese)
    {
        int toolNameMax = 15, conditionMax = 20, objectMax = 5, exampleMax = 12, numberMax = 4;
        String displayToolName=toolName, displayCondition=condition, displayObject=objectWord, displayExample=example;
        

        
        if(japanese == false)
        {
            toolNameMax *= 2;
            conditionMax *= 2;
            objectMax *= 2;
            exampleMax *=2;
        }
        
        if(displayToolName.length() > toolNameMax)
            displayToolName = displayToolName.substring(0,toolNameMax);
        
        if(displayCondition.length() > conditionMax)
            displayCondition = displayCondition.substring(0,conditionMax);
        
        if(displayObject.length() > objectMax)
            displayObject = displayObject.substring(0,objectMax);
        
        if(displayExample.length() > exampleMax)
            displayExample = displayExample.substring(0,exampleMax);
        
//        String format = "%-"+toolNameMax+"s %-"+conditionMax+"s %-"+objectMax+"s %"+numberMax+"d %"+exampleMax+"s";
//        message = String.format(format, displayToolName, displayCondition, displayObject, shrunkNumber, displayExample);
        
        String format = "%-"+(toolNameMax+conditionMax+objectMax)+"s %"+numberMax+"d %-"+exampleMax+"s";
        message = String.format(format, displayToolName+" "+displayCondition+" "+displayObject, shrunkNumber, displayExample);




    }
    
    
}
