/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.test.performance.ui;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Display;
import org.eclipse.test.internal.performance.results.db.ConfigResults;
import org.eclipse.test.internal.performance.results.db.DB_Results;
import org.eclipse.test.internal.performance.results.db.PerformanceResults;
import org.eclipse.test.internal.performance.results.db.ScenarioResults;
/**
* Class used to create scenario fingerprint.
*/
public class FingerPrint {
private static final int GRAPH_WIDTH = 1000;
String component;
PrintStream stream;
File outputDir;
public FingerPrint(String name, PrintStream ps, File outputDir) {
if (!name.startsWith("global")) this.component = name;
this.stream = ps;
this.outputDir = outputDir;
}
/**
* Create and save fingerprints as image and print their reference in the current stream.
*
* @param performanceResults The performance results used to print the fingerprints
*/
public void print(final PerformanceResults performanceResults) {
String buildName = performanceResults.getName();
// Compute fingerprint output file name prefix
int currentUnderscoreIndex = buildName.indexOf('_');
if (currentUnderscoreIndex != -1){
buildName = buildName.substring(0, currentUnderscoreIndex);
}
StringBuffer buffer = new StringBuffer("FP_");
if (this.component != null) {
buffer.append(this.component);
buffer.append('_');
}
buffer.append(DB_Results.getDbBaselineRefVersion());
buffer.append('_');
buffer.append(buildName);
String filePrefix = buffer.toString();
// Print the legend
this.stream.print("The following fingerprints show results for the most representative tests of the ");
if (this.component == null) {
this.stream.print("current build.
\n");
} else {
this.stream.print(this.component);
this.stream.print(" component.
\n");
}
this.stream.print("