本文整理汇总了Java中com.gitblit.models.Metric类的典型用法代码示例。如果您正苦于以下问题:Java Metric类的具体用法?Java Metric怎么用?Java Metric使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metric类属于com.gitblit.models包,在下文中一共展示了Metric类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDayOfWeekMetrics
import com.gitblit.models.Metric; //导入依赖的package包/类
private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E", getTimeZone());
SimpleDateFormat sdf = new SimpleDateFormat("E");
Calendar cal = Calendar.getInstance();
List<Metric> sorted = new ArrayList<Metric>();
int firstDayOfWeek = cal.getFirstDayOfWeek();
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
// rewind date to first day of week
cal.add(Calendar.DATE, firstDayOfWeek - dayOfWeek);
for (int i = 0; i < 7; i++) {
String day = sdf.format(cal.getTime());
for (Metric metric : list) {
if (metric.name.equals(day)) {
sorted.add(metric);
list.remove(metric);
break;
}
}
cal.add(Calendar.DATE, 1);
}
return sorted;
}
示例2: getAuthorMetrics
import com.gitblit.models.Metric; //导入依赖的package包/类
private List<Metric> getAuthorMetrics(Repository repository, String objectId) {
List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);
Collections.sort(authors, new Comparator<Metric>() {
@Override
public int compare(Metric o1, Metric o2) {
if (o1.count > o2.count) {
return -1;
} else if (o1.count < o2.count) {
return 1;
}
return 0;
}
});
if (authors.size() > 10) {
return authors.subList(0, 9);
}
return authors;
}
示例3: MetricsPage
import com.gitblit.models.Metric; //导入依赖的package包/类
public MetricsPage(PageParameters params) {
super(params);
Repository r = getRepository();
if (StringUtils.isEmpty(objectId)) {
add(new Label("branchTitle", getRepositoryModel().HEAD));
} else {
add(new Label("branchTitle", objectId));
}
Metric metricsTotal = null;
List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
metricsTotal = metrics.remove(0);
if (metricsTotal == null) {
add(new Label("branchStats", ""));
} else {
add(new Label("branchStats",
MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
metricsTotal.tag, getTimeUtils().duration(metricsTotal.duration))));
}
insertLinePlot("commitsChart", metrics);
insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
insertPieChart("authorsChart", getAuthorMetrics(r, objectId));
}
示例4: insertLinePlot
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertLinePlot(String wicketId, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(400, 100), ChartType.LINE,
data);
ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM);
dateAxis.setLabels(new String[] { metrics.get(0).name,
metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name });
provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
commitAxis.setLabels(new String[] { "",
String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.decode("#002060"), 1, -1, 5));
add(new Chart(wicketId, provider));
} else {
add(WicketUtils.newBlankImage(wicketId));
}
}
示例5: insertBarPlot
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertBarPlot(String wicketId, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(400, 100),
ChartType.BAR_VERTICAL_SET, data);
ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM);
List<String> labels = new ArrayList<String>();
for (Metric metric : metrics) {
labels.add(metric.name);
}
dateAxis.setLabels(labels.toArray(new String[labels.size()]));
provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
commitAxis.setLabels(new String[] { "",
String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
add(new Chart(wicketId, provider));
} else {
add(WicketUtils.newBlankImage(wicketId));
}
}
示例6: insertActivityGraph
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
&& GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
// daily line chart
GoogleChart chart = new GoogleLineChart("chartDaily", "", "unit",
getString("gb.commits"));
for (Metric metric : metrics) {
chart.addValue(metric.name, metric.count);
}
chart.setWidth(375);
chart.setHeight(150);
GoogleCharts charts = new GoogleCharts();
charts.addChart(chart);
add(new HeaderContributor(charts));
}
}
示例7: insertActivityGraph
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
&& GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(290, 100), ChartType.LINE,
data);
ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM);
dateAxis.setLabels(new String[] { metrics.get(0).name,
metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name });
provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
commitAxis.setLabels(new String[] { "",
String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.decode("#002060"), 1, -1, 5));
add(new Chart("commitsChart", provider));
} else {
add(WicketUtils.newBlankImage("commitsChart"));
}
}
示例8: getChartData
import com.gitblit.models.Metric; //导入依赖的package包/类
public static IChartData getChartData(Collection<Metric> metrics) {
final double[] commits = new double[metrics.size()];
final double[] tags = new double[metrics.size()];
int i = 0;
double max = 0;
for (Metric m : metrics) {
commits[i] = m.count;
if (m.tag > 0) {
tags[i] = m.count;
} else {
tags[i] = -1d;
}
max = Math.max(max, m.count);
i++;
}
IChartData data = new AbstractChartData(max) {
private static final long serialVersionUID = 1L;
public double[][] getData() {
return new double[][] { commits, tags };
}
};
return data;
}
示例9: getScatterData
import com.gitblit.models.Metric; //导入依赖的package包/类
public static IChartData getScatterData(Collection<Metric> metrics) {
final double[] y = new double[metrics.size()];
final double[] x = new double[metrics.size()];
int i = 0;
double max = 0;
for (Metric m : metrics) {
y[i] = m.count;
if (m.duration > 0) {
x[i] = m.duration;
} else {
x[i] = -1d;
}
max = Math.max(max, m.count);
i++;
}
IChartData data = new AbstractChartData(max) {
private static final long serialVersionUID = 1L;
public double[][] getData() {
return new double[][] { x, y };
}
};
return data;
}
示例10: insertLinePlot
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertLinePlot(String wicketId, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(400, 100), ChartType.LINE,
data);
ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM);
dateAxis.setLabels(new String[] { metrics.get(0).name,
metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name });
provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
commitAxis.setLabels(new String[] { "",
String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.BLUE, 1, -1, 5));
add(new Chart(wicketId, provider));
} else {
add(WicketUtils.newBlankImage(wicketId));
}
}
示例11: insertActivityGraph
import com.gitblit.models.Metric; //导入依赖的package包/类
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
&& GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(290, 100), ChartType.LINE,
data);
ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM);
dateAxis.setLabels(new String[] { metrics.get(0).name,
metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name });
provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
commitAxis.setLabels(new String[] { "",
String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.BLUE, 1, -1, 5));
add(new Chart("commitsChart", provider));
} else {
add(WicketUtils.newBlankImage("commitsChart"));
}
}
示例12: MetricsPage
import com.gitblit.models.Metric; //导入依赖的package包/类
public MetricsPage(PageParameters params) {
super(params);
Repository r = getRepository();
if (StringUtils.isEmpty(objectId)) {
add(new Label("branchTitle", getRepositoryModel().HEAD));
} else {
add(new Label("branchTitle", objectId));
}
Metric metricsTotal = null;
List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
metricsTotal = metrics.remove(0);
if (metricsTotal == null) {
add(new Label("branchStats", ""));
} else {
add(new Label("branchStats",
MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
metricsTotal.tag, getTimeUtils().duration(metricsTotal.duration))));
}
Charts charts = new Flotr2Charts();
add(WicketUtils.newBlankImage("commitsChart"));
add(WicketUtils.newBlankImage("dayOfWeekChart"));
add(WicketUtils.newBlankImage("authorsChart"));
createLineChart(charts, "commitsChart", metrics);
createBarChart(charts, "dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
createPieChart(charts, "authorsChart", getAuthorMetrics(r, objectId));
add(new HeaderContributor(charts));
}
示例13: createLineChart
import com.gitblit.models.Metric; //导入依赖的package包/类
private void createLineChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
Chart chart = charts.createLineChart(id, "", "day",
getString("gb.commits"));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String displayFormat = "MMM dd";
if(metrics.size() > 0 && metrics.get(0).name.length() == 7){
df = new SimpleDateFormat("yyyy-MM");
displayFormat = "yyyy MMM";
}
df.setTimeZone(getTimeZone());
chart.setDateFormat(displayFormat);
for (Metric metric : metrics) {
Date date;
try {
date = df.parse(metric.name);
} catch (ParseException e) {
logger().error("Unable to parse date: " + metric.name);
return;
}
chart.addValue(date, (int)metric.count);
if(metric.tag > 0 ){
chart.addHighlight(date, (int)metric.count);
}
}
charts.addChart(chart);
}
}
示例14: createPieChart
import com.gitblit.models.Metric; //导入依赖的package包/类
private void createPieChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
Chart chart = charts.createPieChart(id, "", "day",
getString("gb.commits"));
for (Metric metric : metrics) {
chart.addValue(metric.name, (int)metric.count);
}
charts.addChart(chart);
}
}
示例15: createBarChart
import com.gitblit.models.Metric; //导入依赖的package包/类
private void createBarChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
Chart chart = charts.createBarChart(id, "", "day",
getString("gb.commits"));
for (Metric metric : metrics) {
chart.addValue(metric.name, (int)metric.count);
}
charts.addChart(chart);
}
}