001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Ilya S. Okomin
019: * @version $Revision$
020: */package java.awt.font;
021:
022: import java.awt.geom.AffineTransform;
023:
024: public class FontRenderContext {
025:
026: // Affine transform of this mode
027: private AffineTransform transform;
028:
029: // Is the anti-aliased mode used
030: private boolean fAntiAliased;
031:
032: // Is the fractional metrics used
033: private boolean fFractionalMetrics;
034:
035: public FontRenderContext(AffineTransform trans,
036: boolean antiAliased, boolean usesFractionalMetrics) {
037: if (trans != null) {
038: transform = new AffineTransform(trans);
039: }
040: fAntiAliased = antiAliased;
041: fFractionalMetrics = usesFractionalMetrics;
042: }
043:
044: protected FontRenderContext() {
045: }
046:
047: @Override
048: public boolean equals(Object obj) {
049: if (obj == this ) {
050: return true;
051: }
052:
053: if (obj != null) {
054: try {
055: return equals((FontRenderContext) obj);
056: } catch (ClassCastException e) {
057: return false;
058: }
059: }
060: return false;
061:
062: }
063:
064: public AffineTransform getTransform() {
065: if (transform != null) {
066: return new AffineTransform(transform);
067: }
068: return new AffineTransform();
069: }
070:
071: public boolean equals(FontRenderContext frc) {
072: if (this == frc) {
073: return true;
074: }
075:
076: if (frc == null) {
077: return false;
078: }
079:
080: if (!frc.getTransform().equals(this .getTransform())
081: && !frc.isAntiAliased() == this .fAntiAliased
082: && !frc.usesFractionalMetrics() == this .fFractionalMetrics) {
083: return false;
084: }
085: return true;
086: }
087:
088: public boolean usesFractionalMetrics() {
089: return this .fFractionalMetrics;
090: }
091:
092: public boolean isAntiAliased() {
093: return this .fAntiAliased;
094: }
095:
096: @Override
097: public int hashCode() {
098: return this .getTransform().hashCode()
099: ^ new Boolean(this .fFractionalMetrics).hashCode()
100: ^ new Boolean(this.fAntiAliased).hashCode();
101: }
102:
103: }
|