• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2000, 2009 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.test.performance.ui;
12 
13 import java.util.Comparator;
14 
15 import org.eclipse.swt.graphics.Color;
16 import org.eclipse.swt.graphics.GC;
17 import org.eclipse.swt.graphics.Point;
18 
19 public class TimeLineGraphItem {
20 
21 
22     String title;
23     String description=null;
24     double value;
25     Color color;
26     boolean displayDescription=false;
27     long timestamp;
28     boolean isSpecial=false;
29     boolean drawAsBaseline=false;
30     int x;
31     int y;
32 
TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial,boolean isBaseline)33     TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial,boolean isBaseline) {
34     	this(title, description, value, color,display, timestamp,isSpecial);
35     	this.drawAsBaseline=isBaseline;
36     }
37 
TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial)38     TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp, boolean isSpecial) {
39     	this(title, description, value, color,display, timestamp);
40     	this.isSpecial=isSpecial;
41     }
42 
TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp)43     TimeLineGraphItem(String title, String description,double value,Color color,boolean display, long timestamp) {
44     	this(title, description, value, color,timestamp);
45     	this.displayDescription=display;
46     }
47 
TimeLineGraphItem(String title, String description, double value, Color color,long timestamp)48     TimeLineGraphItem(String title, String description, double value, Color color,long timestamp) {
49         this.title= title;
50         this.value= value;
51         this.color= color;
52         this.description= description;
53         this.timestamp=timestamp;
54     }
55 
getSize(GC g)56     Point getSize(GC g) {
57         Point e1= g.stringExtent(this.description);
58         Point e2= g.stringExtent(this.title);
59         return new Point(Math.max(e1.x, e2.x), e1.y+e2.y);
60     }
61 
62     public static class GraphItemComparator implements Comparator{
compare(Object o1, Object o2)63 		public int compare(Object o1, Object o2) {
64 			long ts1=((TimeLineGraphItem)o1).timestamp;
65 			long ts2=((TimeLineGraphItem)o2).timestamp;
66 
67 			if (ts1>ts2)
68 				return 1;
69 			if (ts1<ts2)
70 				return -1;
71 
72 			return 0;
73 		}
74     }
75 
getX()76 	public int getX() {
77 		return this.x;
78 	}
79 
setX(int x)80 	public void setX(int x) {
81 		this.x = x;
82 	}
83 
getY()84 	public int getY() {
85 		return this.y;
86 	}
87 
setY(int y)88 	public void setY(int y) {
89 		this.y = y;
90 	}
91 
92 
93 }
94