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