use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.
the class DefaultGraphLayoutGenerator method fillInEdgeLocations.
private static void fillInEdgeLocations(GraphModel graphModel) {
Vertex[] vertices = graphModel.getVertices();
GraphPoint centrePoint = null;
DirectedEdge[] inEdges = null;
DirectedEdge[] outEdges = null;
int i = 0;
int j = 0;
for (i = 0; i < vertices.length; i++) {
centrePoint = vertices[i].getCentrePoint();
inEdges = graphModel.getInEdges(vertices[i]);
outEdges = graphModel.getOutEdges(vertices[i]);
for (j = 0; j < inEdges.length; j++) {
inEdges[j].setTerminusPoint(centrePoint);
}
for (j = 0; j < outEdges.length; j++) {
outEdges[j].setOriginPoint(centrePoint);
}
}
}
use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.
the class DefaultGraphLayoutGenerator method fillInVertexLocations.
private static void fillInVertexLocations(GraphModel graphModel, Vector<Vector<Vertex>> rowVector, int valueOfLargestMidPoint, int[] midPoints) {
Vector<Vertex> rowsVertices = null;
Vertex vertex = null;
int rowIndex = 0;
int column = 0;
int rowsLeftMargin = 0;
GraphPoint point = new GraphPoint(0, 0);
for (rowIndex = 0; rowIndex < rowVector.size(); rowIndex++) {
rowsVertices = rowVector.elementAt(rowIndex);
rowsLeftMargin = mLeftMargin + valueOfLargestMidPoint - midPoints[rowIndex];
for (column = 0; column < rowsVertices.size(); column++) {
vertex = rowsVertices.elementAt(column);
point.x = rowsLeftMargin + column * mHorzGap;
point.y = mTopMargin + rowIndex * mVertGap;
vertex.moveAbsolute(point);
graphModel.checkSize(vertex);
}
}
}
use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.
the class CompositeActivity method safeAddChild.
/**
* Adds vertex to graph cloning GraphPoint first (NPE safe)
*
* @param v
* @param g
*/
private void safeAddChild(GraphableVertex v, GraphPoint g) {
GraphPoint p = null;
if (g != null)
p = new GraphPoint(g.x, g.y);
addChild(v, p);
}
use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.
the class AggregationMemberRenderer method draw.
@Override
public void draw(Graphics2D g2d, Vertex vertex) {
GraphPoint centre = vertex.getCentrePoint();
GraphPoint[] outline = vertex.getOutlinePoints();
FontMetrics metrics = g2d.getFontMetrics();
AggregationMember memberPair = mAggregation.getMemberPair(vertex.getID());
try {
String name = memberPair.getItemName();
g2d.drawString(name, centre.x - metrics.stringWidth(name) / 2, vertex.getID() % 2 == 0 ? topYOfOutline(outline) : bottomYOfOutline(outline) + metrics.getHeight());
g2d.drawImage(getImage(memberPair), centre.x - 8, centre.y - 8, null);
// Draw the outline of the vertex
if (outline.length > 1) {
for (int i = 0; i < outline.length - 1; i++) {
g2d.drawLine(outline[i].x, outline[i].y, outline[i + 1].x, outline[i + 1].y);
}
g2d.drawLine(outline[outline.length - 1].x, outline[outline.length - 1].y, outline[0].x, outline[0].y);
}
} catch (Exception ex) {
Logger.error("AggregationMemberRenderer::draw() " + ex);
}
}
use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.
the class LifecycleRenderer method drawVertexHighlight.
// Draws the highlight of the specified vertex the specified dist from its outline
protected void drawVertexHighlight(Graphics2D g2d, Vertex vertex, int dist) {
GraphPoint[] outlinePoints = vertex.getOutlinePoints();
GraphPoint centrePoint = vertex.getCentrePoint();
/*
* float dash1[] ={5.0f}; BasicStroke bs = new BasicStroke(5.0f, BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,10.0f, dash1,0.0f);
*/
for (int i = 0; i < outlinePoints.length - 1; i++) {
drawShiftedLine(dist, g2d, centrePoint, outlinePoints[i].x, outlinePoints[i].y, outlinePoints[i + 1].x, outlinePoints[i + 1].y);
}
drawShiftedLine(dist, g2d, centrePoint, outlinePoints[outlinePoints.length - 1].x, outlinePoints[outlinePoints.length - 1].y, outlinePoints[0].x, outlinePoints[0].y);
}
Aggregations