/** Sets the initial position of the Graph nodes. */ public void initialize() { if (this.sampleGroups != null) { Dimension d = this.getSize(); List<List<V>> moleculeGroups = new ArrayList<List<V>>(); for (int i = 0; i < 3; i++) { moleculeGroups.add(new ArrayList<V>()); } if (d != null) { double height = d.getHeight(); double width = d.getWidth(); String groupName; for (V v : this.getGraph().getVertices()) { if (this.isUpRegulated(sampleGroups, v)) moleculeGroups.get(1).add(v); else if (this.isDownRegulated(sampleGroups, v)) moleculeGroups.get(2).add(v); else moleculeGroups.get(0).add(v); } this.radius = (Math.min(height, width)) * 0.3; int groupRadius = (int) (this.radius / Math.sqrt(moleculeGroups.size())); int j = 0, x, y; Point2D.Double graphCenter = new Point2D.Double(width / 2.0, height / 2.0); PolarPoint2D center = new PolarPoint2D(0, 0, graphCenter); PolarPoint2D coord = new PolarPoint2D(0, 0, center); double theta; for (List<V> group : moleculeGroups) { theta = (2 * Math.PI * j) / moleculeGroups.size(); j++; center.setLocation(this.radius, theta, PolarPoint2D.POLAR); int i = 0; for (V vertex : group) { theta = (2 * Math.PI * i) / group.size(); coord.setLocation(groupRadius, theta, PolarPoint2D.POLAR); this.setLocation(vertex, coord); i++; } } } } }