Logo
Distributed Genetic Programming Framework
print print

File org.jfree.experimental.swt.SWTPaintCanvas.java

Here you can find all the information about the file org.jfree.experimental.swt.SWTPaintCanvas.java. You may explore it here or download it onto your local disk.
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 *
 * -------------------
 * SwtPaintCanvas.java
 * -------------------
 * (C) Copyright 2000-2005, by Object Refinery Limited.
 *
 * Original Author:  Henry Proudhon (henry.proudhon AT insa-lyon.fr);
 * Contributor(s):
 *
 * Changes
 * -------
 * 4 Aug 2006 : New class (HP);
 */


package org.jfree.experimental.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;

/**
 * A paint canvas.
 */

public class SWTPaintCanvas extends Canvas
{
    private Color myColor;
    
    /**
     * Creates a new instance.
     * 
     * @param parent  the parent.
     * @param style  the style.
     * @param color  the color.
     */

    public SWTPaintCanvas(Composite parent, int style, Color color) {
        this(parent, style);
        this.setColor(color);
    }
    
    /**
     * Creates a new instance.
     * 
     * @param parent  the parent.
     * @param style  the style.
     */

    public SWTPaintCanvas(Composite parent, int style) {
        super(parent, style);
        addPaintListener(new PaintListener() {
            public void paintControl(PaintEvent e) {
                e.gc.setForeground(e.gc.getDevice().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setBackground(myColor);
                e.gc.fillRectangle(getClientArea());
                e.gc.drawRectangle(getClientArea().x, getClientArea().y, 
                        getClientArea().width - 1, getClientArea().height - 1);
            }
        });
    }
    
    /**
     * Sets the color.
     * 
     * @param color  the color.
     */

    public void setColor(Color color) {
        if (this.myColor != null) {
            myColor.dispose();
        }
        //this.myColor = new Color( getDisplay(), color.getRGB() );
        this.myColor = color;
    }

    /**
     * Returns the color.
     * 
     * @return The color.
     */

    public Color getColor() {
        return myColor;
    }
    
    /**
     * Overridden to do nothing.
     * 
     * @param c  the color.
     */

    public void setBackground(Color c) {
        return;
    }

    /**
     * Overridden to do nothing.
     * 
     * @param c  the color.
     */

    public void setForeground(Color c) {
        return;
    }
    
    /**
     * Frees resources.
     */

    public void dispose() {
        myColor.dispose();
    }
}

File Information:

file name:SWTPaintCanvas.java
package:org.jfree.experimental.swt
qualified name:org.jfree.experimental.swt.SWTPaintCanvas.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/jfree/experimental/swt/SWTPaintCanvas.java
size:3.759 KB (3850 B)
uploaded: 2018-01-07 12:03:36 GMT+0000
last update: 2006-08-25 12:16:46 GMT+0000
last access: 2018-04-26 04:09:33 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2018-01-07 12:03:34 GMT+0000 served at 2018-04-26 04:09:33 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo