Coverage details for edu.uci.ics.jung.visualization.VertexLocationUtils

LineHitsSource
1 /*
2  * Created on Jul 22, 2005
3  *
4  * Copyright (c) 2005, the JUNG Project and the Regents of the University
5  * of California
6  * All rights reserved.
7  *
8  * This software is open-source under the BSD license; see either
9  * "license.txt" or
10  * http://jung.sourceforge.net/license.txt for a description.
11  */
12 package edu.uci.ics.jung.visualization;
13  
14 import java.awt.geom.AffineTransform;
15 import java.awt.geom.Point2D;
16 import java.util.Iterator;
17  
18 import edu.uci.ics.jung.graph.ArchetypeVertex;
19  
200public class VertexLocationUtils
21 {
22     public static VertexLocationFunction scale(VertexLocationFunction vld, double dx, double dy)
23     {
240        SettableVertexLocationFunction out = new DefaultSettableVertexLocationFunction();
25         // get the max x and max y locations
260        double max_x = 0;
270        double max_y = 0;
280        for (Iterator iter = vld.getVertexIterator(); iter.hasNext(); )
29         {
300            ArchetypeVertex v = (ArchetypeVertex)iter.next();
310            Point2D location = vld.getLocation(v);
320            max_x = Math.max(max_x, location.getX());
330            max_y = Math.max(max_y, location.getY());
34         }
350        AffineTransform at = AffineTransform.getScaleInstance(dx / max_x, dy / max_y);
360        for (Iterator iter = vld.getVertexIterator(); iter.hasNext(); )
37         {
380            ArchetypeVertex v = (ArchetypeVertex)iter.next();
390            Point2D location = vld.getLocation(v);
400            Point2D new_location = new Point2D.Double();
410            at.transform(location, new_location);
420            out.setLocation(v, new_location);
43         }
440        return out;
45     }
46 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.