/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @author Dmitry A. Durnev
 */
package java.awt;

import java.awt.image.BufferStrategy;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;

public class Canvas extends Component implements Accessible {
    private static final long serialVersionUID = -2284879212465893870L;

    protected class AccessibleAWTCanvas extends AccessibleAWTComponent {
        private static final long serialVersionUID = -6325592262103146699L;

        @Override
        public AccessibleRole getAccessibleRole() {
            return AccessibleRole.CANVAS;
        }
    }

    public Canvas() {
        toolkit.lockAWT();
        try {
        } finally {
            toolkit.unlockAWT();
        }
    }

    public Canvas(GraphicsConfiguration a0) {
        this();
        toolkit.lockAWT();
        try {
        } finally {
            toolkit.unlockAWT();
        }
    }

    @Override
    public void update(Graphics g) {
        toolkit.lockAWT();
        try {
            super.update(g);
        } finally {
            toolkit.unlockAWT();
        }
    }

    @Override
    public void addNotify() {
        toolkit.lockAWT();
        try {
            super.addNotify();
        } finally {
            toolkit.unlockAWT();
        }
    }

    public void createBufferStrategy(int a0) throws org.apache.harmony.luni.util.NotImplementedException {
        toolkit.lockAWT();
        try {
        } finally {
            toolkit.unlockAWT();
        }
        if (true) {
            throw new RuntimeException("Method is not implemented"); //TODO: implement //$NON-NLS-1$
        }
        return;
    }

    public void createBufferStrategy(int a0, BufferCapabilities a1) throws AWTException, org.apache.harmony.luni.util.NotImplementedException {
        toolkit.lockAWT();
        try {
        } finally {
            toolkit.unlockAWT();
        }
        if (true) {
            throw new RuntimeException("Method is not implemented"); //TODO: implement //$NON-NLS-1$
        }
        return;
    }

    @Override
    public AccessibleContext getAccessibleContext() {
        return super.getAccessibleContext();
    }

    public BufferStrategy getBufferStrategy() throws org.apache.harmony.luni.util.NotImplementedException {
        toolkit.lockAWT();
        try {
        } finally {
            toolkit.unlockAWT();
        }
        if (true) {
            throw new RuntimeException("Method is not implemented"); //TODO: implement //$NON-NLS-1$
        }
        return null;
    }

    @Override
    public void paint(Graphics g) {
        toolkit.lockAWT();
        try {
            g.clearRect(0, 0, w, h);
        } finally {
            toolkit.unlockAWT();
        }
    }
    
    @Override
    Dimension getDefaultMinimumSize() {
        return new Dimension(w, h);
    }

    @Override
    ComponentBehavior createBehavior() {        
        return GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ? 
                new LWBehavior(this) : 
                new HWBehavior(this) ;
    }

    @Override
    String autoName() {
        return ("canvas" + toolkit.autoNumber.nextCanvas++); //$NON-NLS-1$
    }

    @Override
    AccessibleContext createAccessibleContext() {
        return new AccessibleAWTCanvas();
    }
}


@@ -1028,16 +1028,78 @@
 eRole;%0A%0A
+import org.apache.harmony.luni.util.NotImplementedException;%0A%0A
 public c
@@ -2243,37 +2243,8 @@
 ows 
-org.apache.harmony.luni.util.
 NotI
@@ -2278,248 +2278,42 @@
    t
-oolkit.lockAWT();%0A        try %7B%0A        %7D finally %7B%0A            toolkit.unlockAWT();%0A        %7D%0A        if (true) %7B%0A            throw new RuntimeException(%22Method is not implemented%22); //TODO: implement //$NON-NLS-1$%0A        %7D%0A        return
+hrow new NotImplementedException()
 ;%0A  
@@ -2410,37 +2410,8 @@
 on, 
-org.apache.harmony.luni.util.
 NotI
@@ -2445,248 +2445,42 @@
    t
-oolkit.lockAWT();%0A        try %7B%0A        %7D finally %7B%0A            toolkit.unlockAWT();%0A        %7D%0A        if (true) %7B%0A            throw new RuntimeException(%22Method is not implemented%22); //TODO: implement //$NON-NLS-1$%0A        %7D%0A        return
+hrow new NotImplementedException()
 ;%0A  
@@ -2661,37 +2661,8 @@
 ows 
-org.apache.harmony.luni.util.
 NotI
@@ -2696,253 +2696,42 @@
    t
-oolkit.lockAWT();%0A        try %7B%0A        %7D finally %7B%0A            toolkit.unlockAWT();%0A        %7D%0A        if (true) %7B%0A            throw new RuntimeException(%22Method is not implemented%22); //TODO: implement //$NON-NLS-1$%0A        %7D%0A        return null
+hrow new NotImplementedException()
 ;%0A  

simplify not implemented impl