Source Code Cross Referenced for SyntaxStyle.java in  » Web-Services » soapui-1.7.5 » org » syntax » jedit » 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 » Web Services » soapui 1.7.5 » org.syntax.jedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SyntaxStyle.java - A simple text style class
003:         * Copyright (C) 1999 Slava Pestov
004:         *
005:         * You may use and modify this package for any purpose. Redistribution is
006:         * permitted, in both source and binary form, provided that this notice
007:         * remains intact in all source distributions of this package.
008:         */
009:
010:        package org.syntax.jedit;
011:
012:        import java.awt.Color;
013:        import java.awt.Font;
014:        import java.awt.FontMetrics;
015:        import java.awt.Graphics;
016:        import java.awt.Toolkit;
017:
018:        /**
019:         * A simple text style class. It can specify the color, italic flag,
020:         * and bold flag of a run of text.
021:         * @author Slava Pestov
022:         * @version $Id$
023:         */
024:        public class SyntaxStyle {
025:            /**
026:             * Creates a new SyntaxStyle.
027:             * @param color The text color
028:             * @param italic True if the text should be italics
029:             * @param bold True if the text should be bold
030:             */
031:            public SyntaxStyle(Color color, boolean italic, boolean bold) {
032:                this .color = color;
033:                this .italic = italic;
034:                this .bold = bold;
035:            }
036:
037:            /**
038:             * Returns the color specified in this style.
039:             */
040:            public Color getColor() {
041:                return color;
042:            }
043:
044:            /**
045:             * Returns true if no font styles are enabled.
046:             */
047:            public boolean isPlain() {
048:                return !(bold || italic);
049:            }
050:
051:            /**
052:             * Returns true if italics is enabled for this style.
053:             */
054:            public boolean isItalic() {
055:                return italic;
056:            }
057:
058:            /**
059:             * Returns true if boldface is enabled for this style.
060:             */
061:            public boolean isBold() {
062:                return bold;
063:            }
064:
065:            /**
066:             * Returns the specified font, but with the style's bold and
067:             * italic flags applied.
068:             */
069:            public Font getStyledFont(Font font) {
070:                if (font == null)
071:                    throw new NullPointerException("font param must not"
072:                            + " be null");
073:                if (font.equals(lastFont))
074:                    return lastStyledFont;
075:                lastFont = font;
076:                lastStyledFont = new Font(font.getFamily(), (bold ? Font.BOLD
077:                        : 0)
078:                        | (italic ? Font.ITALIC : 0), font.getSize());
079:                return lastStyledFont;
080:            }
081:
082:            /**
083:             * Returns the font metrics for the styled font.
084:             */
085:            public FontMetrics getFontMetrics(Font font) {
086:                if (font == null)
087:                    throw new NullPointerException("font param must not"
088:                            + " be null");
089:                if (font.equals(lastFont) && fontMetrics != null)
090:                    return fontMetrics;
091:                lastFont = font;
092:                lastStyledFont = new Font(font.getFamily(), (bold ? Font.BOLD
093:                        : 0)
094:                        | (italic ? Font.ITALIC : 0), font.getSize());
095:                fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(
096:                        lastStyledFont);
097:                return fontMetrics;
098:            }
099:
100:            /**
101:             * Sets the foreground color and font of the specified graphics
102:             * context to that specified in this style.
103:             * @param gfx The graphics context
104:             * @param font The font to add the styles to
105:             */
106:            public void setGraphicsFlags(Graphics gfx, Font font) {
107:                Font _font = getStyledFont(font);
108:                gfx.setFont(_font);
109:                gfx.setColor(color);
110:            }
111:
112:            /**
113:             * Returns a string representation of this object.
114:             */
115:            public String toString() {
116:                return getClass().getName() + "[color=" + color
117:                        + (italic ? ",italic" : "") + (bold ? ",bold" : "")
118:                        + "]";
119:            }
120:
121:            // private members
122:            private Color color;
123:            private boolean italic;
124:            private boolean bold;
125:            private Font lastFont;
126:            private Font lastStyledFont;
127:            private FontMetrics fontMetrics;
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.