// Copyright (c) 1995, 1996 Regents of the University of California. // All rights reserved. // // This software was developed by the Arcadia project // at the University of California, Irvine. // // Redistribution and use in source and binary forms are permitted // provided that the above copyright notice and this paragraph are // duplicated in all such forms and that any documentation, // advertising materials, and other materials related to such // distribution and use acknowledge that the software was developed // by the University of California, Irvine. The name of the // University may not be used to endorse or promote products derived // from this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED // WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. // File: NetArc.java // Classes: NetArc // Original Author: ics125b spring 1996 // Modifications : Kedar Patankar // $Id: NetArc.java,v 1.1.1.1 1997/02/27 20:52:43 chandra Exp $ package uci.graphedit; /** This class models an arc in our underlying connected graph model */ public class NetArc extends NetPrimitive { /** The start and end nodes of this arc. */ private NetNode _sourceNode; private NetNode _destNode; protected ArcPerspective arcPerspective; private int id; public void setId(int i){id=i;} public int getId(){return id;} public void set_perspective(ArcPerspective a){ arcPerspective=a;} public ArcPerspective get_perspective(){return arcPerspective;} /** Construct a new NetArc */ public NetArc() { } /** Get and set methods */ public void sourceNode(NetNode s) { _sourceNode = s; } public NetNode sourceNode() { return _sourceNode; } public void destNode(NetNode d) { _destNode = d; } public NetNode destNode() { return _destNode; } /** Connect the source and destination ports, iff they agree to * being connected (i.e., canConnectTo() returns true). Reply true * on success. This method is noramlly called after a new arc * instance is made. Maybe this behavior should be in a constructor, * but I want to use Class#newInstancel so constructors do not get * any arguments. */ public void connect(NetNode s, NetNode d) { sourceNode(s); destNode(d); s.addOutArc(this); d.addInArc(this); postConnect(s,d); } /** Do some application specific action just after this node is * connected to another node. the arguments contain some info about * what ports were connected. */ public void postConnect(NetNode sourceNode,NetNode destNode) { } /** Remove this NetArc from the underlying connected graph model. */ public void dispose() { System.out.println("disposing: " + toString()); if (sourceNode() != null && destNode() != null) { _sourceNode.removeArc(this); _destNode.removeArc(this); // needs-more-work: assumes no parallel arcs! // _sourceNode.postDisconnect(destNode()); // _destNode.postDisconnect(sourceNode()); } } } /* end class NetArc */