Package org.tinyuml.draw

Examples of org.tinyuml.draw.Node


  /**
   * Tests generation between two nodes that can be aligned in SE-NW (\)
   * direction.
   */
  public void testCalculateLineSegmentsWithNodesSeNw() {
    Node node1 = new MyNode();
    node1.setOrigin(10, 10);
    node1.setSize(120, 80);
    Node node2 = new MyNode();
    node2.setOrigin(150, 120);
    node2.setSize(80, 30);
    // goes from top left to bottom right
    List<Point2D> points = builder.calculateLineSegments(node1, node2);
    assertEquals(3, points.size());
    assertEquals(node1.getAbsoluteX2(), points.get(0).getX());
    assertEquals(node1.getAbsCenterY(), points.get(0).getY());
    assertEquals(node2.getAbsCenterX(), points.get(2).getX());
    assertEquals(node2.getAbsoluteY1(), points.get(2).getY());
   
    // reverse directions
    points = builder.calculateLineSegments(node2, node1);
    assertEquals(3, points.size());
    assertEquals(node2.getAbsoluteX1(), points.get(0).getX());
    assertEquals(node2.getAbsCenterY(), points.get(0).getY());
    assertEquals(node1.getAbsCenterX(), points.get(2).getX());
    assertEquals(node1.getAbsoluteY2(), points.get(2).getY());
  }
View Full Code Here


   */
  private void createAndAddShape(Attributes attributes) throws SAXException {
    currentNode = null;
    int elementId = Integer.valueOf(attributes.getValue("element-id"));
    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) {
View Full Code Here

   */
  private void createAndAddShape(Attributes attributes) throws SAXException {
    currentNode = null;
    int elementId = Integer.valueOf(attributes.getValue("element-id"));
    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) {
View Full Code Here

   */
  private void createAndAddShape(Attributes attributes) throws SAXException {
    currentNode = null;
    int elementId = Integer.valueOf(attributes.getValue("element-id"));
    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) {
View Full Code Here

   */
  private void createAndAddShape(Attributes attributes) throws SAXException {
    currentNode = null;
    int elementId = Integer.valueOf(attributes.getValue("element-id"));
    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) {
View Full Code Here

  /**
   * Tests clone() method.
   */
  public void testClone() {
    MyCompositeNode node = new MyCompositeNode();
    Node child = new MyCompositeNode();
    node.addChild(child);
    MyCompositeNode cloned = (MyCompositeNode) node.clone();
   
    // AbstractCompositeNode
    assertEquals(node.getChildren().size(), cloned.getChildren().size());
View Full Code Here

    MyCompositeNode node = new MyCompositeNode();
    node.setParent(parent);
    node.setOrigin(0, 0);
    node.setSize(100, 100);
    // test parent assignment
    Node child = new MyCompositeNode();
    child.setOrigin(5, 5);
    child.setSize(10, 10);
    // add the same child twice
    node.addChild(child);
    node.addChild(child);
    assertEquals("child should only be added once",
      1, node.getChildren().size());
    assertEquals(node, child.getParent());
    node.removeChild(child);
    assertEquals(node, child.getParent());

    // test getChildAt()
    node.addChild(child);
    assertEquals(child, node.getChildAt(8, 8));
    assertEquals(NullElement.getInstance(), node.getChildAt(15, 18));
View Full Code Here

    CompositeNode child = new MyCompositeNode();
    child.setOrigin(5, 5);
    child.setSize(80, 80);
    node.addChild(child);

    Node childchild = new MyCompositeNode();
    childchild.setOrigin(5, 5);
    childchild.setSize(70, 70);
    child.addChild(childchild);
   
    // retrieve childchild
    assertEquals(childchild, node.getChildAt(15, 20));
    assertEquals(node, child.getParent());
    assertEquals(child, childchild.getParent());
   
    assertTrue(childchild.isAncestor(child));
    assertTrue(childchild.isAncestor(parent));
    assertTrue(child.isAncestor(parent));
    assertFalse(parent.isAncestor(child));
    assertFalse(child.isAncestor(childchild));
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void mousePressed(EditorMouseEvent event) {
    CompositeElement parent = editor.getDiagram();
    Node element = createElement();
    element.setOrigin(parent.getMappedX(event.getX()), parent.getMappedY(
      event.getY()));
    AddElementCommand createCommand = new AddElementCommand(editor,
      editor.getDiagram(), element);
    editor.execute(createCommand);
  }
View Full Code Here

  /**
   * Tests clone() method.
   */
  public void testClone() {
    MyCompositeNode node = new MyCompositeNode();
    Node child = new MyCompositeNode();
    node.addChild(child);
    MyCompositeNode cloned = (MyCompositeNode) node.clone();
   
    // AbstractCompositeNode
    assertEquals(node.getChildren().size(), cloned.getChildren().size());
View Full Code Here

TOP

Related Classes of org.tinyuml.draw.Node

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.