# StatusDisplay.py : Panel that displays the current state of the microscope.
#
# Distributed under the terms described in the LICENCE file.
#
# Developed by akuchlin@mems-exchange.org
#

__revision__ = "$Id: StatusDisplay.py,v 1.18 2001/12/17 19:33:37 akuchlin Exp $"

import string
from java import awt
from java.applet import Applet
import gui_util

class StatusDisplay(awt.Panel):
    def __init__(self, client):
	awt.Panel.__init__(self)
        self.client = client
        
	# Create subpanel for the coordinate display
	self.setLayout(  awt.GridBagLayout() )

        self.coord_label = awt.Label( "(    0,    0,    0)")
        self.mag_label = awt.Label( "5X  " )
        self.mode_label = awt.Label( "Brightfield" )
        self.aperture_label = awt.Label( "Aperture: 1" )
        self.light_label = awt.Label( "Light:   0%" )
        self.angle_label = awt.Label( "Rotation:   0 deg" )
        
	gui_util.constrain(self, self.coord_label, 0,0, 2,1)
	gui_util.constrain(self, self.mag_label, 0,1, 1,1)
	gui_util.constrain(self, self.mode_label, 1,1, 1,1)
	gui_util.constrain(self, self.aperture_label, 0,2, 2,1)
	gui_util.constrain(self, self.light_label, 0,3, 2,1)
	gui_util.constrain(self, self.angle_label, 0,4, 2,1)

    def update(self):
        i = self.client.image_disp
	self.coord_label.setText("(%i, %i, %i)" % (i.xpos, i.ypos, i.zpos) )
        self.mag_label.setText(str(i.mag)+'X')
        self.mode_label.setText( string.capitalize(i.mode) )
        self.aperture_label.setText( 'Aperture: %i' % (i.aperture,) )

        percentage = (100*i.light / 255)
        percentage = string.rjust( str(percentage), 3)
        self.light_label.setText( "Light: "+percentage+'%')

        angle = string.rjust( str(i.theta_angle), 3)
        self.angle_label.setText('Rotation: ' + angle + ' deg')


