Subversion Repositories bdplot

Rev

Rev 13 | Rev 23 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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