aboutsummaryrefslogtreecommitdiff
path: root/basebuilder-3.6.2/org.eclipse.releng.basebuilder/plugins/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/TimeLineGraphItem.java
blob: c52d0a984e3fe5c79b6c1a3c4fa11071e51d2c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*******************************************************************************
 * 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.util.Comparator;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;

public class TimeLineGraphItem {


    String title;
    String description=null;
    double value;
    Color color;
    boolean displayDescription=false;
    long timestamp;
    boolean isSpecial=false;
    boolean drawAsBaseline=false;
    int x;
    int y;

    TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial,boolean isBaseline) {
    	this(title, description, value, color,display, timestamp,isSpecial);
    	this.drawAsBaseline=isBaseline;
    }

    TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial) {
    	this(title, description, value, color,display, timestamp);
    	this.isSpecial=isSpecial;
    }

    TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp) {
    	this(title, description, value, color,timestamp);
    	this.displayDescription=display;
    }

    TimeLineGraphItem(String title, String description, double value, Color color,long timestamp) {
        this.title= title;
        this.value= value;
        this.color= color;
        this.description= description;
        this.timestamp=timestamp;
    }

    Point getSize(GC g) {
        Point e1= g.stringExtent(this.description);
        Point e2= g.stringExtent(this.title);
        return new Point(Math.max(e1.x, e2.x), e1.y+e2.y);
    }

    public static class GraphItemComparator implements Comparator{
		public int compare(Object o1, Object o2) {
			long ts1=((TimeLineGraphItem)o1).timestamp;
			long ts2=((TimeLineGraphItem)o2).timestamp;

			if (ts1>ts2)
				return 1;
			if (ts1<ts2)
				return -1;

			return 0;
		}
    }

	public int getX() {
		return this.x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return this.y;
	}

	public void setY(int y) {
		this.y = y;
	}


}