Further cleanup of logging.
This commit is contained in:
2013-01-31 15:56:53 +00:00
parent d474eebfa2
commit d93c8bf2b0
7 changed files with 1194 additions and 1258 deletions

View File

@@ -1,5 +1,6 @@
package eva2.gui; package eva2.gui;
import eva2.client.EvAClient;
import eva2.server.go.populations.Population; import eva2.server.go.populations.Population;
import eva2.server.go.strategies.GeneticAlgorithm; import eva2.server.go.strategies.GeneticAlgorithm;
import eva2.tools.Pair; import eva2.tools.Pair;
@@ -15,44 +16,46 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Some miscellaneous functions to help with Beans, reflection, conversion and generic display. * Some miscellaneous functions to help with Beans, reflection, conversion and
* generic display.
* *
* @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher * @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher
* *
*/ */
public class BeanInspector { public class BeanInspector {
public static boolean TRACE = false; private static final Logger LOGGER = Logger.getLogger(BeanInspector.class.getName());
/** /**
* Check for equality based on bean properties of two target objects. * Check for equality based on bean properties of two target objects.
*/ */
public static boolean equalProperties(Object obj_1, Object obj_2) { public static boolean equalProperties(Object obj1, Object obj2) {
if (obj_1 == null || obj_2 == null) { if (obj1 == null || obj2 == null) {
System.out.println(""); System.out.println("");
return false; return false;
} }
System.out.println("equalProperties: " + obj_1.getClass().getName() + " " + obj_2.getClass().getName()); System.out.println("equalProperties: " + obj1.getClass().getName() + " " + obj2.getClass().getName());
if (obj_1.getClass().getName().equals(obj_2.getClass().getName()) == false) { if (obj1.getClass().getName().equals(obj2.getClass().getName()) == false) {
System.out.println(""); System.out.println("");
return false; return false;
} }
// compare each of the properties !! // compare each of the properties !!
BeanInfo Info_1 = null; BeanInfo beanInfo1;
BeanInfo Info_2 = null; BeanInfo beanInfo2;
PropertyDescriptor[] Properties_1 = null; PropertyDescriptor[] Properties_1 = null;
PropertyDescriptor[] Properties_2 = null; PropertyDescriptor[] Properties_2 = null;
try { try {
Info_1 = Introspector.getBeanInfo(obj_1.getClass()); beanInfo1 = Introspector.getBeanInfo(obj1.getClass());
Info_2 = Introspector.getBeanInfo(obj_2.getClass()); beanInfo2 = Introspector.getBeanInfo(obj2.getClass());
Properties_1 = Info_1.getPropertyDescriptors(); Properties_1 = beanInfo1.getPropertyDescriptors();
Properties_2 = Info_2.getPropertyDescriptors(); Properties_2 = beanInfo2.getPropertyDescriptors();
Info_1.getMethodDescriptors(); beanInfo1.getMethodDescriptors();
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
System.out.println("BeanTest: Couldn't introspect !!!!!!!!!"); LOGGER.log(Level.FINEST, "Could not introspect object.", ex);
return false; return false;
} }
boolean BeansInside = false; boolean BeansInside = false;
@@ -76,8 +79,8 @@ public class BeanInspector {
Object args_2[] = {}; Object args_2[] = {};
//System.out.println("m_Target"+m_Target.toString()); //System.out.println("m_Target"+m_Target.toString());
try { try {
Object value_1 = getter_1.invoke(obj_1, args_1); Object value_1 = getter_1.invoke(obj1, args_1);
Object value_2 = getter_2.invoke(obj_2, args_2); Object value_2 = getter_2.invoke(obj2, args_2);
BeansInside = true; BeansInside = true;
if (BeanInspector.equalProperties(value_1, value_2) == false) { if (BeanInspector.equalProperties(value_1, value_2) == false) {
BeansEqual = false; BeansEqual = false;
@@ -90,13 +93,13 @@ public class BeanInspector {
return BeansEqual; return BeansEqual;
} }
// here we have Integer or Double ... // here we have Integer or Double ...
if (obj_1 instanceof Integer || if (obj1 instanceof Integer
obj_1 instanceof Boolean || || obj1 instanceof Boolean
obj_1 instanceof Float || || obj1 instanceof Float
obj_1 instanceof Double || || obj1 instanceof Double
obj_1 instanceof Long || || obj1 instanceof Long
obj_1 instanceof String) { || obj1 instanceof String) {
return obj_1.equals(obj_2); return obj1.equals(obj2);
} }
System.err.println(" Attention no match !!!"); System.err.println(" Attention no match !!!");
@@ -115,7 +118,9 @@ public class BeanInspector {
} }
/** /**
* Produce a string with newlines and indentation (easier readable for if an object has many properties). * Produce a string with newlines and indentation (easier readable for if an
* object has many properties).
*
* @param obj * @param obj
* @return * @return
*/ */
@@ -124,10 +129,11 @@ public class BeanInspector {
} }
/** /**
* Collect the accessible properties of an object and their values in a string with indentations. * Collect the accessible properties of an object and their values in a
* Special cases: Arrays and Lists are concatenations of their elements, Population is excepted from lists. * string with indentations. Special cases: Arrays and Lists are
* If the object has its own toString method, this one is preferred. Hidden or expert properties are not * concatenations of their elements, Population is excepted from lists. If
* shown. * the object has its own toString method, this one is preferred. Hidden or
* expert properties are not shown.
* *
* @param obj an arbitrary object * @param obj an arbitrary object
* @return a String description of the object * @return a String description of the object
@@ -137,10 +143,11 @@ public class BeanInspector {
} }
/** /**
* Collect the accessible properties of an object and their values in a string. * Collect the accessible properties of an object and their values in a
* Special cases: Arrays and Lists are concatenations of their elements, Population is excepted from lists. * string. Special cases: Arrays and Lists are concatenations of their
* If the object has its own toString method, this one is preferred. Hidden or expert properties are not * elements, Population is excepted from lists. If the object has its own
* shown. * toString method, this one is preferred. Hidden or expert properties are
* not shown.
* *
* @param obj Description of the Parameter * @param obj Description of the Parameter
* @return Description of the Return Value * @return Description of the Return Value
@@ -218,9 +225,6 @@ public class BeanInspector {
//args[0] = obj; //args[0] = obj;
try { try {
String ret = (String) methods[ii].invoke(obj, args); String ret = (String) methods[ii].invoke(obj, args);
if (TRACE) {
System.out.println("toString on "+ obj.getClass() + " gave me " + ret);
}
return makeIndent(indentStr, indentDepth) + ret; return makeIndent(indentStr, indentDepth) + ret;
} catch (Exception e) { } catch (Exception e) {
System.err.println(" ERROR +" + e.getMessage()); System.err.println(" ERROR +" + e.getMessage());
@@ -271,8 +275,7 @@ public class BeanInspector {
if (indentStr != null) { if (indentStr != null) {
if (indentDepth < 1) { if (indentDepth < 1) {
return ""; return "";
} } else {
else {
StringBuffer sbuf = new StringBuffer(indentStr); StringBuffer sbuf = new StringBuffer(indentStr);
for (int i = 2; i <= indentDepth; i++) { for (int i = 2; i <= indentDepth; i++) {
sbuf.append(indentStr); sbuf.append(indentStr);
@@ -300,9 +303,10 @@ public class BeanInspector {
} }
/** /**
* Retrieve names and values of instance fields which are accessible by getter method, optionally * Retrieve names and values of instance fields which are accessible by
* by both getter and setter method. The returned arrays may contain null entries. * getter method, optionally by both getter and setter method. The returned
* Properties marked as hidden or expert are skipped. * arrays may contain null entries. Properties marked as hidden or expert
* are skipped.
* *
* @param target * @param target
* @return * @return
@@ -353,7 +357,6 @@ public class BeanInspector {
return nameVals; return nameVals;
} }
/** /**
* @param obj Description of the Parameter * @param obj Description of the Parameter
*/ */
@@ -422,10 +425,10 @@ public class BeanInspector {
} }
/** /**
* Call a method by a given name with given arguments, if the method is available. * Call a method by a given name with given arguments, if the method is
* Returns the return values of the call or null if it isnt found. * available. Returns the return values of the call or null if it isnt
* This of course means that the caller is unable to distinguish between "method not found" * found. This of course means that the caller is unable to distinguish
* and "method found and it returned null". * between "method not found" and "method found and it returned null".
* *
* @param obj * @param obj
* @param mName * @param mName
@@ -450,8 +453,8 @@ public class BeanInspector {
} }
/** /**
* Produce an array of Class instances matching the types of * Produce an array of Class instances matching the types of the given
* the given object array. * object array.
* *
* @param o * @param o
* @return * @return
@@ -468,9 +471,8 @@ public class BeanInspector {
} }
/** /**
* Check whether an object has a method by the given name and with * Check whether an object has a method by the given name and with matching
* matching signature considering the arguments. Return * signature considering the arguments. Return it if found, or null if not.
* it if found, or null if not.
* *
* @param obj * @param obj
* @param mName the method name * @param mName the method name
@@ -482,13 +484,13 @@ public class BeanInspector {
} }
/** /**
* Check whether an object has a method by the given name and * Check whether an object has a method by the given name and with the given
* with the given parameter signature. Return * parameter signature. Return it if found, or null if not.
* it if found, or null if not.
* *
* @param obj * @param obj
* @param mName the method name * @param mName the method name
* @param paramTypes the parameter types, null allowed if no parameters are expected * @param paramTypes the parameter types, null allowed if no parameters are
* expected
* @return the method or null if it isn't found * @return the method or null if it isn't found
*/ */
public static Method hasMethod(Object obj, String mName, Class[] paramTypes) { public static Method hasMethod(Object obj, String mName, Class[] paramTypes) {
@@ -502,7 +504,8 @@ public class BeanInspector {
} // full match } // full match
else { else {
if (paramTypes != null && (methParamTypes.length == paramTypes.length)) { if (paramTypes != null && (methParamTypes.length == paramTypes.length)) {
boolean mismatch = false; int i=0; boolean mismatch = false;
int i = 0;
while ((i < methParamTypes.length) && (!mismatch)) { while ((i < methParamTypes.length) && (!mismatch)) {
if (!methParamTypes[i].isAssignableFrom(paramTypes[i]) && !isBoxableFrom(methParamTypes[i], paramTypes[i])) { if (!methParamTypes[i].isAssignableFrom(paramTypes[i]) && !isBoxableFrom(methParamTypes[i], paramTypes[i])) {
mismatch = true; mismatch = true;
@@ -520,7 +523,8 @@ public class BeanInspector {
} }
/** /**
* Check if the given first class is a primitive type and can be boxed to match the second class. * Check if the given first class is a primitive type and can be boxed to
* match the second class.
* *
* @param clz1 * @param clz1
* @param clz2 * @param clz2
@@ -536,8 +540,8 @@ public class BeanInspector {
} }
/** /**
* For a primitive type, return the boxed referenced type. * For a primitive type, return the boxed referenced type. Return null for
* Return null for any non-primitive type. * any non-primitive type.
* *
* @param clz1 * @param clz1
* @return * @return
@@ -546,29 +550,21 @@ public class BeanInspector {
if (cls.isPrimitive()) { if (cls.isPrimitive()) {
if (cls == double.class) { if (cls == double.class) {
return Double.class; return Double.class;
} } else if (cls == char.class) {
else if (cls == char.class) {
return Character.class; return Character.class;
} } else if (cls == int.class) {
else if (cls == int.class) {
return Integer.class; return Integer.class;
} } else if (cls == boolean.class) {
else if (cls == boolean.class) {
return Boolean.class; return Boolean.class;
} } else if (cls == byte.class) {
else if (cls == byte.class) {
return Byte.class; return Byte.class;
} } else if (cls == short.class) {
else if (cls == short.class) {
return Short.class; return Short.class;
} } else if (cls == long.class) {
else if (cls == long.class) {
return Long.class; return Long.class;
} } else if (cls == float.class) {
else if (cls == float.class) {
return Float.class; return Float.class;
} } else {
else {
return Void.class; return Void.class;
} }
} else { } else {
@@ -577,44 +573,37 @@ public class BeanInspector {
} }
/** /**
* For a Java primitive wrapper class return the corresponding * For a Java primitive wrapper class return the corresponding primitive
* primitive class. * class.
**/ *
*/
public static Class getUnboxedType(Class cls) { public static Class getUnboxedType(Class cls) {
if (cls == Double.class) { if (cls == Double.class) {
return double.class; return double.class;
} } else if (cls == Character.class) {
else if (cls == Character.class) {
return char.class; return char.class;
} } else if (cls == Integer.class) {
else if (cls == Integer.class) {
return int.class; return int.class;
} } else if (cls == Boolean.class) {
else if (cls == Boolean.class) {
return boolean.class; return boolean.class;
} } else if (cls == Byte.class) {
else if (cls == Byte.class) {
return byte.class; return byte.class;
} } else if (cls == Short.class) {
else if (cls == Short.class) {
return short.class; return short.class;
} } else if (cls == Long.class) {
else if (cls == Long.class) {
return long.class; return long.class;
} } else if (cls == Float.class) {
else if (cls == Float.class) {
return float.class; return float.class;
} } else if (cls == Void.class) {
else if (cls == Void.class) {
return void.class; return void.class;
} } else {
else {
return null; return null;
} }
} }
/** /**
* Just concatenates getClassDescription(obj) and getMemberDescriptions(obj, withValues). * Just concatenates getClassDescription(obj) and getMemberDescriptions(obj,
* withValues).
* *
* @param obj target object * @param obj target object
* @param withValues if true, member values are displayed as well * @param withValues if true, member values are displayed as well
@@ -631,8 +620,8 @@ public class BeanInspector {
} }
/** /**
* Check for info methods on the object to be provided by the developer * Check for info methods on the object to be provided by the developer and
* and return their text as String. * return their text as String.
* *
* @param obj * @param obj
* @return String information about the object's class * @return String information about the object's class
@@ -657,9 +646,10 @@ public class BeanInspector {
} }
/** /**
* Return an info string on the members of the object class, containing name, type, optional * Return an info string on the members of the object class, containing
* value and tool tip text if available. The type is accompanied by a tag "common" or "restricted", * name, type, optional value and tool tip text if available. The type is
* indicating whether the member property is normal or hidden, meaning it may have effect depending * accompanied by a tag "common" or "restricted", indicating whether the
* member property is normal or hidden, meaning it may have effect depending
* on settings of other members only, for instance. * on settings of other members only, for instance.
* *
* @param obj target object * @param obj target object
@@ -683,9 +673,6 @@ public class BeanInspector {
} }
String name = m_Properties[i].getDisplayName(); String name = m_Properties[i].getDisplayName();
if (TRACE) {
System.out.println("PSP looking at "+ name);
}
Method getter = m_Properties[i].getReadMethod(); Method getter = m_Properties[i].getReadMethod();
Method setter = m_Properties[i].getWriteMethod(); Method setter = m_Properties[i].getWriteMethod();
@@ -760,7 +747,8 @@ public class BeanInspector {
} }
/** /**
* Take an object of primitive type (like int, Integer etc) and convert it to double. * Take an object of primitive type (like int, Integer etc) and convert it
* to double.
* *
* @param val * @param val
* @return * @return
@@ -769,36 +757,29 @@ public class BeanInspector {
public static double toDouble(Object val) throws IllegalArgumentException { public static double toDouble(Object val) throws IllegalArgumentException {
if (val instanceof Integer) { if (val instanceof Integer) {
return ((Integer) val).doubleValue(); return ((Integer) val).doubleValue();
} } else if (val instanceof Double) {
else if (val instanceof Double) {
return ((Double) val).doubleValue(); return ((Double) val).doubleValue();
} } else if (val instanceof Boolean) {
else if (val instanceof Boolean) {
return (((Boolean) val) ? 1. : 0.); return (((Boolean) val) ? 1. : 0.);
} } else if (val instanceof Character) {
else if (val instanceof Character) {
return ((Character) val).charValue(); return ((Character) val).charValue();
} } else if (val instanceof Byte) {
else if (val instanceof Byte) {
return ((Byte) val).doubleValue(); return ((Byte) val).doubleValue();
} } else if (val instanceof Short) {
else if (val instanceof Short) {
return ((Short) val).doubleValue(); return ((Short) val).doubleValue();
} } else if (val instanceof Long) {
else if (val instanceof Long) {
return ((Long) val).doubleValue(); return ((Long) val).doubleValue();
} } else if (val instanceof Float) {
else if (val instanceof Float) {
return ((Float) val).doubleValue(); return ((Float) val).doubleValue();
} } else if (val instanceof Void) {
else if (val instanceof Void) {
return 0; return 0;
} }
throw new IllegalArgumentException("Illegal type, cant convert " + val.getClass() + " to double."); throw new IllegalArgumentException("Illegal type, cant convert " + val.getClass() + " to double.");
} }
/** /**
* Take a String and convert it to a destined data type using the appropriate function. * Take a String and convert it to a destined data type using the
* appropriate function.
* *
* @param str * @param str
* @param destType * @param destType
@@ -807,29 +788,21 @@ public class BeanInspector {
public static Object stringToPrimitive(String str, Class<?> destType) throws NumberFormatException { public static Object stringToPrimitive(String str, Class<?> destType) throws NumberFormatException {
if ((destType == Integer.class) || (destType == int.class)) { if ((destType == Integer.class) || (destType == int.class)) {
return Integer.valueOf(str); return Integer.valueOf(str);
} } else if ((destType == Double.class) || (destType == double.class)) {
else if ((destType == Double.class) || (destType == double.class)) {
return Double.valueOf(str); return Double.valueOf(str);
} } else if ((destType == Boolean.class) || (destType == boolean.class)) {
else if ((destType == Boolean.class) || (destType == boolean.class)) {
return Boolean.valueOf(str); return Boolean.valueOf(str);
} } else if ((destType == Byte.class) || (destType == byte.class)) {
else if ((destType == Byte.class) || (destType == byte.class)) {
return Byte.valueOf(str); return Byte.valueOf(str);
} } else if ((destType == Short.class) || (destType == short.class)) {
else if ((destType == Short.class) || (destType == short.class)) {
return Short.valueOf(str); return Short.valueOf(str);
} } else if ((destType == Long.class) || (destType == long.class)) {
else if ((destType == Long.class) || (destType == long.class)) {
return Long.valueOf(str); return Long.valueOf(str);
} } else if ((destType == Float.class) || (destType == float.class)) {
else if ((destType == Float.class) || (destType == float.class)) {
return Float.valueOf(str); return Float.valueOf(str);
} } else if ((destType == Character.class) || (destType == char.class)) {
else if ((destType == Character.class) || (destType == char.class)) {
return str.charAt(0); return str.charAt(0);
} } else {
else {
// if (destType == Void.class) // if (destType == Void.class)
System.err.println("warning, value interpreted as void type"); System.err.println("warning, value interpreted as void type");
return 0; return 0;
@@ -849,28 +822,21 @@ public class BeanInspector {
} }
if ((destType == Integer.class) || (destType == int.class)) { if ((destType == Integer.class) || (destType == int.class)) {
return new Integer(d.intValue()); return new Integer(d.intValue());
} } else if ((destType == Boolean.class) || (destType == boolean.class)) {
else if ((destType == Boolean.class) || (destType == boolean.class)) {
return (d != 0) ? Boolean.TRUE : Boolean.FALSE; return (d != 0) ? Boolean.TRUE : Boolean.FALSE;
} } else if ((destType == Byte.class) || (destType == byte.class)) {
else if ((destType == Byte.class) || (destType == byte.class)) {
return new Byte(d.byteValue()); return new Byte(d.byteValue());
} } else if ((destType == Short.class) || (destType == short.class)) {
else if ((destType == Short.class) || (destType == short.class)) {
return new Short(d.shortValue()); return new Short(d.shortValue());
} } else if ((destType == Long.class) || (destType == long.class)) {
else if ((destType == Long.class) || (destType == long.class)) {
return new Long(d.longValue()); return new Long(d.longValue());
} } else if ((destType == Float.class) || (destType == float.class)) {
else if ((destType == Float.class) || (destType == float.class)) {
return new Float(d.floatValue()); return new Float(d.floatValue());
} } else { // this makes hardly sense...
else { // this makes hardly sense...
System.err.println("warning: converting from double to character or void..."); System.err.println("warning: converting from double to character or void...");
if ((destType == Character.class) || (destType == char.class)) { if ((destType == Character.class) || (destType == char.class)) {
return new Character(d.toString().charAt(0)); return new Character(d.toString().charAt(0));
} } else {
else {
return 0; return 0;
} }
} }
@@ -895,8 +861,9 @@ public class BeanInspector {
} }
/** /**
* Get the primitive class of a Java primitive encapsulation, or null if not applicable. * Get the primitive class of a Java primitive encapsulation, or null if not
* E.g., returns int for Integer, long for Long, Boolean for Boolean etc. * applicable. E.g., returns int for Integer, long for Long, Boolean for
* Boolean etc.
* *
* @param cls * @param cls
* @return * @return
@@ -907,30 +874,25 @@ public class BeanInspector {
} }
if (cls == Double.class) { if (cls == Double.class) {
return double.class; return double.class;
} } else if (cls == Integer.class) {
else if (cls == Integer.class) {
return int.class; return int.class;
} } else if (cls == Boolean.class) {
else if (cls == Boolean.class) {
return Boolean.class; return Boolean.class;
} } else if (cls == Byte.class) {
else if (cls == Byte.class) {
return byte.class; return byte.class;
} } else if (cls == Short.class) {
else if (cls == Short.class) {
return short.class; return short.class;
} } else if (cls == Long.class) {
else if (cls == Long.class) {
return long.class; return long.class;
} } else if (cls == Float.class) {
else if (cls == Float.class) {
return float.class; return float.class;
} }
return null; return null;
} }
/** /**
* Try to convert an object to a destination type, especially for primitive types (int, double etc. * Try to convert an object to a destination type, especially for primitive
* but also Integer, Double etc.). * types (int, double etc. but also Integer, Double etc.).
* *
* @param destType * @param destType
* @param value * @param value
@@ -945,8 +907,7 @@ public class BeanInspector {
if (destType == String.class || destType == SelectedTag.class) { if (destType == String.class || destType == SelectedTag.class) {
if (value.getClass() == String.class) { if (value.getClass() == String.class) {
return value; return value;
} } else {
else {
return value.toString(); return value.toString();
} }
} else if (isJavaPrimitive(destType)) { } else if (isJavaPrimitive(destType)) {
@@ -965,10 +926,9 @@ public class BeanInspector {
return value; return value;
} }
/** /**
* Try to get an object member value using the default getter. * Try to get an object member value using the default getter. Returns null
* Returns null if not successful. * if not successful.
* *
* @param obj * @param obj
* @param mem * @param mem
@@ -1004,9 +964,9 @@ public class BeanInspector {
} }
/** /**
* Try to set an object member to a given value. * Try to set an object member to a given value. Returns true if successful,
* Returns true if successful, else false. The types are adapted as generally as possible, * else false. The types are adapted as generally as possible, converting
* converting using the decodeType() method. * using the decodeType() method.
* *
* @param obj * @param obj
* @param mem * @param mem
@@ -1048,7 +1008,6 @@ public class BeanInspector {
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("Exception in invoking setter: " + e.getMessage()); System.err.println("Exception in invoking setter: " + e.getMessage());
// e.printStackTrace();
return false; return false;
} }
} else { } else {
@@ -1057,11 +1016,13 @@ public class BeanInspector {
} }
} }
/** This method simply looks for an appropriate tiptext /**
* This method simply looks for an appropriate tiptext
*
* @param name The name of the property * @param name The name of the property
* @param methods A list of methods to search. * @param methods A list of methods to search.
* @param target The target object * @param target The target object
* @return String for the tooltip. * @return String for the ToolTip.
*/ */
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target, boolean stripToolTipToFirstPoint, int toHTMLLen) { public static String getToolTipText(String name, MethodDescriptor[] methods, Object target, boolean stripToolTipToFirstPoint, int toHTMLLen) {
String result = ""; String result = "";
@@ -1100,7 +1061,7 @@ public class BeanInspector {
* @param name The name of the property * @param name The name of the property
* @param methods A list of methods to search. * @param methods A list of methods to search.
* @param target The target object * @param target The target object
* @return String for the tooltip. * @return String for the ToolTip.
*/ */
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target) { public static String getToolTipText(String name, MethodDescriptor[] methods, Object target) {
return getToolTipText(name, methods, target, false, 0); return getToolTipText(name, methods, target, false, 0);

View File

@@ -29,7 +29,6 @@ public class GOEPanel extends JPanel implements ItemListener {
private Object backupObject; private Object backupObject;
private PropertyChangeSupport propChangeSupport; private PropertyChangeSupport propChangeSupport;
private static boolean TRACE = false;
/** /**
* The chooser component * The chooser component
*/ */

View File

@@ -264,7 +264,6 @@ public class GenericObjectEditor implements PropertyEditor {
* @param type a value of type 'Class' * @param type a value of type 'Class'
*/ */
public void setClassType(Class<?> type) { public void setClassType(Class<?> type) {
//if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
classType = type; classType = type;
if (editorComponent != null) { if (editorComponent != null) {
editorComponent.updateClassType(); editorComponent.updateClassType();
@@ -337,7 +336,6 @@ public class GenericObjectEditor implements PropertyEditor {
*/ */
private void setObject(Object c) { private void setObject(Object c) {
// This should really call equals() for comparison. // This should really call equals() for comparison.
//if (TRACE) System.out.println("setObject "+ c.getClass().getName() + " " + c);
boolean trueChange = (c != getValue()); boolean trueChange = (c != getValue());
m_Backup = m_Object; m_Backup = m_Object;

View File

@@ -6,13 +6,14 @@ package eva2.gui;
*/ */
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* It represents one plot window in the client GUI. * It represents one plot window in the client GUI.
*/ */
public class GraphWindow { public class GraphWindow {
private static final Logger LOGGER = Logger.getLogger(GraphWindow.class.getName());
public static boolean TRACE = false;
static private int graphCounter = -1; static private int graphCounter = -1;
static private PlotContainer plotContainer; static private PlotContainer plotContainer;
private PlotInterface plotter; private PlotInterface plotter;
@@ -57,9 +58,6 @@ public class GraphWindow {
* *
*/ */
private GraphWindow(String plotName, String strx, String stry) { private GraphWindow(String plotName, String strx, String stry) {
if (TRACE) {
System.out.println("Constructor GraphWindow");
}
name = plotName; name = plotName;
plotter = new Plot(plotName, strx, stry, true); plotter = new Plot(plotName, strx, stry, true);
} }
@@ -76,9 +74,7 @@ public class GraphWindow {
*/ */
public Graph getNewGraph(String infoString) { public Graph getNewGraph(String infoString) {
graphCounter++; graphCounter++;
if (TRACE) { LOGGER.log(Level.FINEST, "Graph.getNewGraph No:{0} - {1} created.", new Object[]{graphCounter, infoString});
System.out.println("Graph.getNewGraph No:" + graphCounter + " - " + infoString);
}
return new Graph(infoString, plotter, graphCounter); return new Graph(infoString, plotter, graphCounter);
} }
} }
@@ -104,7 +100,7 @@ class PlotContainer extends ArrayList<GraphWindow> {
* *
*/ */
public boolean containsName(String name) { public boolean containsName(String name) {
GraphWindow temp = null; GraphWindow temp;
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
temp = (GraphWindow) (get(i)); temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) { if (name.equals(temp.getName())) {
@@ -130,7 +126,7 @@ class PlotContainer extends ArrayList<GraphWindow> {
return actualPlot; return actualPlot;
} }
} }
GraphWindow temp = null; GraphWindow temp;
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
temp = (GraphWindow) (get(i)); temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) { if (name.equals(temp.getName())) {

View File

@@ -9,20 +9,21 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.beans.*; import java.beans.*;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
/** /**
* *
*/ */
public class JExtMenu extends JMenu { public class JExtMenu extends JMenu {
public final static String ACTION = "Action"; public final static String ACTION = "Action";
/** /**
* *
*/ */
@@ -32,6 +33,7 @@ public class JExtMenu extends JMenu{
//setText(m.getText()); //setText(m.getText());
//setMnemonic(m.getMnemonic()); //setMnemonic(m.getMnemonic());
} }
/** /**
* *
*/ */
@@ -41,6 +43,7 @@ public class JExtMenu extends JMenu{
setText(m.getText()); setText(m.getText());
setMnemonic(m.getMnemonic()); setMnemonic(m.getMnemonic());
} }
/** /**
* *
*/ */
@@ -62,6 +65,7 @@ public class JExtMenu extends JMenu{
} }
return item; return item;
} }
/** /**
* *
*/ */
@@ -77,23 +81,18 @@ public class JExtMenu extends JMenu{
String propertyName = e.getPropertyName(); String propertyName = e.getPropertyName();
if (propertyName.equals(Action.NAME)) { if (propertyName.equals(Action.NAME)) {
menuItem.setText((String) e.getNewValue()); menuItem.setText((String) e.getNewValue());
} } else if (propertyName.equals("enabled")) {
else if(propertyName.equals("enabled")) {
menuItem.setEnabled(((Boolean) e.getNewValue()).booleanValue()); menuItem.setEnabled(((Boolean) e.getNewValue()).booleanValue());
} } else if (propertyName.equals(Action.SMALL_ICON)) {
else if(propertyName.equals(Action.SMALL_ICON)){
Icon icon = (Icon) e.getNewValue(); Icon icon = (Icon) e.getNewValue();
menuItem.setIcon(icon); menuItem.setIcon(icon);
menuItem.invalidate(); menuItem.invalidate();
menuItem.repaint(); menuItem.repaint();
} } else if (propertyName.equals(ExtAction.MNEMONIC)) {
else if(propertyName.equals(ExtAction.MNEMONIC)) {
menuItem.setMnemonic(((Character) e.getNewValue()).charValue()); menuItem.setMnemonic(((Character) e.getNewValue()).charValue());
} } else if (propertyName.equals(ExtAction.TOOLTIP)) {
else if(propertyName.equals(ExtAction.TOOLTIP)) {
menuItem.setToolTipText((String) e.getNewValue()); menuItem.setToolTipText((String) e.getNewValue());
} } else if (propertyName.equals(ExtAction.KEYSTROKE)) {
else if(propertyName.equals(ExtAction.KEYSTROKE)) {
menuItem.setAccelerator((KeyStroke) e.getNewValue()); menuItem.setAccelerator((KeyStroke) e.getNewValue());
} }
} }

View File

@@ -92,19 +92,6 @@ public class ModuleServer {
} }
} }
// and the running modules
// @todo running modules sind abgeschaltet
// for (int i = 0; i < m_RunnungModules.size(); i++) {
// String AdapterName = null;
// try {
// AdapterName = ( (ModuleAdapter) m_RunnungModules.get(i)).getAdapterName();
// }
// catch (Exception ee) {
// System.err.println("Error: GetAdapterName" + ee.getMessage());
// }
// ModuleNameList.add(AdapterName);
// }
String[] x = new String[moduleNameList.size()]; String[] x = new String[moduleNameList.size()];
moduleNameList.toArray(x); moduleNameList.toArray(x);
@@ -176,21 +163,6 @@ public class ModuleServer {
return (ModuleAdapter) moduleAdapter; return (ModuleAdapter) moduleAdapter;
} }
} }
// // @todo running modules sind gerade noch abgeschaltet
// for (int i = 0; i < m_RunnungModules.size(); i++) {
// try {
// adapterName = ( (ModuleAdapter) m_RunnungModules.get(i)).getAdapterName();
// }
// catch (Exception e) {
// System.out.println("Error : GetAdapterName" + e);
// }
// if (adapterName.equals(selectedModuleName)) {
// if (TRACE)
// System.out.println(" Choose a running Module!!! " + adapterName);
// m_ModuleAdapter = ( (ModuleAdapter) m_RunnungModules.get(i));
// return (ModuleAdapter) m_ModuleAdapter;
// }
// }
LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName); LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName);
return null; return null;

View File

@@ -6,12 +6,14 @@ import java.util.logging.Logger;
/** /**
* This class defines utility routines that use Java serialization. Any * This class defines utility routines that use Java serialization. Any
* serializable object can be stored to a file, loaded, and cloned (returning * serializable object can be stored to a file, loaded, and cloned (returning a
* a deep copy). * deep copy).
* *
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher, Marcel Kronfeld * @author Holger Ulmer, Felix Streichert, Hannes Planatscher, Marcel Kronfeld
**/ *
*/
public class Serializer { public class Serializer {
/** /**
* The logging instance for this class. * The logging instance for this class.
*/ */
@@ -20,19 +22,22 @@ public class Serializer {
/** /**
* Private constructor to prevent instantiating module class. * Private constructor to prevent instantiating module class.
*/ */
private Serializer() { } private Serializer() {
}
/** /**
* Serialize the object o (and any Serializable objects it refers to) and * Serialize the object o (and any Serializable objects it refers to) and
* store its serialized state in File f. If serializeInMem is true, the object * store its serialized state in File f. If serializeInMem is true, the
* is wrapped in a SerializedObject first, which seems to be more efficient than * object is wrapped in a SerializedObject first, which seems to be more
* writing a nested object directly to a file. * efficient than writing a nested object directly to a file.
* *
* @param o the object to write * @param o the object to write
* @param outStream The stream to write to * @param outStream The stream to write to
* @param serializeInMem flag whether to wrap the object in a SerializedObject * @param serializeInMem flag whether to wrap the object in a
* SerializedObject
* @throws IOException * @throws IOException
**/ *
*/
private static void store(Serializable o, OutputStream outStream, boolean serializeInMem) throws IOException { private static void store(Serializable o, OutputStream outStream, boolean serializeInMem) throws IOException {
ObjectOutputStream out = new ObjectOutputStream(outStream); ObjectOutputStream out = new ObjectOutputStream(outStream);
try { try {
@@ -49,14 +54,15 @@ public class Serializer {
} }
/** /**
* Deserialize the contents of File f and return the resulting object. * Deserialize the contents of File f and return the resulting object. A
* A SerializedObject is unwrapped once. * SerializedObject is unwrapped once.
* *
* @param inputStream The Input stream to read from * @param inputStream The Input stream to read from
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws IOException * @throws IOException
* @return The deserialized Object from the file * @return The deserialized Object from the file
**/ *
*/
private static Object load(final InputStream inputStream) throws IOException, ClassNotFoundException { private static Object load(final InputStream inputStream) throws IOException, ClassNotFoundException {
ObjectInputStream objInputStream = new ObjectInputStream(inputStream); ObjectInputStream objInputStream = new ObjectInputStream(inputStream);
Object ret = objInputStream.readObject(); Object ret = objInputStream.readObject();
@@ -68,13 +74,14 @@ public class Serializer {
} }
/** /**
* Use object serialization to make a "deep clone" of the object o. * Use object serialization to make a "deep clone" of the object o. This
* This method serializes o and all of its member objects, and then * method serializes o and all of its member objects, and then deserializes
* deserializes that graph of objects, which means that everything is * that graph of objects, which means that everything is copied. This
* copied. This differs from the clone() method of an object which is * differs from the clone() method of an object which is usually implemented
* usually implemented to produce a "shallow" clone that copies references * to produce a "shallow" clone that copies references to other objects,
* to other objects, instead of copying all referenced objects. * instead of copying all referenced objects.
**/ *
*/
public static Object deepClone(Object o) { public static Object deepClone(Object o) {
Object obj = null; Object obj = null;
try { try {
@@ -103,7 +110,8 @@ public class Serializer {
* *
* @param outStream The output stream * @param outStream The output stream
* @param data The string data * @param data The string data
**/ *
*/
public static void storeString(final OutputStream outStream, final String data) { public static void storeString(final OutputStream outStream, final String data) {
try { try {
outStream.write(data.getBytes()); outStream.write(data.getBytes());
@@ -113,12 +121,13 @@ public class Serializer {
} }
/** /**
* Deserialize the contents of the InputStream containing * Deserialize the contents of the InputStream containing a string and
* a string and return the resulting string. * return the resulting string.
* *
* @param inputStream The input stream to read from * @param inputStream The input stream to read from
* @return The deserialized data from the stream * @return The deserialized data from the stream
**/ *
*/
public static String loadString(final InputStream inputStream) { public static String loadString(final InputStream inputStream) {
StringBuilder sBuilder = new StringBuilder(); StringBuilder sBuilder = new StringBuilder();
try { try {
@@ -134,9 +143,9 @@ public class Serializer {
} }
/** /**
* Serialize the string s and * Serialize the string s and store its serialized state in File with name
* store its serialized state in File with name Filename. * Filename.
**/ */
public static void storeObject(OutputStream outStream, Serializable s) { public static void storeObject(OutputStream outStream, Serializable s) {
try { try {
store(s, outStream, true); store(s, outStream, true);
@@ -146,21 +155,23 @@ public class Serializer {
} }
/** /**
* Deserialize the contents of File with given name containing * Deserialize the contents of File with given name containing a string and
* a string and return the resulting string. If the indicated file * return the resulting string. If the indicated file doesn't exist or an
* doesnt exist or an error occurs, null is returned. * error occurs, null is returned.
**/ *
*/
public static Object loadObject(InputStream inputStream) { public static Object loadObject(InputStream inputStream) {
return loadObject(inputStream, true); return loadObject(inputStream, true);
} }
/** /**
* Deserialize the contents of File with given name containing * Deserialize the contents of File with given name containing a string and
* a string and return the resulting string. If the indicated file * return the resulting string. If the indicated file doesn't exist or an
* doesnt exist or an error occurs, null is returned. * error occurs, null is returned. If casually is false, an error message is
* If casually is false, an error message is printed and an exception * printed and an exception is raised if the file was not found or an error
* is raised if the file was not found or an error occured on loading. * occured on loading.
**/ *
*/
public static Object loadObject(InputStream inputStream, boolean casually) { public static Object loadObject(InputStream inputStream, boolean casually) {
Object serializedObject = null; Object serializedObject = null;