public double getTotalDistance() { double dist = getDistance() == null ? 0 : getDistance(); if (getChildren().size() > 0) { dist += children.get(0).getTotalDistance(); } return dist; }
private ArrayList<String[]> findCluster(Cluster cluster, double cutDist, int minPatternPerCls) { ArrayList<String[]> clusterTSIdx = new ArrayList<String[]>(); if (cluster.getDistance() != null) { // if (cluster.getDistance() > cutDist) { if (cluster.getDistanceValue() > cutDist) { if (cluster.getChildren().size() > 0) { clusterTSIdx.addAll(findCluster(cluster.getChildren().get(0), cutDist, minPatternPerCls)); clusterTSIdx.addAll(findCluster(cluster.getChildren().get(1), cutDist, minPatternPerCls)); } } else { // String[] idxes = cluster.getName().split("&"); ArrayList<String> itemsInCluster = getNameInCluster(cluster); String[] idxes = itemsInCluster.toArray(new String[itemsInCluster.size()]); if (idxes.length > minPatternPerCls) { clusterTSIdx.add(idxes); } } } return clusterTSIdx; }
public double getTotalDistance() { Double dist = getDistance() == null ? 0 : getDistance().getDistance(); if (getChildren().size() > 0) { dist += children.get(0).getTotalDistance(); } return dist; }
if (cluster.getDistance() == null) {
public double getTotalDistance() { Double dist = getDistance() == null ? 0 : getDistance().getDistance(); if (getChildren().size() > 0) { dist += children.get(0).getTotalDistance(); } return dist; }
@Override public void paint(Graphics2D g, int xDisplayOffset, int yDisplayOffset, double xDisplayFactor, double yDisplayFactor, boolean decorated) { int x1, y1, x2, y2; FontMetrics fontMetrics = g.getFontMetrics(); x1 = (int)(initPoint.getX() * xDisplayFactor + xDisplayOffset); y1 = (int)(initPoint.getY() * yDisplayFactor + yDisplayOffset); x2 = (int)(linkPoint.getX() * xDisplayFactor + xDisplayOffset); y2 = y1; g.fillOval(x1-dotRadius, y1-dotRadius, dotRadius * 2, dotRadius * 2); g.drawLine(x1, y1, x2, y2); if (cluster.isLeaf()) { g.drawString(cluster.getName().toString(), x1 + namePadding, y1 + (fontMetrics.getHeight()/2) - 2); } if (decorated && cluster.getDistance() != null && !cluster.getDistance().isNaN() && cluster.getDistance() > 0) { String s = String.format("%.2f", cluster.getDistance()); Rectangle2D rect = fontMetrics.getStringBounds(s, g); g.drawString(s, x1 - (int)rect.getWidth() , y1 - 2); } x1 = x2; y1 = y2; y2 = (int)(linkPoint.getY() * yDisplayFactor + yDisplayOffset); g.drawLine(x1, y1, x2, y2); for (ClusterComponent child : children) { child.paint(g, xDisplayOffset, yDisplayOffset, xDisplayFactor, yDisplayFactor, decorated); } }
@Override public void paint(Graphics2D g, int xDisplayOffset, int yDisplayOffset, double xDisplayFactor, double yDisplayFactor, boolean decorated) { int x1, y1, x2, y2; FontMetrics fontMetrics = g.getFontMetrics(); x1 = (int)(initPoint.getX() * xDisplayFactor + xDisplayOffset); y1 = (int)(initPoint.getY() * yDisplayFactor + yDisplayOffset); x2 = (int)(linkPoint.getX() * xDisplayFactor + xDisplayOffset); y2 = y1; g.fillOval(x1-dotRadius, y1-dotRadius, dotRadius * 2, dotRadius * 2); g.drawLine(x1, y1, x2, y2); if (cluster.isLeaf()) { g.drawString(cluster.getName(), x1 + namePadding, y1 + (fontMetrics.getHeight()/2) - 2); } if (decorated && cluster.getDistance() != null && !cluster.getDistance().isNaN() && cluster.getDistance().getDistance() > 0) { String s = String.format("%.2f", cluster.getDistance()); Rectangle2D rect = fontMetrics.getStringBounds(s, g); g.drawString(s, x1 - (int)rect.getWidth() , y1 - 2); } x1 = x2; y1 = y2; y2 = (int)(linkPoint.getY() * yDisplayFactor + yDisplayOffset); g.drawLine(x1, y1, x2, y2); for (ClusterComponent child : children) { child.paint(g, xDisplayOffset, yDisplayOffset, xDisplayFactor, yDisplayFactor, decorated); } }
@Override public void paint(Graphics2D g, int xDisplayOffset, int yDisplayOffset, double xDisplayFactor, double yDisplayFactor, boolean decorated) { int x1, y1, x2, y2; FontMetrics fontMetrics = g.getFontMetrics(); x1 = (int)(initPoint.getX() * xDisplayFactor + xDisplayOffset); y1 = (int)(initPoint.getY() * yDisplayFactor + yDisplayOffset); x2 = (int)(linkPoint.getX() * xDisplayFactor + xDisplayOffset); y2 = y1; g.fillOval(x1-dotRadius, y1-dotRadius, dotRadius * 2, dotRadius * 2); g.drawLine(x1, y1, x2, y2); if (cluster.isLeaf()) { g.drawString(cluster.getName(), x1 + namePadding, y1 + (fontMetrics.getHeight()/2) - 2); } if (decorated && cluster.getDistance() != null && !cluster.getDistance().isNaN() && cluster.getDistance().getDistance() > 0) { String s = String.format("%.2f", cluster.getDistance()); Rectangle2D rect = fontMetrics.getStringBounds(s, g); g.drawString(s, x1 - (int)rect.getWidth() , y1 - 2); } x1 = x2; y1 = y2; y2 = (int)(linkPoint.getY() * yDisplayFactor + yDisplayOffset); g.drawLine(x1, y1, x2, y2); for (ClusterComponent child : children) { child.paint(g, xDisplayOffset, yDisplayOffset, xDisplayFactor, yDisplayFactor, decorated); } }
private ClusterComponent createComponent(Cluster<T> cluster, VCoord initCoord, double clusterHeight) { ClusterComponent comp = null; if (cluster != null) { comp = new ClusterComponent(cluster, cluster.isLeaf(), initCoord); double leafHeight = clusterHeight / cluster.countLeafs(); double yChild = initCoord.getY() - (clusterHeight / 2); double distance = cluster.getDistance() == null ? 0 : cluster.getDistance(); for (Cluster<T> child : cluster.getChildren()) { int childLeafCount = child.countLeafs(); double childHeight = childLeafCount * leafHeight; double childDistance = child.getDistance() == null ? 0 : child.getDistance(); VCoord childInitCoord = new VCoord(initCoord.getX() + (distance - childDistance), yChild + childHeight / 2.0); yChild += childHeight; /* Traverse cluster node tree */ ClusterComponent childComp = createComponent(child, childInitCoord, childHeight); childComp.setLinkPoint(initCoord); comp.getChildren().add(childComp); } } return comp; }
Double rWeight = rCluster.getWeightValue(); double weight = lWeight + rWeight; cluster.getDistance().setWeight(weight);
Double rWeight = rCluster.getWeightValue(); double weight = lWeight + rWeight; cluster.getDistance().setWeight(weight);