Source Code Cross Referenced for TransformAttribute.java in  » 6.0-JDK-Core » AWT » java » awt » font » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.font 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        /*
027         * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
028         * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
029         *
030         * The original version of this source code and documentation is
031         * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
032         * of IBM. These materials are provided under terms of a License
033         * Agreement between Taligent and Sun. This technology is protected
034         * by multiple US and International patents.
035         *
036         * This notice and attribution to Taligent may not be removed.
037         * Taligent is a registered trademark of Taligent, Inc.
038         *
039         */
040
041        package java.awt.font;
042
043        import java.awt.geom.AffineTransform;
044        import java.io.Serializable;
045        import java.io.ObjectStreamException;
046
047        /**
048         * The <code>TransformAttribute</code> class provides an immutable
049         * wrapper for a transform so that it is safe to use as an attribute.
050         */
051        public final class TransformAttribute implements  Serializable {
052
053            /** 
054             * The <code>AffineTransform</code> for this 
055             * <code>TransformAttribute</code>, or <code>null</code>
056             * if <code>AffineTransform</code> is the identity transform.
057             */
058            private AffineTransform transform;
059
060            /**
061             * Wraps the specified transform.  The transform is cloned and a
062             * reference to the clone is kept.  The original transform is unchanged.
063             * If null is passed as the argument, this constructor behaves as though 
064             * it were the identity transform.  (Note that it is preferable to use
065             * {@link #IDENTITY} in this case.)
066             * @param transform the specified {@link AffineTransform} to be wrapped,
067             * or null.
068             */
069            public TransformAttribute(AffineTransform transform) {
070                if (transform != null && !transform.isIdentity()) {
071                    this .transform = new AffineTransform(transform);
072                }
073            }
074
075            /**
076             * Returns a copy of the wrapped transform.
077             * @return a <code>AffineTransform</code> that is a copy of the wrapped
078             * transform of this <code>TransformAttribute</code>.
079             */
080            public AffineTransform getTransform() {
081                AffineTransform at = transform;
082                return (at == null) ? new AffineTransform()
083                        : new AffineTransform(at);
084            }
085
086            /**
087             * Returns <code>true</code> if the wrapped transform is
088             * an identity transform.
089             * @return <code>true</code> if the wrapped transform is
090             * an identity transform; <code>false</code> otherwise.
091             * @since 1.4
092             */
093            public boolean isIdentity() {
094                return transform == null;
095            }
096
097            /**
098             * A <code>TransformAttribute</code> representing the identity transform.
099             * @since 1.6
100             */
101            public static final TransformAttribute IDENTITY = new TransformAttribute(
102                    null);
103
104            private void writeObject(java.io.ObjectOutputStream s)
105                    throws java.lang.ClassNotFoundException,
106                    java.io.IOException {
107                // sigh -- 1.3 expects transform is never null, so we need to always write one out
108                if (this .transform == null) {
109                    this .transform = new AffineTransform();
110                }
111                s.defaultWriteObject();
112            }
113
114            /*
115             * @since 1.6
116             */
117            private Object readResolve() throws ObjectStreamException {
118                if (transform == null || transform.isIdentity()) {
119                    return IDENTITY;
120                }
121                return this ;
122            }
123
124            // Added for serial backwards compatability (4348425)
125            static final long serialVersionUID = 3356247357827709530L;
126
127            /**
128             * @since 1.6
129             */
130            public int hashCode() {
131                return transform == null ? 0 : transform.hashCode();
132            }
133
134            /**
135             * Returns <code>true</code> if rhs is a <code>TransformAttribute</code>
136             * whose transform is equal to this <code>TransformAttribute</code>'s
137             * transform.
138             * @param rhs the object to compare to
139             * @return <code>true</code> if the argument is a <code>TransformAttribute</code>
140             * whose transform is equal to this <code>TransformAttribute</code>'s
141             * transform.
142             * @since 1.6
143             */
144            public boolean equals(Object rhs) {
145                try {
146                    TransformAttribute that = (TransformAttribute) rhs;
147                    if (transform == null) {
148                        return that.transform == null;
149                    }
150                    return transform.equals(that.transform);
151                } catch (ClassCastException e) {
152                }
153                return false;
154            }
155        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.