Beispiel #1
0
 private void addElementToDiagram(
     Entity e, DiagramHandler d, boolean setchanged, Rectangle bounds, String state) {
   Entity e2 = e.CloneFromMe();
   e2.assignToDiagram(d);
   e2.setState(state);
   e2.setBounds(bounds);
   d.getDrawPanel().add(e2);
   if (setchanged) d.setChanged(true);
 }
Beispiel #2
0
  @Override
  public boolean contains(Point p) {
    Rectangle bounds = this.getVisibleRect();
    if (!bounds.contains(p)) return false;

    Vector<Entity> entities = this.handler.getDrawPanel().getNotInGroupEntitiesOnPanel();
    for (Entity other : entities) {
      if (other instanceof Relation) { // a relation is always on top
        // move point to coordinate system of other entity
        Point other_p =
            new Point(p.x + this.getX() - other.getX(), p.y + this.getY() - other.getY());
        if (other.contains(other_p)) return false;
      }

      // If the this visibleRect is equal to the other VisibleRect, true will be returned. Otherwise
      // we need to check further
      else if (!this.getVisibleRect().equals(other.getVisibleRect())) {
        Rectangle other_bounds = other.getVisibleRect();
        // move bounds to coordinate system of this component
        other_bounds.x += other.getX() - this.getX();
        other_bounds.y += other.getY() - this.getY();
        if (other_bounds.contains(
            p)) { // the selected element has to be in front except if the other element is totally
          // contained!
          if (bounds.contains(other_bounds)
              || (other.isSelected() && !other_bounds.contains(bounds))) return false;
        }
      }
    }
    return true;
  }
Beispiel #3
0
  // reloads the element on all open panels and adds it to the custom element panel if not already
  // there.
  private void updateElement(Entity element) {

    //		if a new element has been created add it to current diagram
    if (this.originalElement == null) {
      DiagramHandler current = null;
      DrawPanel c = Umlet.getInstance().getGUI().getCurrentDiagram();
      if (c == null) {
        Umlet.getInstance().doNew();
        current = Umlet.getInstance().getGUI().getCurrentDiagram().getHandler();
      } else current = c.getHandler();

      Vector<Entity> ents = current.getDrawPanel().getAllEntities();
      // set location for element
      int x = 10, y = 10;
      for (Entity e : ents) {
        if (e.getY() + e.getHeight() + 10 > y) y = e.getY() + e.getHeight() + 10;
      }

      Rectangle bounds = new Rectangle(x, y, element.getWidth(), element.getHeight());
      this.addElementToDiagram(element, current, true, bounds, element.getState());
    } else { // replace edited element (and ONLY edited element)
      this.originalElement.getHandler().getDrawPanel().remove(this.originalElement);
      this.addElementToDiagram(
          element,
          this.originalElement.getHandler(),
          true,
          this.originalElement.getBounds(),
          this.originalElement.getState());
    }
  }
Beispiel #4
0
 public Entity CloneFromMe() {
   try { // LME
     java.lang.Class<? extends Entity> cx = this.getClass(); // get class of dynamic object
     Entity c = cx.newInstance();
     c.setState(this.getPanelAttributes()); // copy states
     c.setBounds(this.getBounds());
     return c;
   } catch (InstantiationException e) {
     System.err.println("UMLet -> Entity/" + this.getClass().toString() + ": " + e);
   } catch (IllegalAccessException e) {
     System.err.println("UMLet -> Entity/" + this.getClass().toString() + ": " + e);
   }
   return null;
 }
Beispiel #5
0
  private void updatePreview(Entity e) {
    if (e != null) {
      Vector<Entity> entities = this.preview.getDrawPanel().getAllEntities();
      if (entities.size() > 0) {
        e.setBounds(entities.get(0).getBounds());
        e.setState(entities.get(0).getState());
        if (this.preview.getDrawPanel().getSelector().getSelectedEntities().size() > 0)
          this.preview.getDrawPanel().getSelector().singleSelectWithoutUpdatePropertyPanel(e);
        this.preview.getDrawPanel().remove(entities.get(0));
      }

      e.assignToDiagram(this.preview);
      this.preview.getDrawPanel().add(e);
      e.repaint();
    }
  }