示例#1
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());
    }
  }
示例#2
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);
 }
示例#3
0
文件: GenEps.java 项目: aaronc/UMLet
 public void createEpsToStream(
     OutputStream outputStream, DiagramHandler handler) { // create and write stream to file
   try {
     PrintWriter bw = new PrintWriter(outputStream);
     EpsGraphics2D grapics2d = new EpsGraphics2D("umlet_diagram");
     handler.getDrawPanel().paintEntitiesIntoGraphics2D(grapics2d);
     bw.print(grapics2d.toString());
     bw.flush();
     bw.close();
   } catch (Exception fnfe) {
     System.out.println("UMLet: Error: Exception in createEpsToStream: " + fnfe);
   }
 }