/*
* Licensed Materials - Property of Perforce Software, Inc.
* © Copyright Perforce Software, Inc. 2014, 2021
* © Copyright IBM Corp. 2009, 2014
* © Copyright ILOG 1996, 2009
* All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* The Software and Documentation were developed at private expense and
* are "Commercial Items" as that term is defined at 48 CFR 2.101,
* consisting of "Commercial Computer Software" and
* "Commercial Computer Software Documentation", as such terms are
* used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
* as applicable.
*/
import ilog.views.gantt.model.IlvSimpleActivity;
import java.util.Date;
/**
* <code>CustomActivity</code> is an extension of <code>IlvSimpleActivity</code>
* that adds a priority property.
*/
public class CustomActivity extends IlvSimpleActivity
{
// =========================================
// Class Constants
// =========================================
/**
* The highest priority supported by this class. Numerically, this is the
* smallest number.
*/
public static final int HIGHEST_PRIORITY = 1;
/**
* The lowest priority supported by this class. Numerically, this is the
* largest number.
*/
public static final int LOWEST_PRIORITY = 10;
// =========================================
// Instance Variables
// =========================================
/**
* The activity's priority as an integer. The allowed values are from 1 - 10,
* with 1 representing the highest priority. The default value is 5.
*/
private int priority = 5;
// =========================================
// Instance Construction and Initialization
// =========================================
/**
* Constructs a new <code>CustomActivity</code> from the specified ID,
* name, start time, and duration. The new activity will have a default
* priority of 5.
*/
public CustomActivity(String id, String name, Date start, Date end) {
super(id, name, start, end);
}
// =========================================
// Priority Property
// =========================================
/**
* Returns the priority of this activity. 1 is the highest priority and 10
* is the lowest.
*/
public int getPriority() {
return priority;
}
/**
* Sets the priority of this activity. If <code>priority</code> does not
* fall within the allowed range, it is trimmed to be a valid value.
* @param priority The priority of the activity.
*/
public void setPriority(int priority) {
int newPriority = Math.min(LOWEST_PRIORITY,
Math.max(HIGHEST_PRIORITY, priority));
this.priority = newPriority;
}
}