Source Code Cross Referenced for Umlet.java in  » UML » umlet » com » umlet » control » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » umlet » com.umlet.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // The UMLet source code is distributed under the terms of the GPL; see license.txt
0002:        package com.umlet.control;
0003:
0004:        import java.awt.*;
0005:        import java.awt.event.*;
0006:        import java.io.*;
0007:        import java.util.*;
0008:        import java.util.List;
0009:
0010:        import javax.swing.*;
0011:        import javax.swing.filechooser.*;
0012:
0013:        import org.w3c.dom.Element;
0014:        import org.w3c.dom.Document;
0015:        import javax.xml.transform.*;
0016:        import javax.xml.transform.dom.*;
0017:        import javax.xml.transform.stream.*;
0018:        import javax.xml.parsers.*;
0019:
0020:        import com.umlet.control.io.*;
0021:        import com.umlet.element.base.*;
0022:        import com.umlet.element.base.Class;
0023:        import com.umlet.element.base.Package;
0024:        import com.umlet.help.StartUpHelpLabel;
0025:        import com.umlet.plugin.UmletPlugin; //LME
0026:
0027:        /**
0028:         * <p>Title: </p>
0029:         * <p>Description: </p>
0030:         * <p>Copyright: Copyright (c) 2001</p>
0031:         * <p>Company: </p>
0032:         * @author unascribed
0033:         * @version 1.0
0034:         */
0035:
0036:        // 3.2.: 8h, neu starten
0037:        // 4.2.: 6h, Klassen
0038:        // 5.2.:     Interfaces
0039:        public class Umlet extends JComponent {
0040:
0041:            protected static String CUSTOM_ELEMENTS_PATH = "custom_elements/"; //LME
0042:
0043:            JFileChooser _chooser = new JFileChooser(System
0044:                    .getProperty("user.dir"));
0045:            public static UmletPluginHandler pluginHandler = null;
0046:
0047:            private static boolean _isPlugggedIn = false;
0048:
0049:            public static boolean isPlugggedIn() {
0050:                return _isPlugggedIn;
0051:            }
0052:
0053:            public static void setIsPluggedIn(boolean _plugged) {
0054:                _isPlugggedIn = _plugged;
0055:            };
0056:
0057:            private static boolean _isEmbedded = false;
0058:
0059:            public static boolean isEmbedded() {
0060:                return _isEmbedded;
0061:            }
0062:
0063:            public static void setIsEmbedded(boolean _isEmbed) {
0064:                _isEmbedded = _isEmbed;
0065:            };
0066:
0067:            public JFrame window;
0068:
0069:            public void createFrame() {
0070:                window = new JFrame();
0071:                window.setContentPane(this );
0072:            }
0073:
0074:            public class DrawPanel extends JPanel {
0075:                private JScrollPane _scr;
0076:                private int _incx = 0;
0077:                private int _incy = 0;
0078:
0079:                public Dimension getPreferredSize() {
0080:                    int retx = 0;
0081:                    int rety = 0;
0082:                    for (int i = 0; i < getComponents().length; i++) {
0083:                        Component c = getComponent(i);
0084:                        int x = c.getX() + c.getWidth();
0085:                        int y = c.getY() + c.getHeight();
0086:                        if (x > retx)
0087:                            retx = x;
0088:                        if (y > rety)
0089:                            rety = y;
0090:                    }
0091:                    if (_incx > 0) {
0092:                        int viewsx = _scr.getViewport().getWidth();
0093:                        if (viewsx + _incx > retx)
0094:                            retx = viewsx + _incx;
0095:                    }
0096:                    if (_incy > 0) {
0097:                        int viewsy = _scr.getViewport().getHeight();
0098:                        if (viewsy + _incy > rety)
0099:                            rety = viewsy + _incy;
0100:                    }
0101:                    return new Dimension(retx, rety);
0102:                }
0103:
0104:                public void setScrollPanel(JScrollPane scr) {
0105:                    _scr = scr;
0106:                    scr.setViewportView(this );
0107:                }
0108:
0109:                public JScrollPane getScrollPanel() {
0110:                    return _scr;
0111:                }
0112:
0113:                public void incViewPosition(int incx, int incy) {
0114:                    _incx += incx;
0115:                    _incy += incy;
0116:                    Point viewp = _scr.getViewport().getViewPosition();
0117:                    _scr.getViewport().setViewSize(getPreferredSize());
0118:                    _scr.getViewport().setViewPosition(
0119:                            new Point(viewp.x + incx, viewp.y + incy));
0120:                }
0121:
0122:                /*       public void paint(Graphics g) {
0123:                 super.paint(g);
0124:                 for(int x = 0;x<this.getWidth();x+=10) {
0125:                 for(int y = 0;y<this.getWidth();y+=10) {
0126:                 g.drawLine(x,y,x,y);
0127:                 }
0128:                 }
0129:                 }*/
0130:            }
0131:
0132:            public String getHomePath() { //LME: retrieve the home directory
0133:                String homePath = "";
0134:                if (isPlugggedIn())
0135:                    homePath = UmletPlugin.getHomePath();
0136:                else {
0137:                    //System.out.println("loading palette from file...");
0138:                    homePath = "./";
0139:                }
0140:                return homePath;
0141:            }
0142:
0143:            private void generateElementTree(Document doc,
0144:                    List<Entity> entities, Element current, Group group) {
0145:                //list of elements that are not inserted yet (to increase performance)
0146:                List<Entity> toBeCheckedAgain = new ArrayList<Entity>();
0147:                List<Group> insert_groups = new ArrayList<Group>();
0148:                for (Entity e : entities) {
0149:                    //only insert element in right grouping element
0150:                    boolean insert_here = false;
0151:                    if (group == null && e.getGroup() == null)
0152:                        insert_here = true;
0153:                    else if (group != null)
0154:                        if (group.equals(e.getGroup()))
0155:                            insert_here = true;
0156:
0157:                    if (insert_here) {
0158:                        if (e instanceof  Group)
0159:                            insert_groups.add((Group) e);
0160:                        else //insert normal entity element
0161:                        {
0162:                            java.lang.Class c = e.getClass();
0163:                            String sElType = c.getName();
0164:                            int[] coor = e.getCoordinates();
0165:                            String sElPanelAttributes = e.getPanelAttributes();
0166:                            String sElAdditionalAttributes = e
0167:                                    .getAdditionalAttributes();
0168:
0169:                            Element el = doc.createElement("element");
0170:                            current.appendChild(el);
0171:
0172:                            Element elType = doc.createElement("type");
0173:                            elType.appendChild(doc.createTextNode(sElType));
0174:                            el.appendChild(elType);
0175:
0176:                            Element elCoor = doc.createElement("coordinates");
0177:                            el.appendChild(elCoor);
0178:
0179:                            Element elX = doc.createElement("x");
0180:                            elX.appendChild(doc.createTextNode("" + coor[0]));
0181:                            elCoor.appendChild(elX);
0182:
0183:                            Element elY = doc.createElement("y");
0184:                            elY.appendChild(doc.createTextNode("" + coor[1]));
0185:                            elCoor.appendChild(elY);
0186:
0187:                            Element elW = doc.createElement("w");
0188:                            elW.appendChild(doc.createTextNode("" + coor[2]));
0189:                            elCoor.appendChild(elW);
0190:
0191:                            Element elH = doc.createElement("h");
0192:                            elH.appendChild(doc.createTextNode("" + coor[3]));
0193:                            elCoor.appendChild(elH);
0194:
0195:                            Element elPA = doc
0196:                                    .createElement("panel_attributes");
0197:                            elPA.appendChild(doc
0198:                                    .createTextNode(sElPanelAttributes));
0199:                            el.appendChild(elPA);
0200:
0201:                            Element elAA = doc
0202:                                    .createElement("additional_attributes");
0203:                            elAA.appendChild(doc
0204:                                    .createTextNode(sElAdditionalAttributes));
0205:                            el.appendChild(elAA);
0206:                        }
0207:                    } else
0208:                        toBeCheckedAgain.add(e);
0209:                }
0210:
0211:                for (Group g : insert_groups) {
0212:                    Element el = doc.createElement("group");
0213:                    current.appendChild(el);
0214:                    generateElementTree(doc, toBeCheckedAgain, el, g);
0215:                }
0216:            }
0217:
0218:            //[UB]: rewrote this function to use dom instead of
0219:            //      jdom.
0220:            public String createStringToBeSaved() {
0221:                Component[] components = this .getPanel().getComponents();
0222:                List<Entity> entities = new ArrayList<Entity>();
0223:                for (int i = 0; i < components.length; i++) {
0224:                    if (components[i] instanceof  Entity)
0225:                        entities.add((Entity) components[i]);
0226:                }
0227:
0228:                DocumentBuilder db = null;
0229:                try {
0230:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
0231:                            .newInstance();
0232:                    db = dbf.newDocumentBuilder();
0233:                } catch (Exception e) {
0234:                    System.err.println("Error saving XML.");
0235:                }
0236:                Document doc = db.newDocument();
0237:
0238:                Element root = doc.createElement("umlet_diagram");
0239:                doc.appendChild(root);
0240:
0241:                //save helptext
0242:                Element help = doc.createElement("help_text");
0243:                help.appendChild(doc.createTextNode(Constants.getHelpText()));
0244:                root.appendChild(help);
0245:
0246:                //save elements (group = null = rootlayer)
0247:                this .generateElementTree(doc, entities, root, null);
0248:
0249:                //output the stuff...
0250:                StringWriter stringWriter = null;
0251:                try {
0252:                    DOMSource source = new DOMSource(doc);
0253:                    stringWriter = new StringWriter();
0254:                    StreamResult result = new StreamResult(stringWriter);
0255:
0256:                    TransformerFactory transFactory = TransformerFactory
0257:                            .newInstance();
0258:                    Transformer transformer = transFactory.newTransformer();
0259:
0260:                    transformer.transform(source, result);
0261:                } catch (Exception e) {
0262:                    System.err.println("Error saving XML.");
0263:                    e.printStackTrace();
0264:                }
0265:
0266:                return stringWriter.toString();
0267:
0268:            }
0269:
0270:            public static boolean IS_CLIPPING = false;
0271:
0272:            private int MAIN_UNIT = 10;
0273:
0274:            public int getMainUnit() {
0275:                return MAIN_UNIT;
0276:            }
0277:
0278:            private boolean _isChanged = false;
0279:
0280:            public boolean isChanged() {
0281:                return _isChanged;
0282:            }
0283:
0284:            public void setChanged(boolean ch) {
0285:                if (ch != isChanged()) {
0286:                    _isChanged = ch;
0287:                    if (getFileName() == null)
0288:                        return;
0289:                    if (isChanged()) {
0290:                        appendToTitle("* " + getFileName());
0291:                    } else {
0292:                        appendToTitle(getFileName());
0293:                    }
0294:                }
0295:            }
0296:
0297:            private String _fileName = null;
0298:
0299:            private String getFileName() {
0300:                return _fileName;
0301:            }
0302:
0303:            public JMenuItem _saveMenuItem;
0304:
0305:            public void setFileName(String s) {
0306:                _fileName = s;
0307:                if (_saveMenuItem != null) {
0308:                    if (_fileName != null)
0309:                        _saveMenuItem.setEnabled(true);
0310:                    else
0311:                        _saveMenuItem.setEnabled(false);
0312:                }
0313:            }
0314:
0315:            private static String getStringFromFile(String fileName) {
0316:                try {
0317:                    StringBuffer sb = new StringBuffer();
0318:                    BufferedReader br = new BufferedReader(new FileReader(
0319:                            fileName));
0320:                    String line;
0321:                    while (((line = br.readLine()) != "") && line != null)
0322:                        sb = new StringBuffer(sb + line + "\n");
0323:                    String ret = new String(sb);
0324:                    if (ret.length() > 0)
0325:                        if (ret.charAt(ret.length() - 1) == '\n')
0326:                            ret = ret.substring(0, ret.length() - 1);
0327:                    return ret;
0328:                } catch (Exception e) {
0329:                    return null;
0330:                }
0331:            }
0332:
0333:            private static String getStringFromStream(String streamName) {
0334:                try {
0335:                    StringBuffer sb = new StringBuffer();
0336:                    BufferedReader br = new BufferedReader(
0337:                            new InputStreamReader(getInstance().getClass()
0338:                                    .getResourceAsStream(streamName)));
0339:                    String line;
0340:                    while (((line = br.readLine()) != "") && line != null)
0341:                        sb = new StringBuffer(sb + line + "\n");
0342:                    String ret = new String(sb);
0343:                    if (ret.length() > 0)
0344:                        if (ret.charAt(ret.length() - 1) == '\n')
0345:                            ret = ret.substring(0, ret.length() - 1);
0346:                    return ret;
0347:                } catch (Exception e) {
0348:                    return null;
0349:                }
0350:            }
0351:
0352:            public boolean askSaveIfDirty() {
0353:                if (Umlet.getInstance().isChanged()) {
0354:                    int ch = JOptionPane.showOptionDialog(Umlet.getInstance(),
0355:                            "Save changes?", "UMLet",
0356:                            JOptionPane.YES_NO_CANCEL_OPTION,
0357:                            JOptionPane.WARNING_MESSAGE, null, null, null);
0358:                    if (ch == JOptionPane.YES_OPTION) {
0359:                        Umlet.getInstance().doSave();
0360:                        return true;
0361:                    } else if (ch == JOptionPane.CANCEL_OPTION) {
0362:                        return false;
0363:                    }
0364:                }
0365:                return true;
0366:            }
0367:
0368:            public void doNew() {
0369:                if (askSaveIfDirty()) {
0370:                    Vector tmp = Selector.getInstance().getAllEntitiesOnPanel();
0371:                    Controller.getInstance().executeCommand(
0372:                            new RemoveElement(tmp));
0373:
0374:                    //clean up help panel
0375:                    Controller.getInstance().executeCommand(
0376:                            new HelpPanelChanged(null));
0377:
0378:                    Umlet.getInstance().setFileName("New Diagram");
0379:                    Umlet.getInstance().getJspMain().revalidate();
0380:                    Umlet.getInstance().setChanged(false);
0381:                    Controller._instance = null; // clean UNDO-Commands
0382:                    FileOp._instance = null; // reset File settings
0383:                }
0384:            }
0385:
0386:            public void doOpen(String fileNameIn) {
0387:                if (askSaveIfDirty()) {
0388:                    FileOp._instance = null; // reset File settings
0389:                    String fileName;
0390:                    if (fileNameIn == null)
0391:                        fileName = FileOp.getInstance().getMltOpenFilename();
0392:                    else
0393:                        fileName = fileNameIn;
0394:                    if (fileName == null)
0395:                        return;
0396:                    setFileName(fileName);
0397:
0398:                    //      clean up help panel (for backward compatibility if no help has been saved.
0399:                    Controller.getInstance().executeCommand(
0400:                            new HelpPanelChanged(null));
0401:
0402:                    openFileToPanel(fileName, getInstance().getPanel());
0403:                    Controller._instance = null; // clean UNDO-Commands
0404:                }
0405:            }
0406:
0407:            public static void openStreamToPanel(InputStream instr, JPanel p) {
0408:                Vector tmp = Selector.getInstance().getAllEntitiesOnPanel();
0409:                Controller.getInstance().executeCommand(new RemoveElement(tmp));
0410:
0411:                //[UB]: Use the Factory instead of directly instantiating
0412:                //      SAXParser because its constructor became protected
0413:                try {
0414:                    SAXParser parser = SAXParserFactory.newInstance()
0415:                            .newSAXParser();
0416:                    parser.parse(instr, new XMLContentHandler(p));
0417:                } catch (Exception e) {
0418:                    System.err.println("Error parsing the inputstream.");
0419:                    System.err.println(e.getMessage());
0420:                    /*StackTraceElement[] trace=e.getStackTrace();
0421:                    String out="";
0422:                    for (int i=0; i<trace.length; i++) {
0423:                        out+=trace[i].toString()+"\n";
0424:                    }
0425:                    Umlet.getInstance().getPropertyPanel().setText("EX="+out);*/
0426:
0427:                } finally {
0428:                    FileOp.getInstance().setSaveMenuItem(true);
0429:                    Umlet.getInstance().setChanged(false);
0430:                    Umlet.getInstance().repaint();
0431:                    Umlet.getInstance().getPropertyPanel().setText(
0432:                            Constants.getHelpText()); //refresh help text panel
0433:                }
0434:            }
0435:
0436:            private void openFileToPanel(String filename, JPanel p) {
0437:                try {
0438:                    openStreamToPanel(new FileInputStream(filename), p);
0439:                    if (p != Umlet.getInstance().getPalettePanel())
0440:                        setChanged(false);
0441:                } catch (IOException ioe) {
0442:                    System.err.println("IOException: " + ioe);
0443:                } catch (Exception e) {
0444:                    StackTraceElement[] trace = e.getStackTrace();
0445:                    String out = "";
0446:                    for (int i = 0; i < trace.length; i++) {
0447:                        out += trace[i].toString() + "\n";
0448:                    }
0449:                    Umlet.getInstance().getPropertyPanel().setText("EX=" + out);
0450:                    //        System.err.println("EXCEPTION: "+out);
0451:                }
0452:            }
0453:
0454:            private void setEntitiesOnPanel(String s, JPanel p) {
0455:                Vector v = Constants.decomposeStrings(s,
0456:                        Constants.DELIMITER_ENTITIES);
0457:                for (int i = 0; i < v.size(); i++) {
0458:                    String tmp = (String) v.elementAt(i);
0459:                    String s1 = tmp.substring(0, 4);
0460:                    String s2 = tmp.substring(4, tmp.length());
0461:                    if (s1.equals("CLAS")) {
0462:                        p.add(new Class(s2));
0463:                    } else if (s1.equals("INTE")) {
0464:                        p.add(new Interface(s2));
0465:                    } else if (s1.equals("PACK")) {
0466:                        p.add(new Package(s2));
0467:                    } else if (s1.equals("USEC")) {
0468:                        p.add(new UseCase(s2));
0469:                    } else if (s1.equals("NOTE")) {
0470:                        p.add(new Note(s2));
0471:                    } else if (s1.equals("ACTO")) {
0472:                        p.add(new Actor(s2));
0473:                    } else if (s1.equals("RELA")) {
0474:                        Relation r = new Relation(s2);
0475:                        p.add(r);
0476:                    }
0477:                }
0478:                p.repaint();
0479:            }
0480:
0481:            public static void appendToTitle(String s) {
0482:                if (isEmbedded())
0483:                    return;
0484:                if (s == null) {
0485:                    getInstance().window.setTitle("UMLet");
0486:                    return;
0487:                }
0488:                getInstance().window.setTitle("UMLet - " + s);
0489:            }
0490:
0491:            public void doSaveAs() {
0492:                String fileName = FileOp.getInstance().getMltSaveFilename(true);
0493:                if (fileName == null)
0494:                    return;
0495:                save(fileName);
0496:            }
0497:
0498:            public void doSave() {
0499:                if (!isPlugggedIn()) {
0500:                    String fileName = FileOp.getInstance().getMltSaveFilename(
0501:                            false);
0502:                    if (fileName == null)
0503:                        doSaveAs();
0504:                    else
0505:                        save(fileName);
0506:                } else {
0507:                    pluginHandler.notifySave(false);
0508:                }
0509:            }
0510:
0511:            public void doSaveAsSvg(String fileNameIn) {
0512:                if (!isPlugggedIn()) {
0513:                    String fileName;
0514:                    if (fileNameIn == null)
0515:                        fileName = FileOp.getInstance().getSvgFilename();
0516:                    else
0517:                        fileName = fileNameIn;
0518:                    if (fileName == null)
0519:                        return;
0520:                    GenSvg.createAndOutputSvgToFile(fileName);
0521:                } else {
0522:                    pluginHandler.notifySaveAsFormat("svg");
0523:                }
0524:            }
0525:
0526:            public void doSaveAsEps(String fileNameIn) {
0527:                if (!isPlugggedIn()) {
0528:                    String fileName;
0529:                    if (fileNameIn == null)
0530:                        fileName = FileOp.getInstance().getEpsFilename();
0531:                    else
0532:                        fileName = fileNameIn;
0533:                    if (fileName == null)
0534:                        return;
0535:                    GenEps.getInstance().createAndOutputEPSToFile(fileName);
0536:                } else {
0537:                    pluginHandler.notifySaveAsFormat("eps");
0538:                }
0539:            }
0540:
0541:            public void doSaveAsPdf(String fileNameIn) {
0542:                if (!isPlugggedIn()) {
0543:                    String fileName;
0544:                    if (fileNameIn == null)
0545:                        fileName = FileOp.getInstance().getPdfFilename();
0546:                    else
0547:                        fileName = fileNameIn;
0548:                    if (fileName == null)
0549:                        return;
0550:                    GenPdf.getInstance().createAndOutputPdfToFile(fileName);
0551:                } else {
0552:                    pluginHandler.notifySaveAsFormat("pdf");
0553:                }
0554:            }
0555:
0556:            public void doSaveAsJPG(String fileNameIn) {
0557:                if (!isPlugggedIn()) {
0558:                    String fileName;
0559:                    if (fileNameIn == null)
0560:                        fileName = FileOp.getInstance().getJpgFilename();
0561:                    else
0562:                        fileName = fileNameIn;
0563:                    if (fileName == null)
0564:                        return;
0565:                    GenPdf.getInstance().createAndOutputJpgToFile(fileName);
0566:                } else {
0567:                    pluginHandler.notifySaveAsFormat("jpg");
0568:                }
0569:            }
0570:
0571:            private String save(String fileName) {
0572:                String tmp = this .createStringToBeSaved();
0573:                try {
0574:                    PrintWriter out = new PrintWriter(new OutputStreamWriter(
0575:                            new FileOutputStream(fileName), "UTF-8"));
0576:                    out.print(tmp);
0577:                    out.close();
0578:                    setFileName(fileName);
0579:                    appendToTitle(fileName);
0580:                    Umlet.getInstance().setChanged(false);
0581:                } catch (java.io.IOException e) {
0582:                    return null;
0583:                }
0584:                return fileName;
0585:            }
0586:
0587:            public void doLoadClass(String absolutePath, String className) { //LME2
0588:                //String[] fileNameStrArr=FileOp.getInstance().getCustomElementFilename();
0589:                String[] fileNameStrArr = { absolutePath, className };
0590:                if (fileNameStrArr == null)
0591:                    return;
0592:                //System.out.println("doLoadClass: FILE TO LOAD:"+fileNameStrArr[0]);
0593:                Entity e = CustomElementLoader.getInstance().doLoadClass(
0594:                        fileNameStrArr, false, false); //no forced clean build
0595:                //getInstance().getPalettePanel().add(e);
0596:                //System.out.println("doLoadClass->e:"+e);
0597:                //Umlet.getInstance().getPalettePanel().add(e);
0598:                if (e != null) {
0599:                    Umlet.getInstance().getPanel().add(e);
0600:                    e.setLocation(50, 50);
0601:                    //e.setSize(100,100); moved to Entity()
0602:                }
0603:            }
0604:
0605:            private int _oldWidth = -1;
0606:            private int _oldHeight = -1;
0607:
0608:            public int getOldWidth() {
0609:                return _oldWidth;
0610:            }
0611:
0612:            public void setOldWidth(int d) {
0613:                _oldWidth = d;
0614:            }
0615:
0616:            public int getOldHeight() {
0617:                return _oldHeight;
0618:            }
0619:
0620:            public void setOldHeight(int d) {
0621:                _oldHeight = d;
0622:            }
0623:
0624:            //A.Mueller start
0625:            private JTextField _searchField;
0626:
0627:            public JTextField getSearchField() {
0628:                if (_searchField == null) {
0629:                    _searchField = new JTextField();
0630:                    _searchField.setBackground(new Color(148, 172, 251));
0631:                    _searchField.setActionCommand("Search");
0632:                    _searchField.addActionListener(UniversalListener
0633:                            .getInstance());
0634:                }
0635:                return _searchField;
0636:            }
0637:
0638:            //A.Mueller end
0639:
0640:            private JTextArea _sourceCodePanel; //LME
0641:
0642:            public JTextArea getSourceCodePanel() {
0643:                if (_sourceCodePanel == null) {
0644:                    _sourceCodePanel = new JTextArea();
0645:                    _sourceCodePanel.setLineWrap(false); //dont wrap lines
0646:                }
0647:                return _sourceCodePanel;
0648:            }
0649:
0650:            private JScrollPane _scrollPanel2; //LME
0651:
0652:            public JScrollPane getScrollPanel2() { //scrollable panel for the source code
0653:                if (_scrollPanel2 == null) {
0654:                    _scrollPanel2 = new JScrollPane(getSourceCodePanel());
0655:                }
0656:                return _scrollPanel2;
0657:            }
0658:
0659:            public void setSourceCodePanelToEntity(Entity e) { //LME
0660:                _editedEntity = e;
0661:
0662:                if (e != null && !e.getJavaSource().equals("")) {
0663:                    _sourceCodePanel.setText(e.getJavaSource());
0664:                    _sourceCodePanel.setEnabled(true);
0665:                    setCompileCodeMenuButtonEnabled(true);
0666:                } else {
0667:                    _sourceCodePanel
0668:                            .setText("Click on a custom UML element to see and edit its source code here.");
0669:                    _sourceCodePanel.setEnabled(false);
0670:                    setCompileCodeMenuButtonEnabled(false);
0671:                }
0672:                Umlet.getInstance().getJspMain().requestFocus();
0673:            }
0674:
0675:            private JSplitPane _jspRightBottom; //LME
0676:
0677:            public JSplitPane getJspRightBottom() { //register space for the source code panel
0678:                if (_jspRightBottom == null) {
0679:                    _jspRightBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
0680:                    _jspRightBottom.setDividerSize(10);
0681:                }
0682:                return _jspRightBottom;
0683:            }
0684:
0685:            private JSplitPane _jspRightBottom2; //LME
0686:
0687:            public JSplitPane getJspRightBottom2() { //register space for the save/compile-Button within the source code panel 
0688:                if (_jspRightBottom2 == null) {
0689:                    _jspRightBottom2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
0690:                    _jspRightBottom2.setDividerSize(1);
0691:                }
0692:                return _jspRightBottom2;
0693:            }
0694:
0695:            private JButton compileCodeMenuB = new JButton(
0696:                    "Compile and - if o.k. - overwrite current file"); //LME
0697:
0698:            public void setCompileCodeMenuButtonEnabled(boolean flag) { //LME enable/disable the button in the source code panel
0699:                compileCodeMenuB.setEnabled(flag);
0700:            }
0701:
0702:            private JTextPane _propertyPanel;
0703:
0704:            public JTextPane getPropertyPanel() {
0705:                if (_propertyPanel == null) {
0706:                    _propertyPanel = new JTextPane();
0707:                }
0708:                return _propertyPanel;
0709:            }
0710:
0711:            private SelectorFrame _selFrame;
0712:
0713:            public SelectorFrame getSelectorFrame() {
0714:                if (_selFrame == null) {
0715:                    _selFrame = new SelectorFrame();
0716:                }
0717:                return _selFrame;
0718:            }
0719:
0720:            private JScrollPane _scrollPanel;
0721:
0722:            public JScrollPane getScrollPanel() {
0723:                if (_scrollPanel == null) {
0724:                    _scrollPanel = new JScrollPane(getPropertyPanel());
0725:                }
0726:                return _scrollPanel;
0727:            }
0728:
0729:            private static JTextPane _infoText;
0730:
0731:            public static void outputInfoText(String s) {
0732:                _infoText.setText(s);
0733:            }
0734:
0735:            private Entity _editedEntity;
0736:
0737:            public Entity getEditedEntity() {
0738:                return _editedEntity;
0739:            }
0740:
0741:            public String getPropertyString() {
0742:                return _propertyPanel.getText();
0743:            }
0744:
0745:            private DrawPanel _panel;
0746:
0747:            public DrawPanel getPanel() {
0748:                if (_panel == null) {
0749:                    _panel = new DrawPanel();
0750:                }
0751:                return _panel;
0752:            }
0753:
0754:            //[LI&UB]: return the currently selected palette
0755:            public DrawPanel getPalettePanel() {
0756:                String name = (String) _paletteList.getSelectedItem();
0757:                if (name != null)
0758:                    return _paletteHashtable.get(name);
0759:                else
0760:                    return null;
0761:            }
0762:
0763:            //[LI&UB]: workaround for creating a new instance from a static method
0764:            public DrawPanel createDrawPanel() {
0765:                return new DrawPanel();
0766:            }
0767:
0768:            private static Umlet _instance;
0769:
0770:            public static Umlet getInstance() {
0771:                if (_instance == null) {
0772:                    _instance = new Umlet();
0773:                }
0774:                return _instance;
0775:            }
0776:
0777:            private static boolean _isInstanceCreated = false;
0778:
0779:            public static void setInstanceCreated(boolean isCreated) {
0780:                _isInstanceCreated = isCreated;
0781:            }
0782:
0783:            public static boolean isInstanceCreated() {
0784:                return _isInstanceCreated;
0785:            }
0786:
0787:            public void setPropertyPanelToEntity(Entity e) {
0788:                _editedEntity = e;
0789:                if (e != null) {
0790:                    _propertyPanel.setText(e.getPanelAttributes());
0791:                } else {
0792:                    _propertyPanel.setText(Constants.getHelpText());
0793:                }
0794:                Umlet.getInstance().getJspMain().requestFocus();
0795:            }
0796:
0797:            public Vector<Entity> getAllEntities() {
0798:                Vector<Entity> v = new Vector<Entity>();
0799:                for (int i = 0; i < _panel.getComponentCount(); i++) {
0800:                    Component c = _panel.getComponent(i);
0801:                    if (c instanceof  Entity)
0802:                        v.add((Entity) c);
0803:                }
0804:                return v;
0805:            }
0806:
0807:            public Vector<Entity> getAllPaletteEntities() { //LME
0808:                Vector<Entity> v = new Vector<Entity>();
0809:                for (int i = 0; i < getPalettePanel().getComponentCount(); i++) {
0810:                    Component c = getPalettePanel().getComponent(i);
0811:                    if (c instanceof  Entity)
0812:                        v.add((Entity) c);
0813:                }
0814:                return v;
0815:            }
0816:
0817:            public int getCenterX() {
0818:                return _panel.getWidth() / 2;
0819:            }
0820:
0821:            public int getCenterY() {
0822:                return _panel.getHeight() / 2;
0823:            }
0824:
0825:            private JSplitPane _jspMain;
0826:
0827:            public JSplitPane getJspMain() {
0828:                if (_jspMain == null) {
0829:                    _jspMain = new JSplitPane();
0830:                    _jspMain.setDividerSize(10);
0831:                }
0832:                return _jspMain;
0833:            }
0834:
0835:            private JSplitPane _jspRight;
0836:
0837:            public JSplitPane getJspRight() {
0838:                if (_jspRight == null) {
0839:                    _jspRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
0840:                    _jspRight.setDividerSize(3);
0841:                }
0842:                return _jspRight;
0843:            }
0844:
0845:            private JScrollPane _jscrpMain;
0846:
0847:            public JScrollPane getScrollPaneMain() {
0848:                if (_jscrpMain == null) {
0849:                    _jscrpMain = new JScrollPane();
0850:                    getInstance().getPanel().setScrollPanel(_jscrpMain);
0851:                }
0852:                return _jscrpMain;
0853:            }
0854:
0855:            //[LI&UB]: not needed any longer
0856:            /*
0857:            private JScrollPane _jscrpPalette;
0858:            
0859:            public JScrollPane getScrollPanePalette() {
0860:              if (_jscrpPalette==null) {
0861:                  _jscrpPalette=new JScrollPane();
0862:                  getInstance().getPalettePanel().setScrollPanel(_jscrpPalette);
0863:               }
0864:               return _jscrpPalette;
0865:            }
0866:             */
0867:
0868:            public static void main(String args[]) {
0869:                if (args.length != 0) {
0870:                    String action = null;
0871:                    String format = null;
0872:                    String filename = null;
0873:                    for (int i = 0; i < args.length; i++) {
0874:                        if (args[i].startsWith("-action="))
0875:                            action = args[i].substring(8);
0876:                        if (args[i].startsWith("-format="))
0877:                            format = args[i].substring(8);
0878:                        if (args[i].startsWith("-filename="))
0879:                            filename = args[i].substring(10);
0880:                    }
0881:
0882:                    if (action == null && format == null && filename != null) {
0883:                        init(true);
0884:                        Umlet.getInstance().doOpen(filename);
0885:                    } else if (action != null && format != null
0886:                            && filename != null) {
0887:                        if (action.equals("convert")) {
0888:                            init(false); //boolean value indicates not to display the window
0889:                            Umlet.getInstance().doNew();
0890:                            Umlet.getInstance().doConvert(filename, format);
0891:                            System.exit(0);
0892:                        } else
0893:                            printUsage();
0894:                    } else {
0895:                        printUsage();
0896:                    }
0897:                } else { //no arguments specified 
0898:                    init(true);
0899:                    Umlet.getInstance().doNew();
0900:                }
0901:            }
0902:
0903:            public void doConvert(String fileName, String format) {
0904:                Umlet.getInstance().doOpen(fileName);
0905:                String fileNameMain = fileName.substring(0, fileName
0906:                        .indexOf(".uxf"));
0907:                if (format != null && format.equals("jpg"))
0908:                    Umlet.getInstance().doSaveAsJPG(fileNameMain + ".jpg");
0909:                else if (format != null && format.equals("pdf"))
0910:                    Umlet.getInstance().doSaveAsPdf(fileNameMain + ".pdf");
0911:                else if (format != null && format.equals("svg"))
0912:                    Umlet.getInstance().doSaveAsSvg(fileNameMain + ".svg");
0913:                else if (format != null && format.equals("eps"))
0914:                    Umlet.getInstance().doSaveAsEps(fileNameMain + ".eps");
0915:            }
0916:
0917:            private static void printUsage() {
0918:                System.out
0919:                        .println("USAGE: -action=convert -format=(jpg|pdf|svg|eps) -filename=inputfile.uxf");
0920:            }
0921:
0922:            public static void init(UmletPluginHandler pluginHandler,
0923:                    boolean isEmbedded) {
0924:                Umlet.pluginHandler = pluginHandler;
0925:                setIsPluggedIn(true);
0926:                setIsEmbedded(isEmbedded);
0927:                Controller._instance = null; // clean UNDO-Commands
0928:                FileOp._instance = null; // reset File settings    
0929:                init(true);
0930:            }
0931:
0932:            //[LI&UB]: scan for palette files
0933:            public static File[] scanForPalettes() {
0934:                //scan palettes directory...
0935:                FileSystemView fileSystemView = FileSystemView
0936:                        .getFileSystemView();
0937:                File[] paletteFiles = fileSystemView.getFiles(new File(
0938:                        "palettes\\"), false);
0939:
0940:                return paletteFiles;
0941:            }
0942:
0943:            //[LI&UB]: cards is our container for our drawpanels
0944:            private JPanel _cards;
0945:
0946:            public JPanel getCards() {
0947:                if (_cards == null)
0948:                    _cards = new JPanel(new CardLayout());
0949:
0950:                return _cards;
0951:            }
0952:
0953:            //[LI&UB]: for efficient look-up of the currently active drawpanel
0954:            private Hashtable<String, DrawPanel> _paletteHashtable;
0955:
0956:            public Hashtable<String, DrawPanel> getPaletteHashtable() {
0957:                if (_paletteHashtable == null)
0958:                    _paletteHashtable = new Hashtable<String, DrawPanel>();
0959:
0960:                return _paletteHashtable;
0961:            }
0962:
0963:            //[LI&UB]: This is the combobox which lists
0964:            //the different palettes
0965:            private JComboBox _paletteList;
0966:
0967:            public JComboBox getPaletteList() {
0968:                if (_paletteList == null)
0969:                    _paletteList = new JComboBox();
0970:
0971:                return _paletteList;
0972:            }
0973:
0974:            //LME: combobox with custom elements
0975:            private JComboBox _elementsList;
0976:
0977:            public JComboBox getElementsList() {
0978:                if (_elementsList == null)
0979:                    _elementsList = new JComboBox();
0980:                return _elementsList;
0981:            }
0982:
0983:            public static void init(boolean isVisible) {
0984:                if (isInstanceCreated())
0985:                    return;
0986:                setInstanceCreated(true);
0987:
0988:                if (!isEmbedded()) {
0989:                    // create frame window for standalone viewing
0990:                    getInstance().createFrame();
0991:                    getInstance().window
0992:                            .addWindowListener((WindowListener) UniversalListener
0993:                                    .getInstance());
0994:                    getInstance().window.setBounds(10, 10, 980, 780);
0995:                    getInstance().window
0996:                            .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
0997:                    getInstance().window.validate();
0998:                    getInstance().window.repaint();
0999:                }
1000:
1001:                getInstance().setLayout(new BorderLayout());
1002:
1003:                // Add split panel
1004:                getInstance().add(getInstance().getJspMain(),
1005:                        BorderLayout.CENTER);
1006:
1007:                // Add main panel
1008:                //getInstance().getPanel().setBounds(0,0,300,300);
1009:                getInstance().getPanel().setLayout(null);
1010:                getInstance().getPanel().setBackground(Color.white);
1011:                getInstance().getPanel().addMouseListener(
1012:                        UniversalListener.getInstance());
1013:                getInstance().getPanel().addMouseMotionListener(
1014:                        UniversalListener.getInstance());
1015:
1016:                //A.Mueller start
1017:                JPanel p = new JPanel();
1018:                getInstance().getSearchField().addFocusListener(
1019:                        UniversalListener.getInstance());
1020:                p.setLayout(new BorderLayout());
1021:                p.add(getInstance().getScrollPaneMain(), BorderLayout.CENTER);
1022:                p.add(getInstance().getSearchField(), BorderLayout.SOUTH);
1023:                getInstance().getJspMain().add(p, JSplitPane.LEFT);
1024:                getInstance().getSearchField().setVisible(false);
1025:                /*
1026:                 <OLDCODE>
1027:                 getInstance().getJspMain().add(getInstance().getScrollPaneMain(), JSplitPane.LEFT);
1028:                 </OLDCODE>
1029:                 */
1030:                //A.Mueller end
1031:                getInstance().getPanel().addKeyListener(
1032:                        UniversalListener.getInstance()); //LME5
1033:                getInstance().getJspMain().setOneTouchExpandable(true);
1034:
1035:                // Add palette panel
1036:                //[UB & LI]: Also create combobox for listing different palettes
1037:                //           and a jpanel with cardlayout
1038:                JPanel paletteContainer = new JPanel();
1039:                paletteContainer.setLayout(new BorderLayout());
1040:                paletteContainer.add(getInstance().getCards(),
1041:                        BorderLayout.CENTER);
1042:
1043:                Umlet.getInstance().getPaletteList().setEditable(false);
1044:                Umlet.getInstance().getPaletteList().addItemListener(
1045:                        UniversalListener.getInstance());
1046:
1047:                Umlet.getInstance().getElementsList().setEditable(false);
1048:                Umlet.getInstance().getElementsList().addItemListener(
1049:                        UniversalListener.getInstance());
1050:                //JPanel comboBoxPane= new JPanel();
1051:                //comboBoxPane.add(Umlet.getInstance().getPaletteList());
1052:                //paletteContainer.add(comboBoxPane, BorderLayout.PAGE_START);
1053:
1054:                getInstance().getJspRight().add(paletteContainer,
1055:                        JSplitPane.TOP);
1056:
1057:                // Add property panel
1058:                getInstance().getPropertyPanel().addKeyListener(
1059:                        UniversalListener.getInstance());
1060:                getInstance().getJspRightBottom().add(
1061:                        getInstance().getScrollPanel(), JSplitPane.TOP);
1062:
1063:                //getInstance().getJspMain().add(getInstance().getJspRight(), JSplitPane.RIGHT);
1064:
1065:                //LME: add source code panel
1066:                getInstance().getSourceCodePanel().addKeyListener(
1067:                        UniversalListener.getInstance());
1068:                getInstance().getJspRightBottom2().add(
1069:                        getInstance().getScrollPanel2(), JSplitPane.BOTTOM);
1070:                getInstance().getJspRightBottom().setOneTouchExpandable(true);
1071:                Container codeMenu = new Container();
1072:                codeMenu.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 1));
1073:                //LME: Button
1074:                getInstance().compileCodeMenuB
1075:                        .setActionCommand("COMPILE_BUTTON");
1076:                getInstance().compileCodeMenuB
1077:                        .addActionListener(UniversalListener.getInstance());
1078:                codeMenu.add(getInstance().compileCodeMenuB);
1079:                getInstance().getJspRightBottom2()
1080:                        .add(codeMenu, JSplitPane.TOP);
1081:                Umlet.getInstance().setCompileCodeMenuButtonEnabled(false);
1082:                getInstance().getJspRightBottom().add(
1083:                        getInstance().getJspRightBottom2(), JSplitPane.BOTTOM); //add code panel with buttons
1084:
1085:                getInstance().getJspRight().add(
1086:                        getInstance().getJspRightBottom(), JSplitPane.RIGHT); //Register SplitPane
1087:                getInstance().getJspMain().add(getInstance().getJspRight(),
1088:                        JSplitPane.RIGHT); //Register SpitPane
1089:
1090:                KeyStroke bUndo = KeyStroke.getKeyStroke('z');
1091:                AbstractAction aUndo = new AbstractAction() {
1092:                    public void actionPerformed(ActionEvent e) {
1093:                        Selector.getInstance().deselectAll();
1094:                        Controller.getInstance().undo();
1095:                        System.out.println("undo");
1096:                    }
1097:                };
1098:                KeyStroke bRedo = KeyStroke.getKeyStroke('y');
1099:                AbstractAction aRedo = new AbstractAction() {
1100:                    public void actionPerformed(ActionEvent e) {
1101:                        Controller.getInstance().redo();
1102:                    }
1103:                };
1104:
1105:                //  A.Mueller start
1106:                // adding Ctrl+Z and Ctrl+Y (undo and redo) as well -> CHANGED: accellerators now
1107:                //KeyStroke bUndo2 = KeyStroke.getKeyStroke("ctrl Z");
1108:                //KeyStroke bRedo2 = KeyStroke.getKeyStroke("ctrl Y");
1109:
1110:                //adding the slash to activate searching...
1111:                KeyStroke bSearch = KeyStroke.getKeyStroke("ctrl F");
1112:                AbstractAction aSearch = new AbstractAction() {
1113:                    public void actionPerformed(ActionEvent e) {
1114:                        Umlet.getInstance().getSearchField().setText("");
1115:                        Umlet.getInstance().getSearchField().setVisible(true);
1116:                        JPanel p = (JPanel) Umlet.getInstance()
1117:                                .getSearchField().getParent();
1118:                        p.doLayout();
1119:                        Umlet.getInstance().getSearchField().requestFocus();
1120:                    }
1121:                };
1122:                // A.Mueller end
1123:
1124:                KeyStroke bClip = KeyStroke.getKeyStroke('c');
1125:                AbstractAction aClip = new AbstractAction() {
1126:                    public void actionPerformed(ActionEvent e) {
1127:                        Clip.getInstance().copy();
1128:                    }
1129:                };
1130:                KeyStroke bBack = KeyStroke.getKeyStroke(
1131:                        KeyEvent.VK_BACK_SPACE, 0, true); //Use BACKSPACE to remove Element
1132:                AbstractAction aBack = new AbstractAction() {
1133:                    public void actionPerformed(ActionEvent e) {
1134:                        Vector v = Selector.getInstance()
1135:                                .getSelectedEntitiesOnPanel();
1136:                        if (v.size() > 0) {
1137:                            Controller.getInstance().executeCommand(
1138:                                    new RemoveElement(v));
1139:                        }
1140:                    }
1141:                };
1142:                //A.Mueller start
1143:                /* nothing, because they are accelerators now...
1144:                <OLDCODE>
1145:                KeyStroke bDele = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0,true); //Use DELETE to remove Element
1146:                AbstractAction aDele = new AbstractAction() {
1147:                  public void actionPerformed( ActionEvent e ) {
1148:                      Vector v=Selector.getInstance().getSelectedEntitiesOnPanel();
1149:                    if (v.size()>0) {
1150:                      Controller.getInstance().executeCommand(new RemoveElement(v));
1151:                    }
1152:                  }
1153:                };
1154:                KeyStroke bSave = KeyStroke.getKeyStroke('S', Event.CTRL_MASK , false); //Use CTRL-S to save file
1155:                 AbstractAction aSave = new AbstractAction() {
1156:                   public void actionPerformed( ActionEvent e ) {
1157:                     Umlet.getInstance().doSave();
1158:                   }
1159:                 };    
1160:                 </OLDCODE>
1161:                 */
1162:                //A.Mueller end
1163:                //LME5: Use CTRL-O to select overlapped Entities (which otherwise are hard to select)
1164:                //A.Mueller start -> changed O to zero because of ctrl open
1165:                KeyStroke bOtherElement = KeyStroke.getKeyStroke('0',
1166:                        Event.CTRL_MASK, false);
1167:                //A.Mueller end
1168:                AbstractAction aOtherElement = new AbstractAction() {
1169:                    public void actionPerformed(ActionEvent e) {
1170:                        Entity selEntity = Umlet.getInstance()
1171:                                .getEditedEntity();
1172:                        if (selEntity != null) {
1173:                            Vector<Entity> allEntities = Umlet.getInstance()
1174:                                    .getAllEntities();
1175:                            for (int i = 0; i < allEntities.size(); i++) {
1176:                                Entity en = allEntities.elementAt(i);
1177:                                if ((selEntity.getX() <= en.getX())
1178:                                        && (en.getX() <= selEntity.getX()
1179:                                                + selEntity.getWidth())
1180:                                        && (selEntity.getY() <= en.getY())
1181:                                        && (en.getY() <= selEntity.getY()
1182:                                                + selEntity.getHeight())) {
1183:                                    Umlet.getInstance().getPanel().remove(en); //## rearrange (Component)Entity 
1184:                                    Umlet.getInstance().getPanel().add(en, 0); //## in the Container
1185:                                    Selector.getInstance().deselect(selEntity); //deselect selected Entity
1186:                                    Selector.getInstance().singleSelect(en,
1187:                                            false); //select overlapped Entities
1188:                                }
1189:                            }
1190:                        } //#endif(selEntity...
1191:                    }
1192:                };
1193:
1194:                InputMap inputMap = Umlet.getInstance().getJspMain()
1195:                        .getInputMap(
1196:                                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
1197:                ActionMap actionMap = Umlet.getInstance().getJspMain()
1198:                        .getActionMap();
1199:                inputMap.put(bUndo, "undo");
1200:                actionMap.put("undo", aUndo);
1201:                inputMap.put(bRedo, "redo");
1202:                actionMap.put("redo", aRedo);
1203:                //  A.Mueller start
1204:                inputMap.put(bSearch, "search");
1205:                actionMap.put("search", aSearch);
1206:                // A.Mueller end
1207:                inputMap.put(bBack, "back");
1208:                actionMap.put("back", aBack);
1209:                //  A.MUeller start
1210:                //removed following four lines -> is an accellerator now
1211:                //inputMap.put( bDele, "dele" );
1212:                //actionMap.put( "dele", aDele );
1213:                //inputMap.put( bSave, "save" );
1214:                //actionMap.put( "save", aSave );
1215:                //A.Mueller end
1216:                inputMap.put(bClip, "clip");
1217:                actionMap.put("clip", aClip);
1218:                inputMap.put(bOtherElement, "nextelement");
1219:                actionMap.put("nextelement", aOtherElement);
1220:
1221:                // Add menu
1222:                JMenuBar m = new JMenuBar();
1223:                JMenu iFile = new JMenu("File");
1224:                JMenu iEdit = new JMenu("Edit");
1225:                JMenu iHelp = new JMenu("Help"); //L.Trescher
1226:                //JMenu iFont=new JMenu("Font-Size"); //LME5
1227:                m.add(iFile);
1228:                m.add(iEdit);
1229:                m.add(iHelp); //L.Trescher
1230:                //m.add(iFont);
1231:
1232:                JLabel l1 = new JLabel(" Insert custom element: ");
1233:                JLabel l2 = new JLabel(" Palettes: ");
1234:                l1.setEnabled(false); //LME: give a different look to labels  
1235:                l2.setEnabled(false);
1236:                m.add(l1);
1237:                m.add(Umlet.getInstance().getElementsList()); //LME: list of custom elements
1238:                m.add(l2);
1239:                m.add(Umlet.getInstance().getPaletteList()); //LME: moved palette-combobox to menu bar
1240:
1241:                //A.Mueller start
1242:                JMenuItem iNew = new JMenuItem("New");
1243:                iNew.setAccelerator(KeyStroke.getKeyStroke("ctrl N"));
1244:                JMenuItem iOpen = new JMenuItem("Open...");
1245:                iOpen.setAccelerator(KeyStroke.getKeyStroke("ctrl O"));
1246:                JMenuItem iSave = new JMenuItem("Save");
1247:                iSave.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));
1248:                getInstance()._saveMenuItem = iSave;
1249:                getInstance().setFileName(null);
1250:                JMenuItem iSaveAs = new JMenuItem("Save as...");
1251:                JMenuItem iSaveAsGif = new JMenuItem("Save as JPG...");
1252:                JMenuItem iSaveAsSvg = new JMenuItem("Save as SVG...");
1253:                JMenuItem iSaveAsPdf = new JMenuItem("Save as PDF...");
1254:                JMenuItem iSaveAsEps = new JMenuItem("Save as EPS...");
1255:
1256:                JMenuItem iDelete = new JMenuItem("Delete");
1257:                iDelete.setAccelerator(KeyStroke.getKeyStroke("DELETE"));
1258:                JMenuItem iUndo = new JMenuItem("Undo");
1259:                iUndo.setAccelerator(KeyStroke.getKeyStroke("ctrl Z"));
1260:                JMenuItem iRedo = new JMenuItem("Redo");
1261:                iRedo.setAccelerator(KeyStroke.getKeyStroke("ctrl Y"));
1262:                /*JMenuItem iRealign=new JMenuItem("Realign to grid");
1263:                iRealign.setAccelerator(KeyStroke.getKeyStroke("ctrl R"));*/
1264:
1265:                /*
1266:                 <OLDCODE>
1267:                 JMenuItem iNew=new JMenuItem("New");
1268:                JMenuItem iOpen=new JMenuItem("Open");
1269:                JMenuItem iSave=new JMenuItem("Save");
1270:                getInstance()._saveMenuItem=iSave;
1271:                getInstance().setFileName(null);
1272:                JMenuItem iSaveAs=new JMenuItem("Save as..");
1273:                JMenuItem iSaveAsGif=new JMenuItem("Save as JPG..");
1274:                JMenuItem iSaveAsSvg=new JMenuItem("Save as SVG..");
1275:                JMenuItem iSaveAsPdf=new JMenuItem("Save as PDF..");
1276:                JMenuItem iSaveAsEps=new JMenuItem("Save as EPS..");
1277:
1278:                JMenuItem iDelete=new JMenuItem("Delete");
1279:                JMenuItem iUndo=new JMenuItem("Undo");
1280:                JMenuItem iRedo=new JMenuItem("Redo");
1281:                JMenuItem iRealign=new JMenuItem("Realign to grid");
1282:                 </OLDCODE
1283:                 */
1284:                //A.Mueller end
1285:                JMenuItem iOnlineHelp = new JMenuItem("Online Help"); //L.Trescher
1286:                JMenuItem iAboutUmlet = new JMenuItem("About");
1287:
1288:                // A.Mueller Start
1289:                JMenuItem iSearch = new JMenuItem("Find");
1290:                iSearch.setAccelerator(KeyStroke.getKeyStroke('/'));
1291:                JMenuItem iGroup = new JMenuItem("Group");
1292:                iGroup.setAccelerator(KeyStroke.getKeyStroke("ctrl G"));
1293:                JMenuItem iUngroup = new JMenuItem("Ungroup");
1294:                iUngroup.setAccelerator(KeyStroke.getKeyStroke("ctrl U"));
1295:
1296:                //J. Pölz Start
1297:                JMenuItem iClipboard = new JMenuItem("Copy to Clipboard");
1298:                iClipboard.setAccelerator(KeyStroke.getKeyStroke("ctrl C"));
1299:                //J. Pölz End
1300:                //JCheckBoxMenuItem iTransparency = new JCheckBoxMenuItem("Toggle Transparency");
1301:                //iTransparency.setSelected(false);
1302:                //iTransparency.setAccelerator(KeyStroke.getKeyStroke("ctrl T"));
1303:                // A.Mueller End
1304:
1305:                JMenuItem iSelectAll = new JMenuItem("Select all");
1306:                iSelectAll.setAccelerator(KeyStroke.getKeyStroke("ctrl A"));
1307:
1308:                //JMenuItem iFontSize6=new JMenuItem("6");
1309:                //JMenuItem iFontSize8=new JMenuItem("8");
1310:                //JMenuItem iFontSize10=new JMenuItem("10");
1311:                //JMenuItem iFontSize12=new JMenuItem("12");
1312:
1313:                if (!isPlugggedIn())
1314:                    iFile.add(iNew);
1315:                if (!isPlugggedIn())
1316:                    iFile.add(iOpen);
1317:                iFile.add(iSave);
1318:                if (!isPlugggedIn())
1319:                    iFile.add(iSaveAs);
1320:                iFile.add(iSaveAsGif);
1321:                iFile.add(iSaveAsSvg);
1322:                iFile.add(iSaveAsPdf);
1323:                iFile.add(iSaveAsEps);
1324:                //iFile.add(iOnlineHelp); //L.Trescher
1325:                iEdit.add(iUndo);
1326:                iEdit.add(iRedo);
1327:                iEdit.add(iDelete);
1328:                iEdit.add(new JSeparator());
1329:                iEdit.add(iSelectAll);
1330:                //iEdit.add(iRealign); //LME: Realign to grid
1331:                // A.Mueller start
1332:                iEdit.add(iGroup);
1333:                iEdit.add(iUngroup);
1334:                iEdit.add(iSearch);
1335:                iEdit.add(iClipboard);
1336:                // A.Mueller end
1337:
1338:                iHelp.add(iOnlineHelp); //L.Trescher
1339:                iHelp.add(iAboutUmlet);
1340:
1341:                //iFont.add(iFontSize6);
1342:                //iFont.add(iFontSize8);
1343:                //iFont.add(iFontSize10);
1344:                //iFont.add(iFontSize12);
1345:
1346:                iNew.addActionListener(UniversalListener.getInstance());
1347:                iOpen.addActionListener(UniversalListener.getInstance());
1348:                iSave.addActionListener(UniversalListener.getInstance());
1349:                iSaveAs.addActionListener(UniversalListener.getInstance());
1350:                iSaveAsGif.addActionListener(UniversalListener.getInstance());
1351:                iSaveAsSvg.addActionListener(UniversalListener.getInstance());
1352:                iSaveAsEps.addActionListener(UniversalListener.getInstance());
1353:                iSaveAsPdf.addActionListener(UniversalListener.getInstance());
1354:
1355:                iUndo.addActionListener(UniversalListener.getInstance());
1356:                iRedo.addActionListener(UniversalListener.getInstance());
1357:                iDelete.addActionListener(UniversalListener.getInstance());
1358:                iSelectAll.addActionListener(UniversalListener.getInstance());
1359:                //iRealign.addActionListener(UniversalListener.getInstance());
1360:                // A.Mueller Start
1361:                iGroup.addActionListener(UniversalListener.getInstance());
1362:                iSearch.addActionListener(UniversalListener.getInstance());
1363:                iUngroup.addActionListener(UniversalListener.getInstance());
1364:                iClipboard.addActionListener(UniversalListener.getInstance());
1365:                //iTransparency.addActionListener(UniversalListener.getInstance());
1366:                iEdit.addMenuListener(UniversalListener.getInstance());
1367:                // A.Mueller End
1368:                //iFontSize6.addActionListener(UniversalListener.getInstance());
1369:                //iFontSize8.addActionListener(UniversalListener.getInstance());
1370:                //iFontSize10.addActionListener(UniversalListener.getInstance());
1371:                //iFontSize12.addActionListener(UniversalListener.getInstance());
1372:
1373:                iOnlineHelp.addActionListener(UniversalListener.getInstance()); //L.Trescher
1374:                iAboutUmlet.addActionListener(UniversalListener.getInstance());
1375:
1376:                m.setLayout(new FlowLayout(0, 0, 0));
1377:                getInstance().add(m, BorderLayout.NORTH);
1378:
1379:                getInstance().getJspMain().addComponentListener(
1380:                        UniversalListener.getInstance());
1381:                getInstance().getJspRight().addComponentListener(
1382:                        UniversalListener.getInstance());
1383:                //getInstance().addKeyListener(UniversalListener.getInstance());
1384:                //getInstance().setLrSeparatorLocation(520);
1385:                //getInstance().setTbSeparatorLocation(550);
1386:
1387:                //getInstance().getJspMain().setDividerLocation(520);
1388:                //getInstance().getJspRight().setDividerLocation(450);
1389:
1390:                if (!isEmbedded())
1391:                    getInstance().window.setVisible(isVisible); //set invisible in batchrunning mode
1392:                //System.out.println("xxx"+getInstance().toString()+"--"+getInstance().getBounds());
1393:                //getInstance().setOldBounds(getInstance().getBounds());
1394:                getInstance().setPropertyPanelToEntity(null);
1395:                getInstance().setSourceCodePanelToEntity(null); //LME
1396:
1397:                /*String palette=getInstance().getStringFromFile("."+File.separator+"palette.mlt");
1398:                if (palette!=null) {
1399:                  getInstance().setEntitiesOnPanel(palette, getInstance().getPalettePanel());
1400:                } else {
1401:                  palette = getInstance().getStringFromStream("palette.mlt");
1402:                  if (palette!=null) {
1403:                    getInstance().setEntitiesOnPanel(palette, getInstance().getPalettePanel());
1404:                  }
1405:                }*/
1406:                //System.out.println("path="+((new File("palette/palette.uxf")).getAbsolutePath()));
1407:
1408:                String homePath = Umlet.getInstance().getHomePath();
1409:
1410:                //LME: search for all existing palette files (= all .uxf files in the palettes/ directory)
1411:                String[] paletteFileList = new File(homePath + "palettes/")
1412:                        .list(new PaletteFilenameFilter());
1413:                //if (paletteFileList != null) for(int i=0;i<paletteFileList.length;i++) System.out.println("paletteFileList["+i+"]:"+paletteFileList[i]);
1414:
1415:                //[UB & LI]: Load several palette-files
1416:                if (paletteFileList != null && paletteFileList.length > 0) {
1417:                    //System.out.println("Loading palette(s) from palettes/ directory...");
1418:
1419:                    Arrays.sort(paletteFileList, new PaletteSorter());
1420:
1421:                    /* REPLACED BY SORTER      
1422:                     * for(int i=0;i<paletteFileList.length;i++) { //LME: put the default palette on top 
1423:                           	if(paletteFileList[i].equals("default_palette.uxf")&&(i!=0)) {
1424:                           		String dummy=paletteFileList[0];
1425:                           		paletteFileList[0]=paletteFileList[i];
1426:                           		paletteFileList[i]=dummy;
1427:                           	}
1428:                           }*/
1429:
1430:                    for (int i = 0; i < paletteFileList.length; i++) {
1431:                        DrawPanel d = Umlet.getInstance().createDrawPanel();
1432:                        d.setBackground(Color.white);
1433:                        d.setLayout(null);
1434:                        d.addMouseListener(UniversalListener.getInstance());
1435:                        d.addMouseMotionListener(UniversalListener
1436:                                .getInstance());
1437:
1438:                        JScrollPane scrollPnl = new JScrollPane();
1439:                        d.setScrollPanel(scrollPnl);
1440:
1441:                        //dont load help panel with each palette = last null parameter
1442:                        Umlet.getInstance().openFileToPanel(
1443:                                homePath + "palettes/" + paletteFileList[i], d);
1444:                        Umlet.getInstance().getCards().add(scrollPnl,
1445:                                paletteFileList[i]);
1446:
1447:                        Umlet.getInstance().getPaletteList().addItem(
1448:                                paletteFileList[i]);
1449:                        Umlet.getInstance().getPaletteHashtable().put(
1450:                                paletteFileList[i], d);
1451:                    }
1452:                }
1453:
1454:                //load custom elements from "elements" directory
1455:                String[] elementFileList = new File(homePath
1456:                        + CUSTOM_ELEMENTS_PATH)
1457:                        .list(new CustomElementFilenameFilter());
1458:                Umlet.getInstance().getElementsList().addItem("");
1459:                Umlet.getInstance().getElementsList().addItem("NEW ELEMENT");
1460:                if (elementFileList != null && elementFileList.length > 0) {
1461:                    for (int i = 0; i < elementFileList.length; i++) {
1462:                        Umlet.getInstance().getElementsList().addItem(
1463:                                elementFileList[i]);
1464:                    }
1465:                }
1466:
1467:                //GenPdf.getInstance().outputPdf();
1468:                //GenPdf.getInstance().outputJpeg();
1469:
1470:                //load initial Helptext
1471:                StartUpHelpLabel.getInstance().setVisible();
1472:                Umlet.getInstance().getPanel().addContainerListener(
1473:                        StartUpHelpLabel.getInstance());
1474:
1475:            }
1476:
1477:            protected JDialog _compilerMessageDialog;
1478:
1479:            public void showCompilerMessage(String message) { //LME3
1480:                _compilerMessageDialog = new JDialog(window,
1481:                        "Compiler message", true);
1482:                Container contentPane = _compilerMessageDialog.getContentPane();
1483:                contentPane.setLayout(new BorderLayout());
1484:
1485:                JTextArea textField = new JTextArea();
1486:                JScrollPane scrollPane = new JScrollPane(textField); //make textArea scrollable
1487:                textField.setText(message);
1488:                textField.setEditable(false);
1489:
1490:                JButton okButton = new JButton("Ok");
1491:                okButton.setActionCommand("COMPILER_MESSAGE_DIALOG_OK"); //see UniversalListener
1492:                okButton.addActionListener(UniversalListener.getInstance());
1493:
1494:                contentPane.add(scrollPane);
1495:                contentPane.add(okButton, BorderLayout.SOUTH);
1496:                _compilerMessageDialog.setSize(500, 300);
1497:                Dimension screenDim = Toolkit.getDefaultToolkit()
1498:                        .getScreenSize();
1499:                Dimension dialogDim = _compilerMessageDialog.getSize();
1500:                _compilerMessageDialog.setLocation(screenDim.width / 2
1501:                        - dialogDim.width / 2, screenDim.height / 2
1502:                        - dialogDim.height / 2); //center dialog
1503:                _compilerMessageDialog.setVisible(true);
1504:            }
1505:
1506:            protected JDialog _newCustomElementDialog;
1507:
1508:            public JTextField showNewCustomElementDialog() {
1509:                _newCustomElementDialog = new JDialog(window,
1510:                        "Create new custom element", true);
1511:                Container contentPane = _newCustomElementDialog
1512:                        .getContentPane();
1513:                //contentPane.setLayout(new BorderLayout());
1514:                JTextField elementName = new JTextField("NewElement");
1515:                elementName.setColumns(25);
1516:
1517:                JButton okButton = new JButton("Ok");
1518:                okButton.setActionCommand("NEW_CUSTOM_ELEMENT_OK"); //see UniveralListener
1519:                okButton.addActionListener(UniversalListener.getInstance());
1520:                JButton cancelButton = new JButton("Cancel");
1521:                cancelButton.setActionCommand("NEW_CUSTOM_ELEMENT_CANCEL");
1522:                cancelButton.addActionListener(UniversalListener.getInstance());
1523:
1524:                contentPane.add(elementName);
1525:                Container buttonContainer = new Container();
1526:                buttonContainer.setLayout(new FlowLayout());
1527:                buttonContainer.add(okButton);
1528:                buttonContainer.add(cancelButton);
1529:
1530:                contentPane.add(buttonContainer, BorderLayout.SOUTH);
1531:
1532:                _newCustomElementDialog.pack();
1533:                Dimension screenDim = Toolkit.getDefaultToolkit()
1534:                        .getScreenSize();
1535:                Dimension dialogDim = _newCustomElementDialog.getSize();
1536:                _newCustomElementDialog.setLocation(screenDim.width / 2
1537:                        - dialogDim.width / 2, screenDim.height / 2
1538:                        - dialogDim.height / 2); //center dialog
1539:                _newCustomElementDialog.setVisible(true);
1540:                return elementName;
1541:            }
1542:
1543:            private JMenuItem createColorMenuItem(String name, String colStr,
1544:                    Color color, boolean isForeground) {
1545:                JCheckBoxMenuItem item = new JCheckBoxMenuItem(name);
1546:                item.setActionCommand("color_"
1547:                        + (isForeground ? "fgc_" : "bgc_") + name);
1548:                item.addActionListener(UniversalListener.getInstance());
1549:                item.setState(colStr != null && colStr.equals(name));
1550:                item.setIcon(new PlainColorIcon(color));
1551:                return item;
1552:            }
1553:
1554:            public JPopupMenu getContextMenu(Component comp) {
1555:                Entity entity = null;
1556:                if (comp instanceof  Entity && !(comp instanceof  Relation))
1557:                    entity = (Entity) comp;
1558:                JPopupMenu contextMenu = new JPopupMenu();
1559:                JMenuItem delete = new JMenuItem("Delete");
1560:                delete.addActionListener(UniversalListener.getInstance());
1561:                contextMenu.add(delete);
1562:                JMenuItem group = new JMenuItem("Group");
1563:                group.addActionListener(UniversalListener.getInstance());
1564:                contextMenu.add(group);
1565:                JMenuItem ungroup = new JMenuItem("Ungroup");
1566:                ungroup.addActionListener(UniversalListener.getInstance());
1567:                contextMenu.add(ungroup);
1568:
1569:                String fgcol = null, bgcol = null;
1570:                if (entity != null) {
1571:                    fgcol = entity.getFGColorString();
1572:                    bgcol = entity.getBGColorString();
1573:                }
1574:
1575:                if (entity != null && entity.supportsColors) {
1576:
1577:                    //foreground color menu items
1578:
1579:                    JMenu fg_color = new JMenu("Set foreground color");
1580:                    JCheckBoxMenuItem fgc_default = new JCheckBoxMenuItem(
1581:                            "default");
1582:                    fgc_default.setActionCommand("color_fgc_default");
1583:                    fgc_default.addActionListener(UniversalListener
1584:                            .getInstance());
1585:                    fgc_default.setState(fgcol == null || fgcol.equals(""));
1586:                    fg_color.add(fgc_default);
1587:
1588:                    fg_color.add(new JPopupMenu.Separator());
1589:
1590:                    fg_color.add(createColorMenuItem("red", fgcol, Color.red,
1591:                            true));
1592:                    fg_color.add(createColorMenuItem("green", fgcol,
1593:                            Color.green, true));
1594:                    fg_color.add(createColorMenuItem("blue", fgcol, Color.blue,
1595:                            true));
1596:                    fg_color.add(createColorMenuItem("yellow", fgcol,
1597:                            Color.yellow, true));
1598:                    fg_color.add(createColorMenuItem("white", fgcol,
1599:                            Color.white, true));
1600:                    fg_color.add(createColorMenuItem("black", fgcol,
1601:                            Color.black, true));
1602:                    fg_color.add(createColorMenuItem("gray", fgcol, Color.gray,
1603:                            true));
1604:                    fg_color.add(createColorMenuItem("orange", fgcol,
1605:                            Color.orange, true));
1606:                    fg_color.add(createColorMenuItem("magenta", fgcol,
1607:                            Color.magenta, true));
1608:                    fg_color.add(createColorMenuItem("pink", fgcol, Color.pink,
1609:                            true));
1610:
1611:                    //background color menu items
1612:
1613:                    JMenu bg_color = new JMenu("Set background color");
1614:                    JCheckBoxMenuItem bgc_default = new JCheckBoxMenuItem(
1615:                            "default");
1616:                    bgc_default.setActionCommand("color_bgc_default");
1617:                    bgc_default.addActionListener(UniversalListener
1618:                            .getInstance());
1619:                    bgc_default.setState(bgcol == null || bgcol.equals(""));
1620:                    bg_color.add(bgc_default);
1621:
1622:                    bg_color.add(new JPopupMenu.Separator());
1623:
1624:                    bg_color.add(createColorMenuItem("red", bgcol, Color.red,
1625:                            false));
1626:                    bg_color.add(createColorMenuItem("green", bgcol,
1627:                            Color.green, false));
1628:                    bg_color.add(createColorMenuItem("blue", bgcol, Color.blue,
1629:                            false));
1630:                    bg_color.add(createColorMenuItem("yellow", bgcol,
1631:                            Color.yellow, false));
1632:                    bg_color.add(createColorMenuItem("white", bgcol,
1633:                            Color.white, false));
1634:                    bg_color.add(createColorMenuItem("black", bgcol,
1635:                            Color.black, false));
1636:                    bg_color.add(createColorMenuItem("gray", bgcol, Color.gray,
1637:                            false));
1638:                    bg_color.add(createColorMenuItem("orange", bgcol,
1639:                            Color.orange, false));
1640:                    bg_color.add(createColorMenuItem("magenta", bgcol,
1641:                            Color.magenta, false));
1642:                    bg_color.add(createColorMenuItem("pink", bgcol, Color.pink,
1643:                            false));
1644:
1645:                    contextMenu.add(fg_color);
1646:                    contextMenu.add(bg_color);
1647:                } else {
1648:                    //JMenuItem noColors = new JMenuItem("No color support for this element");
1649:                    JMenu noColors = new JMenu("No color support");
1650:                    JMenuItem t1 = new JMenuItem("For enabling colors in");
1651:                    JMenuItem t2 = new JMenuItem("custom elements:");
1652:                    JMenuItem t3 = new JMenuItem("See the updated custom");
1653:                    JMenuItem t4 = new JMenuItem("elements template file.");
1654:                    t1.setEnabled(false);
1655:                    t2.setEnabled(false);
1656:                    t3.setEnabled(false);
1657:                    t4.setEnabled(false);
1658:                    noColors.add(t1);
1659:                    noColors.add(t2);
1660:                    noColors.add(t3);
1661:                    noColors.add(t4);
1662:
1663:                    contextMenu.add(noColors);
1664:                }
1665:                return contextMenu;
1666:            }
1667:
1668:            protected void realignToGrid() { //LME
1669:                Vector<Entity> v = Umlet.getInstance().getAllEntities();
1670:                for (int i = 0; i < v.size(); i++) {
1671:                    Entity entity = v.elementAt(i);
1672:                    int x = entity.getX();
1673:                    int y = entity.getY();
1674:                    if (entity instanceof  Relation) {
1675:                        Relation r = (Relation) entity;
1676:                        r.reLocate();
1677:                    } else {
1678:                        entity.setLocation(x
1679:                                - (x % Umlet.getInstance().getMainUnit()), y
1680:                                - (y % Umlet.getInstance().getMainUnit()));
1681:                    }
1682:                }
1683:            }
1684:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.