Source Code Cross Referenced for TableFrame.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » graph » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.graph;
002:
003:        import net.sourceforge.squirrel_sql.plugins.graph.xmlbeans.TableFrameXmlBean;
004:
005:        import javax.swing.*;
006:        import javax.swing.border.LineBorder;
007:        import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
008:        import javax.swing.plaf.basic.BasicInternalFrameUI;
009:        import javax.imageio.ImageReader;
010:        import javax.imageio.stream.ImageInputStream;
011:        import javax.imageio.stream.ImageInputStreamImpl;
012:        import java.awt.*;
013:        import java.awt.geom.AffineTransform;
014:        import java.net.URL;
015:
016:        public class TableFrame extends JInternalFrame {
017:            GraphTextAreaFactory txtColumsFactory;
018:            JScrollPane scrollPane;
019:            private MyUI _myUI;
020:            private Zoomer _zoomer;
021:            private ZoomerListener _zoomerListener;
022:
023:            public TableFrame(String tableName, TableFrameXmlBean xmlBean,
024:                    TableToolTipProvider toolTipProvider, Zoomer zoomer) {
025:                _zoomer = zoomer;
026:
027:                scrollPane = new JScrollPane();
028:                scrollPane.setBorder(null);
029:
030:                getContentPane().add(scrollPane);
031:
032:                setMaximizable(false);
033:                setClosable(true);
034:                setIconifiable(false);
035:
036:                setTitle(tableName);
037:                setBackground(new Color(255, 255, 204));
038:
039:                setResizable(true);
040:
041:                setFrameIcon(null);
042:
043:                _myUI = new MyUI(this );
044:                setUI(_myUI);
045:
046:                txtColumsFactory = new GraphTextAreaFactory(toolTipProvider,
047:                        zoomer);
048:                scrollPane.setViewportView(txtColumsFactory.getComponent(zoomer
049:                        .isEnabled()));
050:
051:                if (null != xmlBean) {
052:                    double zoom = _zoomer.getZoom();
053:
054:                    Rectangle r = new Rectangle();
055:                    r.x = (int) (zoom * xmlBean.getX() + 0.5);
056:                    r.y = (int) (zoom * xmlBean.getY() + 0.5);
057:                    r.width = (int) (zoom * xmlBean.getWidht() + 0.5);
058:                    r.height = (int) (zoom * xmlBean.getHeight() + 0.5);
059:                    setBounds(r);
060:                    setClosable(!_zoomer.isEnabled());
061:                }
062:
063:                _zoomerListener = new ZoomerListener() {
064:                    public void zoomChanged(double newZoom, double oldZoom,
065:                            boolean adjusting) {
066:                    }
067:
068:                    public void zoomEnabled(boolean b) {
069:                        onZoomEnabled(b);
070:                    }
071:
072:                    public void setHideScrollBars(boolean b) {
073:                    }
074:                };
075:
076:                setBorder(new LineBorder(Color.BLACK));
077:            }
078:
079:            public void setVisible(boolean b) {
080:                if (null != _zoomer) {
081:                    if (b) {
082:                        _zoomer.addZoomListener(_zoomerListener);
083:                        onZoomEnabled(_zoomer.isEnabled());
084:                    } else {
085:                        _zoomer.removeZoomListener(_zoomerListener);
086:                    }
087:                }
088:
089:                super .setVisible(b);
090:            }
091:
092:            private void onZoomEnabled(boolean b) {
093:                scrollPane.setViewportView(txtColumsFactory
094:                        .getComponent(_zoomer.isEnabled()));
095:                setClosable(!b);
096:            }
097:
098:            public TableFrame.MyTitlePaneUI getTitlePane() {
099:                return _myUI.getTitlePane();
100:            }
101:
102:            public TableFrameXmlBean getXmlBean() {
103:                TableFrameXmlBean ret = new TableFrameXmlBean();
104:
105:                double zoom = _zoomer.getZoom();
106:
107:                Rectangle bounds = getBounds();
108:                ret.setX((int) (bounds.x / zoom + 0.5));
109:                ret.setY((int) (bounds.y / zoom + 0.5));
110:                ret.setWidht((int) (bounds.width / zoom + 0.5));
111:                ret.setHeight((int) (bounds.height / zoom + 0.5));
112:
113:                return ret;
114:
115:            }
116:
117:            class MyUI extends BasicInternalFrameUI {
118:                public MyUI(JInternalFrame frame) {
119:                    super (frame);
120:                }
121:
122:                protected JComponent createNorthPane(JInternalFrame w) {
123:                    titlePane = new MyTitlePaneUI(w);
124:                    return titlePane;
125:                }
126:
127:                public TableFrame.MyTitlePaneUI getTitlePane() {
128:                    return (MyTitlePaneUI) _myUI.titlePane;
129:                }
130:
131:            }
132:
133:            class MyTitlePaneUI extends BasicInternalFrameTitlePane {
134:                public static final int UNZOOMED_PREF_HEIGHT = 18;
135:
136:                public MyTitlePaneUI(JInternalFrame f) {
137:                    super (f);
138:                }
139:
140:                protected void installDefaults() {
141:                    super .installDefaults();
142:                    URL resource = TableFrame.class
143:                            .getResource("/net/sourceforge/squirrel_sql/plugins/graph/images/win_bigclose-rollover.gif");
144:                    closeIcon = new ImageIcon(resource);
145:                    selectedTextColor = Color.black;
146:                    notSelectedTextColor = Color.black;
147:                    setFont(new Font(getFont().getFontName(), Font.BOLD,
148:                            getFont().getSize()));
149:                }
150:
151:                protected void paintTitleBackground(Graphics g) {
152:                    g.setColor(new Color(255, 255, 220));
153:                    g.fillRect(0, 0, getWidth(), getHeight());
154:                }
155:
156:                public void paintComponent(Graphics g) {
157:                    paintTitleBackground(g);
158:
159:                    if (frame.getTitle() != null) {
160:                        boolean isSelected = frame.isSelected();
161:                        Font f = g.getFont();
162:                        g.setFont(getFont());
163:                        if (isSelected)
164:                            g.setColor(selectedTextColor);
165:                        else
166:                            g.setColor(notSelectedTextColor);
167:
168:                        // Center text vertically.
169:                        FontMetrics fm = g.getFontMetrics();
170:
171:                        double s = _zoomer.getZoom();
172:                        int baseline = ((int) (getHeight() / s)
173:                                + fm.getAscent() - fm.getLeading() - fm
174:                                .getDescent()) / 2;
175:
176:                        int titleX;
177:                        Rectangle r = new Rectangle(0, 0, 0, 0);
178:                        if (frame.isIconifiable())
179:                            r = iconButton.getBounds();
180:                        else if (frame.isMaximizable())
181:                            r = maxButton.getBounds();
182:                        else if (frame.isClosable())
183:                            r = closeButton.getBounds();
184:                        int titleW;
185:
186:                        String title = frame.getTitle();
187:
188:                        if (r.x == 0)
189:                            r.x = frame.getWidth() - frame.getInsets().right;
190:                        titleX = menuBar.getX() + menuBar.getWidth() + 2;
191:                        titleW = (int) ((r.x - titleX - 3) / _zoomer.getZoom() + 0.5);
192:                        title = getTitle(frame.getTitle(), fm, titleW);
193:
194:                        Graphics2D g2d = (Graphics2D) g;
195:                        AffineTransform origTrans = g2d.getTransform();
196:
197:                        AffineTransform at = new AffineTransform(origTrans);
198:                        at.scale(_zoomer.getZoom(), _zoomer.getZoom());
199:                        g2d.setTransform(at);
200:
201:                        g.drawString(title, titleX, baseline);
202:
203:                        g2d.setTransform(origTrans);
204:
205:                        g.setFont(f);
206:                    }
207:                }
208:
209:                protected LayoutManager createLayout() {
210:                    return new MyTitlePaneLayout();
211:                }
212:
213:                public Dimension getPreferredSize() {
214:                    Dimension ret = super .getPreferredSize();
215:
216:                    ret.height = (int) (UNZOOMED_PREF_HEIGHT
217:                            * _zoomer.getZoom() + 0.5);
218:                    return ret;
219:                }
220:
221:                /**
222:                 * This removes the system menu
223:                 * @return
224:                 */
225:                protected JMenuBar createSystemMenuBar() {
226:                    menuBar = new JMenuBar() {
227:                        public void setSize(int width, int height) {
228:                            super .setSize(0, 0);
229:                        }
230:
231:                        public void setBounds(int x, int y, int width,
232:                                int height) {
233:                            super .setBounds(0, 0, 0, 0);
234:                        }
235:                    };
236:                    menuBar.setBorderPainted(false);
237:                    menuBar.setSize(0, 0);
238:                    menuBar.setBounds(0, 0, 0, 0);
239:                    return menuBar;
240:                }
241:
242:                class MyTitlePaneLayout extends
243:                        BasicInternalFrameTitlePane.TitlePaneLayout {
244:
245:                    public Dimension minimumLayoutSize(Container c) {
246:                        Dimension ret = super.minimumLayoutSize(c);
247:                        ret.width *= _zoomer.getZoom();
248:                        ret.height *= _zoomer.getZoom();
249:                        return ret;
250:                    }
251:                }
252:
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.