Source code: jpicedt/format/pstricks/parser/PsQDiskExpression.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 * Quick disk : (streamlines version of \\pscircle*),
39 * <b>\\qdisk(x0,y0)(rad)</B>
40 * @author $Author: reynal $
41 * @version $Id: PsQDiskExpression.java,v 1.2 2002/08/05 16:44:10 reynal Exp $
42 */
43 public class PsQDiskExpression extends SequenceExpression implements PicObjectConstants {
44
45 private Pool pool;
46
47 /**
48 * Uses default tag.
49 */
50 public PsQDiskExpression(Pool pl){
51 this(pl,null);
52 }
53
54 /**
55 * @param tag if null, default to \\qdisk
56 */
57 public PsQDiskExpression(Pool pl, String tag){
58
59 super(true); // throw IncompleteSequence Exception
60 pool = pl;
61 if (tag == null) tag = "\\qdisk";
62
63 add(new PSTInstanciationExpression(tag, new PicEllipse(),pool));
64 add(WHITE_SPACES_OR_EOL);
65 // circle's center
66 add(new PSTPicPointExpression(PicEllipse.P_CENTER,pool));
67 add(WHITE_SPACES_OR_EOL);
68 // radius :
69 add(new LiteralExpression("{"));
70 add(WHITE_SPACES_OR_EOL);
71 add(new NumericalExpression(DOUBLE,POSITIVE,"}",true){
72 public void action(ParserEvent e){
73 if (DEBUG) System.out.println(e);
74 ((PicEllipse)(pool.currentObj)).setWidth(((Double)e.getValue()).doubleValue() * 2.0 * pool.getDouble(PstricksParser.KEY_R_UNIT));
75 ((PicEllipse)(pool.currentObj)).setHeight(((Double)e.getValue()).doubleValue() * 2.0 * pool.getDouble(PstricksParser.KEY_R_UNIT));
76 }});
77 }
78 public String toString(){
79 return "[PsQDiskExpression]";
80 }
81 }