if(targets==true){ // Case Target Found on parameters
useTargets=true;
for (Iterator iterator = targetNames.iterator(); iterator.hasNext();) {
String targetName = (String) iterator.next();
String valueToParse=(String)parametersObject.get(targetName);
TargetThreshold targThres=new TargetThreshold(valueToParse);
if(targThres.getName().equalsIgnoreCase("bottom"))bottomThreshold=targThres;
else{
if(targThres.isVisible()){
thresholds.put(targThres.getValue(), targThres);
if(targThres.isMain()==true)mainThreshold=targThres.getValue();
}
}
}
if(bottomThreshold==null) bottomThreshold=new TargetThreshold("bottom",null, Color.BLACK,false, true);
}
else if(baselines==true){ // Case Baselines found on parameters
useTargets=false;
for (Iterator iterator = baselinesNames.iterator(); iterator.hasNext();) {
String targetName = (String) iterator.next();
String valueToParse=(String)parametersObject.get(targetName);
TargetThreshold targThres=new TargetThreshold(valueToParse);
if(targThres.getName().equalsIgnoreCase("bottom"))bottomThreshold=targThres;
else{
if(targThres.isVisible()){
thresholds.put(targThres.getValue(), targThres);
if(targThres.isMain()==true)mainThreshold=targThres.getValue();
}
}
}
if(bottomThreshold==null) bottomThreshold=new TargetThreshold("bottom",null, Color.BLACK,false, true);
}
//**************************** TEMPLATE TARGET OR BASELINES DEFINITION **********************
else { // Case targets or baselines defined in template
/* <TARGETS>
* <TARGET name='first' value='5' main='true'>
* </TARGETS>
*/
List thresAttrsList=null;
SourceBean thresholdsSB = (SourceBean)content.getAttribute(TARGETS);
if(thresholdsSB==null){
thresholdsSB = (SourceBean)content.getAttribute(BASELINES);
if(thresholdsSB==null)return;
useTargets=false;
}
if(thresholdsSB!=null){
thresAttrsList = thresholdsSB.getContainedSourceBeanAttributes();
}
if(thresAttrsList==null || thresAttrsList.isEmpty()){
logger.error("targets or baselines not defined; error ");
return;
}
else{
thresholds=new HashMap<Double, TargetThreshold>();
//thresholdColors=new HashMap<String, Color>();
Iterator targetsAttrsIter = thresAttrsList.iterator();
while(targetsAttrsIter.hasNext()) {
SourceBeanAttribute paramSBA = (SourceBeanAttribute)targetsAttrsIter.next();
SourceBean param = (SourceBean)paramSBA.getValue();
String name= (String)param.getAttribute("name");
String value= (String)param.getAttribute("value");
String main= (String)param.getAttribute("main");
String colorS = (String)param.getAttribute("color");
String visibleS = (String)param.getAttribute("visible");
Color colorC=Color.BLACK;
boolean isMain=(main!=null && main.equalsIgnoreCase("true")) ? true : false;
if(colorS!=null){
try{
colorC=Color.decode(colorS);
}
catch (Exception e) {
logger.error("error in color defined, put BLACK as default");
}
}
boolean isVisible=(visibleS!=null && (visibleS.equalsIgnoreCase("false") || visibleS.equalsIgnoreCase("0") || visibleS.equalsIgnoreCase("0.0"))) ? false : true;
// The value of the threshold is bottom or a double value
if(value!=null){
if(value.equalsIgnoreCase("bottom")){ //if definin bottom case
bottomThreshold=new TargetThreshold("bottom",null, colorC,false,true);
}
else if(!value.equalsIgnoreCase("bottom")){
Double valueD=null;
try{
valueD=Double.valueOf(value);
}
catch (NumberFormatException e) {
logger.error("Error in converting threshold double", e);
return;
}
if(isVisible==true){
thresholds.put(valueD, new TargetThreshold(name,valueD,colorC,isMain, isVisible));
if(isMain==true){
mainThreshold=valueD;
}
}
}