Coverage details for edu.uci.ics.jung.graph.decorators.PickableVertexIconFunction

LineHitsSource
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)
370    {
380        if (pi == null)
390            throw new IllegalArgumentException("PickedInfo instance must be non-null");
400        this.pi = pi;
410        this.icon = icon;
420        this.picked_icon = picked_icon;
430    }
44  
45     /**
46      * Returns the appropriate <code>Icon</code>, depending on picked state.
47      */
48     public Icon getIcon(ArchetypeVertex v) {
490        if (pi.isPicked(v))
500            return picked_icon;
51         else
520            return icon;
53     }
54 }

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.