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.
- Direct Known Subclasses:
AWTPlotRenderer
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
computeDotSize
(int h) protected abstract void
drawBoundaryDot
(int x, int y, int w, int h) Draw a single boundary commit (aka uninteresting commit) dot.protected abstract void
drawCommitDot
(int x, int y, int w, int h) Draw a single commit dot.protected abstract int
Draw a decoration for the Ref ref at x,yprotected abstract void
Draw a single line within this cell.protected abstract void
Draw a single line of text.private static int
protected abstract TColor
Obtain the color reference used to paint this lane.private static int
protected void
paintCommit
(PlotCommit<TLane> commit, int h) Paint one commit using the underlying graphics library.
-
Field Details
-
LANE_WIDTH
private static final int LANE_WIDTH- See Also:
-
LINE_WIDTH
private static final int LINE_WIDTH- See Also:
-
LEFT_PAD
private static final int LEFT_PAD- See Also:
-
-
Constructor Details
-
AbstractPlotRenderer
public AbstractPlotRenderer()
-
-
Method Details
-
paintCommit
Paint one commit using the underlying graphics library.- Parameters:
commit
- the commit to render in this cell. Must not be null.h
- total height (in pixels) of this cell.
-
drawLabel
Draw a decoration for the Ref ref at x,y- Parameters:
x
- lefty
- topref
- A peeled ref- Returns:
- width of label in pixels
-
computeDotSize
private static int computeDotSize(int h) -
laneColor
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.
- Parameters:
myLane
- the current lane. May be null.- Returns:
- graphics specific color reference. Must be a valid color.
-
drawLine
Draw a single line within this cell.- Parameters:
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.
- Parameters:
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.
- Parameters:
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
Draw a single line of text.The font and colors used to render the text are left up to the implementation.
- Parameters:
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.
-
laneX
-
laneC
-