KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ProcessRenderer.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
14 import java.awt.*;
15
16 import javax.swing.BorderFactory JavaDoc;
17 import org.jgraph.graph.GraphConstants;
18 import org.enhydra.jawe.JaWEConfig;
19 import org.enhydra.jawe.Utils;
20
21 /**
22  * Class used to display process object.
23  */

24 //public class ProcessRenderer extends VertexRenderer {
25
public class ProcessRenderer extends MultiLinedRenderer {
26
27    private BasicStroke borderStroke = new BasicStroke(2);
28
29    protected static final int procW=JaWEConfig.getInstance().getProcessWidth();
30    protected static final int procH=JaWEConfig.getInstance().getProcessHeight();
31    protected static final int rrW=54;
32    protected static final int rrH=42;
33    protected static final int innerW=ProcessRenderer.procW-rrW/3;
34    protected static final int innerH=ProcessRenderer.procH-rrH/3;
35
36    /**
37     * Paints Process. Overrides super class paint
38     * to add specific painting.
39     */

40    public void paint(Graphics g) {
41       Color fillCol=Utils.getColor(JaWEConfig.getInstance().getProcessColor());
42       int b = borderWidth;
43       Graphics2D g2 = (Graphics2D) g;
44       Object JavaDoc AntiAlias = RenderingHints.VALUE_ANTIALIAS_ON;//Harald Meister
45
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, AntiAlias);//Harald Meister
46
Dimension d = getSize();
47       boolean tmp = selected;
48
49       Color gridC=graph.getGridColor();
50       Color highlightC=graph.getHighlightColor();
51       Color bckgC=fillCol; //graph.getBackground();
52
Color borderC=bordercolor;
53       if (selected) {
54          bckgC=Utils.getColor(JaWEConfig.getInstance().getSelectedActivityColor());
55       }
56
57
58       if (super.isOpaque()) {
59          g.setColor(fillCol);
60          g.fillRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH);
61       }
62
63       try {
64          setBorder(null);
65          setOpaque(false);
66          selected = false;
67
68
69          // drawing label
70
Graphics gl=g.create(rrW/6,rrH/6,innerW,innerH);
71          Rectangle labelRect=new Rectangle(new Dimension(innerW,innerH));
72          super.setBounds(labelRect);
73          graph.setGridColor(bckgC);
74          graph.setHighlightColor(bckgC);
75
76          super.paint(gl);
77
78          setForeground(bordercolor);
79          graph.setGridColor(gridC);
80          graph.setHighlightColor(highlightC);
81       } finally {
82          selected = tmp;
83       }
84       if (bordercolor != null) {
85          g.setColor(bordercolor);
86          g2.setStroke(borderStroke);
87          g.drawRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH);
88       }
89       if (selected) {
90          g2.setStroke(GraphConstants.SELECTION_STROKE);
91          g.setColor(graph.getHighlightColor());
92          g.drawRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH);
93       }
94
95
96    }
97
98    protected Color getFillColor () {
99       return Utils.getColor(JaWEConfig.getInstance().getGenericActivityColor());
100    }
101
102 }
103
104
Popular Tags