package commons.graph.worker;
import java.awt.Color;
import java.awt.Graphics;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JPanel;
import commons.graph.model.Node;
import commons.graph.view.DEFAULTS;
import commons.graph.view.Design;
import commons.ui.toolbox.GU;
public class NodesPainter extends Painter
{

Set<String>       printed = new HashSet<String>();
int               draggedx, draggedy;
GraphDataProvider provider;

public NodesPainter(JPanel panel, Graphics graphics, int draggedx, int draggedy, GraphDataProvider provider, double zoomFactor)
{
   super(panel, graphics, zoomFactor);
   this.draggedx = draggedx;
   this.draggedy = draggedy;
   this.provider = provider;
}

public void init ()
{}

public void work (String a, String b)
{
   Node N = null;
   Design design = null;
   // int cn = 0;
   if (!printed.contains(a))
   {
      N = nodes.getNode(a);
      // cn = edges.countChildren(a);
      design = new Design(DEFAULTS.FONT, provider.hasRelated(a) ? Color.blue : Color.black, DEFAULTS.BACKGROUND, DEFAULTS.BORDER);
      N.screen_x = xpos(N.x) + draggedx;
      N.screen_y = ypos(N.y) + draggedy;
      GU.paintNode(N, graphics, design);
      printed.add(a);
   }
   if (!printed.contains(b))
   {
      N = nodes.getNode(b);
      // cn = edges.countChildren(b);
      design = new Design(DEFAULTS.FONT, provider.hasRelated(b) ? Color.blue : Color.black, DEFAULTS.BACKGROUND, DEFAULTS.BORDER);
      N.screen_x = xpos(N.x) + draggedx;
      N.screen_y = ypos(N.y) + draggedy;
      GU.paintNode(N, graphics, design);
      printed.add(b);
   }
}
}
