import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

public class ColorScalePanel extends ColorMapPanel {
    int width;
    double zerolevel;
    int size = 100;

    public ColorScalePanel(int Width) {	
	spacing=0;

	width=Width;

	setPreferredSize(new Dimension(width, size));

	data = new double[size][1];

	for(int i=0; i<size; i++) data[i][0] = 1.0 - 1.0 / size * i;

	Border border = BorderFactory.createLineBorder(Color.BLACK);
	setBorder(border);
    }

    public void invert() {
	double[][] inverted = new double[size][1];
	for(int i=0; i<size; i++) inverted[i][0] = data[size-1-i][0];
	data = inverted;
	repaint();
    }

    public void Draw(Graphics g) {
	super.draw(g);
	int height=getHeight()-2*borderheight;
	int y=(int) (zerolevel*height) + borderwidth;

	g.setColor(Color.black);
	g.drawLine(borderwidth, y, width-borderwidth-1, y);
    }
}

