KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > JaWEPortView


1 /* PEPortView.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;
12
13 import org.jgraph.graph.*;
14 import org.jgraph.JGraph;
15
16 import java.awt.*;
17 import java.awt.geom.Rectangle2D JavaDoc;
18 import java.net.URL JavaDoc;
19 import javax.swing.UIManager JavaDoc;
20
21 /**
22  * Extends PortView in such a way to implement method for
23  * setting sizes of all ports, which is needed to enlarge
24  * their sizes to easily connect transitions.
25  */

26
27 public class JaWEPortView extends PortView {
28
29    protected static MyPortRenderer renderer;
30
31    /**
32     * Creates object.
33     */

34    public JaWEPortView(Object JavaDoc cell, JGraph graph, CellMapper mapper) {
35       super(cell,graph,mapper);
36    }
37
38    /**
39     * Sets size of all ports to given value.
40     */

41    public static void setPortSize (int s) {
42       if (size<2) size=2;
43       size=s;
44    }
45
46    /**
47     * Returns port's size.
48     */

49    public static int getPortSize () {
50       return size;
51    }
52
53    public CellViewRenderer getRenderer() {
54       if (renderer==null) {
55          renderer = new MyPortRenderer();
56       }
57       return renderer;
58    }
59
60    public static class MyPortRenderer extends PortRenderer {
61
62       public MyPortRenderer() {
63          Color fg=UIManager.getColor("MenuItem.selectionBackground");
64          Color bg=Utils.getColor(JaWEConfig.getInstance().getHandleColor());
65          setForeground(fg);
66          setBackground(bg);
67       }
68    }
69
70 }
71
72 /* End of PEPortView.java */
73
Popular Tags