Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4879/src/net/sourceforge/bprocessor/gl/model
Added Files:
SelectionPath.java
Log Message:
changed instance displaying and selection
--- NEW FILE: SelectionPath.java ---
//---------------------------------------------------------------------------------
// $Id: SelectionPath.java,v 1.1 2007/12/07 14:38:54 rimestad Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.gl.model;
import java.util.List;
import java.util.LinkedList;
import net.sourceforge.bprocessor.model.Geometric;
/**
* A class for a selection path
*/
public class SelectionPath {
private List<Geometric> path = null;
/**
* Create a selection path
*/
public SelectionPath() {
path = new LinkedList<Geometric>();
}
/**
* Contstructor for a complete path
* @param geometrics The geometric path
*/
public SelectionPath(Geometric ...geometrics) {
this();
for (int i = 0; i < geometrics.length; i++) {
this.addGeometricToPath(geometrics[i]);
}
}
/**
* Return last object in selection path
* @return The object
*/
public Geometric getLastInPath() {
return path.get(path.size() - 1);
}
/**
* Add a geometric object to the path
* @param geom The object
*/
public void addGeometricToPath(Geometric geom) {
path.add(geom);
}
/**
* Getter for the first geometric object in the selection path
* @return The geometric obj
*/
public Geometric getFirstInPath() {
if (path.isEmpty()) {
return null;
}
return path.get(0);
}
/** {@inheritDoc} */
public String toString() {
String res = "[";
for (Geometric current : path) {
res += current.getName() + ":";
}
res += "]";
return res;
}
/**
* Return the length of the path
* @return The length
*/
public int getPathLength() {
return path.size();
}
}
|