/*This code was generated using the UMPLE modeling language!*/

package GIS;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import GIS.json.*;
import GIS.core.*;

public class GISFacade {
  // Singleton instance.
  private static GISFacade theInstance;

  //System registry.
  GISRegistry registry = GISRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private GISFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static GISFacade getInstance() {
    if (theInstance == null)
      theInstance = new GISFacade();
    return theInstance;
  }

  public int constructBitmap(String aBits, int aRegionFeatureType) {
    return registry.add(new Bitmap(aBits, (RegionFeatureType) registry
      .getValue(aRegionFeatureType)));
  }

  public JSONObject constructBitmapJSON(String aBits, int aRegionFeatureType)
    throws JSONException {
    Bitmap contextObj =
      new Bitmap(aBits, (RegionFeatureType) registry
        .getValue(aRegionFeatureType));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setBitsInBitmap(int context, String aBits) {
    return ((Bitmap) registry.getValue(context)).setBits(aBits);
  }

  public String getBitsFromBitmap(int context) {
    return ((Bitmap) registry.getValue(context)).getBits();
  }

  public int getRegionFeatureTypeFromBitmap(int context) {
    return registry.getKey(((Bitmap) registry.getValue(context))
      .getRegionFeatureType());
  }

  public JSONObject getRegionFeatureTypeFromBitmapJSON(int context)
    throws JSONException {
    return ((Bitmap) registry.getValue(context)).getRegionFeatureType()
      .getAttributes();
  }

  public void setRegionFeatureTypeInBitmap(int context, int aRegionFeatureType)
    throws Exception {
    ((Bitmap) registry.getValue(context))
      .setRegionFeatureType((RegionFeatureType) registry
        .getValue(aRegionFeatureType));
  }

  public void deleteBitmap(int context) {
    ((Bitmap) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfBitmap(int context) throws JSONException {
    return ((Bitmap) registry.getValue(context)).getAttributes();
  }

  public int constructRegionFeatureType(String aDescription, String aColour,
    String aThickness, String aDashLength, String aGapLength) {
    return registry.add(new RegionFeatureType(aDescription, aColour,
      aThickness, aDashLength, aGapLength));
  }

  public JSONObject constructRegionFeatureTypeJSON(String aDescription,
    String aColour, String aThickness, String aDashLength, String aGapLength)
    throws JSONException {
    RegionFeatureType contextObj =
      new RegionFeatureType(aDescription, aColour, aThickness, aDashLength,
        aGapLength);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public int getFillPatternFromRegionFeatureType(int context) {
    return registry.getKey(((RegionFeatureType) registry.getValue(context))
      .getFillPattern());
  }

  public JSONObject getFillPatternFromRegionFeatureTypeJSON(int context)
    throws JSONException {
    return ((RegionFeatureType) registry.getValue(context)).getFillPattern()
      .getAttributes();
  }

  public void setFillPatternInRegionFeatureType(int context, int aFillPattern)
    throws Exception {
    ((RegionFeatureType) registry.getValue(context))
      .setFillPattern((Bitmap) registry.getValue(aFillPattern));
  }

  public void deleteRegionFeatureType(int context) {
    ((RegionFeatureType) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteFillPatternFromRegionFeatureType(int context, int aBitmap) {
    ((RegionFeatureType) registry.getValue(context))
      .deleteFillPattern((Bitmap) registry.getValue(aBitmap));
  }

  public JSONObject getAttributesOfRegionFeatureType(int context)
    throws JSONException {
    return ((RegionFeatureType) registry.getValue(context)).getAttributes();
  }

  public int constructMap(String aScale, String aName, String aLattitude,
    String aLongitude, String aHeight, String aWidth) {
    return registry.add(new Map(aScale, aName, aLattitude, aLongitude, aHeight,
      aWidth));
  }

  public JSONObject constructMapJSON(String aScale, String aName,
    String aLattitude, String aLongitude, String aHeight, String aWidth)
    throws JSONException {
    Map contextObj =
      new Map(aScale, aName, aLattitude, aLongitude, aHeight, aWidth);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setScaleInMap(int context, String aScale) {
    return ((Map) registry.getValue(context)).setScale(aScale);
  }

  public boolean setNameInMap(int context, String aName) {
    return ((Map) registry.getValue(context)).setName(aName);
  }

  public boolean setLattitudeInMap(int context, String aLattitude) {
    return ((Map) registry.getValue(context)).setLattitude(aLattitude);
  }

  public boolean setLongitudeInMap(int context, String aLongitude) {
    return ((Map) registry.getValue(context)).setLongitude(aLongitude);
  }

  public boolean setHeightInMap(int context, String aHeight) {
    return ((Map) registry.getValue(context)).setHeight(aHeight);
  }

  public boolean setWidthInMap(int context, String aWidth) {
    return ((Map) registry.getValue(context)).setWidth(aWidth);
  }

  public String getScaleFromMap(int context) {
    return ((Map) registry.getValue(context)).getScale();
  }

  public String getNameFromMap(int context) {
    return ((Map) registry.getValue(context)).getName();
  }

  public String getLattitudeFromMap(int context) {
    return ((Map) registry.getValue(context)).getLattitude();
  }

  public String getLongitudeFromMap(int context) {
    return ((Map) registry.getValue(context)).getLongitude();
  }

  public String getHeightFromMap(int context) {
    return ((Map) registry.getValue(context)).getHeight();
  }

  public String getWidthFromMap(int context) {
    return ((Map) registry.getValue(context)).getWidth();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getFeaturesFromMap(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Feature obj : ((Map) registry.getValue(context)).getFeatures()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addFeatureToMap(int context, String aName, int aFeatureType)
    throws Exception {
    return registry.getKey(((Map) registry.getValue(context)).addFeature(aName,
      (FeatureType) registry.getValue(aFeatureType)));
  }

  public JSONObject addFeatureToMapJSON(int context, String aName,
    int aFeatureType) throws JSONException, Exception {
    return ((Map) registry.getValue(context)).addFeature(aName,
      (FeatureType) registry.getValue(aFeatureType)).getAttributes();
  }

  public int addFeatureToMapOnly(int context, int aFeature) throws Exception {
    return registry.getKey(((Map) registry.getValue(context))
      .addFeature((Feature) registry.getValue(aFeature)));
  }

  public JSONObject addFeatureToMapOnlyJSON(int context, int aFeature)
    throws JSONException, Exception {
    return ((Map) registry.getValue(context)).addFeature(
      (Feature) registry.getValue(aFeature)).getAttributes();
  }

  public void deleteMap(int context) {
    ((Map) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteFeatureFromMap(int context, int aFeature) {
    ((Map) registry.getValue(context)).deleteFeature((Feature) registry
      .getValue(aFeature));
  }

  public JSONObject getAttributesOfMap(int context) throws JSONException {
    return ((Map) registry.getValue(context)).getAttributes();
  }

  public int constructRegionalFeature(String aName, int aMap, int aFeatureType) {
    return registry.add(new RegionalFeature(aName, (Map) registry
      .getValue(aMap), (FeatureType) registry.getValue(aFeatureType)));
  }

  public JSONObject constructRegionalFeatureJSON(String aName, int aMap,
    int aFeatureType) throws JSONException {
    RegionalFeature contextObj =
      new RegionalFeature(aName, (Map) registry.getValue(aMap),
        (FeatureType) registry.getValue(aFeatureType));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deleteRegionalFeature(int context) {
    ((RegionalFeature) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfRegionalFeature(int context)
    throws JSONException {
    return ((RegionalFeature) registry.getValue(context)).getAttributes();
  }

  public int constructCurveFeature(String aName, int aMap, int aFeatureType) {
    return registry.add(new CurveFeature(aName, (Map) registry.getValue(aMap),
      (FeatureType) registry.getValue(aFeatureType)));
  }

  public JSONObject constructCurveFeatureJSON(String aName, int aMap,
    int aFeatureType) throws JSONException {
    CurveFeature contextObj =
      new CurveFeature(aName, (Map) registry.getValue(aMap),
        (FeatureType) registry.getValue(aFeatureType));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getPointsFromCurveFeature(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Point obj : ((CurveFeature) registry.getValue(context)).getPoints()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addPointToCurveFeature(int context) throws Exception {
    return registry.getKey(((CurveFeature) registry.getValue(context))
      .addPoint());
  }

  public JSONObject addPointToCurveFeatureJSON(int context)
    throws JSONException, Exception {
    return ((CurveFeature) registry.getValue(context)).addPoint()
      .getAttributes();
  }

  public int addPointToCurveFeatureOnly(int context, int aPoint)
    throws Exception {
    return registry.getKey(((CurveFeature) registry.getValue(context))
      .addPoint((Point) registry.getValue(aPoint)));
  }

  public JSONObject addPointToCurveFeatureOnlyJSON(int context, int aPoint)
    throws JSONException, Exception {
    return ((CurveFeature) registry.getValue(context)).addPoint(
      (Point) registry.getValue(aPoint)).getAttributes();
  }

  public void deleteCurveFeature(int context) {
    ((CurveFeature) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deletePointFromCurveFeature(int context, int aPoint) {
    ((CurveFeature) registry.getValue(context)).deletePoint((Point) registry
      .getValue(aPoint));
  }

  public JSONObject getAttributesOfCurveFeature(int context)
    throws JSONException {
    return ((CurveFeature) registry.getValue(context)).getAttributes();
  }

  public int constructPointFeature(String aName, int aMap, int aFeatureType,
    int aPoint) {
    return registry.add(new PointFeature(aName, (Map) registry.getValue(aMap),
      (FeatureType) registry.getValue(aFeatureType), (Point) registry
        .getValue(aPoint)));
  }

  public JSONObject constructPointFeatureJSON(String aName, int aMap,
    int aFeatureType, int aPoint) throws JSONException {
    PointFeature contextObj =
      new PointFeature(aName, (Map) registry.getValue(aMap),
        (FeatureType) registry.getValue(aFeatureType), (Point) registry
          .getValue(aPoint));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public int getPointFromPointFeature(int context) {
    return registry.getKey(((PointFeature) registry.getValue(context))
      .getPoint());
  }

  public JSONObject getPointFromPointFeatureJSON(int context)
    throws JSONException {
    return ((PointFeature) registry.getValue(context)).getPoint()
      .getAttributes();
  }

  public void setPointInPointFeature(int context, int aPoint) throws Exception {
    ((PointFeature) registry.getValue(context)).setPoint((Point) registry
      .getValue(aPoint));
  }

  public void deletePointFeature(int context) {
    ((PointFeature) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfPointFeature(int context)
    throws JSONException {
    return ((PointFeature) registry.getValue(context)).getAttributes();
  }

  public int constructFeature(String aName, int aMap, int aFeatureType) {
    return registry.add(new Feature(aName, (Map) registry.getValue(aMap),
      (FeatureType) registry.getValue(aFeatureType)));
  }

  public JSONObject constructFeatureJSON(String aName, int aMap,
    int aFeatureType) throws JSONException {
    Feature contextObj =
      new Feature(aName, (Map) registry.getValue(aMap), (FeatureType) registry
        .getValue(aFeatureType));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInFeature(int context, String aName) {
    return ((Feature) registry.getValue(context)).setName(aName);
  }

  public String getNameFromFeature(int context) {
    return ((Feature) registry.getValue(context)).getName();
  }

  public int getMapFromFeature(int context) {
    return registry.getKey(((Feature) registry.getValue(context)).getMap());
  }

  public JSONObject getMapFromFeatureJSON(int context) throws JSONException {
    return ((Feature) registry.getValue(context)).getMap().getAttributes();
  }

  public int getFeatureTypeFromFeature(int context) {
    return registry.getKey(((Feature) registry.getValue(context))
      .getFeatureType());
  }

  public JSONObject getFeatureTypeFromFeatureJSON(int context)
    throws JSONException {
    return ((Feature) registry.getValue(context)).getFeatureType()
      .getAttributes();
  }

  public void setMapInFeature(int context, int aMap) throws Exception {
    ((Feature) registry.getValue(context))
      .setMap((Map) registry.getValue(aMap));
  }

  public void setFeatureTypeInFeature(int context, int aFeatureType)
    throws Exception {
    ((Feature) registry.getValue(context))
      .setFeatureType((FeatureType) registry.getValue(aFeatureType));
  }

  public void deleteFeature(int context) {
    ((Feature) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfFeature(int context) throws JSONException {
    return ((Feature) registry.getValue(context)).getAttributes();
  }

  public int constructCurveFeatureType(String aDescription, String aColour,
    String aThickness, String aDashLength, String aGapLength) {
    return registry.add(new CurveFeatureType(aDescription, aColour, aThickness,
      aDashLength, aGapLength));
  }

  public JSONObject constructCurveFeatureTypeJSON(String aDescription,
    String aColour, String aThickness, String aDashLength, String aGapLength)
    throws JSONException {
    CurveFeatureType contextObj =
      new CurveFeatureType(aDescription, aColour, aThickness, aDashLength,
        aGapLength);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setColourInCurveFeatureType(int context, String aColour) {
    return ((CurveFeatureType) registry.getValue(context)).setColour(aColour);
  }

  public boolean setThicknessInCurveFeatureType(int context, String aThickness) {
    return ((CurveFeatureType) registry.getValue(context))
      .setThickness(aThickness);
  }

  public boolean setDashLengthInCurveFeatureType(int context, String aDashLength) {
    return ((CurveFeatureType) registry.getValue(context))
      .setDashLength(aDashLength);
  }

  public boolean setGapLengthInCurveFeatureType(int context, String aGapLength) {
    return ((CurveFeatureType) registry.getValue(context))
      .setGapLength(aGapLength);
  }

  public String getColourFromCurveFeatureType(int context) {
    return ((CurveFeatureType) registry.getValue(context)).getColour();
  }

  public String getThicknessFromCurveFeatureType(int context) {
    return ((CurveFeatureType) registry.getValue(context)).getThickness();
  }

  public String getDashLengthFromCurveFeatureType(int context) {
    return ((CurveFeatureType) registry.getValue(context)).getDashLength();
  }

  public String getGapLengthFromCurveFeatureType(int context) {
    return ((CurveFeatureType) registry.getValue(context)).getGapLength();
  }

  public void deleteCurveFeatureType(int context) {
    ((CurveFeatureType) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfCurveFeatureType(int context)
    throws JSONException {
    return ((CurveFeatureType) registry.getValue(context)).getAttributes();
  }

  public int constructPointFeatureType(String aDescription, int aSymbol) {
    return registry.add(new PointFeatureType(aDescription, (Bitmap) registry
      .getValue(aSymbol)));
  }

  public JSONObject constructPointFeatureTypeJSON(String aDescription,
    int aSymbol) throws JSONException {
    PointFeatureType contextObj =
      new PointFeatureType(aDescription, (Bitmap) registry.getValue(aSymbol));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public int getSymbolFromPointFeatureType(int context) {
    return registry.getKey(((PointFeatureType) registry.getValue(context))
      .getSymbol());
  }

  public JSONObject getSymbolFromPointFeatureTypeJSON(int context)
    throws JSONException {
    return ((PointFeatureType) registry.getValue(context)).getSymbol()
      .getAttributes();
  }

  public void setSymbolInPointFeatureType(int context, int aSymbol)
    throws Exception {
    ((PointFeatureType) registry.getValue(context)).setSymbol((Bitmap) registry
      .getValue(aSymbol));
  }

  public void deletePointFeatureType(int context) {
    ((PointFeatureType) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfPointFeatureType(int context)
    throws JSONException {
    return ((PointFeatureType) registry.getValue(context)).getAttributes();
  }

  public int constructFeatureType(String aDescription) {
    return registry.add(new FeatureType(aDescription));
  }

  public JSONObject constructFeatureTypeJSON(String aDescription)
    throws JSONException {
    FeatureType contextObj = new FeatureType(aDescription);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setDescriptionInFeatureType(int context, String aDescription) {
    return ((FeatureType) registry.getValue(context))
      .setDescription(aDescription);
  }

  public String getDescriptionFromFeatureType(int context) {
    return ((FeatureType) registry.getValue(context)).getDescription();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getFeaturesFromFeatureType(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Feature obj : ((FeatureType) registry.getValue(context)).getFeatures()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addFeatureToFeatureType(int context, String aName, int aMap)
    throws Exception {
    return registry.getKey(((FeatureType) registry.getValue(context))
      .addFeature(aName, (Map) registry.getValue(aMap)));
  }

  public JSONObject addFeatureToFeatureTypeJSON(int context, String aName,
    int aMap) throws JSONException, Exception {
    return ((FeatureType) registry.getValue(context)).addFeature(aName,
      (Map) registry.getValue(aMap)).getAttributes();
  }

  public int addFeatureToFeatureTypeOnly(int context, int aFeature)
    throws Exception {
    return registry.getKey(((FeatureType) registry.getValue(context))
      .addFeature((Feature) registry.getValue(aFeature)));
  }

  public JSONObject addFeatureToFeatureTypeOnlyJSON(int context, int aFeature)
    throws JSONException, Exception {
    return ((FeatureType) registry.getValue(context)).addFeature(
      (Feature) registry.getValue(aFeature)).getAttributes();
  }

  public void deleteFeatureType(int context) {
    ((FeatureType) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteFeatureFromFeatureType(int context, int aFeature) {
    ((FeatureType) registry.getValue(context)).deleteFeature((Feature) registry
      .getValue(aFeature));
  }

  public JSONObject getAttributesOfFeatureType(int context)
    throws JSONException {
    return ((FeatureType) registry.getValue(context)).getAttributes();
  }

  public int constructPoint() {
    return registry.add(new Point());
  }

  public JSONObject constructPointJSON() throws JSONException {
    Point contextObj = new Point();
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deletePoint(int context) {
    ((Point) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfPoint(int context) throws JSONException {
    return ((Point) registry.getValue(context)).getAttributes();
  }
}