~ubuntu-branches/ubuntu/raring/libfonts-java/raring

« back to all changes in this revision

Viewing changes to source/org/jfree/fonts/monospace/MonospaceFontFamily.java

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2011-12-29 23:12:17 UTC
  • mfrom: (1.1.3) (2.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20111229231217-f0tkh1n7f86opmn8
Tags: 1.1.6.dfsg-3
add missing build-dep on ant-optional... (closes: #652799) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * ===========================================
3
 
 * LibFonts : a free Java font reading library
4
 
 * ===========================================
5
 
 *
6
 
 * Project Info:  http://reporting.pentaho.org/libfonts/
7
 
 *
8
 
 * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors.
9
 
 *
10
 
 * This library is free software; you can redistribute it and/or modify it under the terms
11
 
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
12
 
 * either version 2.1 of the License, or (at your option) any later version.
13
 
 *
14
 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15
 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 
 * See the GNU Lesser General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Lesser General Public License along with this
19
 
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
21
 
 *
22
 
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
23
 
 * in the United States and other countries.]
24
 
 *
25
 
 * ------------
26
 
 * $Id: MonospaceFontFamily.java 3523 2007-10-16 11:03:09Z tmorgner $
27
 
 * ------------
28
 
 * (C) Copyright 2006-2007, by Pentaho Corporation.
29
 
 */
30
 
 
31
 
package org.jfree.fonts.monospace;
32
 
 
33
 
import org.jfree.fonts.registry.FontFamily;
34
 
import org.jfree.fonts.registry.FontRecord;
35
 
 
36
 
/**
37
 
 * Creation-Date: 13.05.2007, 13:14:25
38
 
 *
39
 
 * @author Thomas Morgner
40
 
 */
41
 
public class MonospaceFontFamily implements FontFamily
42
 
{
43
 
  private String familyName;
44
 
  private FontRecord[] fonts;
45
 
 
46
 
  public MonospaceFontFamily(final String familyName)
47
 
  {
48
 
    if (familyName == null)
49
 
    {
50
 
      throw new NullPointerException();
51
 
    }
52
 
    this.familyName = familyName;
53
 
    this.fonts = new FontRecord[4];
54
 
  }
55
 
 
56
 
  /**
57
 
   * Returns the name of the font family (in english).
58
 
   *
59
 
   * @return
60
 
   */
61
 
  public String getFamilyName()
62
 
  {
63
 
    return familyName;
64
 
  }
65
 
 
66
 
  public String[] getAllNames()
67
 
  {
68
 
    return new String[]{ familyName };
69
 
  }
70
 
 
71
 
  /**
72
 
   * This selects the most suitable font in that family. Italics fonts are preferred over oblique fonts.
73
 
   *
74
 
   * @param bold
75
 
   * @param italics
76
 
   * @return
77
 
   */
78
 
  public FontRecord getFontRecord(final boolean bold, final boolean italics)
79
 
  {
80
 
    int index = 0;
81
 
    if (bold)
82
 
    {
83
 
      index += 1;
84
 
    }
85
 
    if (italics)
86
 
    {
87
 
      index += 2;
88
 
    }
89
 
    if (fonts[index] != null)
90
 
    {
91
 
      return fonts[index];
92
 
    }
93
 
    fonts[index] = new MonospaceFontRecord(this, bold, italics);
94
 
    return fonts[index];
95
 
  }
96
 
 
97
 
  public boolean equals(final Object o)
98
 
  {
99
 
    if (this == o)
100
 
    {
101
 
      return true;
102
 
    }
103
 
    if (o == null || getClass() != o.getClass())
104
 
    {
105
 
      return false;
106
 
    }
107
 
 
108
 
    final MonospaceFontFamily that = (MonospaceFontFamily) o;
109
 
 
110
 
    if (!familyName.equals(that.familyName))
111
 
    {
112
 
      return false;
113
 
    }
114
 
 
115
 
    return true;
116
 
  }
117
 
 
118
 
  public int hashCode()
119
 
  {
120
 
    return familyName.hashCode();
121
 
  }
122
 
}