//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.jgraph;

import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.VertexRenderer;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class RouteActivityRenderer  extends VertexRenderer
{
	public void paint(Graphics g)
	{
		int b = borderWidth;
		Graphics2D g2 = (Graphics2D) g;
		Dimension d = getSize();
		boolean is_selected = selected;
		int roundRectArc = BusinessActivityView.getArcSize(d.width - b, d.height - b);
		if (super.isOpaque())
		{
			g.setColor(super.getBackground());
			g.fillRoundRect(b - 1, b - 1, d.width - b, d.height - b, roundRectArc, roundRectArc);
		}
		
		setBorder(null);
		setOpaque(false);
		selected = false;
		super.paint(g);
		
		if (bordercolor != null)
		{
			g.setColor(bordercolor);
			g2.setStroke(new BasicStroke(b));
			g.drawRoundRect(b - 1, b - 1, d.width - b, d.height - b, roundRectArc, roundRectArc);
		}
		
		if (is_selected)
		{
			g2.setStroke(GraphConstants.SELECTION_STROKE);
			g.setColor(graph.getHighlightColor());
			g.drawRoundRect(b - 1, b - 1, d.width - b, d.height - b, roundRectArc, roundRectArc);
		}
	}
}