Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / graphics / InputHistogram.java @ 19361

History | View | Annotate | Download (3.73 KB)

1 19173 nbrodin
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.enhanced.graphics;
20
21
import java.awt.BorderLayout;
22
import java.awt.Color;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
26
import javax.swing.JPanel;
27
28
import org.gvsig.raster.beans.canvas.DrawableElement;
29
import org.gvsig.raster.beans.canvas.GCanvas;
30
import org.gvsig.raster.beans.canvas.layers.Border;
31
import org.gvsig.raster.beans.canvas.layers.GraphicHistogram;
32
import org.gvsig.raster.beans.canvas.layers.MinMaxLines;
33
import org.gvsig.raster.beans.canvas.layers.StraightLine;
34 19280 nbrodin
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation;
35 19277 nbrodin
import org.gvsig.raster.datastruct.Histogram;
36 19296 nbrodin
import org.gvsig.rastertools.enhanced.ui.EnhancedListener;
37 19173 nbrodin
/**
38
 * Componente con el histograma de entrada.
39
 *
40
 * 20/02/2008
41
 * @author Nacho Brodin nachobrodin@gmail.com
42
 */
43
public class InputHistogram extends HistogramGraphicBase {
44 19361 bsanchez
        private static final long serialVersionUID = 681848373747974757L;
45 19173 nbrodin
        private MinMaxLines                      minMaxLines        = null;
46
        private Color                            minmaxColor        = Color.WHITE;
47
        private DrawableElement                  dElement           = null;
48
49
        /**
50
         * Crea una nueva instancia de InputHistogram.
51
         */
52 19288 nbrodin
        public InputHistogram(Histogram hist, DatasetColorInterpretation ci, double[] minList, double[] maxList) {
53
                super(hist, ci, minList, maxList);
54 19296 nbrodin
                init();
55 19173 nbrodin
        }
56
57
        /**
58
         * Inicializaci?n de componentes gr?ficos
59
         */
60
        protected void init() {
61
                super.init();
62 19280 nbrodin
63 19173 nbrodin
                dElement = new StraightLine(Color.YELLOW);
64
                this.setLayout(new BorderLayout());
65
                this.add(getCanvas(), BorderLayout.CENTER);
66
                this.add(getSouthPanel(), BorderLayout.SOUTH);
67
        }
68
69 19205 nbrodin
        /*
70
         * (non-Javadoc)
71
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getSouthPanel()
72 19173 nbrodin
         */
73
        public JPanel getSouthPanel() {
74
                if(south == null) {
75
                        south = new JPanel();
76
                        south.setLayout(new GridBagLayout());
77
                        GridBagConstraints gb = new GridBagConstraints();
78
                        gb.weightx = 1;
79
80
                        gb.anchor = GridBagConstraints.WEST;
81
                        south.add(getMinValue(), gb);
82
83
                        gb.anchor = GridBagConstraints.EAST;
84
                        south.add(getMaxValue(), gb);
85
                }
86
                return south;
87
        }
88
89 19205 nbrodin
        /*
90
         * (non-Javadoc)
91
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getCanvas()
92 19173 nbrodin
         */
93
        public GCanvas getCanvas() {
94
                if(canvas == null) {
95 19280 nbrodin
                        gHist = new GraphicHistogram(histogramDrawed, histogramColor);
96
                        gHist.setType(GraphicHistogram.TYPE_LINE);
97 19173 nbrodin
                        minMaxLines = new MinMaxLines(minmaxColor);
98 19296 nbrodin
                        //minMaxLines.setActionManager(this);
99 19173 nbrodin
100
                        canvas = new GCanvas(Color.BLACK);
101
                        canvas.setDrawableElement(new Border(borderColor));
102 19307 nbrodin
                        canvas.setDrawableElement(gHist);
103
                        canvas.setDrawableElement(dElement);
104 19173 nbrodin
                        canvas.setDrawableElement(minMaxLines);
105
                }
106
                return canvas;
107
        }
108 19296 nbrodin
109
        /**
110
         * Asigna el listener para gestionar el evento de movimiento de gr?ficos
111
         * @param listener
112
         */
113
        public void setListener(EnhancedListener listener) {
114 19361 bsanchez
                getCanvas().addValueChangedListener(listener);
115 19296 nbrodin
        }
116 19361 bsanchez
}