class EdgePencil implements Tool {

    //Architecture
    private ToolEventListener[] listeners;
    private EdgePencilPanel edgePencilPanel;
    //Settings
    private Color color;
    private float weight;
    //State
    private Node sourceNode;

    public EdgePencil() {
        //Default settings
        color = Color.GRAY;
        weight = 1f;

        //Add workspace listener for updating edge pencil panel options and status
        Lookup.getDefault().lookup(ProjectController.class).addWorkspaceListener(new WorkspaceListener() {
            @Override
            public void initialize(Workspace workspace) {
                updatePanel();
            }

            @Override
            public void select(Workspace workspace) {
                updatePanel();
            }

            @Override
            public void unselect(Workspace workspace) {
            }

            @Override
            public void close(Workspace workspace) {
            }

            @Override
            public void disable() {
            }
        });
    }

    private void updatePanel() {
        if (edgePencilPanel != null) {
            GraphController gc = Lookup.getDefault().lookup(GraphController.class);
            if (gc.getGraphModel() != null) {
                edgePencilPanel.setType(gc.getGraphModel().isDirected() || gc.getGraphModel().isMixed());
            }
            sourceNode = null;
            edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status1"));
        }
    }

    @Override
    public void select() {
    }

    @Override
    public void unselect() {
        listeners = null;
        sourceNode = null;
        color = edgePencilPanel.getColor();
        weight = edgePencilPanel.getWeight();
    }

    @Override
    public ToolEventListener[] getListeners() {<FILL_FUNCTION_BODY>}

    @Override
    public ToolUI getUI() {
        return new ToolUI() {
            @Override
            public JPanel getPropertiesBar(Tool tool) {
                edgePencilPanel = new EdgePencilPanel();
                edgePencilPanel.setColor(color);
                edgePencilPanel.setWeight(weight);
                updatePanel();
                return edgePencilPanel;
            }

            @Override
            public String getName() {
                return NbBundle.getMessage(EdgePencil.class, "EdgePencil.name");
            }

            @Override
            public Icon getIcon() {
                return ImageUtilities.loadImageIcon("ToolsPlugin/edgepencil.png", false);
            }

            @Override
            public String getDescription() {
                return NbBundle.getMessage(EdgePencil.class, "EdgePencil.description");
            }

            @Override
            public int getPosition() {
                return 130;
            }
        };
    }

    @Override
    public ToolSelectionType getSelectionType() {
        return ToolSelectionType.SELECTION;
    }
}

        listeners = new ToolEventListener[2];
        listeners[0] = new NodeClickEventListener() {
            @Override
            public void clickNodes(Node[] nodes) {
                Node n = nodes[0];

                if (sourceNode == null) {
                    sourceNode = n;
                    edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status2"));
                } else {
                    color = edgePencilPanel.getColor();
                    weight = edgePencilPanel.getWeight();
                    boolean directed = edgePencilPanel.isDirected;
                    Edge edge =
                        Lookup.getDefault().lookup(GraphElementsController.class).createEdge(sourceNode, n, directed);
                    edge.setColor(color);
                    sourceNode = null;
                    edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status1"));
                }
            }
        };
        listeners[1] = new MouseClickEventListener() {
            @Override
            public void mouseClick(int[] positionViewport, float[] position3d) {
                if (sourceNode != null) {
                    //Cancel
                    edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status1"));
                    sourceNode = null;
                }
            }
        };
        return listeners;
    
<no_super_class>