Package org.tinyuml.umldraw.structure

Examples of org.tinyuml.umldraw.structure.ClassElement


   * Tests the creation of an Association.
   */
  public void testCreateAssociation() {
    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.CLASS)).will(returnValue(clss));
    ClassElement class1 = factory.createClass();
    ClassElement class2 = factory.createClass();

    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(RelationType.DEPENDENCY)).will(returnValue(assoc));

    Association conn = (Association) factory.createAssociation(class1, class2);
    assertEquals(assoc, conn.getModelElement());
    assertEquals(class1, conn.getNode1());
    assertEquals(class2, conn.getNode2());
    assertEquals(1, class1.getConnections().size());
    assertEquals(1, class2.getConnections().size());
    assertNull(conn.getParent());   
  }
View Full Code Here


   * Tests the creation of a note connection.
   */
  public void testCreateNoteConnection() {
    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.CLASS)).will(returnValue(clss));
    ClassElement clss = factory.createClass();
    NoteElement note = factory.createNote();
    NoteConnection conn = (NoteConnection)
      factory.createNoteConnection(clss, note);
    assertEquals(clss, conn.getNode1());
    assertEquals(note, conn.getNode2());
    assertEquals(1, clss.getConnections().size());
    assertEquals(1, note.getConnections().size());
    assertNull(conn.getParent());
  }
View Full Code Here

    mockAttrCompartment.expects(once()).method("setAlignment")
      .with(eq(Alignment.LEFT));
    mockOpCompartment.expects(once()).method("setAlignment")
      .with(eq(Alignment.LEFT));
   
    mockedElement = new ClassElement(umlclass,
      (Compartment) mockMainCompartment.proxy(),
      (Compartment) mockAttrCompartment.proxy(),
      (Compartment) mockOpCompartment.proxy());
  }
View Full Code Here

    int shapeId = Integer.valueOf(attributes.getValue("id"));
    Node shape = null;

    NamedElement elem = elementMap.get(elementId);
    if (elem instanceof UmlClass) {
      shape = new ClassElement((UmlClass) elem);
    } else if (elem instanceof UmlPackage) {
      shape = diagram.getElementFactory().createPackage((UmlPackage) elem);
    } else if (elem instanceof UmlComponent) {
      shape = new ComponentElement((UmlComponent) elem);
    }
View Full Code Here

 
  /**
   * Tests the creation of an Association.
   */
  public void testCreateAssociation() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);

    Association conn = (Association) factory.createConnection(
      RelationType.ASSOCIATION, class1, class2);
    assertStdConnectionConditions(conn, class1, class2);
    Relation relation = (Relation) conn.getModelElement();
View Full Code Here

 
  /**
   * Tests the creation of a Composition.
   */
  public void testCreateComposition() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);
   
    Association composition = (Association) factory.createConnection(
      RelationType.COMPOSITION, class1, class2);
    assertStdConnectionConditions(composition, class1, class2);
    Relation umlcomp = (Relation) composition.getModelElement();
View Full Code Here

 
  /**
   * Tests the creation of an Aggregation.
   */
  public void testCreateAggregation() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);
   
    Association composition = (Association) factory.createConnection(
      RelationType.AGGREGATION, class1, class2);
    assertStdConnectionConditions(composition, class1, class2);
    Relation umlcomp = (Relation) composition.getModelElement();
View Full Code Here

  /**
   * Tests the creation of a note connection.
   */
  public void testCreateNoteConnection() {
    ClassElement clss = (ClassElement) factory.createNode(ElementType.CLASS);
    NoteElement note = (NoteElement) factory.createNode(ElementType.NOTE);
    NoteConnection conn = (NoteConnection)
      factory.createConnection(RelationType.NOTE_CONNECTOR, clss, note);
    assertStdConnectionConditions(conn, clss, note);
    assertNull(conn.getModelElement());
View Full Code Here

 
  /**
   * Tests the clone() method.
   */
  public void testClone() {
    ClassElement cloned = (ClassElement) element.clone();
    assertEquals(1, cloned.getModelElement().getModelElementListeners().size());
    assertTrue(cloned.getModelElement().getModelElementListeners()
      .contains(cloned));
    assertTrue(cloned.getModelElement() != element.getModelElement());
    assertTrue(cloned != element);
    assertTrue(cloned.getMainCompartment() != element.getMainCompartment());
    assertTrue(cloned.getMainCompartment().getParent() == cloned);
    assertTrue(cloned.getAttributesCompartment() !=
               element.getAttributesCompartment());
    assertTrue(cloned.getAttributesCompartment().getParent() == cloned);
    assertTrue(cloned.getOperationsCompartment() !=
               element.getOperationsCompartment());
    assertTrue(cloned.getOperationsCompartment().getParent() == cloned);
   
    // Tests the main label
    assertTrue(cloned.getMainLabel() != element.getMainLabel());
    assertEquals(1, cloned.getMainCompartment().getLabels().size());
    assertEquals(cloned.getMainLabel(),
      cloned.getMainCompartment().getLabels().get(0));
    assertTrue(cloned.getMainCompartment() == cloned.getMainLabel().getParent());
    assertTrue(cloned == cloned.getMainLabel().getSource());
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void editProperties(DiagramElement element) {
    if (element instanceof ClassElement) {
      ClassElement classElement = (ClassElement) element;
      UmlClass umlclass = (UmlClass) classElement.getModelElement();
      EditClassDialog dialog = new EditClassDialog(frame, classElement, true);
      dialog.setLocationRelativeTo(frame);
      dialog.setVisible(true);
      if (dialog.isOk()) {
        umlclass.setAbstract(dialog.classIsAbstract());
        classElement.setShowOperations(dialog.showOperations());
        classElement.setShowAttributes(dialog.showAttributes());
        classElement.setShowStereotypes(dialog.showStereotypes());
        umlclass.setMethods(dialog.getMethods());
        umlclass.setAttributes(dialog.getAttributes());
        umlclass.setStereotypes(dialog.getStereotypes());
      }
    }
View Full Code Here

TOP

Related Classes of org.tinyuml.umldraw.structure.ClassElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.