/// <summary> /// Creates the rendering visual. /// </summary> /// <remarks> /// An ellipse with a + or - symbol. /// </remarks> /// <param name="context">The render context.</param> /// <param name="node">The node.to render.</param> /// <returns>A visual representation.</returns> protected override VisualGroup CreateVisual(IRenderContext context, INode node) { var vg = new AggregationVisual(); var info = (AggregationNodeInfo)node.Tag; vg.HasNode = info.Aggregate.Node != null; vg.IsAggregated = info.IsAggregated; // draw a grey ellipse // if the aggregate represents a node draw a solid border. Draw a dashed border otherwise. var pen = info.Aggregate.Node == null ? new Pen(Brushes.LightGray) { DashStyle = DashStyle.Dash, DashPattern = new[] { 2f, 2f } } : Pens.LightGray; vg.Add(new EllipseVisual(new RectD(PointD.Origin, node.Layout.GetSize())) { Pen = pen, Brush = new SolidBrush(info.IsAggregated ? Color.FromArgb(0x11, 0x6c, 0x91, 0xbf) : Color.FromArgb(0x09, 0x6c, 0x91, 0xbf)) }); // draw a + if aggregated, - otherwise GeneralPath gp = new GeneralPath(); if (info.IsAggregated) { gp.MoveTo(0, -4); gp.LineTo(0, 4); gp.MoveTo(-4, 0); gp.LineTo(4, 0); } else { gp.MoveTo(-4, 0); gp.LineTo(4, 0); } gp.Transform(new Matrix2D(1, 0, 0, 1, node.Layout.Width / 2, node.Layout.Height / 2)); GeneralPathVisual path = new GeneralPathVisual(gp); path.Pen = new Pen(Brushes.DimGray) { Width = 1.5f }; vg.Add(path); vg.Transform = new Matrix(1, 0, 0, 1, (float)node.Layout.X, (float)node.Layout.Y); return(vg); }
protected override GeneralPath GetOutline(INode node) { var cornerSize = Math.Min(node.Layout.Width, node.Layout.Height) * 0.4; var path = new GeneralPath(); path.MoveTo(0, 0); path.LineTo(node.Layout.Width - cornerSize, 0); path.LineTo(node.Layout.Width, cornerSize); path.LineTo(node.Layout.Width, node.Layout.Height); path.LineTo(0, node.Layout.Height); path.Close(); var transform = new Matrix2D(); transform.Translate(node.Layout.GetTopLeft()); path.Transform(transform); return(path); }
protected override GeneralPath GetOutline(INode node) { const double halfEllipseHeight = 0.125; GeneralPath path = new GeneralPath(); path.MoveTo(0, halfEllipseHeight); path.LineTo(0, 1 - halfEllipseHeight); path.CubicTo(0, 1, 1, 1, 1, 1 - halfEllipseHeight); path.LineTo(1, halfEllipseHeight); path.CubicTo(1, 0, 0, 0, 0, halfEllipseHeight); path.Close(); var transform = new Matrix2D(); transform.Translate(node.Layout.GetTopLeft()); transform.Scale(node.Layout.Width, node.Layout.Height); path.Transform(transform); return(path); }
protected override GeneralPath GetOutline(INode node) { double width = Math.Min(node.Layout.Width, node.Layout.Height / BpmnConstants.ConversationWidthHeightRatio); double height = width * BpmnConstants.ConversationWidthHeightRatio; RectD bounds = new RectD(node.Layout.GetCenter().X - width / 2, node.Layout.GetCenter().Y - height / 2, width, height); var path = new GeneralPath(); path.MoveTo(0, 0.5); path.LineTo(0.25, 0); path.LineTo(0.75, 0); path.LineTo(1, 0.5); path.LineTo(0.75, 1); path.LineTo(0.25, 1); path.Close(); var transform = new Matrix2D(); transform.Translate(bounds.GetTopLeft()); transform.Scale(bounds.Width, bounds.Height); path.Transform(transform); return(path); }
/// <summary> /// Creates a visual representation of the constraint indicator. /// </summary> public GeneralPath CreateConstraintIndicator() { IPort port = sourceEnd ? bend.Owner.SourcePort : bend.Owner.TargetPort; var nodeLayout = ((INode)port.Owner).Layout.ToRectD(); PointD portLocation = nodeLayout.Center; double plX = portLocation.X, plY = portLocation.Y; PointD bendLocation = bend.Location.ToPointD(); PointD delta = bendLocation - portLocation; if (delta.VectorLength > MinDistance && !nodeLayout.Contains(bendLocation)) { PointD direction = delta.Normalized; GeneralPath path = new GeneralPath(20); path.MoveTo(-15, 0); path.LineTo(-5, 10); path.LineTo(-2, 7); path.LineTo(-5, 4); path.LineTo(8, 4); path.LineTo(8, -4); path.LineTo(-5, -4); path.LineTo(-2, -7); path.LineTo(-5, -10); path.Close(); // mirror at target end if (!sourceEnd) { path.Transform(new Matrix2D(-1, 0, 0, 1, 0, 0)); } // rotate and translate arrow const int ArrowOffset = 11; if (direction.IsHorizontalVector) { plY = nodeLayout.CenterY; if (direction.X > 0) { plX = nodeLayout.MaxX + ArrowOffset; path.Transform(new Matrix2D(-1, 0, 0, 1, plX, plY)); } else { plX = nodeLayout.X - ArrowOffset; path.Transform(new Matrix2D(1, 0, 0, 1, plX, plY)); } } else { plX = nodeLayout.CenterX; if (direction.Y < 0) { plY = nodeLayout.Y - ArrowOffset; path.Transform(new Matrix2D(0, 1, 1, 0, plX, plY)); } else { plY = nodeLayout.MaxY + ArrowOffset; path.Transform(new Matrix2D(0, 1, -1, 0, plX, plY)); } } return(path); } return(null); }