|
133 | 133 |
|
134 | 134 | // ================================================================================= |
135 | 135 |
|
136 | | - function drawLegend() { |
| 136 | + function drawLegend(arg) { |
137 | 137 |
|
138 | 138 | var legend = this.GetObject(), |
139 | 139 | pp = this.pad_painter(), |
|
144 | 144 | line_color = this.v7EvalColor( "box_border_color", "black"), |
145 | 145 | fill_color = this.v7EvalColor( "box_fill_color", "white"), |
146 | 146 | fill_style = this.v7EvalAttr( "box_fill_style", 1), |
147 | | - text_size = this.v7EvalAttr( "title_size", 12), |
| 147 | + text_size = this.v7EvalAttr( "title_size", 20), |
148 | 148 | text_angle = -1 * this.v7EvalAttr( "title_angle", 0), |
149 | 149 | text_align = this.v7EvalAttr( "title_align", 22), |
150 | 150 | text_color = this.v7EvalColor( "title_color", "black"), |
151 | 151 | text_font = this.v7EvalAttr( "title_font", 41); |
152 | 152 |
|
| 153 | + //if (arg=="drag_resize") { |
| 154 | + // p1.x = parseInt(this.draw_g.attr("x")); |
| 155 | + // p2.y = parseInt(this.draw_g.attr("y")); |
| 156 | + // p2.x = p1.x + parseInt(this.draw_g.attr("width")); |
| 157 | + // p1.y = p2.y + parseInt(this.draw_g.attr("height")); |
| 158 | + //} |
| 159 | + |
153 | 160 | this.CreateG(); |
154 | 161 |
|
155 | 162 | if (fill_style == 0) fill_color = "none"; |
156 | 163 |
|
| 164 | + // position and size required only for drag functions |
| 165 | + // this.draw_g.attr("transfrom", "translate(" + p1.x + "," + p2.y + ")") |
| 166 | + // .attr("x", p1.x) |
| 167 | + // .attr("y", p2.y) |
| 168 | + // .attr("width", p2.x-p1.x) |
| 169 | + // .attr("height", p1.y-p2.y); |
| 170 | + |
157 | 171 | this.draw_g |
158 | 172 | .append("svg:rect") |
159 | 173 | .attr("x", p1.x) |
|
169 | 183 |
|
170 | 184 | if (legend.fTitle) nlines++; |
171 | 185 |
|
172 | | - var arg = { align: text_align, x: (p1.x+p2.x)/2, rotate: text_angle, color: text_color, latex: 1 }; |
| 186 | + var arg = { align: text_align, rotate: text_angle, color: text_color, latex: 1 }; |
173 | 187 |
|
174 | 188 | this.StartTextDrawing(text_font, text_size); |
175 | 189 |
|
176 | 190 | var cnt = 0; |
177 | 191 | if (legend.fTitle) { |
178 | | - this.DrawText(JSROOT.extend({ y: p2.y - 0.5*(p2.y-p1.y)/(nlines+1), text: legend.fTitle }, arg)); |
| 192 | + this.DrawText(JSROOT.extend({ x: p1.x + (p2.x-p1.x)/2, y: p2.y - 0.5*(p2.y-p1.y)/(nlines+1), text: legend.fTitle }, arg)); |
179 | 193 | cnt++; |
180 | 194 | } |
181 | 195 |
|
182 | 196 | for (var i=0; i<legend.fEntries.length; ++i) { |
183 | | - var entry = legend.fEntries[i]; |
184 | | - this.DrawText(JSROOT.extend({ y: p2.y - (cnt+0.5)*(p2.y-p1.y)/(nlines+1), text: entry.fLabel }, arg)); |
| 197 | + var entry = legend.fEntries[i], |
| 198 | + ypos = p2.y - (cnt+0.5)*(p2.y-p1.y)/(nlines+1); |
| 199 | + this.DrawText(JSROOT.extend({ x: p1.x + (p2.x-p1.x)/4, y: ypos, text: entry.fLabel }, arg)); |
| 200 | + |
| 201 | + var objp = this.FindPainterFor(entry.fDrawable.fIO); |
| 202 | + |
| 203 | + if (objp && objp.lineatt) |
| 204 | + this.draw_g |
| 205 | + .append("svg:line") |
| 206 | + .attr("x1", p1.x + (p2.x-p1.x)*0.5) |
| 207 | + .attr("y1", ypos) |
| 208 | + .attr("x2", p1.x + (p2.x-p1.x)*0.8) |
| 209 | + .attr("y2", ypos) |
| 210 | + .call(objp.lineatt.func); |
| 211 | + |
185 | 212 | cnt++; |
186 | 213 | } |
187 | 214 |
|
188 | 215 | this.FinishTextDrawing(); |
| 216 | + |
| 217 | + // this.AddDrag({ minwidth: 10, minheight: 20, canselect: false, |
| 218 | + // redraw: this.Redraw.bind(this, "drag_resize"), |
| 219 | + // ctxmenu: false /*JSROOT.touches && JSROOT.gStyle.ContextMenu && this.UseContextMenu */ }); |
189 | 220 | } |
190 | 221 |
|
191 | 222 | // ================================================================================ |
|
0 commit comments