package com.c2kernel.collection.gui.view; import java.awt.FontMetrics; import java.awt.Graphics2D; import com.c2kernel.collection.Aggregation; import com.c2kernel.collection.AggregationMember; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.view.VertexRenderer; import com.c2kernel.utils.Logger; /** * @version $Revision: 1.24 $ $Date: 2005/12/01 14:23:15 $ * @author $Author: abranson $ */ public class AggregationMemberRenderer implements VertexRenderer { private Aggregation mAggregation = null; public AggregationMemberRenderer() { } public void setAggregation(Aggregation agg) { mAggregation = agg; } 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.getEntityName(); g2d.drawString( name, centre.x-metrics.stringWidth(name)/2, topYOfOutline(outline) ); g2d.drawImage ( memberPair.getImage(), centre.x - 8, centre.y - 8, null ); // Draw the outline of the vertex if(outline.length > 1) { for(int i=0; i bottomY) { bottomY = outline[i].y; } } return bottomY; } }