Debian Codegraph @

Nasal/canvas/map/FIX.symbol

raw
1 # See: http://wiki.flightgear.org/MapStructure
2 # Class things:
3 var name = 'FIX';
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, 0.6, 0.85],
15 fill_color: [0,0,0,0],
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 drawFIX = func(group) {
26 group.createChild("path")
27 .moveTo(-15,15)
28 .lineTo(0,0)
29 .lineTo(15,15)
30 .close()
31 .setStrokeLineWidth(line_width)
32 .setColor(color)
33 .setColorFill(fill_color);
34 }
35 var _name = name;
36
37 var init = func {
38 # initialize the cached fix symbol
39 var draw_fn = me.getOption('draw_function');
40 if(typeof(draw_fn) != 'func')
41 draw_fn = drawFIX;
42
43 var cache = StyleableCacheable.new(
44 name:_name,
45 draw_func: draw_fn,
46 cache: SymbolCache32x32,
47 draw_mode: SymbolCache.DRAW_CENTERED,
48 relevant_keys: ["line_width", "color", "fill_color"],
49 );
50 cache.render(me.element, me.style).setScale(me.style.scale_factor);
51
52 var txt_offset = me.getStyle('text_offset', [3, 0]);
53 var txt_alignment = me.getStyle('text_alignment', 'left-bottom');
54 var txt_color = me.getStyle('text_color', [0,0.6,0.85]);
55 var txt_bgcolor = me.getStyle('text_bgcolor', [0,0,0,0]);
56 var txt_mode = me.getStyle('text_mode', canvas.Text.TEXT);
57 var txt_padding = me.getStyle('text_padding', 0);
58 # non-cached stuff:
59 if (me.style.show_labels){
60 me.text_fix = me.newText(me.model.id).
61 setScale(me.style.scale_factor).
62 setTranslation(txt_offset).
63 setAlignment(txt_alignment).
64 setPadding(txt_padding).
65 setDrawMode(txt_mode).
66 setColor(txt_color).
67 setColorFill(txt_bgcolor);
68 }
69 }
70 var draw = func {me.callback('draw');};