/** * Find the Icon for a given model element. * * @return The Icon or <code>null</code> if there is no Icon. * @param value The model element. * <p>TODO: This should not use string matching on classnames to do this since this means that * we have knowledge about how the model elements are implemented outside of the Model * component. */ public Icon lookupIcon(Object value) { if (value == null) { throw new IllegalArgumentException("Attempted to get an icon given a null key"); } if (value instanceof String) { return null; } Icon icon = iconCache.get(value.getClass()); try { if (Model.getFacade().isAPseudostate(value)) { Object kind = Model.getFacade().getKind(value); DataTypesHelper helper = Model.getDataTypesHelper(); if (helper.equalsINITIALKind(kind)) { icon = initialStateIcon; } if (helper.equalsDeepHistoryKind(kind)) { icon = deepIcon; } if (helper.equalsShallowHistoryKind(kind)) { icon = shallowIcon; } if (helper.equalsFORKKind(kind)) { icon = forkIcon; } if (helper.equalsJOINKind(kind)) { icon = joinIcon; } if (helper.equalsCHOICEKind(kind)) { icon = branchIcon; } if (helper.equalsJUNCTIONKind(kind)) { icon = junctionIcon; } // if (MPseudostateKind.FINAL.equals(kind)) // icon = _FinalStateIcon; } if (Model.getFacade().isAAbstraction(value)) { icon = realizeIcon; } if (Model.getFacade().isAException(value)) { icon = exceptionIcon; } else { // needs more work: sending and receiving icons if (Model.getFacade().isASignal(value)) { icon = signalIcon; } } if (Model.getFacade().isAComment(value)) { icon = commentIcon; } if (icon == null) { String cName = Model.getMetaTypes().getName(value); icon = lookupIconResource(cName); if (icon == null) { LOG.log(Level.FINE, "Can't find icon for {0}", cName); } else { synchronized (iconCache) { iconCache.put(value.getClass(), icon); } } } } catch (InvalidElementException e) { LOG.log(Level.FINE, "Attempted to get icon for deleted element"); return null; } return icon; }