package gve.calc.graph;
import java.awt.*;
import java.awt.event.*;
import gve.calc.formula.*;
public class GraphMorphism extends Part {
Graph graph;
int [] map;
int []xcoord1;
int []ycoord1;
int []xcoord2;
int []ycoord2;
Top i van graph wordt gemapt op top map[i] van de tweede graaf |
public GraphMorphism(Graph g1,Graph g2,int [] mapping) {
graph = (Graph)g1.clone();
map = mapping;
int size = g1.getSize();
xcoord1 = new int[size];
ycoord1 = new int[size];
xcoord2 = new int[size];
ycoord2 = new int[size];
for (int i = size-1; i>=0; i--) {
xcoord1[i] = g1.getXcoord(i);
ycoord1[i] = g1.getYcoord(i);
xcoord2[i] = g2.getXcoord(i);
ycoord2[i] = g2.getYcoord(i);
}
}
private GraphMorphism() {}
public int getSize() { return map.length; }
public Object clone() {
GraphMorphism result = new GraphMorphism();
int size = xcoord1.length;
result.xcoord1 = new int[size];
result.ycoord1 = new int[size];
result.xcoord2 = new int[size];
result.ycoord2 = new int[size];
System.arraycopy(xcoord1,0,result.xcoord1,0,size);
System.arraycopy(ycoord1,0,result.ycoord1,0,size);
System.arraycopy(xcoord2,0,result.xcoord2,0,size);
System.arraycopy(ycoord2,0,result.ycoord2,0,size);
result.map = new int[size];
System.arraycopy(map,0,result.map,0,size);
return result;
}
public Part evaluate(Evaluator ev) {
return (Part)clone();
}
public Component createView(FormulaView view) {
return new GraphMorphismView(this);
}
}