package GraphicsApp;


/**
* GraphicsApp/_RectangleStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/


// rectangle contains shapes which GraphicalObjects a
public class _RectangleStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.Rectangle
{


  // hopping this will be an array of shapes.
  public GraphicsApp.GraphicalObject[] objects ()
  {
            org.omg.CORBA.portable.InputStream $in = null;
            try {
                org.omg.CORBA.portable.OutputStream $out = _request ("_get_objects", true);
                $in = _invoke ($out);
                GraphicsApp.GraphicalObject $result[] = GraphicsApp.ObjectSequenceHelper.read ($in);
                return $result;
            } catch (org.omg.CORBA.portable.ApplicationException $ex) {
                $in = $ex.getInputStream ();
                String _id = $ex.getId ();
                throw new org.omg.CORBA.MARSHAL (_id);
            } catch (org.omg.CORBA.portable.RemarshalException $rm) {
                return objects (        );
            } finally {
                _releaseReply ($in);
            }
  } // objects


  // hopping this will be an array of shapes.
  public void objects (GraphicsApp.GraphicalObject[] newObjects)
  {
            org.omg.CORBA.portable.InputStream $in = null;
            try {
                org.omg.CORBA.portable.OutputStream $out = _request ("_set_objects", true);
                GraphicsApp.ObjectSequenceHelper.write ($out, newObjects);
                $in = _invoke ($out);
                return;
            } catch (org.omg.CORBA.portable.ApplicationException $ex) {
                $in = $ex.getInputStream ();
                String _id = $ex.getId ();
                throw new org.omg.CORBA.MARSHAL (_id);
            } catch (org.omg.CORBA.portable.RemarshalException $rm) {
                objects (newObjects        );
            } finally {
                _releaseReply ($in);
            }
  } // objects


  // function to add shape
  public void addObject (GraphicsApp.GraphicalObject newShape)
  {
            org.omg.CORBA.portable.InputStream $in = null;
            try {
                org.omg.CORBA.portable.OutputStream $out = _request ("addObject", true);
                GraphicsApp.GraphicalObjectHelper.write ($out, newShape);
                $in = _invoke ($out);
                return;
            } catch (org.omg.CORBA.portable.ApplicationException $ex) {
                $in = $ex.getInputStream ();
                String _id = $ex.getId ();
                throw new org.omg.CORBA.MARSHAL (_id);
            } catch (org.omg.CORBA.portable.RemarshalException $rm) {
                addObject (newShape        );
            } finally {
                _releaseReply ($in);
            }
  } // addObject


  // and may be remove a shape from a position?
  public void removeObjectAtPosition (int index) throws GraphicsApp.RectanglePackage.IndexOutOfBounds
  {
            org.omg.CORBA.portable.InputStream $in = null;
            try {
                org.omg.CORBA.portable.OutputStream $out = _request ("removeObjectAtPosition", true);
                $out.write_ulong (index);
                $in = _invoke ($out);
                return;
            } catch (org.omg.CORBA.portable.ApplicationException $ex) {
                $in = $ex.getInputStream ();
                String _id = $ex.getId ();
                if (_id.equals ("IDL:GraphicsApp/Rectangle/IndexOutOfBounds:1.0"))
                    throw GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.read ($in);
                else
                    throw new org.omg.CORBA.MARSHAL (_id);
            } catch (org.omg.CORBA.portable.RemarshalException $rm) {
                removeObjectAtPosition (index        );
            } finally {
                _releaseReply ($in);
            }
  } // removeObjectAtPosition

  // Type-specific CORBA::Object operations
  private static String[] __ids = {
    "IDL:GraphicsApp/Rectangle:1.0"};

  public String[] _ids ()
  {
    return (String[])__ids.clone ();
  }

  private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
  {
     String str = s.readUTF ();
     com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._RectangleStub");
     String[] args = null;
     java.util.Properties props = null;
     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
   try {
     org.omg.CORBA.Object obj = orb.string_to_object (str);
     org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
     _set_delegate (delegate);
   } finally {
     orb.destroy() ;
   }
  }

  private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
  {
     String[] args = null;
     java.util.Properties props = null;
     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
   try {
     String str = orb.object_to_string (this);
     s.writeUTF (str);
   } finally {
     orb.destroy() ;
   }
  }
} // class _RectangleStub
