Revision 13022

View differences:

trunk/libraries/libRaster/src/org/gvsig/raster/datastruct/ColorItem.java
30 30
	private double value = 0.0f;
31 31
	private String nameClass = null;
32 32
	private Color color = Color.black;
33
	private int interpolated = 50;
33
	private double interpolated = 50;
34 34

  
35 35
	/**
36 36
	 * Devuelve el color
......
53 53
	 * L?mites: 0..100
54 54
	 * @return
55 55
	 */
56
	public int getInterpolated() {
56
	public double getInterpolated() {
57 57
		return interpolated;
58 58
	}
59 59

  
......
62 62
	 * entre los valores correctos.
63 63
	 * @param interpolated
64 64
	 */
65
	public void setInterpolated(int interpolated) {
65
	public void setInterpolated(double interpolated) {
66 66
		this.interpolated = interpolated;
67 67
		if (this.interpolated > 100)
68 68
			this.interpolated = 100;
......
130 130
		final int PRIME = 31;
131 131
		int result = 1;
132 132
		result = PRIME * result + ((color == null) ? 0 : color.hashCode());
133
		result = PRIME * result + interpolated;
133
		result = PRIME * result + (int) interpolated;
134 134
		result = PRIME * result + ((nameClass == null) ? 0 : nameClass.hashCode());
135 135
		long temp;
136 136
		temp = Double.doubleToLongBits(value);
trunk/libraries/libRaster/src/org/gvsig/raster/datastruct/ColorTable.java
102 102
	 */
103 103
	protected String    filePath          = null;
104 104

  
105
	private int         errorColor        = 8;
106

  
105 107
	/**
106 108
	 * Constructor vac?o.
107 109
	 * @param name
......
175 177
		applyPalette(colorItems);
176 178
	}
177 179

  
178
	private int error = 8;
179
	private boolean isEqualColor(Color c1, Color c2) {
180
		if (c2.getRed() < (c1.getRed() - error)) return false;
181
		if (c2.getGreen() < (c1.getGreen() - error)) return false;
182
		if (c2.getBlue() < (c1.getBlue() - error)) return false;
183
		if (c2.getAlpha() < (c1.getAlpha() - error)) return false;
180
	private boolean isEqualColor(Color c1, Color c2, int error) {
181
		if ((c2 == null) && (c1 != null))
182
			return false;
183
		if ((c1 == null) && (c2 != null))
184
			return false;
185
		if (c2.getRed() < (c1.getRed() - error))
186
			return false;
187
		if (c2.getGreen() < (c1.getGreen() - error))
188
			return false;
189
		if (c2.getBlue() < (c1.getBlue() - error))
190
			return false;
191
		if (c2.getAlpha() < (c1.getAlpha() - error))
192
			return false;
184 193

  
185
		if (c2.getRed() > (c1.getRed() + error)) return false;
186
		if (c2.getGreen() > (c1.getGreen() + error)) return false;
187
		if (c2.getBlue() > (c1.getBlue() + error)) return false;
188
		if (c2.getAlpha() > (c1.getAlpha() + error)) return false;
194
		if (c2.getRed() > (c1.getRed() + error))
195
			return false;
196
		if (c2.getGreen() > (c1.getGreen() + error))
197
			return false;
198
		if (c2.getBlue() > (c1.getBlue() + error))
199
			return false;
200
		if (c2.getAlpha() > (c1.getAlpha() + error))
201
			return false;
189 202

  
190 203
		return true;
191 204
	}
......
210 223
		int a = c1.getColor().getAlpha() + (int) (((c2.getColor().getAlpha() - c1.getColor().getAlpha()) * (c3.getValue() - c1.getValue())) / max);
211 224
		Color aux = new Color(r & 0xff, g & 0xff, b & 0xff, a & 0xff);
212 225

  
213
		return isEqualColor(c3.getColor(), aux);
226
		return isEqualColor(c3.getColor(), aux, errorColor);
214 227
	}
215 228

  
216 229
	private boolean canDelete(int first, int last) {
......
224 237
	}
225 238

  
226 239
	public void compressPalette() {
240
		System.out.println("Antes: " + colorItems.size());
227 241
		compressPalette(colorItems);
242
		System.out.println("Despues: " + colorItems.size());
228 243
	}
229 244

  
230 245
	public boolean isCompressible() {
......
450 465
				(item2.getColor().getAlpha() + item1.getColor().getAlpha()) >> 1);
451 466

  
452 467
		Color color1, color2;
453
		int perc1, perc2;
468
		double perc1, perc2;
454 469

  
455
		if (percValue > item1.getInterpolated()) {
470
		if (percValue > item2.getInterpolated()) {
456 471
			color1 = halfColor;
457 472
			color2 = item2.getColor();
458
			perc1 = item1.getInterpolated();
473
			perc1 = item2.getInterpolated();
459 474
			perc2 = 100;
460 475
		} else {
461 476
			color1 = item1.getColor();
462 477
			color2 = halfColor;
463 478
			perc1 = 0;
464
			perc2 = item1.getInterpolated();
479
			perc2 = item2.getInterpolated();
465 480
		}
466 481

  
467 482
		double percNew = (percValue - perc1) / (perc2 - perc1);
......
575 590
				color = ((ColorItem) colorItems.get(pos)).getColor();
576 591
			}
577 592

  
578
			if (!color.equals(colorOld)) {
593
			if (!isEqualColor(color, colorOld, 0)) {
579 594
				ColorItem colorItem = new ColorItem();
580 595
				colorItem.setNameClass("");
581 596
				colorItem.setValue(value);
......
650 665
		final int PRIME = 31;
651 666
		int result = 1;
652 667
		result = PRIME * result + ((colorItems == null) ? 0 : colorItems.hashCode());
653
		result = PRIME * result + error;
668
		result = PRIME * result + errorColor;
654 669
		result = PRIME * result + ((filePath == null) ? 0 : filePath.hashCode());
655 670
		result = PRIME * result + (interpolated ? 1231 : 1237);
656 671
		result = PRIME * result + ((name == null) ? 0 : name.hashCode());
......
687 702
			}
688 703
		}
689 704

  
690
		if (error != other.error)
691
			return false;
692 705
		if (filePath == null) {
693 706
			if (other.filePath != null)
694 707
				return false;
......
699 712
				return false;
700 713
		} else if (!name.equals(other.name))
701 714
			return false;
702
		if (!Arrays.equals(nameClass, other.nameClass))
703
			return false;
704 715

  
716
		if (nameClass != null) {
717
			if (nameClass.length != other.nameClass.length)
718
				return false;
719

  
720
			for (int i = 0; i < nameClass.length; i++) {
721
				if (!nameClass[i].equals(other.nameClass[i]))
722
					return false;
723
			}
724
		}
725

  
705 726
		if ( ((paletteByBand == null) && (other.paletteByBand != null)) ||
706 727
				((paletteByBand != null) && (other.paletteByBand == null)) )
707 728
			return false;
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/colorbutton/ColorButton.java
105 105
		if (height2 <= 0)
106 106
			height2 = 1;
107 107

  
108
		if ((width!=width2) || (height!=height2)) {
108
		if ((width != width2) || (height != height2)) {
109 109
			bufferImage = createImage(width2, height2);
110
			if (bufferImage == null) return null;
110
			if (bufferImage == null)
111
				return null;
111 112
			bufferGraphics = bufferImage.getGraphics();
112 113
		}
113 114

  
......
124 125
		if (getBufferGraphics() == null)
125 126
			return;
126 127

  
128
		Color newColor = color;
127 129
		if (isEnabled()) {
128 130
			Shape oldClip = getBufferGraphics().getClip();
129 131
			getBufferGraphics().setClip(1, 1, width - 2, height - 2);
130
			if (color.getAlpha() != 255) {
132
			if ((color == null) || (color.getAlpha() != 255)) {
131 133
				for (int i = 0; (i * 4) <= width; i++) {
132 134
					for (int j = 0; (j * 4) <= height; j++) {
133 135
						if ((i + j) % 2 == 0)
......
140 142
			}
141 143
			getBufferGraphics().setClip(oldClip);
142 144

  
143
			getBufferGraphics().setColor(color);
145
			newColor = color;
144 146
		} else {
145
			getBufferGraphics().setColor(getBackground());
147
			newColor = getBackground();
146 148
		}
147
		getBufferGraphics().fillRect(1, 1, width - 2, height - 2);
148 149

  
150
		if (newColor != null) {
151
			getBufferGraphics().setColor(newColor);
152
			getBufferGraphics().fillRect(1, 1, width - 2, height - 2);
153
		}
154

  
149 155
		if (isEnabled())
150 156
			getBufferGraphics().setColor(Color.black);
151 157
		else
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/imagenavigator/ImageNavigator.java
361 361
		updateWidth = getWidgetImage().getWidth(this);
362 362
		updateHeight = getWidgetImage().getHeight(this);
363 363

  
364
		for (int i = 0; (i * 4) <= width; i++) {
365
			for (int j = 0; (j * 4) <= height; j++) {
366
				if ((i + j) % 2 == 0)
367
					getCacheGraphics().setColor(Color.white);
368
				else
369
					getCacheGraphics().setColor(new Color(204, 204, 204));
370
				getCacheGraphics().fillRect(i * 4, j * 4, 4, 4);
371
			}
372
		}
373
/*
364 374
		getCacheGraphics().setColor(Color.WHITE);
365 375
		getCacheGraphics().fillRect(0, 0, width, height);
376
*/
366 377

  
367 378
		double newY1 = 0.0;
368 379
		double newY2 = 0.0;
......
425 436
	 * Redibujar el componente en el graphics temporal
426 437
	 */
427 438
	private void redrawBuffer(int x, int y) {
428
		getWidgetGraphics().setColor(Color.white);
439
		for (int i = -2; ((i - 2) * 4) <= width; i++) {
440
			for (int j = -2; ((j - 2) * 4) <= height; j++) {
441
				if ((i + j) % 2 == 0)
442
					getWidgetGraphics().setColor(Color.white);
443
				else
444
					getWidgetGraphics().setColor(new Color(204, 204, 204));
445
				getWidgetGraphics().fillRect((i * 4) + (x % 8), (j * 4) + (y % 8), 4, 4);
446
			}
447
		}
448
/*
449
		getWidgetGraphics().setColor(new Color(204, 204, 204));
429 450
		getWidgetGraphics().fillRect(0, 0, width, height);
451
*/
430 452

  
431 453
		getWidgetGraphics().drawImage(imageCache, x, y, null);
432 454

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/colorslideredition/ItemColorSlider.java
25 25
	private double interpolated = 50; // Atencion, es la interpolacion izquierda
26 26
	private Color color = Color.black;
27 27
	private boolean visible = true;
28
	private String name = "";
29

  
28 30
	/**
29 31
	 * Seleted:
30 32
	 * -1: No seleccionado
......
123 125
				break;
124 126
		}
125 127
	}
128

  
129
	/**
130
	 * @return the name
131
	 */
132
	public String getName() {
133
		return name;
134
	}
135

  
136
	/**
137
	 * @param name the name to set
138
	 */
139
	public void setName(String name) {
140
		this.name = name;
141
	}
126 142
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/colorslideredition/ColorSliderEdition.java
59 59
	 */
60 60
	public ColorSliderEdition() {
61 61
		this.setPreferredSize(new Dimension(100, 46));
62
//		items.add(new ItemColorSlider(0, Color.black));
63
//		items.add(new ItemColorSlider(100, new Color(0, 0, 0, 0)));
64
		items.add(new ItemColorSlider(0, Color.black));
65
		items.add(new ItemColorSlider(25, Color.red));
66
		items.add(new ItemColorSlider(50, Color.green));
67
		items.add(new ItemColorSlider(75, Color.blue));
68
		items.add(new ItemColorSlider(100, Color.white));
69 62
		addMouseListener(this);
70 63
		addMouseMotionListener(this);
71 64
	}
......
157 150
		if (height2 <= 0)
158 151
			height2 = 1;
159 152

  
160
		if ((width!=width2) || (height!=height2)) {
153
		if ((width != width2) || (height != height2)) {
161 154
			bufferImage = createImage(width2, height2);
162
			if (bufferImage == null) return null;
155
			if (bufferImage == null)
156
				return null;
163 157
			bufferGraphics = bufferImage.getGraphics();
164 158
		}
165 159

  
......
201 195
	 * Redibujar el componente en el graphics temporal
202 196
	 */
203 197
	private void redrawBuffer() {
204
		if (getBufferGraphics() == null) return;
198
		if (getBufferGraphics() == null)
199
			return;
205 200

  
206 201
		sortItems();
207 202

  
208 203
		getBufferGraphics().setColor(this.getBackground());
209 204

  
210
		getBufferGraphics().fillRect(0,0,width,height);
205
		getBufferGraphics().fillRect(0, 0, width, height);
211 206

  
212 207
		getBufferGraphics().setColor(Color.black);
213 208
		getBufferGraphics().drawRect(LEFT_PAD, 0, width - 1 - LEFT_PAD - RIGHT_PAD, height - 18);
......
223 218
				getBufferGraphics().fillRect(i * 4 + 2 + LEFT_PAD, j * 4 + 2, 4, 4);
224 219
			}
225 220
		}
221
		Color newColor = Color.black;
226 222

  
227
		ArrayList newArray = (ArrayList) items.clone();
228
		for (int i = newArray.size() - 1; i>=0; i--) {
229
			if (((ItemColorSlider) newArray.get(i)).isVisible() == false)
230
				newArray.remove(i);
231
		}
223
		ArrayList newArray = getItemsShowed();
224

  
232 225
		for (int i = LEFT_PAD + 2; i <= width - 2 - RIGHT_PAD; i++) {
233

  
234 226
			int pos = getPosForValue(pixelToValue(i), newArray);
235 227

  
236 228
			if (isInterpolated()) {
237
				getBufferGraphics().setColor(interpolatedColor(newArray, pixelToValue(i), pos));
229
				newColor = interpolatedColor(newArray, pixelToValue(i), pos);
238 230
			} else {
239 231
				if ((pos + 1) < newArray.size()) {
240 232
					double min = ((ItemColorSlider) newArray.get(pos)).getValue();
......
242 234
					if ((min + ((max - min) * ((ItemColorSlider) newArray.get(pos + 1)).getInterpolated() / 100)) < pixelToValue(i))
243 235
						pos++;
244 236
				}
245
				getBufferGraphics().setColor(((ItemColorSlider) newArray.get(pos)).getColor());
237
				if (pos < newArray.size())
238
					newColor = ((ItemColorSlider) newArray.get(pos)).getColor();
246 239
			}
247
			getBufferGraphics().drawLine(i, 2, i, height - 18);
240
			if (newColor != null) {
241
				getBufferGraphics().setColor(newColor);
242
				getBufferGraphics().drawLine(i, 2, i, height - 18);
243
			}
248 244
		}
249 245

  
250 246
		getBufferGraphics().setClip(oldClip);
......
269 265
				paintNext = true;
270 266
		}
271 267

  
272
		for (int i = items.size() - 1; i >=0; i--) {
268
		for (int i = items.size() - 1; i >= 0; i--) {
273 269
			ItemColorSlider aux = (ItemColorSlider) items.get(i);
274 270
			if (!aux.isVisible())
275 271
				continue;
......
307 303
	 * @param color
308 304
	 */
309 305
	private void drawSliderColor(int x, int y, Color color, boolean isSelected) {
306
		if (color == null)
307
			return;
310 308
		Polygon p = new Polygon();
311 309
		p.addPoint(x, y);
312 310
		p.addPoint(x - 5, y + 6);
......
441 439
	 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
442 440
	 */
443 441
	public void mouseReleased(MouseEvent e) {
444
		for (int i = items.size() - 1; i >= 0; i--) {
445
			if (items.size() <= 2)
446
				return;
447
			if (((ItemColorSlider) items.get(i)).isVisible() == false)
448
				items.remove(i);
442
		try {
443
			for (int i = items.size() - 1; i >= 0; i--) {
444
				if (items.size() <= 2)
445
					return;
446
				if (((ItemColorSlider) items.get(i)).isVisible() == false)
447
					items.remove(i);
448
			}
449
		} finally {
450
			callValueChangedListeners();
449 451
		}
450
		callValueChangedListeners();
451 452
	}
452 453

  
453 454
	public ItemColorSlider getSelectedItem() {
......
635 636
		items.clear();
636 637
	}
637 638

  
639
	/**
640
	 * @return the items
641
	 */
642
	public ArrayList getItems() {
643
		return items;
644
	}
645

  
646
	/**
647
	 * Devuelve los items que estan visibles en el componente
648
	 * @return the items
649
	 */
650
	public ArrayList getItemsShowed() {
651
		ArrayList newArray = (ArrayList) items.clone();
652
		for (int i = newArray.size() - 1; i >= 0; i--) {
653
			if (((ItemColorSlider) newArray.get(i)).isVisible() == false)
654
				newArray.remove(i);
655
		}
656

  
657
		return newArray;
658
	}
659

  
638 660
	public void mouseClicked(MouseEvent e) {}
639 661
	public void mouseEntered(MouseEvent e) {}
640 662
	public void mouseExited(MouseEvent e) {}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/colortable/ui/ColorTablePanel.java
178 178

  
179 179
	private TabInterpolated getTabInterpolated() {
180 180
		if (tabInterpolated == null) {
181
			tabInterpolated = new TabInterpolated();
181
			tabInterpolated = new TabInterpolated(this);
182 182
		}
183 183
		return tabInterpolated;
184 184
	}
......
421 421
		getTabInterpolated().clearTable();
422 422
		for (int i = 0; i < colorItems.size(); i++) {
423 423
			ColorItem c1 = (ColorItem) colorItems.get(i);
424
			double percent = (((c1.getValue() - min)*100)/(max - min));
424
			double percent = (((c1.getValue() - min) * 100) / (max - min));
425 425

  
426 426
			ItemColorSlider aux = new ItemColorSlider(percent, c1.getColor());
427 427
			aux.setInterpolated(c1.getInterpolated());
428
			aux.setName(c1.getNameClass());
428 429

  
429 430
			getTabInterpolated().getColorSliderEdition().addItem(aux, false);
430 431
		}
431 432
		getTabInterpolated().initialState();
433
		if (min > max) {
434
			min = 0;
435
			max = 255;
436
		}
437
		getTabInterpolated().setLimits(min, max);
432 438

  
433 439
		active = true;
434 440
		getImageNavigator().updateBuffer();
......
463 469
			for (int i = 0; i < getListViewComponent().getItems().size(); i++) {
464 470
				((ColorTableIconPainter) ((ListViewItem) getListViewComponent().getItems().get(i)).getIcon()).setInterpolated(getCheckBoxInterpolated().isSelected());
465 471
			}
472
			lastColorTableCloned.setInterpolated(getCheckBoxInterpolated().isSelected());
466 473
			getListViewComponent().repaint();
467 474
			getImageNavigator().updateBuffer();
468 475
			getTabInterpolated().setInterpolated(getCheckBoxInterpolated().isSelected());
......
525 532
			return;
526 533

  
527 534
		((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).setColorItems(getTablePalette(), getCheckBoxInterpolated().isSelected(), false);
535
		((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable().compressPalette();
528 536
		getListViewComponent().repaint();
529 537

  
530 538
		reloadTable(false);
531 539
	}
532 540

  
541
	public void tabInterpolatedChanged() {
542
		if (!active)
543
			return;
544

  
545
		((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).setColorItems(getTabInterpolated().getPalette(), getCheckBoxInterpolated().isSelected(), false);
546
		//((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable().compressPalette();
547
		getListViewComponent().repaint();
548

  
549
		getImageNavigator().updateBuffer();
550
	}
551

  
552

  
533 553
	public GridPalette getGridPalette() {
534 554
		return new GridPalette(((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable());
535 555
	}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/colortable/panels/TabInterpolated.java
20 20

  
21 21
import java.awt.GridBagConstraints;
22 22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24
import java.util.ArrayList;
23 25

  
26
import javax.swing.JLabel;
24 27
import javax.swing.JPanel;
25 28

  
26 29
import org.gvsig.gui.beans.colorbutton.ColorButton;
......
30 33
import org.gvsig.gui.beans.colorslideredition.ColorSliderEvent;
31 34
import org.gvsig.gui.beans.colorslideredition.ColorSliderListener;
32 35
import org.gvsig.gui.beans.colorslideredition.ItemColorSlider;
36
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
37
import org.gvsig.raster.datastruct.ColorItem;
38
import org.gvsig.rastertools.colortable.ui.ColorTablePanel;
33 39
/**
34 40
 *
35 41
 * @version 27/06/2007
......
38 44
public class TabInterpolated extends JPanel implements ColorSliderListener, ColorButtonListener {
39 45
	private static final long serialVersionUID = -5208861410196059899L;
40 46

  
47
	private double min = Double.POSITIVE_INFINITY;
48
	private double max = Double.NEGATIVE_INFINITY;
49
	private ColorTablePanel colorTablePanel = null;
50

  
41 51
	//[start]Variables UI
42
	private ColorSliderEdition colorSliderEdition   = null;
43
	private ColorButton colorButton = null;
52
	private ColorSliderEdition colorSliderEdition = null;
53
	private ColorButton        colorButton        = null;
54
	private JLabel             jLabelColor        = null;
44 55
	//[end]
45 56

  
46 57
	//[start] Code UI
47
	public TabInterpolated() {
58
	public TabInterpolated(ColorTablePanel colorTablePanel) {
59
		this.colorTablePanel = colorTablePanel;
48 60
		initialize();
49 61
	}
50 62

  
......
52 64
		setLayout(new GridBagLayout());
53 65

  
54 66
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
67
		gridBagConstraints.gridwidth = 2;
55 68
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
56 69
		gridBagConstraints.weightx = 1.0;
57
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 5);
70
		gridBagConstraints.insets = new Insets(5, 5, 2, 5);
58 71

  
59 72
		add(getColorSliderEdition(), gridBagConstraints);
60 73

  
61
		gridBagConstraints = new java.awt.GridBagConstraints();
74
		gridBagConstraints = new GridBagConstraints();
75
		gridBagConstraints.gridx = 1;
76
		gridBagConstraints.gridy = 1;
77
		gridBagConstraints.anchor = GridBagConstraints.WEST;
78
		gridBagConstraints.weightx = 0.5;
79
		gridBagConstraints.insets = new Insets(2, 2, 5, 5);
80
		add(getColorButton(), gridBagConstraints);
81

  
82
		jLabelColor = new JLabel("Color: ");
83
		jLabelColor.setEnabled(false);
84
		gridBagConstraints = new GridBagConstraints();
62 85
		gridBagConstraints.gridx = 0;
63 86
		gridBagConstraints.gridy = 1;
64
		gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
65
		add(getColorButton(), gridBagConstraints);
87
		gridBagConstraints.anchor = GridBagConstraints.EAST;
88
		gridBagConstraints.weightx = 0.5;
89
		gridBagConstraints.insets = new Insets(2, 5, 5, 2);
90
		add(jLabelColor, gridBagConstraints);
66 91
	}
67 92

  
68 93
	public ColorSliderEdition getColorSliderEdition() {
......
88 113
	}
89 114

  
90 115
	public void actionSelectionChanged(ColorSliderEvent e) {
91
		ItemColorSlider itemColorSlider = colorSliderEdition.getSelectedItem();
116
		ItemColorSlider itemColorSlider = getColorSliderEdition().getSelectedItem();
92 117
		if ((itemColorSlider != null) && (itemColorSlider.getSelected() == 1)) {
93 118
			getColorButton().setColor(itemColorSlider.getColor());
94 119
			getColorButton().setEnabled(true);
120
			jLabelColor.setEnabled(true);
95 121
		} else {
96 122
			getColorButton().setEnabled(false);
123
			jLabelColor.setEnabled(false);
97 124
		}
98 125
	}
99 126

  
100 127
	public void actionValueChanged(ColorSliderEvent e) {
101
		System.out.println("actionValueChanged(ColorSliderEvent e)");
128
		colorTablePanel.tabInterpolatedChanged();
102 129
	}
103 130

  
104 131
	public void actionValueDragged(ColorSliderEvent e) {
132
		colorTablePanel.tabInterpolatedChanged();
105 133
	}
106 134

  
107 135
	private void callValueColorChanged() {
108
		ItemColorSlider itemColorSlider = colorSliderEdition.getSelectedItem();
136
		ItemColorSlider itemColorSlider = getColorSliderEdition().getSelectedItem();
109 137
		if (itemColorSlider != null) {
110 138
			itemColorSlider.setColor(getColorButton().getColor());
111
			colorSliderEdition.repaint();
139
			getColorSliderEdition().repaint();
112 140
		}
113 141
	}
114 142

  
115 143
	public void actionValueDragged(ColorButtonEvent e) {
116 144
		callValueColorChanged();
145
		//colorTablePanel.tabInterpolatedChanged();
117 146
	}
118 147

  
119 148
	public void actionValueChanged(ColorButtonEvent e) {
120 149
		callValueColorChanged();
121
		System.out.println("actionValueChanged(ColorButtonEvent e)");
150
		colorTablePanel.tabInterpolatedChanged();
122 151
	}
123 152

  
124 153
	public void initialState() {
125
		colorSliderEdition.repaint();
154
		getColorSliderEdition().repaint();
126 155
		getColorButton().setEnabled(false);
127 156
	}
128 157

  
158
	public void setLimits(double min, double max) {
159
		this.min = min;
160
		this.max = max;
161
	}
162

  
129 163
	/**
130 164
	 * Borra todas las filas de la tabla.
131 165
	 */
132 166
	public void clearTable() {
133
		colorSliderEdition.removeAllItems();
167
		getColorSliderEdition().removeAllItems();
134 168
	}
169

  
170
	/**
171
	 * Convierte el slider de la paleta en un array de objetos para poder crear
172
	 * con ?l el objeto Palette
173
	 * @return
174
	 * @throws NotInitializeException
175
	 */
176
	public ArrayList getPalette() {
177
		ArrayList arrayList = new ArrayList();
178
		ArrayList items = getColorSliderEdition().getItemsShowed();
179

  
180
		// A?adir el minimo
181
		ItemColorSlider item = (ItemColorSlider) items.get(0);
182
		ColorItem colorItem = new ColorItem();
183
		colorItem.setColor(item.getColor());
184
		colorItem.setInterpolated(item.getInterpolated());
185
		colorItem.setNameClass("");
186
		colorItem.setValue(min);
187
		arrayList.add(colorItem);
188

  
189
		for (int i = 0; i < items.size(); i++) {
190
			item = (ItemColorSlider) items.get(i);
191
			colorItem = new ColorItem();
192
			colorItem.setColor(item.getColor());
193
			colorItem.setInterpolated((int) item.getInterpolated());
194
			colorItem.setNameClass(item.getName());
195

  
196
			colorItem.setValue(min + ((item.getValue() * (max - min)) / 100.0d));
197

  
198
			arrayList.add(colorItem);
199
		}
200

  
201
		// A?adir el maximo
202
		item = (ItemColorSlider) items.get(items.size() - 1);
203
		colorItem = new ColorItem();
204
		colorItem.setColor(item.getColor());
205
		colorItem.setInterpolated(item.getInterpolated());
206
		colorItem.setNameClass("");
207
		colorItem.setValue(max);
208
		arrayList.add(colorItem);
209

  
210

  
211
		return arrayList;
212
	}
135 213
}

Also available in: Unified diff