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.systemsmodel;
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: public class SystemVertexView extends VertexCellView {
29: public SystemVertexView(Object cell, DesignGraph graph,
30: CellMapper cm) {
31: super (cell, graph, cm);
32: }
33:
34: public CellViewRenderer getRenderer() {
35: return new SystemVertexRenderer();
36: }
37:
38: /* System vertex renderer class */
39:
40: public class SystemVertexRenderer extends VertexCellRenderer {
41: public Dimension getPreferredSize() {
42: return calculatePreferredSize(100, 80, 200, 200);
43: }
44:
45: protected void paintComponent(Graphics g) {
46: Dimension lSize = getSize();
47: Rectangle lTopRect = new Rectangle(0, 0, lSize.width / 2,
48: lSize.height / 5);
49: Rectangle lMainRect = new Rectangle(0, lTopRect.height,
50: lSize.width - 1, lSize.height - lTopRect.height - 1);
51:
52: //g.setColor(Color.cyan);
53: g.setColor(getBackground());
54: fillRect(g, lTopRect);
55: fillRect(g, lMainRect);
56:
57: //g.setColor(Color.black);
58: g.setColor(getForeground());
59: g.drawLine(lTopRect.x, lTopRect.y, lTopRect.width,
60: lTopRect.y);
61: g.drawLine(lTopRect.x, lTopRect.y, lTopRect.x,
62: lTopRect.height);
63: g.drawLine(lTopRect.width, lTopRect.y, lTopRect.width,
64: lTopRect.height);
65: g.drawRect(lMainRect.x, lMainRect.y, lMainRect.width,
66: lMainRect.height);
67:
68: paintCaption(g, lMainRect);
69:
70: //super.paintComponent(g);
71: }
72: }
73: }
|