Source Code Cross Referenced for VertexCellRenderer.java in  » UML » MetaBoss » com » metaboss » applications » designstudio » components » 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 » MetaBoss » com.metaboss.applications.designstudio.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.applications.designstudio.components;
016:
017:        import java.awt.AlphaComposite;
018:        import java.awt.Color;
019:        import java.awt.Composite;
020:        import java.awt.Dimension;
021:        import java.awt.FontMetrics;
022:        import java.awt.Graphics;
023:        import java.awt.Graphics2D;
024:        import java.awt.Image;
025:        import java.awt.Rectangle;
026:        import java.awt.image.BufferedImage;
027:
028:        import javax.swing.JLabel;
029:        import javax.swing.SwingUtilities;
030:
031:        import org.jgraph.graph.DefaultGraphCell;
032:        import org.jgraph.graph.VertexRenderer;
033:
034:        import com.metaboss.applications.designstudio.Application;
035:        import com.metaboss.applications.designstudio.BaseUserObject;
036:
037:        /* 		Define the Renderer for the DesignGraph Vertex 		*/
038:
039:        public class VertexCellRenderer extends VertexRenderer {
040:            protected float mAlpha = 0.80f;
041:            protected float mVertexAlpha = 0.60f;
042:
043:            public void paint(Graphics g) {
044:                try {
045:                    if (selected)
046:                        super .paint(g);
047:                    else {
048:                        Graphics2D g2 = (Graphics2D) g;
049:                        Composite originalComposite = g2.getComposite();
050:                        g2.setComposite(AlphaComposite.getInstance(
051:                                AlphaComposite.SRC_OVER, mAlpha));
052:                        try {
053:                            super .paint(g2);
054:                        } finally {
055:                            g2.setComposite(originalComposite);
056:                        }
057:                    }
058:                    //super.paint(g);
059:                    paintSelectionBorder(g);
060:
061:                    DefaultGraphCell lCell = (DefaultGraphCell) view.getCell();
062:                    if (lCell != null) {
063:                        Object lObject = lCell.getUserObject();
064:                        if (lObject instanceof  BaseUserObject) {
065:                            if (Application
066:                                    .isErrorElementID(((BaseUserObject) lObject)
067:                                            .getID())) {
068:                                Dimension d = getSize();
069:                                g.setColor(Color.red);
070:                                g.drawRect(1, 1, d.width - 3, d.height - 3);
071:                            }
072:                        }
073:                    }
074:                } catch (IllegalArgumentException e) {
075:                    // JDK Bug: Zero length string passed to TextLayout constructor
076:                }
077:            }
078:
079:            // calculate vertex prefered size
080:            protected Dimension calculatePreferredSize(int pMinWidth,
081:                    int pMinHeight, int pMaxWidth, int pMaxHeight) {
082:                Image offscreen = new BufferedImage(50, 50,
083:                        BufferedImage.TYPE_INT_RGB);
084:                Graphics g = offscreen.getGraphics();
085:                String lText = getText();
086:
087:                g.setFont(getFont());
088:                int lWidth = (int) getFontMetrics(g.getFont()).getStringBounds(
089:                        lText, g).getWidth() + 10;
090:                int lHeight = getFontMetrics(g.getFont()).getHeight();
091:
092:                if (pMinWidth > lWidth)
093:                    lWidth = pMinWidth;
094:                if (pMinHeight > lHeight)
095:                    lHeight = pMinHeight;
096:                if (pMaxWidth < lWidth)
097:                    lWidth = pMaxWidth;
098:                if (pMaxHeight < lHeight)
099:                    lHeight = pMaxHeight;
100:
101:                return new Dimension(lWidth, lHeight);
102:            }
103:
104:            // paint vertex caption
105:            protected void paintCaption(Graphics g, Rectangle pRect) {
106:                Rectangle iconR = new Rectangle(0, 0, 0, 0);
107:                Rectangle textR = new Rectangle(0, 0, 0, 0);
108:
109:                FontMetrics fm = g.getFontMetrics();
110:                String lText = SwingUtilities.layoutCompoundLabel(fm,
111:                        getText(), null, JLabel.CENTER, JLabel.CENTER,
112:                        JLabel.CENTER, JLabel.CENTER, pRect, iconR, textR, 0);
113:
114:                int textX = textR.x;
115:                int textY = textR.y + fm.getAscent();
116:
117:                g.drawString(lText, textX, textY);
118:            }
119:
120:            // fill rectangle
121:            protected void fillRect(Graphics g, Rectangle pRect) {
122:                if (selected)
123:                    g.fillRect(pRect.x, pRect.y, pRect.width, pRect.height);
124:                else {
125:                    Graphics2D g2 = (Graphics2D) g;
126:                    Composite originalComposite = g2.getComposite();
127:                    g2.setComposite(AlphaComposite.getInstance(
128:                            AlphaComposite.SRC_OVER, mVertexAlpha));
129:                    try {
130:                        g.fillRect(pRect.x, pRect.y, pRect.width, pRect.height);
131:                    } finally {
132:                        g2.setComposite(originalComposite);
133:                    }
134:                }
135:            }
136:
137:            // fill round rectangle
138:            protected void fillRoundRect(Graphics g, Rectangle pRect,
139:                    int arcWidth, int arcHeight) {
140:                if (selected)
141:                    g.fillRoundRect(pRect.x, pRect.y, pRect.width,
142:                            pRect.height, arcWidth, arcHeight);
143:                else {
144:                    Graphics2D g2 = (Graphics2D) g;
145:                    Composite originalComposite = g2.getComposite();
146:                    g2.setComposite(AlphaComposite.getInstance(
147:                            AlphaComposite.SRC_OVER, mVertexAlpha));
148:                    try {
149:                        g.fillRoundRect(pRect.x, pRect.y, pRect.width,
150:                                pRect.height, arcWidth, arcHeight);
151:                    } finally {
152:                        g2.setComposite(originalComposite);
153:                    }
154:                }
155:            }
156:
157:            // fill oval
158:            protected void fillOval(Graphics g, Rectangle pRect) {
159:                if (selected)
160:                    g.fillOval(pRect.x, pRect.y, pRect.width, pRect.height);
161:                else {
162:                    Graphics2D g2 = (Graphics2D) g;
163:                    Composite originalComposite = g2.getComposite();
164:                    g2.setComposite(AlphaComposite.getInstance(
165:                            AlphaComposite.SRC_OVER, mVertexAlpha));
166:                    try {
167:                        g.fillOval(pRect.x, pRect.y, pRect.width, pRect.height);
168:                    } finally {
169:                        g2.setComposite(originalComposite);
170:                    }
171:                }
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.