Source Code Cross Referenced for Group.java in  » UML » umlet » com » umlet » element » base » 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.element.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The UMLet source code is distributed under the terms of the GPL; see license.txt
002:        //Class by A.Mueller Oct.05
003:
004:        package com.umlet.element.base;
005:
006:        import com.umlet.control.AddEntity;
007:        import com.umlet.control.Command;
008:        import com.umlet.control.Constants;
009:        import com.umlet.control.Controller;
010:        import com.umlet.control.MoveLinePoint;
011:        import com.umlet.control.Selector;
012:        import com.umlet.control.StickingPolygon;
013:        import com.umlet.control.Umlet;
014:        import com.umlet.control.UniversalListener;
015:        import com.umlet.element.base.detail.RelationLinePoint;
016:
017:        import java.util.Iterator;
018:        import java.util.Vector;
019:        import java.util.Enumeration;
020:        import java.awt.Graphics;
021:        import java.awt.Graphics2D;
022:        import java.awt.Point;
023:
024:        public class Group extends Entity {
025:            private Vector<Entity> entities;
026:
027:            //after adding all elements to a group the function adjustSize has to be called!
028:            public Group() {
029:                super ();
030:                this .entities = new Vector<Entity>();
031:            }
032:
033:            /**
034:             * Erstellt einen neue Gruppe
035:             *
036:             */
037:            public void groupSelected() {
038:                Vector<Entity> ents = Selector.getInstance()
039:                        .getSelectedEntities();
040:                if (ents.isEmpty())
041:                    return;
042:
043:                for (Iterator<Entity> it = ents.iterator(); it.hasNext();)
044:                    this .addMember(it.next());
045:
046:                adjustSize();
047:                Selector.getInstance().deselectAll();
048:                Selector.getInstance().selectXXX(this );
049:                Controller.getInstance().executeCommandWithoutUndo(
050:                        new AddEntity(this , this .getLocation().x, this 
051:                                .getLocation().y));
052:            }
053:
054:            public void ungroup() {
055:                for (int i = 0; i < entities.size(); i++) {
056:                    entities.get(i).setGroup(null);
057:                    entities.get(i).addMouseListener(
058:                            UniversalListener.getInstance());
059:                    entities.get(i).addMouseMotionListener(
060:                            UniversalListener.getInstance());
061:                }
062:
063:                Umlet.getInstance().getPanel().remove(this );
064:            }
065:
066:            public Vector<Entity> getMembers() {
067:                return entities;
068:            }
069:
070:            public void addMember(Entity member) {
071:                this .entities.add(member);
072:                member.setGroup(this );
073:                member.removeMouseListener(UniversalListener.getInstance());
074:                member.removeMouseMotionListener(UniversalListener
075:                        .getInstance());
076:            }
077:
078:            public void paint(Graphics g) {
079:                if (this .isSelected()) {
080:                    Graphics2D g2 = (Graphics2D) g;
081:                    Constants.getFRC(g2);
082:                    g2.setColor(java.awt.Color.green);
083:                    g2.setStroke(Constants.getStroke(1, 1));
084:                    g2
085:                            .drawRect(0, 0, this .getWidth() - 1, this 
086:                                    .getHeight() - 1);
087:                    g2.setStroke(Constants.getStroke(0, 1));
088:                }
089:            }
090:
091:            public void adjustSize() {
092:                if (entities.isEmpty())
093:                    return;
094:                Enumeration e = entities.elements();
095:                int maxX = 0;
096:                int maxY = 0;
097:                int minX = 0;
098:                int minY = 0;
099:                boolean first = true;
100:                while (e.hasMoreElements()) {
101:                    Entity temp = (Entity) e.nextElement();
102:                    if (!first) {
103:                        maxX = Math.max(temp.getX() + temp.getWidth(), maxX);
104:                        maxY = Math.max(temp.getY() + temp.getHeight(), maxY);
105:                        minX = Math.min(temp.getX(), minX);
106:                        minY = Math.min(temp.getY(), minY);
107:                    } else {
108:                        first = false;
109:                        maxX = temp.getX() + temp.getWidth();
110:                        maxY = temp.getY() + temp.getHeight();
111:                        minX = temp.getX();
112:                        minY = temp.getY();
113:                    }
114:                }
115:                this .setLocation(minX, minY);
116:                this .setSize((maxX - minX), (maxY - minY));
117:            }
118:
119:            @Override
120:            public StickingPolygon getStickingBorder() {
121:                return null;
122:            }
123:
124:            @Override
125:            public Entity CloneFromMe() {
126:                Selector.getInstance().deselectAll();
127:                Group temp = new Group();
128:
129:                for (Entity e : this .entities) {
130:                    Entity clone = e.CloneFromMe();
131:                    Command cmd;
132:                    int MAIN_UNIT = Umlet.getInstance().getMainUnit();
133:                    if (e.getParent() == Umlet.getInstance().getPalettePanel()) {
134:                        Point viewp = Umlet.getInstance().getScrollPaneMain()
135:                                .getViewport().getViewPosition();
136:                        cmd = new AddEntity(clone, viewp.x
137:                                - (viewp.x % MAIN_UNIT) + e.getX()
138:                                - this .getX() + MAIN_UNIT * 2, viewp.y
139:                                - (viewp.y % MAIN_UNIT) + e.getY()
140:                                - this .getY() + MAIN_UNIT * 2);
141:                    } else {
142:                        cmd = new AddEntity(clone, e.getX() + MAIN_UNIT * 2, e
143:                                .getY()
144:                                + MAIN_UNIT * 2);
145:                    }
146:
147:                    clone.setState(e.getState());
148:                    Controller.getInstance().executeCommandWithoutUndo(cmd);
149:                    temp.addMember(clone);
150:
151:                }
152:                temp.adjustSize();
153:                return temp;
154:            }
155:
156:            public int getPossibleResizeDirections() { //LME: deny resizing of groups
157:                return 0;
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.