/** * Produces a ChartingPropertyInspector which tracks property number index from the given * properties list, stored in the provided parent frame, and applied in the given simulation. This * constructor will give the user a chance to cancel the construction, in which case * validInspector will be set to false, and generator may be set to null. In that case, assume * that the inspector will be deleted immediately after. */ public ChartingPropertyInspector( Properties properties, int index, Frame parent, final GUIState simulation) { super(properties, index, parent, simulation); generator = chartToUse(properties.getName(index), parent, simulation); globalAttributes = findGlobalAttributes(); // so we share timer information. If null, we're in trouble. validInspector = (generator != null); }
/** * Returns the name of the given property. Returns null if the index is out of the range [0 ... * numProperties() - 1 ] */ public String getName(int index) { if (auxillary != null) return auxillary.getName(index); if (index < 0 || index >= numProperties()) return null; try { if (nameMethods.get(index) != null) return (String) (((Method) (nameMethods.get(index))).invoke(object, new Object[0])); } catch (Exception e) { e.printStackTrace(); return null; } String name = ((Method) (getMethods.get(index))).getName(); if (name.startsWith("is")) return name.substring(2); else if (name.equals("longValue")) // Integers of various kinds return "Value"; else if (name.equals("doubleValue")) // Other Numbers return "Value"; else if (name.equals("booleanValue")) // Booleans return "Value"; else if (name.equals("toString")) // Strings, StringBuffers return "Value"; else return name.substring(3); // "get", "set" }