databionics.io
Class ClsFile

java.lang.Object
  extended by databionics.io.BaseFile
      extended by databionics.io.ListFile
          extended by databionics.io.MapFile
              extended by databionics.io.ClsFile
Direct Known Subclasses:
DiagnosisFile

public class ClsFile
extends MapFile

File that stores classification of data points or best matches. Attention: The list and the map store the DataClass objects retrieved from the header of the *.cls file and not the classification pairs from the body of the file. The actual classification is stored in two IntArrayLists as integer pairs (index of data points, class number). For fast access to the class number by the index value use get(int index) backed by an additional OpenIntIntMap.


Field Summary
protected  cern.colt.list.IntArrayList boldClasses
          Class indices to be highlighted in some display
protected  ColorTable classColors
          Default color table
protected  cern.colt.list.IntArrayList classes
          Column with class numbers
protected  cern.colt.map.OpenIntIntHashMap key2pos
          Column with data point keys
protected  cern.colt.list.IntArrayList keys
          Column with data point keys
protected static org.apache.log4j.Logger log
          Log4j logging.
 
Fields inherited from class databionics.io.MapFile
map
 
Fields inherited from class databionics.io.ListFile
data
 
Fields inherited from class databionics.io.BaseFile
allowEmptyLines, comment, commentPrefix, delimiter, delimiters, file, header, headerPrefix, loc, nf
 
Constructor Summary
ClsFile()
          Standard constructor
ClsFile(BMFile bmFile)
           
ClsFile(java.lang.String filename)
          Constructor with a filename
 
Method Summary
 void add(int index, int cls)
          Add an index - class number pair
 void add2bold(int i)
          add an single class to boldclass
 void addClass(int cls)
          Add a data class if it's not in the list
 void addClass(int cls, java.lang.String name)
          Add a data class if it's not in the list
protected  void buildHeader()
          Generate header.
protected  java.lang.String buildLine(int row)
          Construct a line for saving.
 boolean changeIndex(int from, int to)
          Change Index of class.
protected  void checkHeader()
          Check consistency of header information.
 void clear()
          Clear class list, set all class numbers to 0
 java.lang.Object clone()
          Deprecated. deprecated because incomplete. TODO: make complete
 cern.colt.list.IntArrayList getBoldClasses()
          Get highlighted classes.
 int getByIndex(int index)
          Get class number of a classification by its index
 DataClass getClass(int pos)
          Get a data class by its position in the list
 DataClass getClassByIndex(int index)
          Get a data class by its index
 cern.colt.list.IntArrayList getClasses()
          Get classes.
static FileType getFileType()
          Get the type of file.
 int getHighestClassIndex()
           
 cern.colt.list.IntArrayList getKeys()
          Get keys.
 int getQuick(int pos)
          Get class number of a classification by its position in the list
 int getSize()
          Get the number of lines in file.
 boolean hasClass(int classnumber)
           
protected  void parseHeader()
          Parse the header.
protected  void parseLine(int row, java.lang.String line)
          Parse a line.
 void remove(DataClass cls)
          Remove a class, set all corresponding class numbers to 0
 void remove(int cls)
          Remove a class, set all corresponding class numbers to 0.
 void removeFromBold(int i)
          Remove class from boldclasses
 void removeOne(int index, int classes)
           
 void set(int index, int cls)
          Deprecated. is a wrapper to add only, wich should manage id right, check if code is still working. if yes change set to add. stammi
 void setBoldClasses(int[] classes)
          Set highlighted classes.
 void setBoldClasses(cern.colt.list.IntArrayList classes)
          Set highlighted classes.
 void setClasses(int[] classes)
          Set classes.
 void setClasses(cern.colt.list.IntArrayList classes)
          Set classes.
 void setKeys()
          Add automatically generated keys.
 void setKeys(int[] keys)
          Set keys.
 void setKeys(cern.colt.list.IntArrayList keys)
          Set keys.
 int size(DataClass cls)
          Get size of a class
 int size(int cls)
          Get size of a class
 void sort()
          Sort classifications by key number.
 
Methods inherited from class databionics.io.MapFile
add, getMap, remove, setData, setMap
 
Methods inherited from class databionics.io.ListFile
getData
 
Methods inherited from class databionics.io.BaseFile
checkHeaderAgainstSize, getComment, getFile, getFilename, getHeader, getLocale, getNumberFormat, init, isHeader, isNaN, isNumber, load, load, parseError, save, save, setComment, setFilename, setLocale, writeStringList, writeStringList
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log
Log4j logging.


keys

protected cern.colt.list.IntArrayList keys
Column with data point keys


classes

protected cern.colt.list.IntArrayList classes
Column with class numbers


key2pos

