001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.util.viewer;
028:
029: import java.awt.BorderLayout;
030: import java.awt.Color;
031: import java.awt.Container;
032: import java.awt.FlowLayout;
033: import java.awt.event.ActionEvent;
034: import java.awt.event.ActionListener;
035:
036: import javax.swing.BorderFactory;
037: import javax.swing.JButton;
038: import javax.swing.JColorChooser;
039: import javax.swing.JFrame;
040: import javax.swing.JPanel;
041: import javax.swing.event.ChangeEvent;
042: import javax.swing.event.ChangeListener;
043:
044: /**
045: * This class instanciates the GUI of the (Geo)Object Viewer Color chooser.
046: *
047: * @author Thierry Badard & Arnaud Braun
048: * @version 1.0
049: *
050: */
051:
052: class ObjectViewerColorChooser extends JFrame {
053:
054: public static final String FRAME_TITLE = "GeOxygene Color Chooser";
055:
056: public Color selectedColor;
057: public JButton frameButton;
058:
059: public ObjectViewerColorChooser(Color presetColor, JButton button) {
060: super (FRAME_TITLE);
061:
062: this .selectedColor = presetColor;
063: this .frameButton = button;
064:
065: //Set up the banner at the top of the window
066: //final JLabel banner = new JLabel("GeOxygene",JLabel.CENTER);
067: //banner.setForeground(Color.yellow);
068: //banner.setOpaque(true);
069: //banner.setFont(new Font("SansSerif", Font.BOLD, 24));
070: //banner.setPreferredSize(new Dimension(100, 65));
071:
072: //JPanel bannerPanel = new JPanel(new BorderLayout());
073: //bannerPanel.add(banner, BorderLayout.CENTER);
074: //bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner"));
075:
076: //Set up color chooser for setting text color
077: //final JColorChooser tcc = new JColorChooser(banner.getForeground());
078: final JColorChooser tcc = new JColorChooser(presetColor);
079: tcc.getSelectionModel().addChangeListener(new ChangeListener() {
080: public void stateChanged(ChangeEvent e) {
081: selectedColor = tcc.getColor();
082: //Color newColor = tcc.getColor();
083: //banner.setForeground(newColor);
084: }
085: });
086: tcc.setBorder(BorderFactory
087: .createTitledBorder("Choose a Color"));
088:
089: //Add the control panel at the bottom of the window
090: final JPanel controlPanel = new JPanel(new FlowLayout(
091: FlowLayout.CENTER, 20, 10));
092:
093: JButton okButton = new JButton("Ok");
094: okButton.addActionListener(new ActionListener() {
095: public void actionPerformed(ActionEvent e) {
096: //Set the choosen color here !!!
097: frameButton.setIcon(new RectIcon(selectedColor));
098: ObjectViewerColorChooser.this .dispose();
099: }
100: });
101:
102: JButton cancelButton = new JButton("Cancel");
103: cancelButton.addActionListener(new ActionListener() {
104: public void actionPerformed(ActionEvent e) {
105: ObjectViewerColorChooser.this .dispose();
106: }
107: });
108: controlPanel.add(okButton);
109: controlPanel.add(cancelButton);
110:
111: //Add the components to the colorchooser frame
112: Container contentPane = getContentPane();
113: //contentPane.add(bannerPanel, BorderLayout.NORTH);
114: contentPane.add(tcc, BorderLayout.CENTER);
115: contentPane.add(controlPanel, BorderLayout.SOUTH);
116: }
117: }
|