01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package com.artenum.so6.dataflow.graph.ui;
34:
35: import com.artenum.so6.dataflow.StyleManager;
36: import com.artenum.so6.dataflow.graph.WorkspaceNode;
37:
38: import java.awt.BasicStroke;
39: import java.awt.Color;
40: import java.awt.Dimension;
41: import java.awt.Graphics;
42: import java.awt.Graphics2D;
43: import java.awt.Rectangle;
44: import java.awt.Stroke;
45:
46: import javax.swing.JComponent;
47:
48: /**
49: * @author seb
50: */
51: public class WorkspaceUI extends JComponent {
52: public final static Dimension SIZE = new Dimension(35, 35);
53: public final static Stroke STROKE = new BasicStroke(2F);
54: private final static Color SELECTED_LINE = Color.RED;
55: private final static Color DEFAULT_LINE = Color.BLACK;
56: private WorkspaceNode node;
57:
58: public WorkspaceUI(WorkspaceNode node) {
59: this .node = node;
60: setPreferredSize(SIZE);
61: setMaximumSize(SIZE);
62: setMinimumSize(SIZE);
63: setBounds(new Rectangle(SIZE));
64: }
65:
66: public void paint(Graphics g) {
67: Graphics2D g2 = (Graphics2D) g;
68: g2.setColor(node.isUpToDate() ? StyleManager.getInstance()
69: .getWsUpToDateColor() : StyleManager.getInstance()
70: .getWsNeedUpdateColor());
71: g2.fillOval(1, 1, SIZE.width - 1, SIZE.height - 1);
72:
73: if (node.isSelected()) {
74: g2.setColor(SELECTED_LINE);
75: } else {
76: g2.setColor(DEFAULT_LINE);
77: }
78:
79: g2.setStroke(STROKE);
80: g2.drawOval(1, 1, SIZE.width - 2, SIZE.height - 2);
81: }
82: }
|