# Coverage details for edu.uci.ics.jung.visualization.RandomVertexLocationDecorator

Line | Hits | Source
--- | --- | ---
1 |  | `/*`
2 |  | `* Created on Jul 19, 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.Dimension;`
15 |  | `import java.awt.geom.Point2D;`
16 |  | `import java.util.Date;`
17 |  | `import java.util.HashMap;`
18 |  | `import java.util.Iterator;`
19 |  | `import java.util.Map;`
20 |  | ``
21 |  | `import cern.jet.random.engine.DRand;`
22 |  | `import cern.jet.random.engine.RandomEngine;`
23 |  | `import edu.uci.ics.jung.graph.ArchetypeVertex;`
24 |  | ``
25 |  | `public class RandomVertexLocationDecorator implements VertexLocationFunction`
26 |  | `{`
27 |  | `RandomEngine rand;`
28 | 19 | `Map v_locations = new HashMap();`
29 |  | `Dimension dim;`
30 |  | ``
31 |  | `public RandomVertexLocationDecorator(Dimension d)`
32 | 19 | `{`
33 | 19 | `this.rand = new DRand((int)(new Date().getTime()));`
34 | 19 | `this.dim = d;`
35 | 19 | `}`
36 |  | ``
37 |  | `public RandomVertexLocationDecorator(Dimension d, int seed)`
38 | 0 | `{`
39 | 0 | `this.rand = new DRand(seed);`
40 | 0 | `this.dim = d;`
41 | 0 | `}`
42 |  | ``
43 |  | `/**`
44 |  | `* Resets all vertex locations returned by <code>getLocation</code>`
45 |  | `* to new (random) locations.`
46 |  | `*/`
47 |  | `public void reset()`
48 |  | `{`
49 | 0 | `v_locations.clear();`
50 | 0 | `}`
51 |  | ``
52 |  | `public Point2D getLocation(ArchetypeVertex v)`
53 |  | `{`
54 | 1015 | `Point2D location = (Point2D)v_locations.get(v);`
55 | 1015 | `if (location == null)`
56 |  | `{`
57 | 905 | `location = new Point2D.Double(rand.nextDouble() * dim.width, rand.nextDouble() * dim.height);`
58 | 905 | `v_locations.put(v, location);`
59 |  | `}`
60 | 1015 | `return location;`
61 |  | `}`
62 |  | ``
63 |  | `public Iterator getVertexIterator()`
64 |  | `{`
65 | 0 | `return v_locations.keySet().iterator();`
66 |  | `}`
67 |  | `}`

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.