// modify the canvas itself @Override public synchronized ICanvas setSize(V2 size) { // reset size this.size = size; // reset camera if (use_camera) camera.setProjectionSize(size); return this; }
@Override public synchronized ICanvas setCamera(ICamera camera) { // attach camera and reset its field size this.camera = camera; camera.setProjectionSize(size); // maintain invariant: (camera == null) => use_camera = false if (!use_camera && camera != null) use_camera = true; else if (camera == null) use_camera = false; return this; }