當前位置: 首頁>>代碼示例>>Java>>正文


Java Metric類代碼示例

本文整理匯總了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;
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:25,代碼來源:MetricsPage.java

示例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;
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:19,代碼來源:MetricsPage.java

示例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));
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:23,代碼來源:MetricsPage.java

示例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));
	}
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:25,代碼來源:MetricsPage.java

示例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));
	}
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:25,代碼來源:MetricsPage.java

示例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));
	}
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:19,代碼來源:OverviewPage.java

示例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"));
	}
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:25,代碼來源:SummaryPage.java

示例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;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:25,代碼來源:WicketUtils.java

示例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;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:25,代碼來源:WicketUtils.java

示例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));
	}
}
 
開發者ID:BullShark,項目名稱:IRCBlit,代碼行數:25,代碼來源:MetricsPage.java

示例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"));
	}
}
 
開發者ID:BullShark,項目名稱:IRCBlit,代碼行數:25,代碼來源:SummaryPage.java

示例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));

}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:33,代碼來源:MetricsPage.java

示例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);
	}
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:30,代碼來源:MetricsPage.java

示例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);
	}
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:12,代碼來源:MetricsPage.java

示例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);
	}
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:11,代碼來源:MetricsPage.java


注:本文中的com.gitblit.models.Metric類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。