Module: Deplate::Regions::Img_R

Includes:
Img_standard
Defined in:
lib/deplate/regions.rb

Instance Method Summary collapse

Instance Method Details

#check_arguments(type, arr) ⇒ Object



616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/deplate/regions.rb', line 616

def check_arguments(type, arr)
    rv = []
    for a in arr
        v = @args["%s_%s" % [type, a]] || @args["_%s" % a]
        rv << "%s=%s" % [a, v] if v
    end
    if rv.empty?
        return nil
    else
        rv.unshift(nil)
        return rv.join(", ")
    end
end

#prepare(accum, out, sfx) ⇒ Object



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/deplate/regions.rb', line 573

def prepare(accum, out, sfx)
    pre  = []
    post = []

    # trellis.device(jpeg, file="plotTrouble2.jpg",
    # theme = col.whitebg(),height=480,width=480)
    # trellis.last.object()
    # dev.off() 
    case sfx
    when "png"
        args = check_arguments("png", ["width", "height", "pointsize", 
                               "bg"])
        pre << %{png(filename="#{out}"%s)} % args
    when "jpg"
        args = check_arguments("png", ["width", "height", "pointsize", 
                               "bg", "pointsize", "quality", "res"])
        pre << %{jpg(filename="#{out}"%s)} % args
    when "bmp"
        args = check_arguments("png", ["width", "height", "pointsize", 
                               "bg", "pointsize", "res"])
        pre << %{bmp(filename="#{out}"%s)} % args
    when "pdf"
        args = check_arguments("pdf", ["width", "height", "family", 
                               "title", "encoding", "bg", "fg", 
                               "pointsize"])
        pre << %{pdf(file="#{out}", onefile=TRUE%s)} % args
    when "ps"
        args = check_arguments("ps", ["width", "height", "family", 
                               "title", "encoding", "bg", "fg", 
                               "pointsize", "horizontal"])
        pre << %{postscript(file="#{out}", onefile=TRUE, paper="special"%s)} % args
    when "wmf"
        args = check_arguments("wmf", ["width", "height", "pointsize"])
        pre << %{win.metafile(filename="#{out}"%s)} % args
    else
        log(["Unknown suffix", sfx], :error)
        raise
    end
    post << "dev.off()"
    post << "q(runLast=FALSE)"
    return (pre + accum + post).flatten
end

#run(r, out, sfx) ⇒ Object



630
631
632
# File 'lib/deplate/regions.rb', line 630

def run(r, out, sfx)
    Deplate::Regions::R.run(self, r, nil)
end