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); }
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; }
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(); } }