AW: [Rd] Re: some problems with windows(rescale=) (PR#794)

joehl@web.de joehl@web.de
Fri, 19 Jan 2001 16:53:01 +0100 (MET)



Thanks to Prof. Brian Ripley and Guido Masarotto for fixing the initial rescaling of windows(rescale="fixed").

Now I can provide more detailed desciptions how to replicate the other problems I observed.

concerning 
2) wrong row distances with windows(rescale="fit") 
just use function testit() to see what I mean

# comparing the two devices appears normal
testit(width=8, height=6)

# compare the two devices for DIN A4
# with rescale="fit" lines are closer together
testit(width=16.53543, height=11.69291)

# exagerate effect
testit(width=32, height=24)

## the following function closes all devices
## creates two devices of the specified size
## with rescale="R" and rescale="fit"
## determines cex needed to fill the window (in x direction) and fills it

testit <- function(width, height){
	stroptim <- function(str, width=NULL, height=NULL, units="user", range.cex=c(0.01, 24)){
		units <- match.arg(units, c("user", "figure", "inches"))
		m <- max(length(str), length(width), length(height))
		str <- rep(str, length=m)
		wcex <- hcex <- rep(Inf, m)
		if (!is.null(width)){
			fn <- function(cex, str, width)strwidth(str, cex=cex, units=units)-width
			frange <- rbind(fn(range.cex[1], str, width), fn(range.cex[2], str, width))
			for (i in seq(length=m)){
				if (prod(sign(frange[,i]))<0){
				  u <- uniroot(fn, range.cex, str=str[i], width=width[i])
				  wcex[i] <- u$root
				}else{
				  wcex[i] <- range.cex[which.min(abs(frange[,i]))]
				}
			}
		}
		if (!is.null(height)){
			fn <- function(cex, str, height)strheight(str, cex=cex, units=units)-height
			frange <- rbind(fn(range.cex[1], str, height), fn(range.cex[2], str, height))
			for (i in seq(length=m)){
				if (prod(sign(frange[,i]))<0){
				  u <- uniroot(fn, range.cex, str=str[i], height=height[i])
				  hcex[i] <- u$root
				}else{
				  hcex[i] <- range.cex[which.min(abs(frange[,i]))]
				}
			}
		}
		pmin(wcex, hcex)
	}

	while (length(dev.list())) dev.off()

	jandltext <- "there is hardly anything i know for sure\nneither of the future nor of the past\nnor should i know what to ask\nif the person answering was you\n\n(Ernst Jandl, stanzen)"

	windows(width=width, height=height)
	par(cex=1)
	par(mai=c(0,0,0,0))
	plot.new()
	par(usr=c(0,2,0,2))
	text(1,1, jandltext, cex=stroptim(jandltext, width=diff(par("usr")[1:2])))

	windows(width=width, height=height, rescale="fit")
	par(cex=1)
	par(mai=c(0,0,0,0))
	plot.new()
	par(usr=c(0,2,0,2))
	stroptim(jandltext, width=diff(par("usr")[1:2]))
	text(1,1, jandltext, cex=stroptim(jandltext, width=diff(par("usr")[1:2])))
}

concerning
3a) windows(rescale="fit") destroys aspect ratio
3b) repeated rescaling destroys proper font size as well 
Degeneration of aspect ratio only happens if in WindowsNT | DisplayProperties | Plus! | ShowWindowContentsWhileDragging is ACTIVATED and one intensely uses the mouse to do extreme rescaling.
Since this windows option is easy to deactivate, I have no further problems with that.


Best regards


Jens Oehlschlägel


--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = x86
 os = Win32
 system = x86, Win32
 status = 
 major = 1
 minor = 2.1
 year = 2001
 month = 01
 day = 15
 language = R

Windows NT 4.0 (build 1381) Service Pack 6

Search Path:
 .GlobalEnv, package:ctest, Autoloads, package:base
______________________________________________________________________________
Die Fachpresse ist sich einig: WEB.DE 16mal Testsieger! Kostenlos E-Mail, 
Fax, SMS, Verschlüsselung, POP3, WAP....testen Sie uns! http://freemail.web.de


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._