KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > nbprefuse > render > GeneralizationEdgeRenderer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * GeneralizationEdgeRenderer.java
22  *
23  * Created on October 30, 2005, 12:45 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.nbprefuse.render;
30
31 import java.awt.BasicStroke JavaDoc;
32 import java.awt.Color JavaDoc;
33 import java.awt.Graphics2D JavaDoc;
34 import java.awt.Polygon JavaDoc;
35 import java.awt.Shape JavaDoc;
36 import java.awt.geom.AffineTransform JavaDoc;
37 import java.awt.geom.Point2D JavaDoc;
38 import java.awt.geom.Rectangle2D JavaDoc;
39 import org.openide.ErrorManager;
40 import prefuse.render.EdgeRenderer;
41 import prefuse.util.ColorLib;
42 import prefuse.visual.EdgeItem;
43 import prefuse.visual.VisualItem;
44
45 /**
46  *
47  * @author Jeri Lockhart
48  */

49 public class GeneralizationEdgeRenderer
50                 extends EdgeRenderer {
51     
52     
53     protected static final Polygon JavaDoc GENERLIZATION_ARROW_HEAD =
54             new Polygon JavaDoc(new int[] {0,-8,8,0}, new int[] {0,-16,-16,0}, 4);
55     
56     /** Creates a new instance of GeneralizationEdgeRenderer */
57     public GeneralizationEdgeRenderer() {
58         super();
59         m_arrowHead = GENERLIZATION_ARROW_HEAD;
60         setRenderType(RENDER_TYPE_DRAW); // dflt RENDER_TYPE_DRAW_AND_FILL
61

62     }
63     
64   
65     /**
66      * @see prefuse.render.Renderer#render(java.awt.Graphics2D, prefuse.visual.VisualItem)
67      */

68     public void render(Graphics2D JavaDoc g, VisualItem item) {
69         // render the edge line
70
super.render(g, item);
71         // retain the following order of filling and drawing
72
// fill first
73
g.setPaint(Color.WHITE);
74         g.fill(m_curArrow);
75         // then draw outline
76
g.setPaint(ColorLib.getColor(item.getStrokeColor()));
77         g.draw(m_curArrow);
78     }
79     
80 }
81
Popular Tags