예제 #1
0
 /**
  * Appends a whole StyledDocument to the end of the current document, by adding all the elements
  * of the latter to the end of the former.
  *
  * @param doc The StyledDocument to add to the end of current document.
  */
 public void append(StyledDocument doc) {
   if (doc != null) {
     for (int i = 0; i < doc.getLength(); i++) {
       elements.add((StyledElement) doc.getStyledElement(i));
     }
   }
 }
예제 #2
0
  /**
   * 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;
  }
예제 #3
0
  /**
   * 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);
  }