xref: /JGit/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java (revision 5c5f7c6b146b24f2bd4afae1902df85ad6e57ea3)
1 /*
2  * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Distribution License v. 1.0 which is available at
6  * https://www.eclipse.org/org/documents/edl-v10.php.
7  *
8  * SPDX-License-Identifier: BSD-3-Clause
9  */
10 
11 package org.eclipse.jgit.awtui;
12 
13 import java.awt.Color;
14 import java.util.LinkedList;
15 
16 import org.eclipse.jgit.revplot.PlotCommitList;
17 import org.eclipse.jgit.revplot.PlotLane;
18 
19 class SwingCommitList extends PlotCommitList<SwingCommitList.SwingLane> {
20 	final LinkedList<Color> colors;
21 
SwingCommitList()22 	SwingCommitList() {
23 		colors = new LinkedList<>();
24 		repackColors();
25 	}
26 
repackColors()27 	private void repackColors() {
28 		colors.add(Color.green);
29 		colors.add(Color.blue);
30 		colors.add(Color.red);
31 		colors.add(Color.magenta);
32 		colors.add(Color.darkGray);
33 		colors.add(Color.yellow.darker());
34 		colors.add(Color.orange);
35 	}
36 
37 	/** {@inheritDoc} */
38 	@Override
createLane()39 	protected SwingLane createLane() {
40 		final SwingLane lane = new SwingLane();
41 		if (colors.isEmpty())
42 			repackColors();
43 		lane.color = colors.removeFirst();
44 		return lane;
45 	}
46 
47 	/** {@inheritDoc} */
48 	@Override
recycleLane(SwingLane lane)49 	protected void recycleLane(SwingLane lane) {
50 		colors.add(lane.color);
51 	}
52 
53 	static class SwingLane extends PlotLane {
54 		private static final long serialVersionUID = 1L;
55 		Color color;
56 	}
57 }
58