All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.cloudfarming.client.editors.ImageEditor Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2008-2012 AgroSense Foundation.
 *
 * AgroSense is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * There are special exceptions to the terms and conditions of the GPLv3 as it is applied to
 * this software, see the FLOSS License Exception
 * .
 *
 * AgroSense 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with AgroSense.  If not, see .
 */
package nl.cloudfarming.client.editors;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyEditor;
import org.openide.explorer.propertysheet.ExPropertyEditor;
import org.openide.explorer.propertysheet.PropertyEnv;

/**
 *
 * @author Timon Veenstra
 */
public class ImageEditor implements PropertyEditor, ExPropertyEditor {

    private final PropertyChangeSupport supp = new PropertyChangeSupport(this);
    private Image value;

    @Override
    public void setValue(Object o) {
        this.value = (Image) o;
    }

    @Override
    public Object getValue() {
        return value;
    }

    @Override
    public boolean isPaintable() {
        return true;
    }

    @Override
    public void paintValue(Graphics grphcs, Rectangle rctngl) {
        if (value != null) {
            grphcs.drawImage(value, rctngl.x, rctngl.y, rctngl.width, rctngl.height, null);
        }
    }

    @Override
    public String getJavaInitializationString() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String getAsText() {
        return value == null ? "empty" : value.toString();
    }

    @Override
    public void setAsText(String string) throws IllegalArgumentException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String[] getTags() {
        return null;
    }

    @Override
    public Component getCustomEditor() {
        return null;
    }

    @Override
    public boolean supportsCustomEditor() {
        return false;
    }

    @Override
    public void addPropertyChangeListener(PropertyChangeListener pl) {
        supp.addPropertyChangeListener(pl);
    }

    @Override
    public void removePropertyChangeListener(PropertyChangeListener pl) {
        supp.removePropertyChangeListener(pl);
    }
    private PropertyEnv env;

    @Override
    public void attachEnv(PropertyEnv pe) {
        env = pe;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy