/// <summary> /// Get the current index of a single-valued ring type. Returns -1 if the value is not singular. /// </summary> public int GetIndexOfSingleValue(RingConstraintType value) { switch (value) { //case RingConstraintType.Undefined: case RingConstraintType.Reflexive: case RingConstraintType.PurelyReflexive: case RingConstraintType.Irreflexive: case RingConstraintType.Symmetric: case RingConstraintType.Antisymmetric: case RingConstraintType.Asymmetric: case RingConstraintType.Transitive: case RingConstraintType.Intransitive: case RingConstraintType.StronglyIntransitive: case RingConstraintType.Acyclic: return(myEnumValueToPositionMap[(int)value]); } return(-1); }
public SingleRingTypeInfo( RingConstraintType nodeType, RingConstraintType[] incompatibleWith, RingConstraintType[] incompatibleWithCombination, RingConstraintType[] impliedBy, RingConstraintType[] impliedByCombination, RingConstraintType[] usedInCombinationBy, string displayName, string description, SurveyQuestionGlyph glyph) { NodeType = nodeType; IncompatibleWith = incompatibleWith; IncompatibleWithCombination = incompatibleWithCombination; ImpliedBy = impliedBy; ImpliedByCombination = impliedByCombination; UsedInCombinationBy = usedInCombinationBy; DisplayName = displayName; Description = description; Glyph = glyph; }
/// <summary> /// Draw all ring constraint types /// </summary> protected override void OnPaintShape(DiagramPaintEventArgs e, ref PaintHelper helper) { base.OnPaintShape(e, ref helper); RingConstraint ringConstraint = this.AssociatedRingConstraint; RectangleF boundsF = RectangleD.ToRectangleF(this.AbsoluteBounds); Graphics g = e.Graphics; RingConstraintType ringType = ringConstraint.RingType; RectangleF innerBounds; Pen pen = helper.Pen; Brush brush = helper.Brush; switch (ringType) { case RingConstraintType.Undefined: break; case RingConstraintType.Reflexive: DrawLeftDot(g, boundsF, brush); break; case RingConstraintType.PurelyReflexive: DrawLeftDot(g, boundsF, brush); { float height = boundsF.Height; float left = boundsF.Left + boundsF.Width / 2; DashStyle originalDashStyle = pen.DashStyle; pen.DashStyle = DashStyle.Solid; g.DrawLine(pen, left, boundsF.Top + height * (.5f - SMALL_LENGTH_FACTOR / 2), left, boundsF.Top + height * (.5f + SMALL_LENGTH_FACTOR / 2)); pen.DashStyle = originalDashStyle; } break; case RingConstraintType.Irreflexive: DrawLeftDot(g, boundsF, brush); DrawRightLine(g, boundsF, pen, 1f); break; case RingConstraintType.Asymmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, true); DrawBottomLine(g, boundsF, pen); break; case RingConstraintType.Antisymmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, false); DrawBottomLine(g, boundsF, pen); break; case RingConstraintType.Transitive: DrawTriangleDots(g, boundsF, brush, false); break; case RingConstraintType.Intransitive: case RingConstraintType.StronglyIntransitive: DrawTriangleDots(g, boundsF, brush, ringType == RingConstraintType.StronglyIntransitive); DrawTriangleBottomLine(g, boundsF, pen); break; case RingConstraintType.Acyclic: DrawTriangleDots(g, boundsF, brush, false); DrawBottomLine(g, boundsF, pen); break; case RingConstraintType.AcyclicTransitive: DrawTriangle(g, boundsF, pen); DrawTriangleDots(g, boundsF, brush, false); DrawBottomLine(g, boundsF, pen, .6f); break; case RingConstraintType.AcyclicIntransitive: case RingConstraintType.AcyclicStronglyIntransitive: DrawTriangle(g, boundsF, pen); DrawTriangleBottomLine(g, boundsF, pen); DrawTriangleDots(g, boundsF, brush, ringType == RingConstraintType.AcyclicStronglyIntransitive); DrawBottomLine(g, boundsF, pen); break; case RingConstraintType.TransitiveAsymmetric: case RingConstraintType.TransitiveAntisymmetric: case RingConstraintType.AsymmetricIntransitive: case RingConstraintType.AsymmetricStronglyIntransitive: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, ringType != RingConstraintType.TransitiveAntisymmetric); DrawBottomLine(g, boundsF, pen); innerBounds = GetInnerBounds(boundsF); DrawTriangle(g, innerBounds, pen); DrawTriangleDots(g, innerBounds, brush, ringType == RingConstraintType.AsymmetricStronglyIntransitive); switch (ringType) { case RingConstraintType.AsymmetricIntransitive: case RingConstraintType.AsymmetricStronglyIntransitive: DrawTriangleBottomLine(g, innerBounds, pen); break; } break; case RingConstraintType.ReflexiveTransitive: case RingConstraintType.TransitiveIrreflexive: DrawLeftDot(g, boundsF, brush); if (ringType == RingConstraintType.TransitiveIrreflexive) { DrawRightLine(g, boundsF, pen, .75f); } innerBounds = GetInnerBounds(boundsF); DrawTriangle(g, innerBounds, pen); DrawTriangleDots(g, innerBounds, brush, false); break; case RingConstraintType.Symmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, true); break; case RingConstraintType.SymmetricTransitive: case RingConstraintType.SymmetricIntransitive: case RingConstraintType.SymmetricStronglyIntransitive: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, true); innerBounds = GetInnerBounds(boundsF); DrawTriangle(g, innerBounds, pen); DrawTriangleDots(g, innerBounds, brush, ringType == RingConstraintType.SymmetricStronglyIntransitive); if (ringType != RingConstraintType.SymmetricTransitive) { DrawTriangleBottomLine(g, innerBounds, pen); } break; case RingConstraintType.SymmetricIrreflexive: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, true); innerBounds = GetReflexiveInSymmetricBounds(boundsF); DrawEllipse(g, innerBounds, pen); DrawRightLine(g, innerBounds, pen, 1f); break; case RingConstraintType.ReflexiveSymmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, true); DrawEllipse(g, GetReflexiveInSymmetricBounds(boundsF), pen); break; case RingConstraintType.ReflexiveAntisymmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, false); DrawEllipse(g, GetReflexiveInSymmetricBounds(boundsF), pen); DrawBottomLine(g, boundsF, pen); break; case RingConstraintType.ReflexiveTransitiveAntisymmetric: DrawLeftDot(g, boundsF, brush); DrawRightDot(g, boundsF, pen, brush, false); DrawBottomLine(g, boundsF, pen); innerBounds = GetInnerBounds(boundsF); DrawTriangle(g, innerBounds, pen); DrawTriangleDots(g, innerBounds, brush, false); g.DrawArc(pen, GetReflexiveInSymmetricBounds(boundsF), 27, 300); // Angles determined empirically to stop on triangle, not worth calculating break; } }