Top Description Fields Constructors Methods
org.eclipse.jgit.revplot

public abstract Class AbstractPlotRenderer<TLane extends PlotLane, TColor>

extends Object
Class Inheritance
Type Parameters
<TLane>
type of lane being used by the application.
<TColor>
type of color object used by the graphics library.
Imports
org.eclipse.jgit.lib.Ref, org.eclipse.jgit.revwalk.RevFlag

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.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int
protected abstract void
drawBoundaryDot(int
upper left of the oval's bounding box.
x
,
int
upper left of the oval's bounding box.
y
,
int
width of the oval's bounding box.
w
,
int
height of the oval's bounding box.
h
)

Draw a single boundary commit (aka uninteresting commit) dot.

protected abstract void
drawCommitDot(int
upper left of the oval's bounding box.
x
,
int
upper left of the oval's bounding box.
y
,
int
width of the oval's bounding box.
w
,
int
height of the oval's bounding box.
h
)

Draw a single commit dot.

protected abstract int

Returns:

width of label in pixels
drawLabel
(int
left
x
,
int
top
y
,
Ref
A peeled ref
ref
)

Draw a decoration for the Ref ref at x,y

protected abstract void
drawLine(TColor
the color to use while drawing the line.
color
,
int
starting X coordinate, 0 based.
x1
,
int
starting Y coordinate, 0 based.
y1
,
int
ending X coordinate, 0 based.
x2
,
int
ending Y coordinate, 0 based.
y2
,
int
number of pixels wide for the line. Always at least 1.
width
)

Draw a single line within this cell.

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

Draw a single line of text.

private static int
laneC(PlotLane myLane)

protected abstract TColor

Returns:

graphics specific color reference. Must be a valid color.
laneColor
(TLane
the current lane. May be null.
myLane
)

Obtain the color reference used to paint this lane.

private static int
laneX(PlotLane myLane)

protected void
paintCommit(PlotCommit<TLane>
the commit to render in this cell. Must not be null.
commit
,
int
total height (in pixels) of this cell.
h
)

Paint one commit using the underlying graphics library.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LANE_WIDTHback to summary
private static final int LANE_WIDTH
LEFT_PADback to summary
private static final int LEFT_PAD
LINE_WIDTHback to summary
private static final int LINE_WIDTH

Constructor Detail

AbstractPlotRendererback to summary
public AbstractPlotRenderer()

Method Detail

computeDotSizeback to summary
private static int computeDotSize(int h)
drawBoundaryDotback to summary
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:int

upper left of the oval's bounding box.

y:int

upper left of the oval's bounding box.

w:int

width of the oval's bounding box.

h:int

height of the oval's bounding box.

drawCommitDotback to summary
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:int

upper left of the oval's bounding box.

y:int

upper left of the oval's bounding box.

w:int

width of the oval's bounding box.

h:int

height of the oval's bounding box.

drawLabelback to summary
protected abstract int drawLabel(int x, int y, Ref ref)

Draw a decoration for the Ref ref at x,y

Parameters
x:int

left

y:int

top

ref:Ref

A peeled ref

Returns:int

width of label in pixels

drawLineback to summary
protected abstract void drawLine(TColor color, int x1, int y1, int x2, int y2, int width)

Draw a single line within this cell.

Parameters
color:TColor

the color to use while drawing the line.

x1:int

starting X coordinate, 0 based.

y1:int

starting Y coordinate, 0 based.

x2:int

ending X coordinate, 0 based.

y2:int

ending Y coordinate, 0 based.

width:int

number of pixels wide for the line. Always at least 1.

drawTextback to summary
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.

Parameters
msg:String

the text to draw. Does not contain LFs.

x:int

first pixel from the left that the text can be drawn at. Character data must not appear before this position.

y:int

pixel coordinate of the baseline of the text. Implementations must adjust this coordinate to account for the way their implementation handles font rendering.

laneCback to summary
private static int laneC(PlotLane myLane)
laneColorback to summary
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.

Parameters
myLane:TLane

the current lane. May be null.

Returns:TColor

graphics specific color reference. Must be a valid color.

laneXback to summary
private static int laneX(PlotLane myLane)
paintCommitback to summary
protected void paintCommit(PlotCommit<TLane> commit, int h)

Paint one commit using the underlying graphics library.

Parameters
commit:PlotCommit<TLane>

the commit to render in this cell. Must not be null.

h:int

total height (in pixels) of this cell.

Annotations
@SuppressWarnings:unchecked