Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jpicedt/format/pstricks/parser/PSTLineStyleExpression.java


1   /*
2    *  jPicEdt version 1.3.2, a picture editor for LaTeX.
3    *  Copyright (C) 1999-2002  Sylvain Reynal
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    *  This program is distributed in the hope that it will be useful,
9    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   *  GNU General Public License for more details.
12   *  You should have received a copy of the GNU General Public License
13   *  along with this program; if not, write to the Free Software
14   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15   *  Sylvain Reynal
16   *  Département de Physique
17   *  Ecole Nationale Supérieure de l'Electronique et de ses Applications (ENSEA)
18   *  6, avenue du Ponceau
19   *  95014 CERGY CEDEX
20   *  FRANCE
21   *  Tel : 00 +33 130 736 245
22   *  Fax : 00 +33 130 736 667
23   *  e-mail : reynal@ensea.fr
24   *  jPicEdt web page : http://www.jpicedt.org
25   */
26  package jpicedt.format.pstricks.parser;
27  
28  import jpicedt.graphic.io.parser.*;
29  import jpicedt.graphic.io.formatter.*;
30  import jpicedt.graphic.model.*;
31  import java.awt.*;
32  
33  /**
34   * Parses statements similar to "linestyle=style" where style is one of PicObjectConstants predefined line styles.
35   * @author $Author: reynal $
36   * @version $Id: PSTLineStyleExpression.java,v 1.2 2002/08/05 16:44:10 reynal Exp $ 
37   */
38  public class PSTLineStyleExpression extends SequenceExpression implements PicObjectConstants {
39  
40    private Pool pool;
41    private Pool.Key setKey;
42  
43  
44    /**
45     * @param attributeSetKey used to fetch the attribute set in which parsed parameters are stored. 
46     */
47    public PSTLineStyleExpression(Pool pl, Pool.Key attributeSetKey) {
48  
49      super(false);// doesn't throw IncompleteSequenceException (which means that there might be nothing b/w [ and ])
50  
51      pool = pl;
52      this.setKey = attributeSetKey;
53  
54      add(new LiteralExpression("linestyle="));
55      add(WHITE_SPACES_OR_EOL);
56      add(
57        new WordExpression(null, false) {// no postfix, swallows as many letters as possible, no digit
58          public void action(ParserEvent e) {
59            if (DEBUG) System.out.println(e);
60            String style = (String)(e.getValue());
61            if (style.equals("none"))
62              pool.setAttribute(setKey,LINE_STYLE, NONE);
63            else if (style.equals("dotted"))
64              pool.setAttribute(setKey,LINE_STYLE, DOTTED);
65            else if (style.equals("dashed"))
66              pool.setAttribute(setKey,LINE_STYLE, DASHED);
67            else
68              pool.setAttribute(setKey,LINE_STYLE, SOLID);// "solid"
69          }
70        });
71    }
72  }
73