Author: mmichaud
Date: 2008-12-19 08:51:20 -0800 (Fri, 19 Dec 2008)
New Revision: 15472

Added:
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedHandler.java
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Utils/Bounded.java
Removed:
   
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedDoubleHandler.java
   
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedIntegerHandler.java
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedDouble.java
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedInteger.java
Modified:
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Command/input.java
   
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiHandlerFactory.java
   
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiTunableInterceptor.java
   csplugins/trunk/pasteur/mathieu/Tunable2/src/Tunable/Tunable.java
Log:
the Bounded has been set

Modified: csplugins/trunk/pasteur/mathieu/Tunable2/src/Command/input.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Command/input.java     
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Command/input.java     
2008-12-19 16:51:20 UTC (rev 15472)
@@ -4,15 +4,14 @@
 import java.security.acl.Group;
 import Tunable.*;
 import Tunable.Tunable.Param;
-import Sliders.*;
 import java.util.ArrayList;
 import java.util.List;
+import Utils.*;
 
 
 
-
-
-public class input implements command {
+public class input<O extends Comparable<String>> implements command {
+       
        @Tunable(description="Integer", type=Integer.class,flag=Param.Nothing)
        public Integer integer1 = new Integer(10);
        
@@ -22,36 +21,30 @@
        @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
        public Group Group1;
 
+       
@Tunable(description="BoundedObject",type=Bounded.class,flag=Param.Double)
+       public Bounded<O> boundObject= new Bounded<O>((O)"10", (O)"50", false, 
true);
+       
+       @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
+       public Group Group2;
+
        @Tunable(description="List", type=List.class, flag=Param.Nothing)
        public List<String> list;
 
        @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
-       public Group Group2;
+       public Group Group3;
 
        @Tunable(description ="Double", type=Double.class,flag=Param.Nothing)
        public Double double1 = new Double(3.4);
        
        @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
-       public Group Group3;
-       
-       @Tunable(description="BoundedInteger", 
type=BoundedInteger.class,flag=Param.UseSlider)
-       public BoundedInteger integer2 = new BoundedInteger(new Integer(50),new 
Integer(10),new Integer(200),new Boolean(true),new Boolean(true));
-       
-       @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
        public Group Group4;
-       
-       @Tunable(description="Boundeddouble", 
type=BoundedDouble.class,flag=Param.UseSlider)
-       public BoundedDouble double2 = new BoundedDouble(new Double(15.4),new 
Double(0.0),new Double(200.0),new Boolean(true),new Boolean(true));
-
-       @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
-       public Group Group5;
        
        @Tunable(description="Boolean",type=Boolean.class ,flag=Param.Nothing)
        public Boolean boolean1 = new Boolean(false);
 
        @Tunable(description="Group",type=Group.class,flag=Param.Nothing)
-       public Group Group6;
-       
+       public Group Group5;
+
 /*
        @Tunable(description="try with button", type=JButton.class, 
flag=Param.Nothing)
        public JButton button1 = new JButton();                 

Deleted: 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedDoubleHandler.java
===================================================================
--- 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedDoubleHandler.java  
    2008-12-19 11:46:24 UTC (rev 15471)
+++ 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedDoubleHandler.java  
    2008-12-19 16:51:20 UTC (rev 15472)
@@ -1,142 +0,0 @@
-package Factory;
-
-
-import java.awt.Color;
-import java.lang.reflect.*;
-import javax.swing.*;
-import GuiInterception.Guihandler;
-import Tunable.Tunable;
-import Tunable.Tunable.Param;
-import java.lang.Object;
-import Sliders.*;
-
-
-
-public class BoundedDoubleHandler implements Guihandler{
-       
-       Field f;
-       Tunable t;
-       Object o;
-       JTextField jtf; 
-       mySlider slider;
-       
-       Double upperbound;
-       Double lowerbound;
-       Double value;
-       String title;
-       Boolean useslider;
-       Boolean available;
-       Double handlevalue;
-       BoundedDouble input;
-       BoundedDouble output;
-       
-       public BoundedDoubleHandler(Field f, Object o, Tunable t){
-               this.f=f;
-               this.t=t;
-               this.o=o;
-               try{
-                       this.input=(BoundedDouble) f.get(o);    
-               }catch(Exception e){e.printStackTrace();}
-               this.title=f.getName();
-               this.value=input.getValue();
-               this.available=t.available();
-               this.upperbound=input.getUpperBound();
-               this.lowerbound=input.getLowerBound();
-               if(t.flag()==Param.UseSlider)this.useslider=true;
-       }
-       
-       
-       public void handle(){
-               if(available==true){
-                       Number s = slider.getValue();
-                       handlevalue = s.doubleValue();
-               }
-               else handlevalue = value;
-               try {
-                       output = new 
BoundedDouble(handlevalue,lowerbound,upperbound,true,true);
-                       if ( handlevalue != null ) f.set(o,output);
-               } catch (Exception e) { e.printStackTrace(); }
-       }
-
-       
-       
-       public JPanel getInputPanel(){
-               JPanel pane = new JPanel();             
-               try{
-                       if(available==true){
-                               if(useslider==true  && lowerbound!=null && 
upperbound!=null){                           
-                                       slider = new 
mySlider(title,lowerbound.doubleValue(),upperbound.doubleValue(),value.doubleValue());
-                                       pane.add(slider);
-                               }
-                       }
-                       else{
-                               jtf = new JTextField(value.toString());
-                               jtf.setEnabled(false);
-                               jtf.setBackground(Color.GRAY);
-                       }
-               }catch (Exception e){e.printStackTrace();}
-               return pane;
-       }
-
-       
-       public JPanel getresultpanel(){
-               JPanel result = new JPanel();
-               try{
-                       jtf = new JTextField(f.get(o).toString());
-                       if(available==false){
-                               jtf.setBackground(Color.GRAY);
-                               jtf.setEnabled(false);
-                       }
-               }catch (Exception e){e.printStackTrace();}              
-               result.add(new JLabel(title));
-               result.add(jtf);
-               return result;
-       }
-
-
-       public JPanel update(){
-               if(available==true){
-                       Number s = slider.getValue();
-                       handlevalue = s.doubleValue();
-               }
-               else handlevalue =value;
-               jtf = new JTextField(handlevalue.toString());
-               JPanel result = new JPanel();
-               result.add(jtf);
-               return result;
-       }
-       
-       
-       public void cancel(){
-               output = new 
BoundedDouble(value,lowerbound,upperbound,true,true);
-               try{
-                       f.set(o,output);
-               }catch(Exception e){e.printStackTrace();}
-       }
-       
-       
-
-       public Tunable getTunable() {
-               return t;
-       }
-
-
-       public Field getField() {
-               return f;
-       }
-
-
-       public Object getObject() {
-               return o;
-       }
-
-
-       @Override
-       public Class<?> getclass() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-
-
-}
\ No newline at end of file

Added: csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedHandler.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedHandler.java    
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedHandler.java    
2008-12-19 16:51:20 UTC (rev 15472)
@@ -0,0 +1,133 @@
+package Factory;
+
+import GuiInterception.*;
+import Tunable.*;
+import java.lang.reflect.*;
+import javax.swing.JPanel;
+import Utils.*;
+import Tunable.Tunable.Param;
+import javax.swing.*;
+import Sliders.*;
+
+public class BoundedHandler<O extends Comparable<String>> implements 
Guihandler{
+       
+       Field f;
+       Tunable t;
+       Object o;
+       
+       Bounded<String> boundedInObject;
+       Bounded<String> boundedOutObject;
+       Boolean useslider=false;
+       JTextField jtf;
+       mySlider slider;
+       O upperBound;
+       O lowerBound;
+       String title;
+       O value;
+       Number result = null;
+       
+       
+       @SuppressWarnings("unchecked")
+       public BoundedHandler(Field f, Object o, Tunable t){
+               this.f=f;
+               this.o=o;
+               this.t=t;
+               if(t.flag()==Param.DoubleSlider || 
t.flag()==Param.IntegerSlider) this.useslider=true;
+               try{
+                       boundedInObject = (Bounded) f.get(o);
+                       boundedOutObject =  (Bounded) f.get(o);
+               }catch(Exception e){e.printStackTrace();}
+               this.upperBound=(O) boundedInObject.getUpperBound();
+               this.lowerBound=(O)boundedInObject.getLowerBound();
+               this.title=f.getName();
+       }
+       
+       
+
+
+       @Override
+       public void cancel() {
+               try{
+                       f.set(o,boundedInObject);
+               }catch(Exception e){e.printStackTrace();}
+       }
+
+
+       public JPanel getInputPanel() {
+               JPanel inputPane = new JPanel();
+               if(useslider==true){
+                       if(t.flag()==Param.DoubleSlider){
+                               slider = new mySlider((java.lang.String) 
title,Double.parseDouble((String) lowerBound),Double.parseDouble((String) 
upperBound),Double.parseDouble((String) lowerBound));
+                       }
+                       if(t.flag()==Param.IntegerSlider){
+                               slider = new mySlider((java.lang.String) 
title,Integer.parseInt((String) lowerBound),Integer.parseInt((String) 
upperBound),Integer.parseInt((String) lowerBound));
+                       }
+               inputPane.add(slider);
+               }
+               else{
+                       jtf = new JTextField("",5);
+                       inputPane.add(jtf);
+               }
+               return inputPane;
+       }
+
+
+       
+       
+       public JPanel getresultpanel() {
+               return null;
+       }
+
+       public void handle() {
+               if(t.flag()==Param.DoubleSlider || 
t.flag()==Param.IntegerSlider) boundedOutObject.setValue(result.toString());
+               else boundedOutObject.setValue((String)value); 
+               try{
+                       f.set(o,boundedOutObject);
+               }catch(Exception e){e.printStackTrace();}
+       }
+
+
+       @SuppressWarnings("unchecked")
+       public JPanel update() {
+               JPanel resultPane = new JPanel();
+               if(t.flag()==Param.DoubleSlider){
+                       result=slider.getValue().doubleValue();
+                       //boundedOutObject.setValue(result.toString());
+                       jtf=new JTextField(result.toString());
+               }
+               if(t.flag()==Param.IntegerSlider){
+                       result=slider.getValue().intValue();
+                       //boundedOutObject.setValue(result.toString());
+                       jtf=new JTextField(result.toString());
+               }
+               if(t.flag()==Param.Double) {
+                       value =(O) jtf.getText();
+                       //boundedOutObject.setValue((String) value);
+                       jtf=new JTextField(value.toString());
+               }
+               if(t.flag()==Param.Integer) {
+                       value =(O) jtf.getText();
+                       //boundedOutObject.setValue((String)value);
+                       jtf=new JTextField(value.toString());
+               }
+               resultPane.add(jtf);
+               return resultPane;
+       }
+
+       
+       
+       public Object getObject() {
+               return o;
+       }
+       public Tunable getTunable() {
+               return t;
+       }
+       public Field getField() {
+               return f;
+       }
+       public Class<?> getclass() {
+               return null;
+       }
+
+
+}
\ No newline at end of file

Deleted: 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedIntegerHandler.java
===================================================================
--- 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedIntegerHandler.java 
    2008-12-19 11:46:24 UTC (rev 15471)
+++ 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Factory/BoundedIntegerHandler.java 
    2008-12-19 16:51:20 UTC (rev 15472)
@@ -1,176 +0,0 @@
-package Factory;
-
-import java.lang.reflect.*;
-import javax.swing.*;
-import java.awt.Color;
-import GuiInterception.Guihandler;
-import Tunable.Tunable;
-import Tunable.Tunable.Param;
-import Sliders.*;
-
-
-public class BoundedIntegerHandler implements Guihandler{
-       
-       Field f;
-       Tunable t;
-       Object o;
-       JTextField jtf;
-       mySlider slider;
-       
-       Boolean useslider=false;
-       String title;
-       Integer upperbound;
-       Integer lowerbound;
-       Integer value;
-       Boolean available;
-       Integer i;
-
-       BoundedInteger input;
-       BoundedInteger output;
-       
-       
-       public BoundedIntegerHandler(Field f, Object o, Tunable t){
-               this.f=f;
-               this.t=t;
-               this.o=o;
-               this.available=t.available();
-               this.title=f.getName();
-               try{
-                       this.input = (BoundedInteger) f.get(o);
-               }catch(Exception e){e.printStackTrace();}
-               
-               this.value=input.getValue();
-               this.lowerbound =input.getLowerBound();
-               this.upperbound = input.getUpperBound();
-               if(t.flag()==Param.UseSlider)this.useslider=true;
-       }
-       
-       
-       public void handle(){
-               if(useslider==true){
-                       Number s = slider.getValue();
-                       i = s.intValue();
-               }
-               else i = Integer.parseInt(jtf.getText());
-               if(i>= lowerbound && i<=upperbound){
-                       output = new 
BoundedInteger(i,lowerbound,upperbound,true,true);
-                       try {
-                               if (i != null) f.set(o,output);
-                       } catch (Exception e) { e.printStackTrace();}
-               }
-               else{
-                       output = new 
BoundedInteger(input.getValue(),lowerbound,upperbound,true,true);
-                       try {
-                               if (i != null) f.set(o,output);
-                       } catch (Exception e) { e.printStackTrace();}
-               }
-               
-       }
-
-       
-       public JPanel getInputPanel(){
-               JPanel pane = new JPanel();
-               try{
-                       if(available==true){
-                               if(useslider==true  && lowerbound!=null && 
upperbound!=null){
-                                               slider = new 
mySlider(title,lowerbound.intValue(),upperbound.intValue(),value.intValue());
-                                               pane.add(slider);               
        
-                               }
-                       }
-                       else{
-                               jtf = new JTextField(value);
-                               jtf.setEnabled(false);
-                               jtf.setBackground(Color.GRAY);
-                               //pane.add(new JLabel(title));
-                               pane.add(jtf);
-                       }
-                       
-               }catch (Exception e){e.printStackTrace();}
-               return pane;
-       }
-       
-
-       
-       public JPanel getresultpanel(){
-               JPanel result = new JPanel();
-                       try{
-                               jtf = new JTextField((f.get(o)).toString());
-                               if(available==false){
-                                       jtf.setEnabled(false);
-                                       jtf.setBackground(Color.GRAY);
-                       }                       
-                       }catch (Exception e){e.printStackTrace();}
-               result.add(new JLabel(title));
-               result.add(jtf);
-               return result;
-
-       }
-
-
-       public void cancel(){
-               try{
-                       f.set(o, f.get(o));
-               }catch(Exception e){e.printStackTrace();}
-       }
-       
-       
-       
-       public JPanel update(){
-               if(available==true){
-                       Number s = slider.getValue();
-                       i = s.intValue();
-               }
-               else i = value;
-               JPanel result = new JPanel();
-               jtf= new JTextField(i.toString());
-               result.add(jtf);
-               return result;
-       }
-
-       
-       public void     setValue(Object object){
-               try{
-                       f.set(o, object);
-               }catch(Exception e){e.printStackTrace();}
-       }
-       
-       
-       @Override
-       public Tunable getTunable() {
-               return t;
-       }
-
-
-       @Override
-       public Field getField() {
-               return f;
-       }
-       
-
-       public Object getObject() {
-               return o;
-       }
-
-
-       @Override
-       public Class<?> getclass() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       
-//     @Override
-//     public void stateChanged(ChangeEvent CE) {
-//             JSlider source = (JSlider) CE.getSource();
-//                     //if(!source.getValueIsAdjusting())
-//             jtf.setText(String.valueOf(source.getValue()));
-//                     
-//             
-//     }
-//
-//     @Override
-//     public void actionPerformed(ActionEvent ae) {
-//             if(ae.getSource()!=jtf.getText())
-//             slider.setValue(Integer.parseInt(jtf.getText()));
-//     }
-}
\ No newline at end of file

Modified: 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiHandlerFactory.java
===================================================================
--- 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiHandlerFactory.java
 2008-12-19 11:46:24 UTC (rev 15471)
+++ 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiHandlerFactory.java
 2008-12-19 16:51:20 UTC (rev 15472)
@@ -1,6 +1,6 @@
 package GuiInterception;
 
-import Command.*;
+
 import Factory.*;
 import HandlerFactory.HandlerFactory;
 import java.lang.reflect.*;
@@ -8,21 +8,17 @@
 import java.util.List;
 import Tunable.Tunable;
 import Tunable.Tunable.Param;
+import Utils.Bounded;
 import Sliders.*;
 
 
 public class GuiHandlerFactory<T> implements HandlerFactory<Guihandler> {
 
 
-       command command = new input();
        public Guihandler getHandler(Field f, Object o, Tunable t){
                Param parameter= t.flag();
                Class<?> type = f.getType();
                
-               if(type== BoundedInteger.class)
-                       return new BoundedIntegerHandler(f,o,t);
-               if(type== BoundedDouble.class)
-                       return new BoundedDoubleHandler(f,o,t);
                if(type== Integer.class)
                        return new IntegerHandler(f,o,t);
                if(type== Double.class)
@@ -33,6 +29,8 @@
                        return new StringHandler(f,o,t);
                if(type==Group.class)
                        return new GroupHandler(f,o,t);
+               if(type==Bounded.class)
+                       return new BoundedHandler(f,o,t);
                if(type == List.class){
                        if(parameter==Param.MultiSelect){
                                return new ListMultipleHandler<T>(f,o,t);

Modified: 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiTunableInterceptor.java
===================================================================
--- 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiTunableInterceptor.java
     2008-12-19 11:46:24 UTC (rev 15471)
+++ 
csplugins/trunk/pasteur/mathieu/Tunable2/src/GuiInterception/GuiTunableInterceptor.java
     2008-12-19 16:51:20 UTC (rev 15472)
@@ -8,6 +8,8 @@
 import javax.swing.border.TitledBorder;
 import java.util.List;
 import java.util.Properties;
+
+import Factory.BoundedHandler;
 import Properties.*;
 
 
@@ -118,9 +120,8 @@
        }
        
        protected void save(List<Guihandler> list){
-               for(Guihandler guihandler : list) guihandler.handle();  
+               for(Guihandler guihandler : list)       guihandler.handle();
                properties.saveProperties(prop);
-               //properties.saveProperties(prop);
        }
        
        protected void cancel(List<Guihandler> list){

Deleted: csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedDouble.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedDouble.java     
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedDouble.java     
2008-12-19 16:51:20 UTC (rev 15472)
@@ -1,42 +0,0 @@
-package Sliders;
-
-
-public class BoundedDouble{
-       
-       Double value;
-       Double lowerBound;
-       Double upperBound;
-       Boolean lowerBool;
-       Boolean upperBool;
-       
-       
-       public BoundedDouble(Double value,Double lowerBound,Double 
upperBound,Boolean lowerBool,Boolean upperBool){
-               this.value=value;
-               this.lowerBound=lowerBound;
-               this.upperBound=upperBound;
-               this.lowerBool=lowerBool;
-               this.upperBool=upperBool;
-       }
-       
-       public Double getValue(){
-               return value;
-       }
-
-       public Double getLowerBound(){
-               return lowerBound;
-       }
-       
-       public Double getUpperBound(){
-               return upperBound;
-       }
-       
-       public Boolean getLowerBool(){
-               return lowerBool;
-       }
-       
-       public Boolean getUpperBool(){
-               return upperBool;
-       }
-}
-
-

Deleted: 
csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedInteger.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedInteger.java    
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Sliders/BoundedInteger.java    
2008-12-19 16:51:20 UTC (rev 15472)
@@ -1,40 +0,0 @@
-package Sliders;
-
-
-public class BoundedInteger{
-       
-       Integer value;
-       Integer lowerBound;
-       Integer upperBound;
-       Boolean lowerBool;
-       Boolean upperBool;
-       
-       
-       public BoundedInteger(Integer value,Integer lowerBound,Integer 
upperBound,Boolean lowerBool,Boolean upperBool){
-               this.value=value;
-               this.lowerBound=lowerBound;
-               this.upperBound=upperBound;
-               this.lowerBool=lowerBool;
-               this.upperBool=upperBool;
-       }
-       
-       public Integer getValue(){
-               return value;
-       }
-
-       public Integer getLowerBound(){
-               return lowerBound;
-       }
-       
-       public Integer getUpperBound(){
-               return upperBound;
-       }
-       
-       public Boolean getLowerBool(){
-               return lowerBool;
-       }
-       
-       public Boolean getUpperBool(){
-               return upperBool;
-       }
-}

Modified: csplugins/trunk/pasteur/mathieu/Tunable2/src/Tunable/Tunable.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Tunable/Tunable.java   
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Tunable/Tunable.java   
2008-12-19 16:51:20 UTC (rev 15472)
@@ -2,10 +2,6 @@
 
 import java.lang.annotation.*;
 
-//import javax.lang.model.element.Modifier;
-
-
-
 @Retention(RetentionPolicy.RUNTIME) // makes this availabe for reflection
 @Target({ElementType.FIELD,ElementType.TYPE}) // says we're just looking at 
fields and  methods
 
@@ -14,5 +10,5 @@
        public Class<?> type();
        public Param flag();
        public boolean available() default true;        
-       public enum Param { UseSlider, Nothing,MultiSelect }    
+       public enum Param { 
IntegerSlider,DoubleSlider,Integer,Double,Nothing,MultiSelect }     
 }

Added: csplugins/trunk/pasteur/mathieu/Tunable2/src/Utils/Bounded.java
===================================================================
--- csplugins/trunk/pasteur/mathieu/Tunable2/src/Utils/Bounded.java     
2008-12-19 11:46:24 UTC (rev 15471)
+++ csplugins/trunk/pasteur/mathieu/Tunable2/src/Utils/Bounded.java     
2008-12-19 16:51:20 UTC (rev 15472)
@@ -0,0 +1,76 @@
+package Utils;
+
+
+public class Bounded<O extends Comparable<String>>{
+       
+       O value;
+       O lowerBound;
+       O upperBound;
+       Boolean lowerBool;
+       Boolean upperBool;
+       
+       
+       public Bounded(O lowerBound,O upperBound,Boolean lowerBool,Boolean 
upperBool){
+               this.lowerBound=lowerBound;
+               this.upperBound=upperBound;
+               this.lowerBool=lowerBool;
+               this.upperBool=upperBool;
+               
+               if (lowerBound == null)
+                       throw new NullPointerException("lower bound is null!");
+
+               if (upperBound == null)
+                       throw new NullPointerException("upper bound is null!");
+
+               if (lowerBound.compareTo((String) upperBound) >= 0)
+                       throw new IllegalArgumentException("lower value is 
greater than or equal to upper value");
+       }
+       
+       public O getValue(){
+               return value;
+       }
+
+       public O getLowerBound(){
+               return lowerBound;
+       }
+       
+       public O getUpperBound(){
+               return upperBound;
+       }
+       
+       public Boolean isLowerBool(){
+               return lowerBool;
+       }
+       
+       public Boolean isUpperBool(){
+               return upperBool;
+       }
+       
+       public void setValue(O v) {
+               if (v == null)
+                       throw new NullPointerException("value is null!");
+
+               int up = v.compareTo((String) upperBound);
+
+               if (upperBool) {
+                       if (up >= 0)
+                               throw new IllegalArgumentException("value is 
greater than or equal to upper limit");
+               } else {
+                       if (up > 0)
+                               throw new IllegalArgumentException("value is 
greater than upper limit");
+               }
+
+               int low = v.compareTo((String) lowerBound);
+
+               if (lowerBool) {
+                       if (low <= 0)
+                               throw new IllegalArgumentException("value is 
less than or equal to lower limit");
+               } else {
+                       if (low < 0)
+                               throw new IllegalArgumentException("value is 
less than lower limit");
+               }
+
+               value = v;
+       }
+       
+}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to