Statistics
| Revision:

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

History | View | Annotate | Download (4.25 KB)

1
/* 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.JLabel;
27
import javax.swing.JPanel;
28

    
29
import org.gvsig.raster.beans.canvas.DrawableElement;
30
import org.gvsig.raster.beans.canvas.GCanvas;
31
import org.gvsig.raster.beans.canvas.layers.Border;
32
import org.gvsig.raster.beans.canvas.layers.GraphicHistogram;
33
import org.gvsig.raster.beans.canvas.layers.MinMaxLines;
34
import org.gvsig.raster.beans.canvas.layers.StraightLine;
35
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation;
36
import org.gvsig.raster.datastruct.Histogram;
37
import org.gvsig.raster.util.RasterToolsUtil;
38
import org.gvsig.rastertools.enhanced.ui.EnhancedListener;
39

    
40
/**
41
 * Componente con el histograma de entrada.
42
 * 
43
 * 20/02/2008
44
 * @author Nacho Brodin nachobrodin@gmail.com
45
 */
46
public class InputHistogram extends HistogramGraphicBase {
47
        private static final long                serialVersionUID   = 1L;
48
        
49
        private MinMaxLines                      minMaxLines        = null; 
50
        private Color                            minmaxColor        = Color.WHITE;
51
        private DrawableElement                  dElement           = null;
52
        
53
        /**
54
         * Crea una nueva instancia de InputHistogram.
55
         */
56
        public InputHistogram(Histogram hist, DatasetColorInterpretation ci, double[] minList, double[] maxList) {
57
                super(hist, ci, minList, maxList);
58
                init();
59
        }
60
        
61
        /**
62
         * Inicializaci?n de componentes gr?ficos
63
         */
64
        protected void init() {
65
                super.init();
66
                        
67
                dElement = new StraightLine(Color.YELLOW);
68
                this.setLayout(new BorderLayout());
69
                this.add(getNorthPanel(), BorderLayout.NORTH);
70
                this.add(getCanvas(), BorderLayout.CENTER);
71
                this.add(getSouthPanel(), BorderLayout.SOUTH);
72
        }
73
        
74
        /*
75
         * (non-Javadoc)
76
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getNorthPanel()
77
         */
78
        public JPanel getNorthPanel() {
79
                if(north == null) {
80
                        north = new JPanel();
81
                        north.setLayout(new BorderLayout());
82
                        north.add(getSlider(), BorderLayout.CENTER);
83
                        north.add(new JLabel(RasterToolsUtil.getText(null, "input_hist")), BorderLayout.NORTH);
84
                }
85
                return north;
86
        }
87
        
88
        /*
89
         * (non-Javadoc)
90
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getSouthPanel()
91
         */
92
        public JPanel getSouthPanel() {
93
                if(south == null) {
94
                        south = new JPanel();
95
                        south.setLayout(new GridBagLayout());
96
                        GridBagConstraints gb = new GridBagConstraints();
97
                        gb.weightx = 1;
98
                        
99
                        gb.anchor = GridBagConstraints.WEST;
100
                        south.add(getMinValue(), gb);
101
                        
102
                        gb.anchor = GridBagConstraints.EAST;
103
                        south.add(getMaxValue(), gb);
104
                }
105
                return south;
106
        }
107
        
108
        /*
109
         * (non-Javadoc)
110
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getCanvas()
111
         */
112
        public GCanvas getCanvas() {
113
                if(canvas == null) {
114
                        gHist = new GraphicHistogram(histogramDrawed, histogramColor);
115
                        gHist.setType(GraphicHistogram.TYPE_LINE);
116
                        minMaxLines = new MinMaxLines(minmaxColor);
117
                        //minMaxLines.setActionManager(this);
118
                        
119
                        canvas = new GCanvas(Color.BLACK);
120
                        canvas.setDrawableElement(new Border(borderColor));
121
                        canvas.setDrawableElement(minMaxLines);
122
                        canvas.setDrawableElement(gHist);
123
                        canvas.setDrawableElement(dElement); 
124
                }
125
                return canvas;
126
        }
127

    
128
        /**
129
         * Asigna el listener para gestionar el evento de movimiento de gr?ficos
130
         * @param listener
131
         */
132
        public void setListener(EnhancedListener listener) {
133
                getCanvas();
134
                minMaxLines.setActionManager(listener);
135
        }
136
}