Redraw = false;
Graphics grap = chart.getGraphics();
grap.setColor(Color.GRAY);
grap.fillRect(0, 0, WIDTH_TOT * model.getMatrix().getNumVariables() + 1, HEIGHT_TOT * model.getMatrix().getNumVariables() + 1);
grap.drawImage(chart, 0, 0, null);
TimeConsumingWorker worker = new TimeConsumingWorker(new ProgressMonitorShow(this, "Constructin Dispersion Matrix...", 1)) {
@Override
public Object construct() {
Graphics g = chart.getGraphics();
VariableNumber Elenco[] = model.getMatrix().getVariables();
try {
if (fuzzyN != -1) {
// Pulizia dell'immagine
g.setColor(Color.WHITE);
g.fillRect(0, 0, WIDTH_TOT * Elenco.length + 1, HEIGHT_TOT * Elenco.length + 1);
initShow(10000 * (Elenco.length * Elenco.length));
short[] c1 = ((ClusteringInfosFuzzy) ((FuzzyKMean) (session.getListOfClustering().get(clustering)))
.getClusteringInfos(curClust)).getAssignment();
int[] v = ((FuzzyKMean) (session.getListOfClustering().get(clustering))).getVarClust();
int l = 0;
// Disegno dei grafici
for (int row = 0; row < Elenco.length; row++) {
for (int col = 0; col < Elenco.length; col++) {
g.setColor(Color.BLACK);
g.drawRect(col * WIDTH_TOT, row * HEIGHT_TOT, WIDTH_TOT, HEIGHT_TOT);
if (col == row) {
// Scrittura della variabile
Graphics2D gr = (Graphics2D) g;
gr.setFont(new Font("Arial", Font.BOLD, 13));
FontRenderContext context = gr.getFontRenderContext();
Font f = new Font("Arial", Font.BOLD, 12);
Rectangle2D bounds = f.getStringBounds(Elenco[row].getName(), context);
g.setFont(new Font("Arial", Font.BOLD, 12));
g.drawString(Elenco[row].getName(), col * WIDTH_TOT + (WIDTH_TOT - (int) bounds.getWidth()) / 2, row
* HEIGHT_TOT - (int) bounds.getY() + (HEIGHT_TOT - (int) bounds.getHeight()) / 2);
//UPDATE 02/11/2006: +visualizzazione variabile clusterizzata
if (l < v.length && v[l] == col) {
g.drawString("(Clusterized)", col * WIDTH_TOT + 10, row * HEIGHT_TOT - (int) bounds.getY()
+ (HEIGHT_TOT - (int) bounds.getHeight()) / 2 + 15);
l++;
}
g.setFont(new Font("Arial", Font.PLAIN, 12));
} else {
// Calcolo del passo del grafico
double yFoot = HEIGHT_GRAPH / Elenco[row].getUniStats().getRangeValue();
double xFoot = WIDTH_GRAPH / Elenco[col].getUniStats().getRangeValue();
// Plottaggio del grafico
for (int i = 1; i <= WIDTH_GRAPH; i++) {
boolean[] done = new boolean[101];
int k = 1;
for (int j = Elenco[col].getStartInt(i); j < Elenco[col].getEndInt(i); j++) {
if ((int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot) >= 0) {
if (!done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)]) {
updateInfos(((row * Elenco.length) + (col)) * 10000 + i + (k++), "Plotting scatter "
+ ((row * Elenco.length) + (col + 1)), false);
//g.setColor(JavaWatColor.getColor(((Integer)(c.get(Elenco[col].getObsID(j)-1))).intValue()));
g.setColor(JavaWatColor.getColor(c1[Elenco[col].getObsID(j) - 1]));
g
.fillOval(
col
* WIDTH_TOT
+ 5
+ /* i - 1,*/
(int) (((Elenco[col].getValue(j) - Elenco[col].getUniStats()
.getMinValue())) * xFoot) - 1,
(((row + 1) * HEIGHT_TOT) - 5 - (int) (((Elenco[col].getValue(j, row) - Elenco[row]
.getUniStats().getMinValue())) * yFoot)), 1, 1);
done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)] = true;
}
}
}
}
}
}
}
} else {
g.setColor(Color.WHITE);
g.fillRect(0, 0, 300, 100);
g.setColor(Color.BLACK);
g.drawString("With this data the graphic cannot be create", 50, 50);
}
} catch (Exception e) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, 300, 100);
g.setColor(Color.BLACK);
g.drawString("With this data the graphic cannot be create", 50, 50);
}
updateInfos(10000 * (Elenco.length * Elenco.length) + 1, "End", false);
return null;
}
@Override
public void finished() {
DispersionPanel.this.repaint();
}
};
worker.start();
} else {
g.drawImage(chart, 0, 0, null);
}
}