/// <summary> /// Creates the <see cref="IVisual"/> which renders the node. /// </summary> /// <param name="context">The current render context. The render context provides /// additional information like the <see cref="CanvasControl"/> where the node is rendered.</param> /// <param name="node">The node to render</param> /// <returns>A visual which renders the given node.</returns> protected override VisualGroup CreateVisual(IRenderContext context, INode node) { var layout = node.Layout.ToRectD(); // Draw a drop shadow var group = new VisualGroup(); // Only draw the shadow if the zoomlevel is > 0.3 if (context.Zoom > 0.3) { group.Children.Add(new ImageVisual { Image = CreateShadow(layout.Size), Rectangle = new RectD(-(layout.Width*0.5d) + dropShadowOffset, -(layout.Height*0.5d) + dropShadowOffset, layout.Width*2, layout.Height*2) }); } else { group.Add(null); } // create the actual node visualization var ballVisual = new BallVisual(); ballVisual.Update(layout.Size, GetNodeColor(node)); group.Add(ballVisual); // now translate all to the final location group.Transform = new Matrix(1, 0, 0, 1, (float) layout.X, (float) layout.Y); return group; }
/// <summary> /// Creates the <see cref="IVisual"/> which renders the node. /// </summary> /// <param name="context">The current render context. The render context provides /// additional information like the <see cref="CanvasControl"/> where the node is rendered.</param> /// <param name="node">The node to render</param> /// <returns>A visual which renders the given node.</returns> protected override VisualGroup CreateVisual(IRenderContext context, INode node) { var layout = node.Layout.ToRectD(); // Draw a drop shadow var group = new VisualGroup(); // Only draw the shadow if the zoomlevel is > 0.3 if (context.Zoom > 0.3) { group.Children.Add(new ImageVisual { Image = CreateShadow(layout.Size), Rectangle = new RectD(-(layout.Width * 0.5d) + dropShadowOffset, -(layout.Height * 0.5d) + dropShadowOffset, layout.Width * 2, layout.Height * 2) }); } else { group.Add(null); } // Check if a Color is stored in the node's tag Color color = Color; if (node.Tag is Color) { color = (Color)node.Tag; } // create the actual node visualization var ballVisual = new BallVisual(); ballVisual.Update(layout.Size, color); group.Add(ballVisual); // Draw 'edges' connecting nodes with their labels var labelsGroup = new VisualGroup(); RenderLabelEdges(context, node, labelsGroup); group.Add(labelsGroup); // now translate all to the final location group.Transform = new Matrix(1, 0, 0, 1, (float)layout.X, (float)layout.Y); return(group); }