/*********************************************	Copyright © 2001 Jason Lamport.	All rights reserved.----------------------J_DigitalDisplay  creates a digital readout*******************************************/package com.strangelight.v4control;import com.strangelight.*;import com.strangelight.salsa.*;import java.awt.*;public class J_DigitalDisplay extends Canvas {	public static final int	BLUE_ON_BLACK_8x13	= 0;		private static final String[] base_uris = {		"/images/digits/blue_8x13_"	};	private static final int BLANK_SPACE = 10;		private static final int MINUS_SIGN = 11;		//	indexes of non-digit character images		public J_DigitalDisplay(int digits, int style ) {				value = null;		digit_images = new J_Image[] {			new J_Image(base_uris[style] + "0.JPG"),			new J_Image(base_uris[style] + "1.JPG"),			new J_Image(base_uris[style] + "2.JPG"),			new J_Image(base_uris[style] + "3.JPG"),			new J_Image(base_uris[style] + "4.JPG"),			new J_Image(base_uris[style] + "5.JPG"),			new J_Image(base_uris[style] + "6.JPG"),			new J_Image(base_uris[style] + "7.JPG"),			new J_Image(base_uris[style] + "8.JPG"),			new J_Image(base_uris[style] + "9.JPG"),			new J_Image(base_uris[style] + "_.JPG"),			new J_Image(base_uris[style] + "-.JPG"),		};		digit_width = digit_images[0].get_image().getWidth(null);		digit_height = digit_images[0].get_image().getHeight(null);		value = null;		num_digits = digits;		this.setSize(digit_width * num_digits, digit_height);	}		public Integer get_value() {		return value;	}		public void set_value(int new_value) {		set_value( new Integer(new_value) );	}		public void set_value(Integer new_value) {		value = new_value;		Graphics g = this.getGraphics();		if ( g != null ) {			this.paint(g);		}	}		public void paint(Graphics g) {		int x, y, cur_digit;		Integer temp_value = 			( value == null )			?	null			:	new Integer( Math.abs(value.intValue()) );		;				cur_digit = BLANK_SPACE;		y=0;		for ( int i = (num_digits - 1) ; i >= 0; i-- ) {			x = i * digit_width;			if ( temp_value != null ) {					cur_digit = temp_value.intValue() % 10;			}			g.drawImage( digit_images[cur_digit].get_image(), x, y, null );			if ( temp_value == null ) {				cur_digit = BLANK_SPACE;			} else {				temp_value = new Integer( temp_value.intValue()/10 );				if ( temp_value.intValue() == 0 ) {					cur_digit =						( value.intValue() < 0 )						?	MINUS_SIGN						:	BLANK_SPACE					;					temp_value = null;				}							}		}		if ( cur_digit != BLANK_SPACE ) throw new E_OutOfBounds(			value + " has more than " + num_digits + " digits/characters"		);	}	public Dimension getPreferredSize() {		return getSize();	}		public Dimension getMaximumSize() {		return getSize();	}		public Dimension getMinimumSize() {		return getSize();	}			private int digit_width, digit_height, num_digits;	private Integer value;	private J_Image[] digit_images;	}