// The core code that implements the algorithm of resizing, rescaling and // restyling a dendrogram or tree diagram: DH = UP? J - PH : I - PW; //DH is zero initially in conditional statement // if UP is true by ?-checking, starting vertical coordinate of tree drawing // if UP is false, starting horizontal coordinate of tree drawing if (HC.Mode == 1) { // Horizontal/vertical auto-resizing is realized by positive/negative Tot Tot += DH; } else { // Handle horizontal drawing width if (DH * HR < 0) { CK = 1; // To the reverse direction of resizing } else { CK = 0; // To the same direction of resizing } K = HR; // Store HR value before being changed // Get remainder pixels after assigning pixels to clustering levels HR = DH % CL; if (HR == 0) CK = 0; // No resizing as DH = 0 DH /= CL; // Get DH that is signed multiple of CL UW += DH; // Increase/decrease the unit width of tree if (Tot == 0) { Tot = Math.abs(HR); // Initialize Tot with HR } else { if (CK == 0) { Tot += Math.abs(HR); //Increment Tot by HR } else { Tot -= Math.abs(HR); //Offset Tot by reverse HR if (Tot > 0) { HR = -HR; //Reverse direction of resizing } else if (Tot < 0) { Tot = -Tot; //Make Tot positive } } } if (Tot >= CL) { Tot -= CL; //Subtract CL from Tot if Tot grows over it //Then each of clustering levels should decrement or increment one pixel, // that is, decrease or increase the unit width of tree drawing if (HR < 0) { UW--; // Decrement the unit width, shrinking tree. } else if (HR > 0) { UW++; // Increment the unit width, enlarging tree. } } if (HR == 0) HR = K; // If no resizing, restore HR value } // Handle vertical drawing height, which is analogous to the horizontal way. DH = UP? I - PW : J - PH; // DH is evaluated by ?-checking UP value if (DH * VR < 0) { // Vertical remainder pixels instead of HR CK = 1; } else { CK = 0; } K = VR; // Store VR value before being changed // Get remainder pixels after assigning pixels to clustering lines VR = DH % CN; // Number of data points instead of CL if (VR == 0) CK = 0; DH /= CN; // Get DH that is the signed multiple of CN LSP -= DH; if (Sum == 0) { //Sum instead of Tot Sum = Math.abs(VR); } else { if (CK == 0) { Sum += Math.abs(VR); } else { Sum -= Math.abs(VR); if (Sum > 0) { VR = -VR; } else if (Sum < 0) { Sum = -Sum; } } } if (Sum >= CN) { Sum -= CN; if (VR < 0) { LSP++; } else if (VR > 0) { LSP--; } } if (VR == 0) VR = K; // If no resizing, restore VR value.