m_missing = new boolean[inst.numInstances()][inst.numAttributes()]; m_type = new int[2][inst.numAttributes()];
m_missing = new boolean[inst.numInstances()][m_selectedAttribs.length+1]; m_type = new int[2];
  public void initInternalFields() {    Instances inst = m_data;    m_classIndex = m_classAttrib.getSelectedIndex();    double minC=0, maxC=0;    int originalClassIndex = m_data.classIndex();    m_data.setClassIndex(m_classIndex);    /** Resampling  **/    if(Double.parseDouble(m_resamplePercent.getText())<100) {      try {	if( m_data.attribute(m_classIndex).isNominal() ) {	  weka.filters.supervised.instance.Resample r = new weka.filters.supervised.instance.Resample();		  	  r.setRandomSeed( Integer.parseInt(m_rseed.getText()) );	  r.setSampleSizePercent( Double.parseDouble(m_resamplePercent.getText()) );		  	  if(origDist.isSelected())	    r.setBiasToUniformClass(0);	  else	    r.setBiasToUniformClass(1);	  r.setInputFormat(m_data);	  inst = weka.filters.Filter.useFilter(m_data, r);	}	else {	  weka.filters.unsupervised.instance.Resample r = new weka.filters.unsupervised.instance.Resample();		  	  r.setRandomSeed( Integer.parseInt(m_rseed.getText()) );	  r.setSampleSizePercent( Double.parseDouble(m_resamplePercent.getText()) );	  r.setInputFormat(m_data);	  inst = weka.filters.Filter.useFilter(m_data, r);	}      }      catch(Exception ex) { System.out.println("Error occurred while sampling"); ex.printStackTrace();  }    }    m_data.setClassIndex(originalClassIndex);        m_points = new int[inst.numInstances()][inst.numAttributes()];    m_pointColors = new int[inst.numInstances()];    m_missing = new boolean[inst.numInstances()][inst.numAttributes()];    m_type = new int[2][inst.numAttributes()];    jitterVals = new int[inst.numInstances()][2];          /** Setting up the color list for non-numeric attribute as well as jittervals**/    if(!(inst.attribute(m_classIndex).isNumeric())) {	        for(int i=m_colorList.size(); i<inst.attribute(m_classIndex).numValues()+1; i++) {	Color pc = m_defaultColors[i % 10];	int ija =  i / 10;	ija *= 2; 	for (int j=0;j<ija;j++) {	  pc = pc.darker();     	}	m_colorList.addElement(pc);      }	        for(int i=0; i<inst.numInstances(); i++) {	//set to black for missing class value which is last colour is default list	if(inst.instance(i).isMissing(m_classIndex))	  m_pointColors[i] =  m_defaultColors.length-1;	else	  m_pointColors[i] = (int) inst.instance(i).value(m_classIndex);	jitterVals[i][0] = rnd.nextInt(m_jitter.getValue()+1)	  - m_jitter.getValue()/2;	jitterVals[i][1] = rnd.nextInt(m_jitter.getValue()+1)	  - m_jitter.getValue()/2;	            }    }    /** Setting up color variations for numeric attribute as well as jittervals **/    else {      for(int i=0; i<inst.numInstances(); i++) {	if(!(inst.instance(i).isMissing(m_classIndex))) {	  minC = maxC = inst.instance(i).value(m_classIndex);	  break;	}      }	        for(int i=1; i<inst.numInstances(); i++) {	if(!(inst.instance(i).isMissing(m_classIndex))) {	  if(minC > inst.instance(i).value(m_classIndex))	    minC = inst.instance(i).value(m_classIndex);	  if(maxC < inst.instance(i).value(m_classIndex))	    maxC = inst.instance(i).value(m_classIndex);	}      }	        for(int i=0; i<inst.numInstances(); i++) {	double r = (inst.instance(i).value(m_classIndex) - minC) / (maxC - minC);	r = (r * 240) + 15;	m_pointColors[i] = (int)r;	jitterVals[i][0] = rnd.nextInt(m_jitter.getValue()+1)	  - m_jitter.getValue()/2;	jitterVals[i][1] = rnd.nextInt(m_jitter.getValue()+1)	  - m_jitter.getValue()/2;      }    }    /** Creating local cache of the data values **/    double min[]=new double[inst.numAttributes()], max=0;    double ratio[] = new double[inst.numAttributes()];    double cellSize = m_plotSize.getValue(), temp1=0, temp2=0;    for(int j=0; j<inst.numAttributes(); j++) {      int i;      for(i=0; i<inst.numInstances(); i++) {	min[j] = max = 0;	if(!(inst.instance(i).isMissing(j))) {	  min[j] = max = inst.instance(i).value(j);	  break;	}      }      for( i=i; i<inst.numInstances(); i++ ) {	if(!(inst.instance(i).isMissing(j))) {	  if(inst.instance(i).value(j) < min[j])	    min[j] = inst.instance(i).value(j);	  if(inst.instance(i).value(j) > max)	    max = inst.instance(i).value(j);	}      }      ratio[j] =  cellSize / (max - min[j]);    }    for(int j=0; j<inst.numAttributes(); j++) {      if(inst.attribute(j).isNominal() || inst.attribute(j).isString()) {	m_type[0][j] = 1;  m_type[1][j] = inst.attribute(j).numValues();	temp1 = cellSize/(double)m_type[1][j];	temp2 = temp1/2;	for(int i=0; i<inst.numInstances(); i++) {	  m_points[i][j] = (int) Math.round(temp2+temp1*inst.instance(i).value(j));	  if(inst.instance(i).isMissing(j))	    m_missing[i][j] = true;    //represents missing value	}      }      else {	m_type[0][j] = m_type[1][j] = 0;	for(int i=0; i<inst.numInstances(); i++) {	  m_points[i][j] = (int) Math.round((inst.instance(i).value(j)					     -min[j])*ratio[j]);		  if(inst.instance(i).isMissing(j))	    m_missing[i][j] = true;    //represents missing value	}      }    }    m_cp.setColours(m_colorList);  }