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

Quick Search    Search Deep

Source code: jpicedt/format/pstricks/parser/PsBezierExpression.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  import jpicedt.graphic.PicPoint;
36  
37  /**
38   * Rules for parsing cubic splines with a PsTricks syntax :
39   * <ul>
40   * <li>\\psbezier[parameters]{arrows}(x0,y0)(x1,y1)(x2,y2)(x3,y3)
41   * <li>\\psbezier*[parameters]{arrows}(x0,y0)(x1,y1)(x2,y2)(x3,y3)
42   * </ul>
43   * or PsTricks's object previously defined by help of a \\newpsobject command.
44   * @author $Author: reynal $
45   * @version $Id: PsBezierExpression.java,v 1.2 2002/08/05 16:44:10 reynal Exp $ 
46   *
47   */
48  public class PsBezierExpression extends SequenceExpression implements PicObjectConstants {
49  
50    private Pool pool;
51    private double xQ0, yQ0;
52  
53    /**
54     * tag = \\psbezier and proto = new PicBezierCubic.
55     */
56    public PsBezierExpression(Pool pl){
57      this(pl, "\\psbezier");
58    }
59  
60    /** 
61     * Constructor allowing to set a non-standard tag. Used e.g. by PsObjectExpression
62     */
63    public PsBezierExpression(Pool pl, String tag){
64  
65      super(true); // throw IncompleteSequence Exception
66      pool = pl;
67  
68      add(new PSTInstanciationExpression(tag, new PicBezierCubic(),pool));
69      add(WHITE_SPACES_OR_EOL);
70  
71      add(new OptionalExpression(new StarExpression(pool))); // filled ?
72      add(WHITE_SPACES_OR_EOL);
73  
74      // add optional param here
75      add(new OptionalExpression(new EnclosingExpression("[",new PSTParametersExpression(pool,Pool.CURRENT_OBJ_ATTRIBUTES),"]"))); // push in object's attributeSet
76      add(WHITE_SPACES_OR_EOL);
77  
78      // arrows :
79      add(new PSTArrowExpression(pool));
80      add(WHITE_SPACES_OR_EOL);
81  
82      // first point
83      add(new PSTPicPointExpression(PicBezierCubic.P_1,pool));
84      add(WHITE_SPACES_OR_EOL);
85  
86      // first control point
87      add(new PSTPicPointExpression(PicBezierCubic.P_CTRL1,pool));
88      add(WHITE_SPACES_OR_EOL);
89  
90      // second control point
91      add(new PSTPicPointExpression(PicBezierCubic.P_CTRL2,pool));
92      add(WHITE_SPACES_OR_EOL);
93  
94      // last point
95      add(new PSTPicPointExpression(PicBezierCubic.P_2,pool));
96    }
97  
98    public String toString(){
99      return "[PsBezierExpression]";
100   }
101 
102 }