alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*******************************************************************************
 * Copyright (c) 2005, 2006 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(description);
        Point e2= g.stringExtent(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 x;
	}

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

	public int getY() {
		return y;
	}

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


}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.