de.uni.freiburg.iig.telematik.sepia.graphic.netgraphics.AbstractPNGraphics Maven / Gradle / Ivy
Show all versions of SEPIA Show documentation
package de.uni.freiburg.iig.telematik.sepia.graphic.netgraphics;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractFlowRelation;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractMarking;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPlace;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractTransition;
/**
*
* Abstract petri net graphics super class. It contains all net type specific graphical information needed to draw the petri net.
*
*
* @author Adrian Lange
*
* @param
* Type of Petri net places
* @param
* Type of Petri net transitions
* @param
* Type of Petri net relations
* @param
* Type of Petri net markings
* @param
* Type of Petri net place states
*/
public abstract class AbstractPNGraphics,
T extends AbstractTransition,
F extends AbstractFlowRelation,
M extends AbstractMarking,
S extends Object> {
private Map placeGraphics = new HashMap();
private Map> tokenGraphics = new HashMap>();
private Map transitionGraphics = new HashMap();
private Map arcGraphics = new HashMap();
private Map arcAnnotationGraphics = new HashMap();
private Map placeLabelAnnotationGraphics = new HashMap();
private Map transitionLabelAnnotationGraphics = new HashMap();
/**
* @return the arcGraphics
*/
public Map getArcGraphics() {
return arcGraphics;
}
public ArcGraphics getArcGraphics(String arcName) {
return arcGraphics.get(arcName);
}
public boolean containsArcGraphics(String arcName){
return arcGraphics.containsKey(arcName);
}
public Map getArcAnnotationGraphics() {
return arcAnnotationGraphics;
}
public boolean containsArcAnnotationGraphics(String arcName){
return arcAnnotationGraphics.containsKey(arcName);
}
public AnnotationGraphics getArcAnnotationGraphics(String arcName) {
return arcAnnotationGraphics.get(arcName);
}
/**
* @return the placeGraphics
*/
public Map getPlaceGraphics() {
return placeGraphics;
}
public NodeGraphics getPlaceGraphics(String placeName) {
return placeGraphics.get(placeName);
}
public boolean containsPlaceGraphics(String placeName){
return placeGraphics.containsKey(placeName);
}
/**
* @return the placeLabelAnnotationGraphics
*/
public Map getPlaceLabelAnnotationGraphics() {
return placeLabelAnnotationGraphics;
}
public AnnotationGraphics getPlaceLabelAnnotationGraphics(String placeName) {
return placeLabelAnnotationGraphics.get(placeName);
}
public boolean containsPlaceLabelAnnotationGraphics(String placeName){
return placeLabelAnnotationGraphics.containsKey(placeName);
}
public Map> getTokenGraphics() {
return tokenGraphics;
}
public Set getTokenGraphics(String placeName) {
return tokenGraphics.get(placeName);
}
public boolean containsTokenGraphics(String placeName){
return tokenGraphics.containsKey(placeName);
}
/**
* @return the transitionGraphics
*/
public Map getTransitionGraphics() {
return transitionGraphics;
}
public NodeGraphics getTransitionGraphics(String transitionName) {
return transitionGraphics.get(transitionName);
}
public boolean containsTransitionGraphics(String transitionName){
return transitionGraphics.containsKey(transitionName);
}
/**
* @return the transitionLabelAnnotationGraphics
*/
public Map getTransitionLabelAnnotationGraphics() {
return transitionLabelAnnotationGraphics;
}
public AnnotationGraphics getTransitionLabelAnnotationGraphics(String transitionName) {
return transitionLabelAnnotationGraphics.get(transitionName);
}
public boolean containsTransitionLabelAnnotationGraphics(String transitionName){
return transitionLabelAnnotationGraphics.containsKey(transitionName);
}
public void setArcAnnotationGraphics(Map arcAnnotationGraphics) {
this.arcAnnotationGraphics = arcAnnotationGraphics;
}
/**
* @param arcGraphics
* the arcGraphics to set
*/
public void setArcGraphics(Map arcGraphics) {
this.arcGraphics = arcGraphics;
}
/**
* @param placeLabelAnnotationGraphics
* the placeLabelAnnotationGraphics to set
*/
public void setPlaceLabelAnnotationGraphics(Map placeLabelAnnotationGraphics) {
this.placeLabelAnnotationGraphics = placeLabelAnnotationGraphics;
}
/**
* @param placeGraphics
* the placeGraphics to set
*/
public void setPlaceGraphics(Map placeGraphics) {
this.placeGraphics = placeGraphics;
}
public void setTokenGraphics(Map> tokenGraphics) {
this.tokenGraphics = tokenGraphics;
}
/**
* @param transitionLabelAnnotationGraphics
* the transitionLabelAnnotationGraphics to set
*/
public void setTransitionLabelAnnotationGraphics(Map transitionLabelAnnotationGraphics) {
this.transitionLabelAnnotationGraphics = transitionLabelAnnotationGraphics;
}
/**
* @param transitionGraphics
* the transitionGraphics to set
*/
public void setTransitionGraphics(Map transitionGraphics) {
this.transitionGraphics = transitionGraphics;
}
@Override
public String toString() {
StringBuilder str = new StringBuilder();
str.append("Graphics:\n");
str.append(" placeGraphics# " + placeGraphics.size());
if (placeGraphics.size() > 0)
str.append(":\n" + map2Str(placeGraphics) + "\n");
else
str.append("\n");
str.append(" transitionGraphics# " + transitionGraphics.size());
if (transitionGraphics.size() > 0)
str.append(":\n" + map2Str(transitionGraphics) + "\n");
else
str.append("\n");
str.append(" arcGraphics# " + arcGraphics.size());
if (arcGraphics.size() > 0)
str.append(":\n" + map2Str(arcGraphics) + "\n");
else
str.append("\n");
str.append(" tokenGraphics# " + tokenGraphics.size());
if (tokenGraphics.size() > 0)
str.append(":\n" + map2Str(tokenGraphics) + "\n");
else
str.append("\n");
str.append(" arcAnnotationGraphics# " + arcAnnotationGraphics.size());
if (arcAnnotationGraphics.size() > 0)
str.append(":\n" + map2Str(arcAnnotationGraphics) + "\n");
else
str.append("\n");
str.append(" placeLabelAnnotationGraphics# " + placeLabelAnnotationGraphics.size());
if (placeLabelAnnotationGraphics.size() > 0)
str.append(":\n" + map2Str(placeLabelAnnotationGraphics) + "\n");
else
str.append("\n");
str.append("transitionLabelAnnotationGraphics# " + transitionLabelAnnotationGraphics.size());
if (transitionLabelAnnotationGraphics.size() > 0)
str.append(":\n" + map2Str(transitionLabelAnnotationGraphics) + "\n");
else
str.append("\n");
return str.toString();
}
protected static String map2Str(Map m) {
boolean empty = true;
StringBuilder str = new StringBuilder();
for (Entry pairs : m.entrySet()) {
if (!empty)
str.append("\n");
str.append(" " + pairs.getKey() + ": " + pairs.getValue());
empty = false;
}
return str.toString();
}
}