Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Created on Mar 10, 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.graph.decorators; | |
13 | ||
14 | import javax.swing.Icon; | |
15 | ||
16 | import edu.uci.ics.jung.graph.ArchetypeVertex; | |
17 | import edu.uci.ics.jung.visualization.PickedInfo; | |
18 | ||
19 | /** | |
20 | * Supplies an Icon for each vertex according to the <code>Icon</code> | |
21 | * parameters given in the constructor, so that picked and | |
22 | * non-picked vertices can be made to look different. | |
23 | */ | |
24 | public class PickableVertexIconFunction implements VertexIconFunction { | |
25 | ||
26 | protected Icon icon; | |
27 | protected Icon picked_icon; | |
28 | protected PickedInfo pi; | |
29 | ||
30 | /** | |
31 | * | |
32 | * @param pi specifies which vertices report as "picked" | |
33 | * @param icon <code>Icon</code> used to represent vertices | |
34 | * @param picked_icon <code>Icon</code> used to represent picked vertices | |
35 | */ | |
36 | public PickableVertexIconFunction(PickedInfo pi, Icon icon, Icon picked_icon) | |
37 | 0 | { |
38 | 0 | if (pi == null) |
39 | 0 | throw new IllegalArgumentException("PickedInfo instance must be non-null"); |
40 | 0 | this.pi = pi; |
41 | 0 | this.icon = icon; |
42 | 0 | this.picked_icon = picked_icon; |
43 | 0 | } |
44 | ||
45 | /** | |
46 | * Returns the appropriate <code>Icon</code>, depending on picked state. | |
47 | */ | |
48 | public Icon getIcon(ArchetypeVertex v) { | |
49 | 0 | if (pi.isPicked(v)) |
50 | 0 | return picked_icon; |
51 | else | |
52 | 0 | return icon; |
53 | } | |
54 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |