KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* StartRenderer.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 start object.
19 */

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

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