A line space within the graph.

Commits are strung onto a lane. For many UIs a lane represents a column.

Beispiel #1
0
 public override void reset()
 {
     passingLanes = NO_LANES;
     children     = NO_CHILDREN;
     lane         = null;
     base.reset();
 }
Beispiel #2
0
 public void addPassingLane(PlotLane c) {
     int cnt = passingLanes.Length;
     if (cnt == 0)
         passingLanes = new PlotLane[] { c };
     else if (cnt == 1)
         passingLanes = new PlotLane[] { passingLanes[0], c };
     else {
         PlotLane[] n = new PlotLane[cnt + 1];
         System.Array.Copy(passingLanes, 0, n, 0, cnt);
         n[cnt] = c;
         passingLanes = n;
     }
 }
Beispiel #3
0
        private PlotLane nextFreeLane()
        {
            PlotLane p = createLane();

            if (freeLanes.Count == 0)
            {
                p.position = lanesAllocated++;
            }
            else
            {
                int min = freeLanes.First().Key;
                p.position = min;
                freeLanes.Remove(min);
            }
            return(p);
        }
Beispiel #4
0
        public void addPassingLane(PlotLane c)
        {
            int cnt = passingLanes.Length;

            if (cnt == 0)
            {
                passingLanes = new PlotLane[] { c }
            }
            ;
            else if (cnt == 1)
            {
                passingLanes = new PlotLane[] { passingLanes[0], c }
            }
            ;
            else
            {
                PlotLane[] n = new PlotLane[cnt + 1];
                System.Array.Copy(passingLanes, 0, n, 0, cnt);
                n[cnt]       = c;
                passingLanes = n;
            }
        }
Beispiel #5
0
 public override void reset()
 {
     passingLanes = NO_LANES;
     children = NO_CHILDREN;
     lane = null;
     base.reset();
 }
Beispiel #6
0
 /// <summary>
 /// Return colors and other reusable information to the plotter when a lane is no longer needed.
 /// </summary>
 protected void recycleLane(PlotLane lane)
 {
     // Nothing.
 }
Beispiel #7
0
        /// <summary>
        /// Paint one commit using the underlying graphics library.
        /// </summary>
        /// <param name="commit">the commit to render in this cell. Must not be null.</param>
        /// <param name="h">total height (in pixels) of this cell.</param>
        protected virtual void paintCommit(PlotCommit commit, int h)
        {
            if (commit == null)
            {
                throw new ArgumentNullException("commit");
            }

            int      dotSize = computeDotSize(h);
            PlotLane myLane  = commit.getLane();
            int      myLaneX = laneC(myLane);
            TColor   myColor = laneColor(myLane);

            int maxCenter = 0;

            foreach (PlotLane passingLane in (PlotLane[])commit.passingLanes)
            {
                int    cx = laneC(passingLane);
                TColor c  = laneColor(passingLane);
                drawLine(c, cx, 0, cx, h, LINE_WIDTH);
                maxCenter = Math.Max(maxCenter, cx);
            }

            int nParent = commit.ParentCount;

            for (int i = 0; i < nParent; i++)
            {
                PlotCommit p;
                PlotLane   pLane;
                TColor     pColor;
                int        cx;

                p     = (PlotCommit)commit.GetParent(i);
                pLane = p.getLane();
                if (pLane == null)
                {
                    continue;
                }

                pColor = laneColor(pLane);
                cx     = laneC(pLane);

                if (Math.Abs(myLaneX - cx) > LANE_WIDTH)
                {
                    if (myLaneX < cx)
                    {
                        int ix = cx - LANE_WIDTH / 2;
                        drawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
                        drawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
                    }
                    else
                    {
                        int ix = cx + LANE_WIDTH / 2;
                        drawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
                        drawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
                    }
                }
                else
                {
                    drawLine(pColor, myLaneX, h / 2, cx, h, LINE_WIDTH);
                }
                maxCenter = Math.Max(maxCenter, cx);
            }

            int dotX = myLaneX - dotSize / 2 - 1;
            int dotY = (h - dotSize) / 2;

            if (commit.getChildCount() > 0)
            {
                drawLine(myColor, myLaneX, 0, myLaneX, dotY, LINE_WIDTH);
            }

            if (commit.has(RevFlag.UNINTERESTING))
            {
                drawBoundaryDot(dotX, dotY, dotSize, dotSize);
            }
            else
            {
                drawCommitDot(dotX, dotY, dotSize, dotSize);
            }

            int textx = Math.Max(maxCenter + LANE_WIDTH / 2, dotX + dotSize) + 8;
            int n     = commit.refs == null ? 0 : commit.refs.Length;

            for (int i = 0; i < n; ++i)
            {
                textx += drawLabel(textx + dotSize, h / 2, commit.refs[i]);
            }

            String msg = commit.getShortMessage();

            drawText(msg, textx + dotSize + n * 2, h / 2);
        }
Beispiel #8
0
 private int laneC(PlotLane myLane)
 {
     return(laneX(myLane) + LANE_WIDTH / 2);
 }
Beispiel #9
0
        private int laneX(PlotLane myLane)
        {
            int p = myLane != null?myLane.getPosition() : 0;

            return(LEFT_PAD + LANE_WIDTH * p);
        }
Beispiel #10
0
 /// <summary>
 /// Obtain the color reference used to paint this lane.
 /// <para>
 /// Colors returned by this method will be passed to the other drawing
 /// primitives, so the color returned should be application specific.
 /// </para>
 /// <para>
 /// If a null lane is supplied the return value must still be acceptable to a
 /// drawing method. Usually this means the implementation should return a
 /// default color.
 /// </para>
 /// </summary>
 /// <param name="myLane">the current lane. May be null.</param>
 /// <returns>graphics specific color reference. Must be a valid color.</returns>
 protected abstract TColor laneColor(PlotLane myLane);