KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > graph > EndRenderer


1 /* EndRenderer.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.graph;
12
13 import org.enhydra.jawe.*;
14 import org.jgraph.graph.*;
15 import java.awt.*;
16
17 /**
18 * Class used to display end object.
19 */

20 public class EndRenderer extends VertexRenderer {
21
22    private BasicStroke borderStroke = new BasicStroke(2);
23
24    /**
25    * Paints End. Overrides super class paint
26    * to add specific painting.
27    */

28    public void paint(Graphics g){
29       Color fillCol=Utils.getColor(JaWEConfig.getInstance().getEndColor());
30       int b = borderWidth;
31       Graphics2D g2 = (Graphics2D) g;
32       Object JavaDoc AntiAlias = RenderingHints.VALUE_ANTIALIAS_ON;//Harald Meister
33
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, AntiAlias);//Harald Meister
34
Dimension d = getSize();
35       boolean tmp = selected;
36
37       if (super.isOpaque()) {
38          g.setColor(fillCol);
39          g.fillOval(b-1, b-1, d.width-b, d.height-b);
40       }
41       try {
42          setBorder(null);
43          setOpaque(false);
44          selected = false;
45          super.paint(g);
46       } finally {
47          selected = tmp;
48       }
49       if (bordercolor != null) {
50          g.setColor(bordercolor);
51          g2.setStroke(borderStroke);
52          g.drawOval(b-1, b-1, d.width-b, d.height-b);
53       }
54       if (selected) {
55          g2.setStroke(GraphConstants.SELECTION_STROKE);
56          g.setColor(graph.getHighlightColor());
57          g.drawOval(b-1, b-1, d.width-b, d.height-b);
58       }
59    }
60
61 }
62
Popular Tags