/*
* This software may only be used by you under license from AT&T Corp.
* ("AT&T"). A copy of AT&T's Source Code Agreement is available at
* AT&T's Internet website having the URL:
* <http://www.research.att.com/sw/tools/graphviz/license/source.html>
* If you received this software without first entering into a license
* with AT&T, you have an infringing copy of this software and cannot use
* it without violating AT&T's intellectual property rights.
*/
package att.grappa;
import java.io.*;
import java.util.*;
/**
* This class describes a subgraph, which can consist of
* nodes, edges and other subgraphs. Note: The topmost
* or root subgraph is the entire graph (the Graph object), which is
* an extension of this class.
*
* @version 1.2, 10 Oct 2006; Copyright 1996 - 2006 by AT&T Corp.
* @author <a href="mailto:john@research.att.com">John Mocenigo</a>, <a href="http://www.research.att.com">Research @ AT&T Labs</a>
* @see Graph
*/
public class Subgraph extends Element
implements Comparator
{
/**
* Default graph name prefix used by setName().
*
* @see Subgraph#setName()
*/
public final static String defaultNamePrefix = "G";
// node, edge and graph dictionaries for this subgraph
private Hashtable nodedict = null;
private Hashtable edgedict = null;
private Hashtable graphdict = null;
// indicators for dislaying element labels when drawing
private boolean nodeLabels = true;
private boolean edgeLabels = true;
private boolean subgLabels = true;
// default node attributes
private Hashtable nodeAttributes = null;
// default edge attributes
private Hashtable edgeAttributes = null;
// for cluster subgraphs
private boolean cluster = false;
/**
* Reference to the current selection (or vector of selections).
* Normally set and used by a GrappaAdapter.
*/
public Object currentSelection = null;
/**
* This constructor is needed by the Graph constructor
*/
Subgraph() {
//super();
cluster = true; // the root is a cluster subgraph
subgraphAttrsOfInterest();
}
/**
* Use this constructor when creating a subgraph within a subgraph.
*
* @param subg the parent subgraph.
* @param name the name of this subgraph.
*/
public Subgraph(Subgraph subg, String name) {
super(SUBGRAPH,subg);
setName(name);
Enumeration enm = subg.getNodeAttributePairs();
while(enm.hasMoreElements()) {
setNodeAttribute((Attribute)enm.nextElement());
}
enm = subg.getEdgeAttributePairs();
while(enm.hasMoreElements()) {
setEdgeAttribute((Attribute)enm.nextElement());
}
enm = subg.getLocalAttributePairs();
while(enm.hasMoreElements()) {
setAttribute((Attribute)enm.nextElement());
}
subgraphAttrsOfInterest();
}
/**
* Use this constructor when creating a subgraph within a subgraph
* with an automatically generated name.
*
* @param subg the parent subgraph.
* @see Subgraph#setName()
*/
public Subgraph(Subgraph subg) {
this(subg,(String)(null));
}
// a listing of the attributes of interest for Subgraphs
private void subgraphAttrsOfInterest() {
//attrOfInterest(BBOX_ATTR);
attrOfInterest(MINBOX_ATTR);
attrOfInterest(MINSIZE_ATTR);
attrOfInterest(LABEL_ATTR);
attrOfInterest(LP_ATTR);
attrOfInterest(STYLE_ATTR);
}
/**
* Check if this element is a subgraph.
* Useful for testing the subclass type of a Element object.
*
* @return true if this object is a Subgraph.
*/
public boolean isSubgraph() {
return(true);
}
/**
* Get the type of this element.
* Useful for distinguishing Element objects.
*
* @return the class variable constant SUBGRAPH.
* @see GrappaConstants#SUBGRAPH
*/
public int getType() {
return(SUBGRAPH);
}
/**
* Generates and sets the name for this subgraph.
* The generated name is the concatenation of the
* Subgraph.defaultNamePrefix with the numeric
* id of this subgraph Instance.
* Implements the abstract Element method.
*
* @see Element#getId()
*/
void setName() {
String oldName = name;
while(true) {
name = Subgraph.defaultNamePrefix + getId() + "_" + System.currentTimeMillis();
if(getGraph().findSubgraphByName(name) == null) {
break;
}
}
// update subgraph graph dictionary
if(getSubgraph() != null) {
if(oldName != null) {
getSubgraph().removeSubgraph(oldName);
}
getSubgraph().addSubgraph(this);
}
canonName = null;
}
/**
* Sets the subgraph name to a copy of the supplied argument.
* When the argument is null, setName() is called.
* When the name is not unique or when the name has the same format as
* that generated by setName(), a IllegalArgumentException is thrown.
*
* @param newName the new name for the subgraph.
* @see Subgraph#setName()
*/
public void setName(String newName) throws IllegalArgumentException {
if(newName == null) {
setName();
return;
}
String oldName = name;
// test if the new name is the same as the old name (if any)
if(oldName != null && oldName.equals(newName)) {
return;
}
// is name unique?
if(getGraph().findSubgraphByName(newName) != null) {
throw new IllegalArgumentException("graph name (" + newName + ") is not unique");
}
name = newName;
if(name.startsWith("cluster")) {
cluster = true;
}
// update subgraph graph dictionary
if(getSubgraph() != null) {
if(oldName != null) {
getSubgraph().removeSubgraph(oldName);
}
getSubgraph().addSubgraph(this);
}
canonName = null;
}
/**
* Check if the subgraph is a cluster subgraph.
*
* @return true, if the graph is a cluster subgraph.
*/
public boolean isCluster() {
return cluster;
}
/**
* Check if the subgraph is the root of the graph.
*
* @return true, if the graph is the root of the graph.
*/
public boolean isRoot() {
return (this == (Subgraph)getGraph());
}
/**
* Gets the subgraph-specific default attribute for the named node attribute.
*
* @param key the name of the node attribute pair to be retrieved.
* @return the requested attribute pair or null if not found.
*/
public Attribute getNodeAttribute(String key) {
if(nodeAttributes == null) return(null);
return((Attribute)(nodeAttributes.get(key)));
}
/**
* Gets the subgraph-specific default value for the named node attribute.
*
* @param key the name of the node attribute pair to be retrieved.
* @return the requested attribute value or null if not found.
*/
public Object getNodeAttributeValue(String key) {
Attribute attr;
if(nodeAttributes == null) return(null);
if((attr = (Attribute)(nodeAttributes.get(key))) == null) return(null);
return(attr.getValue());
}
/**
* Gets an enumeration of the subgraph-specific node attribute keys
*
* @return an enumeration of String objects.
*/
public Enumeration getNodeAttributeKeys() {
if(nodeAttributes == null) return Grappa.emptyEnumeration.elements();
return(nodeAttributes.keys());
}
/**
* Gets an enumeration of the subgraph-specific node attributes
*
* @return an enumeration of Attribute objects.
*/
public Enumeration getNodeAttributePairs() {
if(nodeAttributes == null) return Grappa.emptyEnumeration.elements();
return(nodeAttributes.elements());
}
/**
* Sets the subgraph-specific default for the specified node attribute.
* If the attribute is not from the pare
没有合适的资源?快使用搜索试试~ 我知道了~
petri编辑工具Pipe2
共859个文件
html:223个
class:201个
java:156个
5星 · 超过95%的资源 需积分: 9 47 下载量 20 浏览量
2008-04-29
11:13:32
上传
评论 1
收藏 7.44MB ZIP 举报
温馨提示
petri编辑工具Pipe2源码,java写的
资源推荐
资源详情
资源评论
收起资源包目录
petri编辑工具Pipe2 (859个子文件)
Subgraph.class 31KB
GrappaColor.class 29KB
GrappaNexus.class 27KB
DataLayer.class 24KB
GrappaPanel.class 23KB
GuiFrame.class 22KB
Element.class 21KB
CUP$Parser$actions.class 17KB
PNMatrix.class 17KB
StateSpaceGenerator.class 16KB
Matrix.class 15KB
Graph.class 15KB
GrappaStyle.class 14KB
ArcPath.class 14KB
GrappaSupport.class 14KB
Dnamaca.class 14KB
GrappaAdapter.class 13KB
EigenvalueDecomposition.class 12KB
Comparison.class 12KB
lr_parser.class 11KB
GSPN.class 11KB
DataLayerWriter.class 11KB
Attribute.class 10KB
InvariantAnalysis.class 10KB
Transition.class 10KB
PrintfParser.class 10KB
Parser.class 9KB
GrappaShape.class 9KB
GSPNNew.class 9KB
Arc.class 9KB
AnnotationNote.class 9KB
GrappaLine.class 8KB
Place.class 8KB
ReachabilityGraphGenerator.class 8KB
TableField.class 7KB
GrappaSupportRects.class 7KB
Edge.class 7KB
SingularValueDecomposition.class 7KB
GrappaConstants.class 7KB
Lexer.class 7KB
SelectionObject.class 7KB
Classification.class 7KB
PlaceTransitionObject.class 7KB
GuiView.class 7KB
ArcPathPoint.class 6KB
ModuleManager.class 6KB
Export.class 6KB
Simulation.class 6KB
Node.class 6KB
ResultsHTMLPane.class 6KB
myNode.class 6KB
CreateGui.class 6KB
GrappaSupportPrintf.class 5KB
PNMLTransformer.class 5KB
SteadyStateSolver.class 5KB
Matrixes.class 5KB
Animator.class 5KB
HelpBox.class 4KB
Grappa.class 4KB
GraphPanel.class 4KB
GraphFrame.class 4KB
ModuleManager$TreeHandler.class 4KB
StateList.class 4KB
ReachabilityGraphGenerator$1.class 4KB
PetriNetObjectHandler.class 4KB
GuiFrame$ZoomAction.class 4KB
CircularByteBuffer$CircularByteBufferInputStream.class 4KB
GSPNNew$1.class 4KB
PetriNetObject.class 4KB
ExtFileManager.class 4KB
AnimationHistory.class 4KB
StateSpace$1.class 3KB
ArrowHead.class 3KB
CircularByteBuffer.class 3KB
LUDecomposition.class 3KB
Dnamaca$DnamacaRun$ExternalTask$ActualTask.class 3KB
CircularByteBuffer$CircularByteBufferOutputStream.class 3KB
PetriNetChooserPanel.class 3KB
PlaceTransitionObjectHandler.class 3KB
QRDecomposition.class 3KB
GuiView$MouseHandler.class 3KB
Comparison$1.class 3KB
ExceptionDisplay$Display.class 3KB
GrappaBox.class 3KB
ModuleLoader.class 3KB
ArcHandler.class 3KB
Subgraph$Enumerator.class 3KB
Matrixes$1.class 3KB
GrappaPathIterator.class 2KB
TransitionRecord.class 2KB
GuiFrame$FileAction.class 2KB
AnnotationNote$ResizePoint.class 2KB
Classification$1.class 2KB
GuiFrame$AnimateAction.class 2KB
Constants.class 2KB
AnnotationNoteHandler.class 2KB
StateSpace.class 2KB
Grid.class 2KB
ResultsHTMLPane$2.class 2KB
myTree.class 2KB
共 859 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
- xiaohahe2011-10-18非常好,为我的论文实验提供了很好的平台和代码
- ray_z20092012-09-02其实网上有很多Pipe2的源码,不一定非要在这里下,但是pipe的确很强大,用来学习Petri网
taurus_chw
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功