Top Level Namespace

Includes:
Magick

Defined Under Namespace

Modules: RSyntaxTree Classes: Element, ElementList, ErrorMessage, RSGenerator, SVGGraph, StringParser, TreeGraph

Constant Summary collapse

FONT_DIR =
File.expand_path(File.dirname(__FILE__) + "/../fonts")
ETYPE_UNDEFINED =

element.rb

Aa class that represents a basic tree element, either node or leaf.

This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach’s excellent program phpSyntaxTree.

Copyright © 2007-2009 Yoichiro Hasebe <[email protected]> Copyright © 2003-2004 Andre Eisenbach <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

0
ETYPE_NODE =
1
ETYPE_LEAF =
2
E_WIDTH =

Element width

60
E_PADD =

Element height padding

7
V_SPACE =
20
H_SPACE =
10
B_SIDE =
5
B_TOPBOT =
5

Instance Method Summary collapse

Instance Method Details

#escape_high_ascii(string) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rsyntaxtree/string_parser.rb', line 34

def escape_high_ascii(string)
  html = ""
  string.length.times do |i|
    ch = string[i]
    if(ch < 127)
      html += ch.chr
    else
      html += sprintf("&#%d;", ch)
    end
  end  
  html
end

#img_get_txt_height(text, font = "Verdana", font_size = 10, multibyte = false) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/rsyntaxtree/imgutils.rb', line 63

def img_get_txt_height(text, font = "Verdana", font_size = 10, multibyte = false)

  metrics = img_get_txt_metrics(text, font, font_size, multibyte)
  y = metrics.height
  return y
  
end

#img_get_txt_metrics(text, font, font_size, multiline) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rsyntaxtree/imgutils.rb', line 34

def img_get_txt_metrics(text, font, font_size, multiline)

  background = Image.new(500, 250)

  gc = Draw.new
  gc.annotate(background, 0, 0, 0, 0, text) do |gc|
    gc.font = font
    gc.pointsize = font_size
    gc.gravity = CenterGravity
    gc.stroke = 'none'
  end

  if multiline
    metrics = gc.get_multiline_type_metrics(background, text)
  else
    metrics = gc.get_type_metrics(background, text)
  end

  return metrics
end

#img_get_txt_width(text, font = "Verdana", font_size = 10, multibyte = false) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/rsyntaxtree/imgutils.rb', line 55

def img_get_txt_width(text, font = "Verdana", font_size = 10, multibyte = false)

  metrics = img_get_txt_metrics(text, font, font_size, multibyte)
  x = metrics.width
  return x
  
end