svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / graphics / InputHistogram.java @ 19361
History | View | Annotate | Download (3.73 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.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 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
35 |
import org.gvsig.raster.datastruct.Histogram; |
36 |
import org.gvsig.rastertools.enhanced.ui.EnhancedListener; |
37 |
/**
|
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 |
private static final long serialVersionUID = 681848373747974757L; |
45 |
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 |
public InputHistogram(Histogram hist, DatasetColorInterpretation ci, double[] minList, double[] maxList) { |
53 |
super(hist, ci, minList, maxList);
|
54 |
init(); |
55 |
} |
56 |
|
57 |
/**
|
58 |
* Inicializaci?n de componentes gr?ficos
|
59 |
*/
|
60 |
protected void init() { |
61 |
super.init();
|
62 |
|
63 |
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 |
/*
|
70 |
* (non-Javadoc)
|
71 |
* @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getSouthPanel()
|
72 |
*/
|
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 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see org.gvsig.rastertools.enhanced.graphics.HistogramGraphicBase#getCanvas()
|
92 |
*/
|
93 |
public GCanvas getCanvas() {
|
94 |
if(canvas == null) { |
95 |
gHist = new GraphicHistogram(histogramDrawed, histogramColor);
|
96 |
gHist.setType(GraphicHistogram.TYPE_LINE); |
97 |
minMaxLines = new MinMaxLines(minmaxColor);
|
98 |
//minMaxLines.setActionManager(this);
|
99 |
|
100 |
canvas = new GCanvas(Color.BLACK); |
101 |
canvas.setDrawableElement(new Border(borderColor)); |
102 |
canvas.setDrawableElement(gHist); |
103 |
canvas.setDrawableElement(dElement); |
104 |
canvas.setDrawableElement(minMaxLines); |
105 |
} |
106 |
return canvas;
|
107 |
} |
108 |
|
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 |
getCanvas().addValueChangedListener(listener); |
115 |
} |
116 |
} |