| 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 java.awt.Paint; | |
| 15 | ||
| 16 | import edu.uci.ics.jung.graph.Vertex; | |
| 17 | import edu.uci.ics.jung.visualization.PickedInfo; | |
| 18 | ||
| 19 | /** | |
| 20 | * Paints each vertex according to the <code>Paint</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 PickableVertexPaintFunction implements VertexPaintFunction { | |
| 25 | ||
| 26 | protected Paint draw_paint; | |
| 27 | protected Paint fill_paint; | |
| 28 | protected Paint picked_paint; | |
| 29 | protected PickedInfo pi; | |
| 30 | ||
| 31 | /** | |
| 32 | * | |
| 33 | * @param pi specifies which vertices report as "picked" | |
| 34 | * @param draw_paint <code>Paint</code> used to draw vertex shapes | |
| 35 | * @param fill_paint <code>Paint</code> used to fill vertex shapes | |
| 36 | * @param picked_paint <code>Paint</code> used to fill picked vertex shapes | |
| 37 | */ | |
| 38 | public PickableVertexPaintFunction(PickedInfo pi, Paint draw_paint, Paint fill_paint, Paint picked_paint) | |
| 39 | 0 | { |
| 40 | 0 | if (pi == null) |
| 41 | 0 | throw new IllegalArgumentException("PickedInfo instance must be non-null"); |
| 42 | 0 | this.pi = pi; |
| 43 | 0 | this.draw_paint = draw_paint; |
| 44 | 0 | this.fill_paint = fill_paint; |
| 45 | 0 | this.picked_paint = picked_paint; |
| 46 | 0 | } |
| 47 | ||
| 48 | public Paint getDrawPaint(Vertex v) | |
| 49 | { | |
| 50 | 0 | return draw_paint; |
| 51 | } | |
| 52 | ||
| 53 | public Paint getFillPaint(Vertex v) | |
| 54 | { | |
| 55 | 0 | if (pi.isPicked(v)) |
| 56 | 0 | return picked_paint; |
| 57 | else | |
| 58 | 0 | return fill_paint; |
| 59 | } | |
| 60 | ||
| 61 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |