/** * Creates a new instance of ClassNode. Examines LEM Class object and creates subtrees based on * the objects attributes, state machine and events. * * @param c LEM class object to be contained. */ public ClassNode(org.jdns.xtuml.metamodel.Class c) { this.thisClass = c; attributeListing = new StyledDocument(); Iterator i = c.getAllAttributes().iterator(); while (i.hasNext()) { AttributeNode attribute = new AttributeNode((org.jdns.xtuml.metamodel.Attribute) i.next(), null, null); add(attribute); attributeListing.append(attribute.getStyledDocument()); } StateMachine m = thisClass.getStateMachine(); if (m != null) { add(new StateMachineNode(m)); } Iterator j = thisClass.getEvents().iterator(); if (!j.hasNext()) return; DefaultMutableTreeNode eventLevel = new DefaultMutableTreeNode("Events"); while (j.hasNext()) { eventLevel.add(new EventNode((Event) j.next())); } add(eventLevel); }
/** * Returns StyledDocument object containing preformatted LEM Class description, followed by the * list of attributes that the Class has. * * @return the StyledDocument of the ClassNode. */ public StyledDocument getStyledDocument() { StyledDocument doc = new StyledDocument(); SimpleAttributeSet s = new SimpleAttributeSet(); StyleConstants.setFontFamily(s, "Times New Roman"); StyleConstants.setFontSize(s, 14); StyleConstants.setBold(s, true); StyleConstants.setForeground(s, Color.blue); StyledElement element = new StyledElement(toString() + "\n", s); doc.addStyle(element); SimpleAttributeSet s1 = new SimpleAttributeSet(); StyleConstants.setFontFamily(s1, "Times New Roman"); StyleConstants.setFontSize(s1, 14); StyleConstants.setBold(s1, false); StyleConstants.setForeground(s1, Color.black); StyledElement element1 = new StyledElement(getDescription(), s1); doc.addStyle(element1); StyledElement element2 = new StyledElement("\n-------------- Attributes ----------------\n", s1); doc.addStyle(element2); doc.append(attributeListing); return doc; }