001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package sec.geo;
006
007import armyc2.c2sd.graphics2d.*;
008import org.gavaghan.geodesy.GeodeticCalculator;
009
010/**
011 *
012 * @author Michael Deutch
013 */
014public class ShapeObject {
015
016    public static final int GEOARC = 0;
017    public static final int GEOBLOCK = 1;
018    public static final int GEOBLOCK2 = 2;
019    public static final int GEOELLIPSE = 3;
020    public static final int GEOPATH = 4;
021    public static final int GEOPOINT = 5;
022    public static final int AREA = 6;
023    private int type = -1;
024    private GeoEllipse geoEllipse = null;
025    private GeoPath geoPath = null;
026    private GeoArc geoArc = null;
027    private GeoBlock geoBlock = null;
028    private GeoBlock2 geoBlock2 = null;
029    private GeoPoint geoPoint = null;
030    private Area area = null;
031    protected final GeodeticCalculator geoCalc = null;
032
033    public ShapeObject(Object obj) {
034        if (obj instanceof GeoArc) {
035            geoArc = (GeoArc) obj;
036            type = GEOARC;
037        } else if (obj instanceof GeoPath) {
038            geoPath = (GeoPath) obj;
039            type = GEOPATH;
040        } else if (obj instanceof GeoEllipse) {
041            geoEllipse = (GeoEllipse) obj;
042            type = GEOELLIPSE;
043        } else if (obj instanceof GeoBlock) {
044            geoBlock = (GeoBlock) obj;
045            type = GEOBLOCK;
046        } else if (obj instanceof GeoBlock2) {
047            geoBlock2 = (GeoBlock2) obj;
048            type = GEOBLOCK2;
049        } else if (obj instanceof GeoPoint) {
050            geoPoint = (GeoPoint) obj;
051            type = GEOPOINT;
052        } else if (obj instanceof Area) {
053            area = (Area) obj;
054            type = AREA;
055        }
056    }
057
058    public void arcTo(GeoPoint pivot, double widthMeters, double heightMeters, double leftAzimuthDegrees,
059            double rightAzimuthDegrees) {
060        switch (type) {
061            case GEOELLIPSE:
062                geoEllipse.arcTo(pivot, widthMeters, heightMeters, leftAzimuthDegrees, rightAzimuthDegrees);
063                break;
064            case GEOARC:
065                geoArc.arcTo(pivot, widthMeters, heightMeters, leftAzimuthDegrees, rightAzimuthDegrees);
066                break;
067            case GEOPATH:
068                geoPath.arcTo(pivot, widthMeters, heightMeters, leftAzimuthDegrees, rightAzimuthDegrees);
069                break;
070            default:
071                break;
072        }
073
074    }
075
076    public PathIterator getPathIterator(AffineTransform at) {
077        switch (type) {
078            case GEOELLIPSE:
079                return geoEllipse.getPathIterator(at);
080            case GEOPATH:
081                return geoPath.getPathIterator(at);
082            case GEOBLOCK:
083                return geoBlock.getPathIterator(at);
084            case GEOBLOCK2:
085                return geoBlock2.getPathIterator(at, 0);
086            case GEOARC:
087                return geoArc.getPathIterator(at);
088            default:
089                return null;
090        }
091    }
092
093    public void moveTo(GeoPoint point) {
094        switch (type) {
095            case GEOELLIPSE:
096                //geoEllipse.moveTo(point);
097                break;
098            case GEOPOINT:
099                //geoEllipse.moveTo(point);
100                break;
101            case GEOARC:
102                geoArc.moveTo(point);
103                break;
104            case GEOPATH:
105                geoPath.moveTo(point);
106                break;
107            case GEOBLOCK:
108                geoBlock.moveTo(point);
109                break;
110            case GEOBLOCK2:
111                geoBlock2.moveTo(point);
112                break;
113            default:
114                break;
115        }
116    }
117
118    public void moveToLatLong(double longitudeDegrees, double latitudeDegrees) {
119        switch (type) {
120            case GEOELLIPSE:
121                //geoEllipse.moveTo(point);
122                break;
123            case GEOPOINT:
124                //geoPoint.moveTo(point);
125                break;
126            case GEOARC:
127                geoArc.moveToLatLong(longitudeDegrees, latitudeDegrees);
128                break;
129            case GEOPATH:
130                geoPath.moveToLatLong(longitudeDegrees, latitudeDegrees);
131                break;
132            case GEOBLOCK:
133                geoBlock.moveToLatLong(longitudeDegrees, latitudeDegrees);
134                break;
135            case GEOBLOCK2:
136                geoBlock2.moveToLatLong(longitudeDegrees, latitudeDegrees);
137                break;
138            default:
139                break;
140        }
141    }
142
143    public void lineTo(GeoPoint point) {
144        switch (type) {
145            case GEOELLIPSE:
146                //geoEllipse.moveTo(point);
147                break;
148            case GEOPOINT:
149                //geoEllipse.moveTo(point);
150                break;
151            case GEOARC:
152                geoArc.lineTo(point);
153                break;
154            case GEOPATH:
155                geoPath.lineTo(point);
156                break;
157            case GEOBLOCK:
158                geoBlock.lineTo(point);
159                break;
160            case GEOBLOCK2:
161                geoBlock2.lineTo(point);
162                break;
163            default:
164                break;
165        }
166    }
167
168    public void lineToLatLong(double longitudeDegrees, double latitudeDegrees) {
169        lineTo(new GeoPoint(longitudeDegrees, latitudeDegrees));
170    }
171
172    public void closePath() {
173        switch (type) {
174            case GEOARC:
175                geoArc.closePath();
176                break;
177            case GEOBLOCK:
178                geoBlock.closePath();
179                break;
180            case GEOBLOCK2:
181                geoBlock2.closePath();
182                break;
183            case GEOPATH:
184                geoPath.closePath();
185                ;
186                break;
187            default:
188                break;
189        }
190
191    }
192}