/*******************************************************************************
* Copyright (c)                                                                *
*           2005   Tristan Allwood,                                            *
*           2005   Daniel Burke,                                               *
*           2005   Marc Hull,                                                  *
*           2005   Ekaterina Itskova,                                          *
*           2005   Steve Zymler                                                *
*                                                                              *
* Permission is hereby granted, free of charge, to any person obtaining a      *
* copy of this software and associated documentation files (the                *
* "Software"), to deal in the Software without restriction, including          *
* without limitation the rights to use, copy, modify, merge, publish,          *
* distribute, sublicense, and/or sell copies of the Software, and to           *
* permit persons to whom the Software is furnished to do so, subject to        *
* the following conditions:                                                    *
*                                                                              *
* The above copyright notice and this permission notice shall be included      *
* in all copies or substantial portions of the Software.                       *
*                                                                              *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS      *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                   *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.       *
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY         *
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,         *
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE            *
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                       *
*******************************************************************************/
/*
 * Created on Dec 18, 2004
 */
package uk.ac.ic.doc.kevlar.gui.internal.widgets.swing;


/**
 * @param <T> 
 * @author tora
 */
/*
public class SwingWidget<T extends JComponent & IWrappableSwingComponent>
        extends AMouseListenerObject {

    private final T baseComponent;
    BufferedImage bi;

    Image swtImage;

    public SwingWidget(T base) {
        super();
        baseComponent = base;
        baseComponent.setVisible(true);
        baseComponent.setOpaque(true);
        bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
        validate();
    }

    public void validate() {
        baseComponent.update(bi.getGraphics());
        swtImage = new Image(Display.getDefault(), ConvertSwtAwt
                .convertToSWT(bi));
        redraw();
        System.out.println(baseComponent);
    }

    public boolean capturesMouse() {
        return true;
    }

    public void mouseEnter() {
        super.mouseEnter();
        baseComponent.processMouseEvent(new MouseEvent(baseComponent,
                MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(), 0, 0, 0,
                0, false));
        validate();
    }

    public void mouseExit() {
        super.mouseExit();
        baseComponent.processMouseEvent(new MouseEvent(baseComponent,
                MouseEvent.MOUSE_EXITED, System.currentTimeMillis(),
                MouseEvent.BUTTON1_DOWN_MASK, 0, 0, 0, false));
        validate();
    }

    public void mousePress(Point position, int mouseButton) {
        super.mousePress(position, mouseButton);
        System.out.println("Mouse Pressed " + position);
        baseComponent
                .processMouseEvent(new MouseEvent(baseComponent,
                        MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(),
                        getAwtMouseMask(mouseButton), position.x, position.y,
                        0, false));
        validate();
    }

    public void mouseRelease(Point position, int mouseButton) {
        super.mouseRelease(position, mouseButton);
        System.out.println("Mouse Released " + position);
        baseComponent
                .processMouseEvent(new MouseEvent(baseComponent,
                        MouseEvent.MOUSE_RELEASED, System.currentTimeMillis(),
                        getAwtMouseMask(mouseButton), position.x, position.y,
                        0, false));
        validate();
    }

    public void mouseMoving(Point position) {
        super.mouseMoving(position);

        if( isMouseDown() ) {
            baseComponent.processMouseMotionEvent(new MouseEvent(baseComponent,
                    MouseEvent.MOUSE_DRAGGED, System.currentTimeMillis(), MouseEvent.BUTTON1_DOWN_MASK,
                    position.x, position.y, 0, false));
        } else {
            baseComponent.processMouseMotionEvent(new MouseEvent(baseComponent,
                    MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0,
                    position.x, position.y, 0, false));
        }
        
        validate();
    }


    private int getAwtMouseMask(int mouseButton) throws AssertionError {

        switch (mouseButton) {
        case MB_LEFT:
            return MouseEvent.BUTTON1_MASK;
        case MB_RIGHT:
            return MouseEvent.BUTTON2_MASK;
        case MB_MIDDLE:
            return MouseEvent.BUTTON3_MASK;
        default:
            throw new AssertionError("Don't know the mouse button!");
        }
    }

    public void setSize(Point size) {
        super.setSize(size);
        baseComponent.setSize(size.x, size.y);
        bi = new BufferedImage(size.x, size.y, BufferedImage.TYPE_INT_RGB);
        validate();
    }

    public T getComponent() {
        return baseComponent;
    }

    public void drawBefore(GC gc, Rectangle redrawArea) {
        super.drawBefore(gc, redrawArea);
        gc.drawImage(swtImage, redrawArea.x, redrawArea.y, redrawArea.width,
                redrawArea.height, redrawArea.x, redrawArea.y,
                redrawArea.width, redrawArea.height);
    }

}
*/