Subversion Repositories bdplot

Rev

Rev 13 | Rev 23 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 pdel 1
### bdopen
2
### Used to open a graphics driver with BDplot.
3
 
13 pdel 4
### In X11, height  and width are scaled to get a nicer window on the screen.
7 pdel 5
### This hack is ugly. At least there should be a scaling factor in stead so that all measures are scaled (fonts, etc).
6
 
5 pdel 7
bdopen <- function(file=bdp()$file,paper=bdp()$paper,mfrow=bdp()$mfrow)
8
{
9
  .bdcalcsizes(paper=paper)
10
  prm <- .bdgetpars()
11
  if( !is.na(prm$file) )
12
    {
13
      ## If figdir is supplied, prepending it to filename.
14
      if(!is.null(prm$figdir)&!is.na(prm$figdir))
15
        {
16
          prm$file <- paste(prm$figdir,prm$file,sep="")
17
        }
18
      ## determining device driver from filename
19
      nchars <- nchar(prm$file)
20
 
21
      if( any( substr(prm$file,nchars-2,nchars)==".ps",substr(prm$file,nchars-3,nchars)==".eps")){
22
        m <- {
23
          cat("B/D plotting writing to postscript file\n")
11 pdel 24
          postscript(file=prm$file, width=prm$width, height=prm$height, paper="special", family = "Helvetica", horizontal=FALSE)
5 pdel 25
        }
26
      } else if ( substr(prm$file,nchars-3,nchars)==".pdf")
27
        {
11 pdel 28
          pdf(file=prm$file, width=prm$width, height=prm$height, paper="special",family = "Helvetica")
5 pdel 29
        } else if (any(substr(prm$file,nchars-3,nchars)==".jpg", substr(prm$file,nchars-4,nchars)==".jpeg")) {
30
          cat("Writing to jpeg file\n")
11 pdel 31
          jpeg(filename=prm$file,width=prm$width,height=prm$height,units=prm$size.unit,quality=prm$jpeg.quality,res=prm$jpeg.res,type="cairo")
32
### bitmap(file=prm$file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
5 pdel 33
        }
34
    }
35
  else {
36
    ## to X. Note that this doesn't work on win and osx.
7 pdel 37
    X11(height=prm$height*2,width=prm$width*2)
5 pdel 38
    }
39
 
40
  par(mfrow=mfrow)
41
 }
15 pdel 42