protected cern.colt.map.OpenIntIntHashMap key2pos
Column with data point keys


classColors

protected ColorTable classColors
Default color table


boldClasses

protected cern.colt.list.IntArrayList boldClasses
Class indices to be highlighted in some display

Constructor Detail

ClsFile

public ClsFile()
Standard constructor


ClsFile

public ClsFile(java.lang.String filename)
Constructor with a filename

Parameters:
filename - Name of the file

ClsFile

public ClsFile(BMFile bmFile)
Method Detail

sort

public void sort()
Sort classifications by key number.


parseHeader

protected void parseHeader()
Parse the header.

Overrides:
parseHeader in class BaseFile

parseLine

protected void parseLine(int row,
                         java.lang.String line)
Parse a line.

Overrides:
parseLine in class BaseFile
Parameters:
row - Number of current line.
line - Current line.

checkHeader

protected void checkHeader()
Check consistency of header information.

Overrides:
checkHeader in class BaseFile

buildHeader

protected void buildHeader()
Generate header.

Overrides:
buildHeader in class BaseFile

buildLine

protected java.lang.String buildLine(int row)
Construct a line for saving.

Overrides:
buildLine in class ListFile
Parameters:
row - Number of current line.
Returns:
Line with that number.

getClass

public DataClass getClass(int pos)
Get a data class by its position in the list

Parameters:
position - of data class

addClass

public void addClass(int cls,
                     java.lang.String name)
Add a data class if it's not in the list

Parameters:
cls - class number
name - class name

addClass

public void addClass(int cls)
Add a data class if it's not in the list

Parameters:
cls - class number

getClassByIndex

public DataClass getClassByIndex(int index)
Get a data class by its index

Parameters:
index - class number

getSize

public int getSize()
Get the number of lines in file.

Overrides:
getSize in class ListFile
Returns:
Number of lines in file.

add

public void add(int index,
                int cls)
Add an index - class number pair

Parameters:
index - of data point or best match
cls - class number

set

public void set(int index,
                int cls)
Deprecated. is a wrapper to add only, wich should manage id right, check if code is still working. if yes change set to add. stammi

Set an index - class number pair

Parameters:
index - of data point or best match
cls - class number

remove

public void remove(int cls)
Remove a class, set all corresponding class numbers to 0. Ignores 0 as parameter.

Overrides:
remove in class MapFile
Parameters:
cls - class number

removeOne

public void removeOne(int index,
                      int classes)
Parameters:
index -
classes -

remove

public void remove(DataClass cls)
Remove a class, set all corresponding class numbers to 0

Parameters:
cls - class

changeIndex

public boolean changeIndex(int from,
                           int to)
Change Index of class.

Parameters:
from - old Index
to - new Index

clear

public void clear()
Clear class list, set all class numbers to 0


size

public int size(int cls)
Get size of a class

Parameters:
cls - class number
Returns:
number of data points in this class

size

public int size(DataClass cls)
Get size of a class

Parameters:
cls - class
Returns:
number of data points in this class

getQuick

public int getQuick(int pos)
Get class number of a classification by its position in the list

Parameters:
position - of classification

getByIndex

public int getByIndex(int index)
Get class number of a classification by its index

Parameters:
index - index of the data point

clone

public java.lang.Object clone()
Deprecated. deprecated because incomplete. TODO: make complete

This function makes a copy of the special Instance of this class

Overrides:
clone in class java.lang.Object
Returns:
an independent copy of this

getKeys

public cern.colt.list.IntArrayList getKeys()
Get keys.


setKeys

public void setKeys(cern.colt.list.IntArrayList keys)
Set keys.


setKeys

public void setKeys(int[] keys)
Set keys.


setKeys

public void setKeys()
Add automatically generated keys.


getClasses

public cern.colt.list.IntArrayList getClasses()
Get classes.


setClasses

public void setClasses(cern.colt.list.IntArrayList classes)
Set classes.


setClasses

public void setClasses(int[] classes)
Set classes.


getBoldClasses

public cern.colt.list.IntArrayList getBoldClasses()
Get highlighted classes.


setBoldClasses

public void setBoldClasses(cern.colt.list.IntArrayList classes)
Set highlighted classes.


setBoldClasses

public void setBoldClasses(int[] classes)
Set highlighted classes.


add2bold

public void add2bold(int i)
add an single class to boldclass

Parameters:
int - i class to add

removeFromBold

public void removeFromBold(int i)
Remove class from boldclasses

Parameters:
i - position of classnumber in (IntArrayList) boldClasses

getFileType

public static FileType getFileType()
Get the type of file.


getHighestClassIndex

public int getHighestClassIndex()
Returns:
The highest classIndex

hasClass

public boolean hasClass(int classnumber)


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.