package gov.nasa.gsfc.seadas.watermask.ui;

import org.openide.awt.ColorComboBox;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created with IntelliJ IDEA.
 * User: knowles
 * Date: 9/4/12
 * Time: 11:39 AM
 * To change this template use File | Settings | File Templates.
 */
public class LandColorComboBox {
    private LandMasksData landMasksData;

    private JLabel jLabel;
    private ColorComboBox colorExComboBox = new ColorComboBox();

    public LandColorComboBox(LandMasksData landMasksData) {

        this.landMasksData = landMasksData;

        jLabel = new JLabel("Color");
        jLabel.setToolTipText("Land mask color");

        colorExComboBox.setSelectedColor(new Color(225,225,225));
        colorExComboBox.setPreferredSize(colorExComboBox.getPreferredSize());
        colorExComboBox.setMinimumSize(colorExComboBox.getPreferredSize());

        colorExComboBox.setSelectedColor((landMasksData.getLandMaskColor()));

        addControlListeners();
    }


    private void addControlListeners() {

        colorExComboBox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                landMasksData.setLandMaskColor(colorExComboBox.getSelectedColor());
            }
        });
    }


    public JLabel getjLabel() {
        return jLabel;
    }

    public JComboBox getColorExComboBox() {
        return colorExComboBox;
    }
}
