001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * Glyph.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.layout.text;
030:
031: import org.jfree.fonts.text.Spacing;
032:
033: /**
034: * Creation-Date: 03.04.2007, 16:41:38
035: *
036: * @author Thomas Morgner
037: */
038: public final class Glyph {
039: private static final int[] EMPTY_EXTRA_CHARS = new int[0];
040:
041: public static final int SPACE_CHAR = 0;
042: public static final int LETTER = 1;
043:
044: private int codepoint;
045: private int breakWeight;
046: private int classification;
047: private Spacing spacing;
048: private int width;
049: private int height;
050: private int baseLine;
051: private int kerning;
052: private int[] extraChars;
053:
054: public Glyph(final int codepoint, final int breakWeight,
055: final int classification, final Spacing spacing,
056: final int width, final int height, final int baseLine,
057: final int kerning, final int[] extraChars) {
058:
059: // Log.debug ("Glyph: -" + ((char) (0xffff & codepoint)) + "- [" + baseLine + ", " + height + "]");
060: if (spacing == null) {
061: this .spacing = Spacing.EMPTY_SPACING;
062: } else {
063: this .spacing = spacing;
064: }
065: if (extraChars == null) {
066: this .extraChars = EMPTY_EXTRA_CHARS;
067: } else if (extraChars.length == 0) {
068: this .extraChars = EMPTY_EXTRA_CHARS;
069: } else {
070: this .extraChars = (int[]) extraChars.clone();
071: }
072:
073: this .baseLine = baseLine;
074: this .codepoint = codepoint;
075: this .breakWeight = breakWeight;
076: this .width = width;
077: this .height = height;
078: this .classification = classification;
079: this .kerning = kerning;
080: }
081:
082: public int getClassification() {
083: return classification;
084: }
085:
086: public int[] getExtraChars() {
087: if (extraChars.length == 0) {
088: return EMPTY_EXTRA_CHARS;
089: }
090: return (int[]) extraChars.clone();
091: }
092:
093: public int getBaseLine() {
094: return baseLine;
095: }
096:
097: public int getCodepoint() {
098: return codepoint;
099: }
100:
101: public int getBreakWeight() {
102: return breakWeight;
103: }
104:
105: public Spacing getSpacing() {
106: return spacing;
107: }
108:
109: public int getWidth() {
110: return width;
111: }
112:
113: public int getHeight() {
114: return height;
115: }
116:
117: public int getKerning() {
118: return kerning;
119: }
120:
121: public boolean equals(final Object o) {
122: if (this == o) {
123: return true;
124: }
125: if (o == null || getClass() != o.getClass()) {
126: return false;
127: }
128:
129: final Glyph glyph = (Glyph) o;
130:
131: if (breakWeight != glyph.breakWeight) {
132: return false;
133: }
134: if (codepoint != glyph.codepoint) {
135: return false;
136: }
137: if (height != glyph.height) {
138: return false;
139: }
140: if (kerning != glyph.kerning) {
141: return false;
142: }
143: if (width != glyph.width) {
144: return false;
145: }
146: if (!spacing.equals(glyph.spacing)) {
147: return false;
148: }
149:
150: return true;
151: }
152:
153: public int hashCode() {
154: int result = codepoint;
155: result = 29 * result + breakWeight;
156: result = 29 * result + spacing.hashCode();
157: result = 29 * result + width;
158: result = 29 * result + height;
159: result = 29 * result + kerning;
160: return result;
161: }
162:
163: public String toString() {
164: return getClass().getName() + "={codepoint='"
165: + ((char) (codepoint & 0xffff)) + ", extra-chars="
166: + extraChars.length + '}';
167: }
168: }
|