CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org/jrobin/data/Normalizer.java 41
org/jrobin/graph/Normalizer.java 48
	}

	double[] normalize(long[] rawTimestamps, double[] rawValues) {
		int rawCount = rawTimestamps.length;
		long rawStep = rawTimestamps[1] - rawTimestamps[0];
		// check if we have a simple match
		if (rawCount == count && rawStep == step && rawTimestamps[0] == timestamps[0]) {
			return getCopyOf(rawValues);
		}
		// reset all normalized values to NaN
		double[] values = new double[count];
		Arrays.fill(values, Double.NaN);
		for (int rawSeg = 0, seg = 0; rawSeg < rawCount && seg < count; rawSeg++) {
			double rawValue = rawValues[rawSeg];
			if (!Double.isNaN(rawValue)) {
				long rawLeft = rawTimestamps[rawSeg] - rawStep;
				while (seg < count && rawLeft >= timestamps[seg]) {
					seg++;
				}
				boolean overlap = true;
				for (int fillSeg = seg; overlap && fillSeg < count; fillSeg++) {

File Line
org/jrobin/graph/RrdGraphDefTemplate.java 467
org/jrobin/graph/RrdGraphDefTemplate.java 531
	private void resolveArea(Node parentNode) throws RrdException {
		validateTagsOnlyOnce(parentNode, new String[] {"datasource", "color", "legend"});
		String datasource = null, legend = null;
		Paint color = null;
		Node[] childNodes = getChildNodes(parentNode);
		for (Node childNode : childNodes) {
			String nodeName = childNode.getNodeName();
			if (nodeName.equals("datasource")) {
				datasource = getValue(childNode);
			}
			else if (nodeName.equals("color")) {
				color = getValueAsColor(childNode);
			}
			else if (nodeName.equals("legend")) {
				legend = getValue(childNode);
			}
		}
		if (datasource != null) {
			if (color != null) {
				rrdGraphDef.area(datasource, color, legend);

File Line
org/jrobin/data/Normalizer.java 64
org/jrobin/graph/Normalizer.java 71
					double t2 = Math.min(rawTimestamps[rawSeg], timestamps[fillSeg]);
					if (t1 < t2) {
						values[fillSeg] = Util.sum(values[fillSeg], (t2 - t1) * rawValues[rawSeg]);
					}
					else {
						overlap = false;
					}
				}
			}
		}
		for (int seg = 0; seg < count; seg++) {
			values[seg] /= step;
		}
		return values;
	}

	private static double[] getCopyOf(double[] rawValues) {
		int n = rawValues.length;
		double[] values = new double[n];
		System.arraycopy(rawValues, 0, values, 0, n);
		return values;
	}
}

File Line
org/jrobin/graph/ValueAxis.java 60
org/jrobin/graph/ValueAxisLogarithmic.java 48
	ValueAxisLogarithmic(RrdGraph rrdGraph) {
		this.rrdGraph = rrdGraph;
		this.im = rrdGraph.im;
		this.gdef = rrdGraph.gdef;
		this.worker = rrdGraph.worker;
	}

	boolean draw() {
		Font font = gdef.smallFont;
		Paint gridColor = gdef.colors[COLOR_GRID];
		Paint mGridColor = gdef.colors[COLOR_MGRID];
		Paint fontColor = gdef.colors[COLOR_FONT];
		int fontHeight = (int) Math.ceil(rrdGraph.getSmallFontHeight());
		int labelOffset = (int) (worker.getFontAscent(font) / 2);