com.ctreber.aclib.gui.MODouble Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml Show documentation
Show all versions of plantuml Show documentation
PlantUML is a component that allows to quickly write :
* sequence diagram,
* use case diagram,
* class diagram,
* activity diagram,
* component diagram,
* state diagram
* object diagram
The newest version!
package com.ctreber.aclib.gui;
/**
*
*
* © 2002 Christian Treber, [email protected]
* @author Christian Treber, [email protected]
*
*/
public class MODouble extends MonitoredObject
{
private double fDouble;
private boolean fCheckRange = false;
private double fMin;
private double fMax;
public MODouble()
{
}
public MODouble(double pDouble)
{
fDouble = pDouble;
}
public MODouble(double pDouble, double pMin, double pMax)
{
fMin = pMin;
fMax = pMax;
fCheckRange = true;
set(pDouble);
}
public void set(double pDouble)
{
if(!checkRange(pDouble))
{
throw new IllegalArgumentException("Argument '" + pDouble +
"' out of range [" + niceFormat(fMin) + "; " + niceFormat(fMax) + "]");
}
fDouble = pDouble;
fireValueChanged();
}
private static String niceFormat(double pDouble)
{
if(pDouble == Double.MAX_VALUE)
{
return "Infinity";
}
if(pDouble == Double.MIN_VALUE)
{
return "-Infinity";
}
return Double.toString(pDouble);
}
public double get()
{
return fDouble;
}
private boolean checkRange(double pDouble)
{
return !fCheckRange || (fMin <= pDouble) && (pDouble <= fMax);
}
public boolean checkRange()
{
return checkRange(fDouble);
}
}