C THIS SUBROUTINE CALCULATES A SET OF LIMITS 'XLOW,XHIGH,YLOW,YHIGH'
C WHICH ARE USED TO PERFORM THE TRIMMING OPERATION.
C
	SUBROUTINE WINDOW (SWITCH)
	LOGICAL SWITCH
	COMMON /LIMITS/XMIN,XMAX,YMIN,YMAX
	COMMON /FRAME/ A,B,C,D
	COMMON /SIZE/  XLOW,XHIGH,YLOW,YHIGH
	COMMON /SCALE/ XDIFF,YDIFF
C
	XLOW = AMIN1 (XMIN,XMAX)
	XHIGH = AMAX1(XMIN,XMAX)
	YLOW = AMIN1 (YMIN,YMAX)
	YHIGH = AMAX1(YMIN,YMAX)
	IF (.NOT.SWITCH) GO TO 20
	XLOW = AMAX1(XLOW,AMIN1(AMIN1(A,B),XHIGH))
	XHIGH = AMIN1(XHIGH,AMAX1(AMAX1(A,B),XLOW))
	YLOW = AMAX1(YLOW,AMIN1(AMIN1(C,D),YHIGH))
	YHIGH = AMIN1(YHIGH,AMAX1(AMAX1(C,D),YLOW))
20	XDIFF = 4095./(XMAX-XMIN)
	YDIFF = 4095./(YMAX-YMIN)
	RETURN
	END
