Commit c8dae14a authored by lafabregue's avatar lafabregue

first released version v6.0

parents
temporary/*
*.class
# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
*.hprof
This diff is collapsed.
temporary/*
*.class
# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
*.hprof
File added
File added
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package jcl.clustering;
import java.awt.Color;
/**
* <p>
* Classe permettant l'affectation automatique de couleurs distinctes aux
* clusters.
* </p>
*
* @author Alexandre BLANSCHE
*/
public class ClustersColorizer {
/** Constante definissant le degre de luminosite des couleurs */
private static final double BRIGHTNESS = 1.5;
/** Constante definissant le nombre de couleurs par niveau */
private static final int NB_COLORS_PER_LEVEL = 6;
/** */
public static boolean whiteCluster = false;
/**
*
* @param result
*/
public static void colorize(final ClusteringResult result) {
ClustersColorizer.colorize(result, 0);
}
/**
*
* @param result
* @param initialPhase
*/
private static void colorize(final ClusteringResult result,
final double initialPhase) {
double phase = initialPhase;
final int nbLevels = ClustersColorizer.getNbLevels(result
.getNbClusters());
int nbColorsPerLevel = ClustersColorizer.NB_COLORS_PER_LEVEL;
final Cluster theFirstCluster = result.getCluster(0);
if (theFirstCluster != null) {
theFirstCluster.setColor(Color.getHSBColor(0, 0, 0));
int nbColorsLeft = result.getNbClusters() - 1;
int cluster = 1;
final double saturation = 1.;
for (int i = 0; i < nbLevels; i++) {
final double brightness = (nbLevels
+ ClustersColorizer.BRIGHTNESS - i)
/ (nbLevels + ClustersColorizer.BRIGHTNESS);
int nbColors = 0;
if (ClustersColorizer.whiteCluster || (i > 0)) {
result.getCluster(cluster).setColor(
Color.getHSBColor(0, 0, (float) brightness));
cluster++;
nbColorsLeft--;
nbColors = Math.min(nbColorsPerLevel - 1, nbColorsLeft);
} else {
nbColors = Math.min(nbColorsPerLevel - 1, nbColorsLeft);
}
for (int j = 0; j < nbColors; j++) {
double hue = phase + (j / ((double) nbColors));
while (hue > 1) {
hue -= 1;
}
result.getCluster(cluster).setColor(
Color.getHSBColor((float) hue, (float) saturation,
(float) brightness));
cluster++;
}
nbColorsLeft -= nbColors;
if (nbColorsPerLevel > 1) {
nbColorsPerLevel--;
}
phase += i / (2. * (nbColorsPerLevel - 1.));
}
}
}
/**
*
* @param result
*/
public static void colorizeRandom(final ClusteringResult result) {
ClustersColorizer.colorize(result, Math.random());
}
/**
*
* @param nbClusters
* @return ???
*/
private static int getNbLevels(final int nbClusters) {
int nbColorsPerLevel = ClustersColorizer.NB_COLORS_PER_LEVEL;
int nbColorsLeft = nbClusters;
if (ClustersColorizer.whiteCluster) {
nbColorsLeft--;
}
int nbLevels = 0;
while (nbColorsLeft > 0) {
nbColorsLeft -= nbColorsPerLevel;
if (nbColorsPerLevel > 1) {
nbColorsPerLevel--;
}
nbLevels++;
}
return nbLevels;
}
}
This diff is collapsed.
This diff is collapsed.
package jcl.data;
import java.io.Serializable;
import java.util.Arrays;
import jcl.data.attribute.AttributeMultiDimSequence;
/**
* @author Francois Petitjean
*
*/
public class ImageMultiDimSequenceData extends Data implements Serializable {
private static final long serialVersionUID = 1L;
/**launch
* position des valeurs dans l'image en cas de masque global
*/
public long[] indexInImage;
public ImageMultiDimSequenceData(Data[] arffData) {
launch(arffData);
}
private void launch(Data[] tabArrfData) {
if (tabArrfData == null) {
System.err.println("Invalid image provided ");
return;
}
/* creating the band names */
int nbAttributes = tabArrfData[0].getDataObject(0).getNbAttributes();
String[] attributesNames = Arrays.copyOf(tabArrfData[0].getAttributesNames(),tabArrfData[0].getAttributesNames().length);
String[] attNames = { "Sequence" };
this.setAttributesNames(attNames);
int nbDataObjects = tabArrfData[0].getNbObjects();
/*
* We creates the data array. We need as many DataObject items as pixels
* on image. Each item will contain a tuple.
*/
this.setLocked(new boolean[nbDataObjects]);
this.dataObjects = new DataObject[nbDataObjects];
/*
* les indices représentent, de gauche à droite : - le numero de l'image
* - la bande selectionnée - la coordonnée x - la coordonnée y
*/
double[][][] buffer = new double[nbDataObjects][tabArrfData.length][];
// on charge toutes les données des images dans le buffer
// Recupérer les data des ArffSession
for(int dataObject=0; dataObject < nbDataObjects; dataObject++)
for(int arffData = 0; arffData < tabArrfData.length; arffData++){
double[] tabAttributes = new double[nbAttributes];
for(int attribute =0; attribute < nbAttributes; attribute++){
tabAttributes[attribute] = tabArrfData[arffData].getDataObject(dataObject).getAttribute(attribute).getValue();
}
buffer[dataObject][arffData] = tabAttributes ;
}
for (int indexCourant = 0; indexCourant < buffer.length; indexCourant++) {
// every data object has one attribute : a sequence
dataObjects[indexCourant] = new DataObject(1);
dataObjects[indexCourant].setAttribute(0,new AttributeMultiDimSequence(buffer[indexCourant]));
this.setLocked(indexCourant, false);
}
}
public void setProperties(int mode, int simplifyFrom) {
AttributeMultiDimSequence.setMode(mode);
AttributeMultiDimSequence.setSimplifyFrom(simplifyFrom);
}
}
This diff is collapsed.
package jcl.data;
public class StandardData {
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package jcl.data.distance;
import jcl.data.attribute.AttributeSymbolicCategorial;
public class CategorialDistance implements Distance<AttributeSymbolicCategorial,EmptyDistanceParameter> {
private static CategorialDistance instance = new CategorialDistance();
private CategorialDistance(){}
public static CategorialDistance getInstance(){
return instance;
}
@Override
public double compute(AttributeSymbolicCategorial a1, AttributeSymbolicCategorial a2, EmptyDistanceParameter p) {
double dist = 0.0;
if (a1.getIndexValue()!= a2.getIndexValue()) {
dist = 1.0 / a1.getNbValues();
}
return dist;
}
}
This diff is collapsed.
This diff is collapsed.
package jcl.data.distance;
public interface DistanceParameter {}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.