01: //THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: //CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: //BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: //OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: //LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: //EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: //POSSIBILITY OF SUCH DAMAGE.
13: //
14: //Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.usecasesmodel;
16:
17: import java.awt.Dimension;
18: import java.awt.Graphics;
19: import java.awt.Rectangle;
20:
21: import org.jgraph.graph.CellMapper;
22: import org.jgraph.graph.CellViewRenderer;
23:
24: import com.metaboss.applications.designstudio.components.DesignGraph;
25: import com.metaboss.applications.designstudio.components.VertexCellRenderer;
26: import com.metaboss.applications.designstudio.components.VertexCellView;
27:
28: /* Use case vertex view */
29:
30: public class UseCaseVertexView extends VertexCellView {
31: public UseCaseVertexView(Object cell, DesignGraph graph,
32: CellMapper cm) {
33: super (cell, graph, cm);
34: }
35:
36: // Returns the Renderer for this View
37: public CellViewRenderer getRenderer() {
38: return new UseCaseVertexRenderer();
39: }
40:
41: /* State vertex renderer class */
42:
43: public class UseCaseVertexRenderer extends VertexCellRenderer {
44: public static final int MIN_WIDTH = 80;
45: public static final int MIN_HEIGHT = 50;
46: public static final int MAX_WIDTH = 200;
47: public static final int MAX_HEIGHT = 200;
48: public static final int ARC_SIZE = 90;
49:
50: public Dimension getPreferredSize() {
51: return calculatePreferredSize(MIN_WIDTH, MIN_HEIGHT,
52: MAX_WIDTH, MAX_HEIGHT);
53: }
54:
55: protected void paintComponent(Graphics g) {
56: Dimension lSize = getSize();
57:
58: g.setColor(getBackground());
59: fillRoundRect(g, new Rectangle(0, 0, lSize.width - 1,
60: lSize.height - 1), ARC_SIZE, ARC_SIZE);
61: g.setColor(getForeground());
62: g.drawRoundRect(0, 0, lSize.width - 1, lSize.height - 1,
63: ARC_SIZE, ARC_SIZE);
64:
65: Rectangle viewR = new Rectangle(0, 0, lSize.width - 1,
66: lSize.height - 1);
67: paintCaption(g, viewR);
68: }
69: }
70: }
|