001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package com.artenum.so6.dataflow.graph;
034:
035: import com.artenum.graph.interfaces.Connection;
036:
037: import com.artenum.so6.dataflow.graph.ui.WorkspaceUI;
038:
039: import java.awt.Point;
040: import java.awt.Rectangle;
041:
042: import java.util.Iterator;
043: import java.util.Properties;
044:
045: /**
046: * @author seb
047: */
048: public class WorkspaceNode extends So6Node {
049: private boolean uptodate = false;
050:
051: public WorkspaceNode(Properties externalProps) {
052: super (externalProps);
053: ui = new WorkspaceUI(this );
054: ui.setBounds(new Rectangle(ui.getPreferredSize()));
055: new So6DragListener(this , true);
056: }
057:
058: public void updateNode() {
059: checkUptoDate();
060: }
061:
062: public void checkUptoDate() {
063: uptodate = true;
064:
065: long currentConnectionTicket;
066:
067: for (Iterator conIt = getConnections().iterator(); conIt
068: .hasNext();) {
069: ConnectionNode conNode = (ConnectionNode) ((Connection) conIt
070: .next()).getOtherCell(this );
071:
072: if (!conNode.isUpToDate()) {
073: uptodate = false;
074:
075: break;
076: }
077: }
078: }
079:
080: public boolean isUpToDate() {
081: return uptodate;
082: }
083:
084: public Point getConnectionPoint(Connection connection) {
085: Point remoteCellPoint = connection.getOtherCell(this )
086: .getConnectionPoint(connection);
087:
088: Point result1 = ui.getBounds().getLocation();
089: result1.translate(ui.getWidth() / 2, 0);
090:
091: Point result2 = (Point) result1.clone();
092: result2.translate(0, ui.getHeight());
093:
094: double dist1 = remoteCellPoint.distance(result1);
095: double dist2 = remoteCellPoint.distance(result2);
096:
097: return (dist1 < dist2) ? result1 : result2;
098:
099: /*
100: double lineLength = remoteCellPoint.distance(wsCenterPoint);
101: double stepX = (17.5 * (remoteCellPoint.x - wsCenterPoint.x)) / lineLength;
102: double stepY = (17.5 * (remoteCellPoint.y - wsCenterPoint.y)) / lineLength;
103:
104: Point result = (Point) wsCenterPoint.clone();
105: result.translate((int) stepX, (int) stepY);
106: */
107: }
108: }
|