1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18 * @author Ilya S. Okomin 19 * @version $Revision$ 20 */ 21 22package java.awt.font; 23 24import java.awt.geom.AffineTransform; 25import java.io.Serializable; 26 27import org.apache.harmony.awt.internal.nls.Messages; 28 29/** 30 * The TransformAttribute class is a wrapper for the AffineTransform class in 31 * order to use it as attribute. 32 * 33 * @since Android 1.0 34 */ 35public final class TransformAttribute implements Serializable { 36 37 /** 38 * The Constant serialVersionUID. 39 */ 40 private static final long serialVersionUID = 3356247357827709530L; 41 42 // affine transform of this TransformAttribute instance 43 /** 44 * The transform. 45 */ 46 private AffineTransform fTransform; 47 48 /** 49 * Instantiates a new TransformAttribute from the specified AffineTransform. 50 * 51 * @param transform 52 * the AffineTransform to be wrapped. 53 */ 54 public TransformAttribute(AffineTransform transform) { 55 if (transform == null) { 56 // awt.94=transform can not be null 57 throw new IllegalArgumentException(Messages.getString("awt.94")); //$NON-NLS-1$ 58 } 59 if (!transform.isIdentity()) { 60 this.fTransform = new AffineTransform(transform); 61 } 62 } 63 64 /** 65 * Gets the initial AffineTransform which is wrapped. 66 * 67 * @return the initial AffineTransform which is wrapped. 68 */ 69 public AffineTransform getTransform() { 70 if (fTransform != null) { 71 return new AffineTransform(fTransform); 72 } 73 return new AffineTransform(); 74 } 75 76 /** 77 * Checks if this transform is an identity transform. 78 * 79 * @return true, if this transform is an identity transform, false 80 * otherwise. 81 */ 82 public boolean isIdentity() { 83 return (fTransform == null); 84 } 85 86} 87