Source code: jpicedt/format/pstricks/parser/PSTBooleanExpression.java
1 /* jPicEdt version 1.3.2, a picture editor for LaTeX.
2 Copyright (C) 1999-2002 Sylvain Reynal
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 Sylvain Reynal
19 Département de Physique
20 Ecole Nationale Supérieure de l'Electronique et de ses Applications (ENSEA)
21 6, avenue du Ponceau
22 95014 CERGY CEDEX
23 FRANCE
24
25 Tel : 00 +33 130 736 245
26 Fax : 00 +33 130 736 667
27 e-mail : reynal@ensea.fr
28 jPicEdt web page : http://www.jpicedt.org
29 */
30
31 package jpicedt.format.pstricks.parser;
32
33 import jpicedt.graphic.io.parser.*;
34 import jpicedt.graphic.model.*;
35
36 /**
37 * Used by PSTParametersExpression to parse statements involving true/false parameters values, for instance
38 * "shadow=true" or "shadow=false" ...
39 * @author $Author: reynal $
40 * @version $Id: PSTBooleanExpression.java,v 1.2 2002/08/05 16:44:10 reynal Exp $
41 */
42 public class PSTBooleanExpression extends SequenceExpression implements PicObjectConstants {
43
44 private Pool pool;
45 private Pool.Key setKey;
46 private PicAttributeName attribute;
47
48 /**
49 * @param pl parser's pool
50 * @param tag LHS tag (e.g. "shadow" or "doubleline") for the StatementExpression ;
51 * @param attribute name of attribute to modify (must be a predefined PicAttributeName of type "Double" or at least "Number")
52 * @param attributeSetKey used to fetch the attribute set in which parsed parameters are stored.
53 */
54 public PSTBooleanExpression(Pool pl, String tag, PicAttributeName attributeName, Pool.Key attributeSetKey){
55
56 super(true); // throw IncompleteSequence Exception
57 pool = pl;
58 attribute = attributeName;
59 this.setKey = attributeSetKey;
60
61 add(new LiteralExpression(tag + "="));
62 add(new AlternateExpression(
63 new LiteralExpression("true"){
64 public void action(ParserEvent e){
65 if (DEBUG) System.out.println(e);
66 pool.setAttribute(setKey,attribute, new Boolean(true));
67 }},
68 new LiteralExpression("false"){
69 public void action(ParserEvent e){
70 if (DEBUG) System.out.println(e);
71 pool.setAttribute(setKey,attribute, new Boolean(false));}}));
72 }
73
74 }