~ubuntu-branches/ubuntu/utopic/libjmathtex-java/utopic

« back to all changes in this revision

Viewing changes to be/ugent/caagt/jmathtex/CharBox.java

  • Committer: Bazaar Package Importer
  • Author(s): Adriaan Peeters
  • Date: 2007-09-25 14:07:55 UTC
  • Revision ID: james.westby@ubuntu.com-20070925140755-mro37pqu4wkhqa9t
Tags: upstream-0.7~pre
ImportĀ upstreamĀ versionĀ 0.7~pre

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* CharBox.java
 
2
 * =========================================================================
 
3
 * This file is part of the JMathTeX Library - http://jmathtex.sourceforge.net
 
4
 * 
 
5
 * Copyright (C) 2004-2007 Universiteit Gent
 
6
 * 
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or (at
 
10
 * your option) any later version.
 
11
 * 
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * General Public License for more details.
 
16
 * 
 
17
 * A copy of the GNU General Public License can be found in the file
 
18
 * LICENSE.txt provided with the source distribution of this program (see
 
19
 * the META-INF directory in the source jar). This license can also be
 
20
 * found on the GNU website at http://www.gnu.org/licenses/gpl.html.
 
21
 * 
 
22
 * If you did not receive a copy of the GNU General Public License along
 
23
 * with this program, contact the lead developer, or write to the Free
 
24
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
25
 * 02110-1301, USA.
 
26
 * 
 
27
 */
 
28
 
 
29
package be.ugent.caagt.jmathtex;
 
30
 
 
31
import java.awt.Font;
 
32
import java.awt.Graphics2D;
 
33
 
 
34
/**
 
35
 * A box representing a single character.
 
36
 */
 
37
class CharBox extends Box {
 
38
 
 
39
   private final CharFont cf;
 
40
 
 
41
   private final Font font;
 
42
 
 
43
   /**
 
44
    * Create a new CharBox that will represent the character defined by the given
 
45
    * Char-object.
 
46
    * 
 
47
    * @param c a Char-object containing the character's font information.
 
48
    */
 
49
   public CharBox(Char c) {
 
50
      cf = c.getCharFont();
 
51
      font = c.getFont();
 
52
      width = c.getWidth();
 
53
      height = c.getHeight();
 
54
      depth = c.getDepth();
 
55
   }
 
56
 
 
57
   public void draw(Graphics2D g2, float x, float y) {
 
58
      // copy
 
59
      Font f = g2.getFont();
 
60
 
 
61
      g2.setFont(font);
 
62
      g2.drawString(Character.toString(cf.c), x, y);
 
63
 
 
64
      // restore
 
65
      g2.setFont(f);
 
66
   }
 
67
 
 
68
   public int getLastFontId() {
 
69
      return cf.fontId;
 
70
   }
 
71
}