Author: tfmorris Date: 2008-10-15 17:06:40-0700 New Revision: 15929 Modified: trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java
Log: Use StringBuffer for efficiency. Protect against null pointers. Modified: trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java?view=diff&rev=15929&p1=trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java&p2=trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java&r1=15928&r2=15929 ============================================================================== --- trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java (original) +++ trunk/modules/dev/src/org/argouml/dev/figinspector/FigInspectorPanel.java 2008-10-15 17:06:40-0700 @@ -155,27 +155,43 @@ return null; } String className = f.getClass().getName(); - String descr = className.substring(className.lastIndexOf(".") + 1); - descr += + StringBuffer descr = new StringBuffer( + className.substring(className.lastIndexOf(".") + 1)); +// descr.append(" paints=").append(f.getPaintCount()); +// descr.append(" damages=").append(f.getDamageCount()); + descr.append( " bounds=[" + f.getX() + "," + f.getY() + "," + f.getWidth() - + "," + f.getHeight() + "]"; - descr += + + "," + f.getHeight() + "]"); + descr.append( " fill=[" + f.getFillColor().getRed() + "," + f.getFillColor().getGreen() + "," - + f.getFillColor().getBlue() + "]"; + + f.getFillColor().getBlue() + "]"); if (f.getOwner() != null) { - descr += " - owner=" + f.getOwner(); + descr.append(" - owner=").append(f.getOwner()); } if (f instanceof FigText) { - descr += " \"" + ((FigText) f).getText() + "\""; + descr.append(" \"").append(((FigText) f).getText()).append("\""); } if (!f.isVisible()) { - descr += " - INVISIBLE"; + descr.append(" - INVISIBLE"); } if (f.isFilled()) { - descr += " - FILLED"; + descr.append(" - FILLED"); + } + + descr.append(" - lay=").append(toString(f.getLayer())); + descr.append(" - grp=").append(toString(f.getGroup())); + return descr.toString(); + } + + private static String toString(Object o) { + if (o == null) { + return "null"; + } + try { + return o.toString(); + } catch (Throwable e) { + return "???"; } - descr += " - lay=" + f.getLayer() + " - grp=" + f.getGroup(); - return descr; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
