📄 wktawt.java
字号:
/*
* This file is part of the GeOxygene project source files.
*
* GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
* the development and deployment of geographic (GIS) applications. It is a open source
* contribution of the COGIT laboratory at the Institut G閛graphique National (the French
* National Mapping Agency).
*
* See: http://oxygene-project.sourceforge.net
*
* Copyright (C) 2005 Institut G閛graphique National
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this library (see file LICENSE if present); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* Generated By:JavaCC: Do not edit this line. WktAwt.java */
package fr.ign.cogit.geoxygene.util.conversion;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.StringTokenizer;
public class WktAwt implements WktAwtConstants {
static class EndOfFile extends Exception {}
static class EmptyLine extends Exception {}
/*-----------------------------------------------------*/
/*- Create AwtShape from Wkt object(s) ----------------*/
/*-----------------------------------------------------*/
public static AwtShape makeAwtShape(InputStream in)
throws ParseException
{
WktAwt parser=new WktAwt(in);
AwtAggregate geom=new AwtAggregate();
while (true) {
try {
geom.add(parser.parseOneLine());
} catch (EndOfFile e) {
break;
} catch (EmptyLine e) {}
}
return geom;
}
public static AwtShape makeAwtShape(String wkt)
throws ParseException
{
InputStream in=new ByteArrayInputStream(wkt.getBytes());
return makeAwtShape(in);
}
/*-----------------------------------------------------*/
/*- Main function for testing -------------------------*/
/*-----------------------------------------------------*/
static Ellipse2D makeVisiblePoint(Point2D point)
{
return new Ellipse2D.Double(point.getX()-5, point.getY()-5, 10, 10);
}
final public Point2D point() throws ParseException {
Token xy;
xy = jj_consume_token(POINT);
StringTokenizer tkz=new StringTokenizer(xy.image);
String xStr=tkz.nextToken();
String yStr=tkz.nextToken();
double x=Double.parseDouble(xStr);
double y=Double.parseDouble(yStr);
{if (true) return new Point2D.Double(x,y);}
throw new Error("Missing return statement in function");
}
final public Point2D pointText() throws ParseException {
Point2D p=new Point2D.Double(Double.NaN, Double.NaN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
p = point();
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return p;}
throw new Error("Missing return statement in function");
}
final public GeneralPath linestringText() throws ParseException {
GeneralPath lineString=new GeneralPath();
Point2D p;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
p = point();
lineString.moveTo((float)p.getX(), (float)p.getY());
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 12:
;
break;
default:
jj_la1[1] = jj_gen;
break label_1;
}
jj_consume_token(12);
p = point();
lineString.lineTo((float)p.getX(), (float)p.getY());
}
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return lineString;}
throw new Error("Missing return statement in function");
}
final public AwtShape polygonText() throws ParseException {
AwtSurface poly=new AwtSurface();
GeneralPath lineString;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
lineString = linestringText();
lineString.closePath();
poly=new AwtSurface(lineString);
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 12:
;
break;
default:
jj_la1[3] = jj_gen;
break label_2;
}
jj_consume_token(12);
lineString = linestringText();
lineString.closePath();
poly.addInterior(lineString);
}
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[4] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return poly;}
throw new Error("Missing return statement in function");
}
final public AwtShape multipointText() throws ParseException {
GeneralPath multi=new GeneralPath();
Point2D p;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
p = point();
multi.append(new GeneralPath(makeVisiblePoint(p)), false);
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 12:
;
break;
default:
jj_la1[5] = jj_gen;
break label_3;
}
jj_consume_token(12);
p = point();
multi.append(new GeneralPath(makeVisiblePoint(p)), false);
}
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return new AwtSurface(multi);}
throw new Error("Missing return statement in function");
}
final public AwtShape multilinestringText() throws ParseException {
GeneralPath multi=new GeneralPath();
GeneralPath lineString;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
lineString = linestringText();
multi.append(lineString,false);
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 12:
;
break;
default:
jj_la1[7] = jj_gen;
break label_4;
}
jj_consume_token(12);
lineString = linestringText();
multi.append(lineString,false);
}
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return new AwtOutline(multi);}
throw new Error("Missing return statement in function");
}
final public AwtShape multipolygonText() throws ParseException {
AwtAggregate multi=new AwtAggregate();
AwtShape poly;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
poly = polygonText();
multi.add(poly);
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 12:
;
break;
default:
jj_la1[9] = jj_gen;
break label_5;
}
jj_consume_token(12);
poly = polygonText();
multi.add(poly);
}
jj_consume_token(10);
break;
case 11:
jj_consume_token(11);
break;
default:
jj_la1[10] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return multi;}
throw new Error("Missing return statement in function");
}
final public AwtShape geometrycollectionText() throws ParseException {
AwtAggregate collec=new AwtAggregate();
AwtShape geom;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
geom = geometryTaggedText();
collec.add(geom);
label_6:
while (true) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -