~ubuntu-branches/ubuntu/oneiric/libjlatexmath-java/oneiric

« back to all changes in this revision

Viewing changes to src/org/scilab/forge/jlatexmath/PhantomAtom.java

  • Committer: Bazaar Package Importer
  • Author(s): Sylvestre Ledru
  • Date: 2009-09-29 11:14:53 UTC
  • Revision ID: james.westby@ubuntu.com-20090929111453-0pmbj5as45odpxei
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* PhantomAtom.java
 
2
 * =========================================================================
 
3
 * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net
 
4
 * 
 
5
 * Copyright (C) 2004-2007 Universiteit Gent
 
6
 * Copyright (C) 2009 DENIZET Calixte
 
7
 * 
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or (at
 
11
 * your option) any later version.
 
12
 * 
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 * 
 
18
 * A copy of the GNU General Public License can be found in the file
 
19
 * LICENSE.txt provided with the source distribution of this program (see
 
20
 * the META-INF directory in the source jar). This license can also be
 
21
 * found on the GNU website at http://www.gnu.org/licenses/gpl.html.
 
22
 * 
 
23
 * If you did not receive a copy of the GNU General Public License along
 
24
 * with this program, contact the lead developer, or write to the Free
 
25
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
26
 * 02110-1301, USA.
 
27
 * 
 
28
 */
 
29
 
 
30
package org.scilab.forge.jlatexmath;
 
31
 
 
32
/**
 
33
 * An atom representing another atom that should be drawn invisibly.
 
34
 */
 
35
public class PhantomAtom extends Atom implements Row {
 
36
 
 
37
    // RowAtom to be drawn invisibly
 
38
    private RowAtom elements;
 
39
    
 
40
    // dimensions to be taken into account
 
41
    private boolean w = true, h = true, d = true;
 
42
    
 
43
    public PhantomAtom(Atom el) {
 
44
        if (el == null)
 
45
            elements = new RowAtom();
 
46
        else
 
47
            elements = new RowAtom(el);
 
48
    }
 
49
    
 
50
    public PhantomAtom(Atom el, boolean width, boolean height, boolean depth) {
 
51
        this(el);
 
52
        w = width;
 
53
        h = height;
 
54
        d = depth;
 
55
    }
 
56
    
 
57
    public Box createBox(TeXEnvironment env) {
 
58
        Box res = elements.createBox(env);
 
59
        return new StrutBox((w ? res.getWidth() : 0), (h ? res.getHeight() : 0),
 
60
                            (d ? res.getDepth() : 0), res.getShift());
 
61
    }
 
62
    
 
63
    public int getLeftType() {
 
64
        return elements.getLeftType();
 
65
    }
 
66
    
 
67
    public int getRightType() {
 
68
        return elements.getRightType();
 
69
    }
 
70
    
 
71
    public void setPreviousAtom(Dummy prev) {
 
72
        elements.setPreviousAtom(prev);
 
73
    }
 
74
}