package org.perfcake.pc4idea.editor.designer.common;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Stanislav Kaleta
 * Date: 18.11.2014
 */
public class DependenciesPanel extends JPanel {
    private List<DependencyLine> dependencyLines;


    public DependenciesPanel(){
        this.setOpaque(false);
        dependencyLines = new ArrayList<>();
    }

    @Override
    protected void paintComponent(Graphics g){
        g.setColor(Color.black);

        for (DependencyLine line : dependencyLines){
            g.drawLine(line.getLineStart().x,line.getLineStart().y,line.getLineEnd().x,line.getLineEnd().y);
        }
    }

    public void removeAllDependencyLines(){
        dependencyLines.clear();
    }

    public void addDependencyLine(Point start, Point end){
        dependencyLines.add(new DependencyLine(start,end));
    }

    private class DependencyLine {
        Point lineStart;
        Point lineEnd;

        private DependencyLine(Point lineStart, Point lineEnd){
            this.lineStart = lineStart;
            this.lineEnd = lineEnd;
        }

        private Point getLineStart(){
            return lineStart;
        }
        private Point getLineEnd(){
            return lineEnd;
        }
    }
}

@@ -47,16 +47,80 @@
 ommon;%0A%0A
+import com.intellij.openapi.editor.colors.EditorColorsManager;%0A%0A
 import j
@@ -129,24 +129,24 @@
 ax.swing.*;%0A
-
 import java.
@@ -388,17 +388,16 @@
 Lines;%0A%0A
-%0A
     publ
@@ -576,33 +576,281 @@
     
-g.setColor(Color.black);%0A
+Graphics2D g2d = (Graphics2D)g;%0A        g2d.setColor(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground().darker().darker());%0A        g2d.setStroke(new BasicStroke(1.0f,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_MITER,10.0f,new float%5B%5D%7B2.0f,2.0f%7D,0.0f));
 %0A   
@@ -1164,24 +1164,24 @@
 Point end)%7B%0A
-
         depe
@@ -1224,24 +1224,48 @@
 tart,end));%0A
+        this.repaint();%0A
     %7D%0A%0A    p

set line stroke and color