Junction.java [src/SwmmObjects] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package SwmmObjects;
import java.text.DecimalFormat;
import org.apache.commons.lang3.StringUtils;
/**
*
* @author Lucas Yaege
*/
public class Junction
{
public String name;
public double elevation;
public double maxDepth;
public double initDepth;
public double surDepth;
public double aponded;
private DecimalFormat df = new DecimalFormat("#.###");
public Junction( String name, double elevation, double maxDepth, double initDepth, double surDepth, double aponded )
{
this.name = name;
this.elevation = elevation;
this.maxDepth = maxDepth;
this.initDepth = initDepth;
this.surDepth = surDepth;
this.aponded = aponded;
}
public Junction(String name)
{
this.name = name;
this.elevation = 0d;
this.maxDepth = 0d;
this.initDepth = 0d;
this.surDepth = 0d;
this.aponded = 0d;
}
public String toString()
{
return toString(17, 40);
}
public String toString(int padDistance, int namePadDistance)
{
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.rightPad(this.name, namePadDistance));
sb.append(StringUtils.rightPad(df.format(this.elevation), padDistance));
sb.append(StringUtils.rightPad(df.format(this.maxDepth) , padDistance));
sb.append( StringUtils.rightPad(df.format(this.initDepth), padDistance));
sb.append( StringUtils.rightPad(df.format(this.surDepth), padDistance));
sb.append( StringUtils.rightPad(df.format(this.aponded), padDistance));
sb.append("\n");
return sb.toString();
}
}