Source Code Cross Referenced for Class.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:        package com.umlet.element.base;
003:
004:        import java.awt.*;
005:        import java.util.*;
006:
007:        import com.umlet.control.*;
008:
009:        /**
010:         * <p>Title:</p>
011:         * <p>Description:</p>
012:         * <p>Copyright: Copyright (c) 2001</p>
013:         * <p>Company:</p>
014:         * 
015:         * @author unascribed
016:         * @version 1.0
017:         */
018:
019:        public class Class extends Entity {
020:
021:            // A.Mueller start
022:            private Vector<Class> innerClasses;
023:            private boolean _isTemplate = false;
024:            private boolean _isInnerClass = false;
025:            private String _panelString = "";
026:            private int _templateHeight = 0;
027:            private int _templateWidth = 0;
028:
029:            // A.Mueller end
030:
031:            public Class(String s) {
032:                super (s);
033:                innerClasses = new Vector<Class>(); //A.Mueller
034:            }
035:
036:            public Class() {
037:                super ();
038:                innerClasses = new Vector<Class>(); //A.Mueller
039:            }
040:
041:            private Vector getStringVector() {
042:                if (this .isInnerClass())
043:                    return Constants.decomposeStrings(_panelString, "\n"); //A.Mueller
044:                Vector ret = Constants.decomposeStrings(this 
045:                        .getPanelAttributes(), "\n");
046:                return ret;
047:            }
048:
049:            // A.Mueller start
050:            public Vector<Class> getInnerClasses() {
051:                return this .innerClasses;
052:            }
053:
054:            public boolean isInnerClass() {
055:                return _isInnerClass;
056:            }
057:
058:            public void setIsInnerClass(boolean i) {
059:                this ._isInnerClass = i;
060:            }
061:
062:            public void setPanelString(String p) {
063:                this ._panelString = p;
064:            }
065:
066:            // A.Mueller end
067:
068:            public void paint(Graphics g) {
069:                int innerSoFar = 0; //A.Mueller
070:
071:                Graphics2D g2 = (Graphics2D) g;
072:                g2.setFont(Constants.getFont());
073:                Constants.getFRC(g2);
074:                Vector tmp = getStringVector();
075:                int yPos = 0;
076:
077:                yPos += Constants.getDistLineToText();
078:
079:                Composite[] composites = colorize(g2); //LME: enable colors
080:                g2.setColor(_activeColor);
081:
082:                /*EDIT fixed EMPTY_CLASS_1*/
083:                String line1 = "";
084:                if (!tmp.isEmpty())
085:                    line1 = (String) tmp.elementAt(0);
086:                /*END EDIT*/
087:
088:                if (line1 != null && line1.startsWith("template"))
089:                    _isTemplate = true;
090:
091:                Rectangle r = this .getBounds();
092:
093:                boolean DASHED = false;
094:                boolean CENTER = true;
095:                for (int i = 0; i < tmp.size(); i++) {
096:                    String s = (String) tmp.elementAt(i);
097:                    if (s.equals("--")) {
098:                        CENTER = false;
099:
100:                        // A.Mueller start
101:                        if (_isTemplate)
102:                            g2.drawLine(0, yPos, this .getWidth() - 1
103:                                    - this .getWidth() / 10, yPos);
104:                        else
105:                            g2.drawLine(0, yPos, this .getWidth(), yPos);
106:                        // A.Mueller end
107:
108:                        yPos += Constants.getDistLineToText();
109:
110:                        // A.Mueller start
111:                    } else if (s.equals("lt=.")) {
112:                        DASHED = true;
113:                    } else if (s.equals("{active}") && i == 0) {
114:                        g2.drawLine(Constants.getFontsize() / 2, 0, Constants
115:                                .getFontsize() / 2, this .getHeight() - 1);
116:                        g2.drawLine(this .getWidth() - Constants.getFontsize()
117:                                / 2, 0, this .getWidth()
118:                                - Constants.getFontsize() / 2,
119:                                this .getHeight() - 1);
120:                        yPos = this .getHeight()
121:                                / 2
122:                                - (tmp.size() - 1)
123:                                * (Constants.getFontsize() + Constants
124:                                        .getDistTextToText()) / 2;
125:                    } else if (s.startsWith("template") && i == 0) {
126:                        String[] template = s.split("=");
127:                        if (template.length == 2) {
128:
129:                            _templateWidth = Constants.getPixelWidth(g2,
130:                                    template[1])
131:                                    + Constants.getDistLineToText()
132:                                    + Constants.getDistTextToLine();
133:                            _templateHeight = Constants.getFontsize()
134:                                    + Constants.getDistTextToLine()
135:                                    + Constants.getDistLineToText();
136:
137:                            Polygon border = new Polygon();
138:                            border.addPoint(0, _templateHeight / 2);
139:                            border.addPoint(getWidth() - _templateWidth,
140:                                    _templateHeight / 2);
141:                            border.addPoint(0, _templateHeight / 2);
142:                            border.addPoint(0, this .getHeight());
143:                            border.addPoint(0, this .getHeight() - 1);
144:                            border.addPoint(this .getWidth() - this .getWidth()
145:                                    / 10, this .getHeight() - 1);
146:                            border.addPoint(this .getWidth() - this .getWidth()
147:                                    / 10, this .getHeight() - 1);
148:                            border.addPoint(this .getWidth() - this .getWidth()
149:                                    / 10, _templateHeight + 1);
150:                            border.addPoint(getWidth() - _templateWidth,
151:                                    _templateHeight + 1);
152:                            border.addPoint(getWidth() - _templateWidth,
153:                                    _templateHeight / 2);
154:
155:                            g2.setStroke(Constants.getStroke(1, 1));
156:                            g2.setComposite(composites[1]); //set alpha composite
157:                            g2.setColor(_fillColor);
158:                            g2.fillRect(getWidth() - _templateWidth, 0,
159:                                    _templateWidth, _templateHeight + 1);
160:                            g2.fillPolygon(border);
161:                            g2.setComposite(composites[0]); //reset composite
162:                            if (_selected)
163:                                g2.setColor(_activeColor);
164:                            else
165:                                g2.setColor(_deselectedColor);
166:
167:                            //draw border lines of template box
168:                            g2.drawRect(getWidth() - _templateWidth, 0,
169:                                    _templateWidth - 1, _templateHeight); //template box
170:                            Constants.write(g2, template[1], getWidth()
171:                                    - _templateWidth
172:                                    + Constants.getDistLineToText(), Constants
173:                                    .getFontsize()
174:                                    + Constants.getDistLineToText(), false);
175:                            g2.setStroke(Constants.getStroke(0, 1));
176:
177:                            //draw border lines of class
178:                            g2.drawLine(0, _templateHeight / 2, getWidth()
179:                                    - _templateWidth, _templateHeight / 2);
180:                            g2.drawLine(0, _templateHeight / 2, 0, this 
181:                                    .getHeight());
182:                            g2.drawLine(0, this .getHeight() - 1, this 
183:                                    .getWidth()
184:                                    - this .getWidth() / 10,
185:                                    this .getHeight() - 1);
186:                            g2.drawLine(this .getWidth() - this .getWidth() / 10,
187:                                    this .getHeight() - 1, this .getWidth()
188:                                            - this .getWidth() / 10,
189:                                    _templateHeight);
190:
191:                            yPos = yPos + _templateHeight
192:                                    + Constants.getDistLineToText();
193:                        } else
194:                            _isTemplate = false;
195:                    } else if (s.equals("{innerclass")) {
196:                        String state = "";
197:                        // Counting the inner lines helps to determine the Height of the
198:                        // resulting innerClass (lines times the fontsize gives us the height of
199:                        // the contents) by adding also the INNER words we make sure to have enough
200:                        // space at the bottom since the lines of the classes also need space
201:                        int innerLines = 0;
202:                        int innerCount = 0;
203:                        for (i++; i < tmp.size(); i++) {
204:                            if (tmp.elementAt(i).equals("{innerclass")) {
205:                                innerCount++;
206:                                innerLines++;
207:                            } else if (tmp.elementAt(i).equals("innerclass}")) {
208:                                if (innerCount > 0)
209:                                    innerCount--;
210:                                else
211:                                    break;
212:                            } else
213:                                innerLines++;
214:                            state = state + "\n" + tmp.elementAt(i);
215:                        }
216:
217:                        Class temp;
218:                        try {
219:                            temp = innerClasses.get(innerSoFar);
220:                            temp.setPanelString(state);
221:                        } catch (ArrayIndexOutOfBoundsException e) {
222:                            temp = new Class();
223:                            innerClasses.add(innerSoFar, temp);
224:                            temp.setIsInnerClass(true);
225:                            temp.setPanelString(state);
226:                            innerSoFar++;
227:                        }
228:
229:                        int height = innerLines * Constants.getFontsize()
230:                                + Constants.getDistLineToText()
231:                                + Constants.getDistTextToLine()
232:                                + Constants.getDistTextToText() * --innerLines;
233:
234:                        if (this .isSelected())
235:                            temp.onSelected();
236:                        else
237:                            temp.onDeselected();
238:
239:                        temp.setLocation(5, yPos);
240:
241:                        if (_isTemplate)
242:                            temp.setSize(this .getWidth() - this .getWidth() / 10
243:                                    - 10, height);
244:                        else
245:                            temp.setSize(this .getWidth() - 10, height);
246:
247:                        temp.removeMouseListener(UniversalListener
248:                                .getInstance());
249:                        temp.removeMouseMotionListener(UniversalListener
250:                                .getInstance());
251:                        temp.paint(g.create(5, yPos, this .getWidth() - 5, temp
252:                                .getHeight()));
253:                        yPos = yPos + temp.getHeight()
254:                                + Constants.getDistLineToText();
255:
256:                        // A.Mueller end
257:
258:                    } else {
259:                        if (_selected)
260:                            g2.setColor(_activeColor);
261:                        else
262:                            g2.setColor(_deselectedColor);
263:                        yPos += Constants.getFontsize();
264:                        if (CENTER) {
265:                            //A.Mueller
266:                            if (_isTemplate)
267:                                Constants.write(g2, s,
268:                                        ((int) this .getWidth() - this 
269:                                                .getWidth() / 10) / 2, yPos,
270:                                        true);
271:                            else
272:                                Constants.write(g2, s,
273:                                        (int) this .getWidth() / 2, yPos, true);
274:                        } else {
275:                            Constants.write(g2, s, Constants.getFontsize() / 2,
276:                                    yPos, false);
277:                        }
278:                        yPos += Constants.getDistTextToText();
279:                    }
280:                }
281:
282:                if (!_isTemplate) {
283:                    g2.setComposite(composites[1]); //set aplha composite for drawing the background color
284:                    g2.setColor(_fillColor);
285:                    g2.fillRect(0, 0, (int) r.getWidth() - 1, (int) r
286:                            .getHeight() - 1);
287:                    g2.setComposite(composites[0]); //reset composite settings
288:                    if (_selected)
289:                        g2.setColor(_activeColor);
290:                    else
291:                        g2.setColor(_deselectedColor);
292:                    if (DASHED)
293:                        g2.setStroke(Constants.getStroke(1, 1));
294:                    g2.drawRect(0, 0, (int) r.getWidth() - 1, (int) r
295:                            .getHeight() - 1);
296:                }
297:
298:                _isTemplate = false;
299:            }
300:
301:            public StickingPolygon getStickingBorder() { //A.Mueller
302:                // LME: define the polygon on which relations stick on
303:                if (!_isTemplate)
304:                    return super .getStickingBorder();
305:                StickingPolygon p = new StickingPolygon();
306:                p.addLine(new Point(0, _templateHeight / 2), new Point(this 
307:                        .getWidth()
308:                        - _templateWidth, _templateHeight / 2),
309:                        Constants.RESIZE_TOP);
310:                p.addLine(new Point(this .getWidth() - _templateWidth,
311:                        _templateHeight / 2), new Point(this .getWidth()
312:                        - _templateWidth, 0), Constants.RESIZE_TOP);
313:                p.addLine(new Point(this .getWidth() - _templateWidth, 0),
314:                        new Point(this .getWidth(), 0), Constants.RESIZE_TOP);
315:                p.addLine(new Point(this .getWidth(), 0), new Point(this 
316:                        .getWidth(), _templateHeight), Constants.RESIZE_RIGHT);
317:                p.addLine(new Point(this .getWidth(), _templateHeight),
318:                        new Point(this .getWidth() - this .getWidth() / 10,
319:                                _templateHeight), Constants.RESIZE_RIGHT);
320:                p.addLine(new Point(this .getWidth() - this .getWidth() / 10,
321:                        this .getHeight() - 1), new Point(this .getWidth()
322:                        - this .getWidth() / 10, _templateHeight),
323:                        Constants.RESIZE_RIGHT);
324:                p.addLine(new Point(0, _templateHeight / 2), new Point(0, this 
325:                        .getHeight()), Constants.RESIZE_LEFT);
326:                p.addLine(new Point(0, this .getHeight() - 1), new Point(this 
327:                        .getWidth()
328:                        - this .getWidth() / 10, this .getHeight() - 1),
329:                        Constants.RESIZE_BOTTOM);
330:                return p;
331:            }
332:
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.