Class AbstractPlotRenderer<TLane extends PlotLane,​TColor>

  • Type Parameters:
    TLane - type of lane being used by the application.
    TColor - type of color object used by the graphics library.

    public abstract class AbstractPlotRenderer<TLane extends PlotLane,​TColor>
    extends Object
    Basic commit graph renderer for graphical user interfaces.

    Lanes are drawn as columns left-to-right in the graph, and the commit short message is drawn to the right of the lane lines for this cell. It is assumed that the commits are being drawn as rows of some sort of table.

    Client applications can subclass this implementation to provide the necessary drawing primitives required to display a commit graph. Most of the graph layout is handled by this class, allowing applications to implement only a handful of primitive stubs.

    This class is suitable for us within an AWT TableCellRenderer or within a SWT PaintListener registered on a Table instance. It is meant to rubber stamp the graphics necessary for one row of a plotted commit list.

    Subclasses should call paintCommit(PlotCommit, int) after they have otherwise configured their instance to draw one commit into the current location.

    All drawing methods assume the coordinate space for the current commit's cell starts at (upper left corner is) 0,0. If this is not true (like say in SWT) the implementation must perform the cell offset computations within the various draw methods.

    • Constructor Detail

      • AbstractPlotRenderer

        public AbstractPlotRenderer()
    • Method Detail

      • paintCommit

        protected void paintCommit​(PlotCommit<TLane> commit,
                                   int h)
        Paint one commit using the underlying graphics library.
        commit - the commit to render in this cell. Must not be null.
        h - total height (in pixels) of this cell.
      • drawLabel

        protected abstract int drawLabel​(int x,
                                         int y,
                                         Ref ref)
        Draw a decoration for the Ref ref at x,y
        x - left
        y - top
        ref - A peeled ref
        width of label in pixels
      • laneColor

        protected abstract TColor laneColor​(TLane myLane)
        Obtain the color reference used to paint this lane.

        Colors returned by this method will be passed to the other drawing primitives, so the color returned should be application specific.

        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.

        myLane - the current lane. May be null.
        graphics specific color reference. Must be a valid color.
      • drawLine

        protected abstract void drawLine​(TColor color,
                                         int x1,
                                         int y1,
                                         int x2,
                                         int y2,
                                         int width)
        Draw a single line within this cell.
        color - the color to use while drawing the line.
        x1 - starting X coordinate, 0 based.
        y1 - starting Y coordinate, 0 based.
        x2 - ending X coordinate, 0 based.
        y2 - ending Y coordinate, 0 based.
        width - number of pixels wide for the line. Always at least 1.
      • drawCommitDot

        protected abstract void drawCommitDot​(int x,
                                              int y,
                                              int w,
                                              int h)
        Draw a single commit dot.

        Usually the commit dot is a filled oval in blue, then a drawn oval in black, using the same coordinates for both operations.

        x - upper left of the oval's bounding box.
        y - upper left of the oval's bounding box.
        w - width of the oval's bounding box.
        h - height of the oval's bounding box.
      • drawBoundaryDot

        protected abstract void drawBoundaryDot​(int x,
                                                int y,
                                                int w,
                                                int h)
        Draw a single boundary commit (aka uninteresting commit) dot.

        Usually a boundary commit dot is a light gray oval with a white center.

        x - upper left of the oval's bounding box.
        y - upper left of the oval's bounding box.
        w - width of the oval's bounding box.
        h - height of the oval's bounding box.
      • drawText

        protected abstract void drawText​(String msg,
                                         int x,
                                         int y)
        Draw a single line of text.

        The font and colors used to render the text are left up to the implementation.

        msg - the text to draw. Does not contain LFs.
        x - first pixel from the left that the text can be drawn at. Character data must not appear before this position.
        y - pixel coordinate of the baseline of the text. Implementations must adjust this coordinate to account for the way their implementation handles font rendering.