Statistics
| Revision:

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

History | View | Annotate | Download (3.07 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.JPanel;
27

    
28
import org.gvsig.raster.beans.canvas.GCanvas;
29
import org.gvsig.raster.beans.canvas.layers.Border;
30
import org.gvsig.raster.beans.canvas.layers.GraphicHistogram;
31
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation;
32
import org.gvsig.raster.datastruct.Histogram;
33
/**
34
 * Componente con el histograma de salida.
35
 * 
36
 * 20/02/2008
37
 * @author Nacho Brodin nachobrodin@gmail.com
38
 */
39
public class OutputHistogram extends HistogramGraphicBase {
40
        private static final long serialVersionUID = 1L;
41

    
42
        /**
43
         * Crea una nueva instancia de OutputHistogram.
44
         */
45
        public OutputHistogram(Histogram hist, DatasetColorInterpretation ci, double[] minList, double[] maxList) {
46
                super(hist, ci, minList, maxList);
47
                init();
48
        }
49
        
50
        /**
51
         * Inicializaci?n de componentes gr?ficos
52
         */
53
        protected void init() {
54
                super.init();
55
                histogramColor = Color.GREEN;
56
                this.setLayout(new BorderLayout());
57
                this.add(getCanvas(), BorderLayout.CENTER);
58
                this.add(getSouthPanel(), BorderLayout.SOUTH);
59
        }
60
        
61
        /*
62
         * (non-Javadoc)
63
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#createDrawableElements()
64
         */
65
        protected void createDrawableElements() {
66
        }
67

    
68
        /*
69
         * (non-Javadoc)
70
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getCanvas()
71
         */
72
        public GCanvas getCanvas() {
73
                if (canvas == null) {
74
                        GraphicHistogram gHist = new GraphicHistogram(histogramDrawed, histogramColor);
75
                        gHist.setType(GraphicHistogram.TYPE_LINE);
76

    
77
                        canvas = new GCanvas(Color.BLACK);
78
                        canvas.setDrawableElement(new Border(borderColor));
79
                        canvas.setDrawableElement(gHist);
80
                }
81
                return canvas;
82
        }
83

    
84
        /*
85
         * (non-Javadoc)
86
         * @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getSouthPanel()
87
         */
88
        public JPanel getSouthPanel() {
89
                if(south == null) {
90
                        south = new JPanel();
91
                        south.setLayout(new GridBagLayout());
92
                        GridBagConstraints gb = new GridBagConstraints();
93
                        gb.weightx = 1;
94
                        
95
                        gb.anchor = GridBagConstraints.WEST;
96
                        south.add(getMinValue(), gb);
97
                        
98
                        gb.anchor = GridBagConstraints.EAST;
99
                        south.add(getMaxValue(), gb);
100
                }
101
                return south;
102
        }
103
}