Debian Codegraph @

Nasal/canvas/map/NDB.symbol

raw
1 # See: http://wiki.flightgear.org/MapStructure
2 # Class things:
3 var name = 'NDB';
4 var parents = [DotSym];
5 var __self__ = caller(0)[0];
6 DotSym.makeinstance( name, __self__ );
7
8 SymbolLayer.get(name).df_style = {
9 line_width: 3,
10 scale_factor: 1,
11 font: "LiberationFonts/LiberationSans-Regular.ttf",
12 font_color: [0,0,0],
13 font_size: 28,
14 color: [0.5, 0, 0.5],
15 dash_array: [0,2,0,2],
16 show_labels: 1,
17 };
18
19
20 var element_type = "group"; # we want a group, becomes "me.element"
21
22 ##
23 # used during initialization to populate the symbol cache with a FIX symbol
24 #
25 var drawNDB = func(group) {
26 group.createChild("path")
27 .moveTo(-4, 0)
28 .horizTo(4)
29 .moveTo(0, -4)
30 .vertTo(4)
31 .moveTo(-8, 0)
32 .arcSmallCW(8,8,0,16,0)
33 .arcSmallCW(8,8,0,-16,0)
34 .moveTo(-15,0)
35 .arcSmallCW(15,15,0,30,0)
36 .arcSmallCW(15,15,0,-30,0)
37 .setStrokeLineWidth(line_width)
38 .setStrokeDashArray(dash_array)
39 .setColor(color);
40 }
41 var _name = name;
42
43 var init = func {
44 # initialize the cached fix symbol
45 var draw_fn = me.getOption('draw_function');
46 if(typeof(draw_fn) != 'func')
47 draw_fn = drawNDB;
48
49 var cache = StyleableCacheable.new(
50 name:_name,
51 draw_func: draw_fn,
52 cache: SymbolCache32x32,
53 draw_mode: SymbolCache.DRAW_CENTERED,
54 relevant_keys: ["line_width", "color", "dash_array"],
55 );
56 cache.render(me.element, me.style).setScale(me.style.scale_factor);
57
58 var txt_offset = me.getStyle('text_offset', [3, 0]);
59 var txt_alignment = me.getStyle('text_alignment', 'left-bottom');
60 var txt_color = me.getStyle('text_color', [0,0.6,0.85]);
61 var txt_bgcolor = me.getStyle('text_bgcolor', [0,0,0,0]);
62 var txt_mode = me.getStyle('text_mode', canvas.Text.TEXT);
63 var txt_padding = me.getStyle('text_padding', 0);
64 # non-cached stuff:
65 if (me.style.show_labels){
66 me.text_fix = me.newText(me.model.id).
67 setScale(me.style.scale_factor).
68 setTranslation(txt_offset).
69 setAlignment(txt_alignment).
70 setPadding(txt_padding).
71 setDrawMode(txt_mode).
72 setColor(txt_color).
73 setColorFill(txt_bgcolor);
74 }
75 }
76 var draw = func {me.callback('draw');};