/*This code was generated using the UMPLE modeling language!*/

package Shapes;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import Shapes.json.*;
import Shapes.core.*;

public class ShapesFacade {
  // Singleton instance.
  private static ShapesFacade theInstance;

  //System registry.
  ShapesRegistry registry = ShapesRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private ShapesFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static ShapesFacade getInstance() {
    if (theInstance == null)
      theInstance = new ShapesFacade();
    return theInstance;
  }

  public int constructShape2D(String aCenter) {
    return registry.add(new Shape2D(aCenter));
  }

  public JSONObject constructShape2DJSON(String aCenter) throws JSONException {
    Shape2D contextObj = new Shape2D(aCenter);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setCenterInShape2D(int context, String aCenter) {
    return ((Shape2D) registry.getValue(context)).setCenter(aCenter);
  }

  public String getCenterFromShape2D(int context) {
    return ((Shape2D) registry.getValue(context)).getCenter();
  }

  public void deleteShape2D(int context) {
    ((Shape2D) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfShape2D(int context) throws JSONException {
    return ((Shape2D) registry.getValue(context)).getAttributes();
  }

  public int constructPolygon(String aCenter) {
    return registry.add(new Polygon(aCenter));
  }

  public JSONObject constructPolygonJSON(String aCenter) throws JSONException {
    Polygon contextObj = new Polygon(aCenter);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deletePolygon(int context) {
    ((Polygon) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfPolygon(int context) throws JSONException {
    return ((Polygon) registry.getValue(context)).getAttributes();
  }

  public int constructEllipticalShape(String aCenter, String aSemiMajorAxis) {
    return registry.add(new EllipticalShape(aCenter, aSemiMajorAxis));
  }

  public JSONObject constructEllipticalShapeJSON(String aCenter,
    String aSemiMajorAxis) throws JSONException {
    EllipticalShape contextObj = new EllipticalShape(aCenter, aSemiMajorAxis);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setSemiMajorAxisInEllipticalShape(int context,
    String aSemiMajorAxis) {
    return ((EllipticalShape) registry.getValue(context))
      .setSemiMajorAxis(aSemiMajorAxis);
  }

  public String getSemiMajorAxisFromEllipticalShape(int context) {
    return ((EllipticalShape) registry.getValue(context)).getSemiMajorAxis();
  }

  public void deleteEllipticalShape(int context) {
    ((EllipticalShape) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfEllipticalShape(int context)
    throws JSONException {
    return ((EllipticalShape) registry.getValue(context)).getAttributes();
  }

  public int constructRectangle(String aCenter, String aOrientation,
    String aHeight, String aWidth) {
    return registry.add(new Rectangle(aCenter, aOrientation, aHeight, aWidth));
  }

  public JSONObject constructRectangleJSON(String aCenter, String aOrientation,
    String aHeight, String aWidth) throws JSONException {
    Rectangle contextObj =
      new Rectangle(aCenter, aOrientation, aHeight, aWidth);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setHeightInRectangle(int context, String aHeight) {
    return ((Rectangle) registry.getValue(context)).setHeight(aHeight);
  }

  public boolean setWidthInRectangle(int context, String aWidth) {
    return ((Rectangle) registry.getValue(context)).setWidth(aWidth);
  }

  public String getHeightFromRectangle(int context) {
    return ((Rectangle) registry.getValue(context)).getHeight();
  }

  public String getWidthFromRectangle(int context) {
    return ((Rectangle) registry.getValue(context)).getWidth();
  }

  public void deleteRectangle(int context) {
    ((Rectangle) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfRectangle(int context) throws JSONException {
    return ((Rectangle) registry.getValue(context)).getAttributes();
  }

  public int constructSimplePolygon(String aCenter, String aOrientation) {
    return registry.add(new SimplePolygon(aCenter, aOrientation));
  }

  public JSONObject constructSimplePolygonJSON(String aCenter,
    String aOrientation) throws JSONException {
    SimplePolygon contextObj = new SimplePolygon(aCenter, aOrientation);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setOrientationInSimplePolygon(int context, String aOrientation) {
    return ((SimplePolygon) registry.getValue(context))
      .setOrientation(aOrientation);
  }

  public String getOrientationFromSimplePolygon(int context) {
    return ((SimplePolygon) registry.getValue(context)).getOrientation();
  }

  public void deleteSimplePolygon(int context) {
    ((SimplePolygon) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfSimplePolygon(int context)
    throws JSONException {
    return ((SimplePolygon) registry.getValue(context)).getAttributes();
  }

  public int constructEllipse(String aCenter, String aSemiMajorAxis) {
    return registry.add(new Ellipse(aCenter, aSemiMajorAxis));
  }

  public JSONObject constructEllipseJSON(String aCenter, String aSemiMajorAxis)
    throws JSONException {
    Ellipse contextObj = new Ellipse(aCenter, aSemiMajorAxis);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deleteEllipse(int context) {
    ((Ellipse) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfEllipse(int context) throws JSONException {
    return ((Ellipse) registry.getValue(context)).getAttributes();
  }

  public int constructCircle(String aCenter, String aSemiMajorAxis) {
    return registry.add(new Circle(aCenter, aSemiMajorAxis));
  }

  public JSONObject constructCircleJSON(String aCenter, String aSemiMajorAxis)
    throws JSONException {
    Circle contextObj = new Circle(aCenter, aSemiMajorAxis);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deleteCircle(int context) {
    ((Circle) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfCircle(int context) throws JSONException {
    return ((Circle) registry.getValue(context)).getAttributes();
  }

  public int constructRegularPolygon(String aCenter, String aOrientation,
    String aNumPoints, String aRadius) {
    return registry.add(new RegularPolygon(aCenter, aOrientation, aNumPoints,
      aRadius));
  }

  public JSONObject constructRegularPolygonJSON(String aCenter,
    String aOrientation, String aNumPoints, String aRadius)
    throws JSONException {
    RegularPolygon contextObj =
      new RegularPolygon(aCenter, aOrientation, aNumPoints, aRadius);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumPointsInRegularPolygon(int context, String aNumPoints) {
    return ((RegularPolygon) registry.getValue(context))
      .setNumPoints(aNumPoints);
  }

  public boolean setRadiusInRegularPolygon(int context, String aRadius) {
    return ((RegularPolygon) registry.getValue(context)).setRadius(aRadius);
  }

  public String getNumPointsFromRegularPolygon(int context) {
    return ((RegularPolygon) registry.getValue(context)).getNumPoints();
  }

  public String getRadiusFromRegularPolygon(int context) {
    return ((RegularPolygon) registry.getValue(context)).getRadius();
  }

  public void deleteRegularPolygon(int context) {
    ((RegularPolygon) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfRegularPolygon(int context)
    throws JSONException {
    return ((RegularPolygon) registry.getValue(context)).getAttributes();
  }

  public int constructArbitraryPolygon(String aCenter, String aPoints) {
    return registry.add(new ArbitraryPolygon(aCenter, aPoints));
  }

  public JSONObject constructArbitraryPolygonJSON(String aCenter, String aPoints)
    throws JSONException {
    ArbitraryPolygon contextObj = new ArbitraryPolygon(aCenter, aPoints);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setPointsInArbitraryPolygon(int context, String aPoints) {
    return ((ArbitraryPolygon) registry.getValue(context)).setPoints(aPoints);
  }

  public String getPointsFromArbitraryPolygon(int context) {
    return ((ArbitraryPolygon) registry.getValue(context)).getPoints();
  }

  public void deleteArbitraryPolygon(int context) {
    ((ArbitraryPolygon) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfArbitraryPolygon(int context)
    throws JSONException {
    return ((ArbitraryPolygon) registry.getValue(context)).getAttributes();
  }
}