class HeatMap implements Tool {
    //Architecture

    private ToolEventListener[] listeners;
    private HeatMapPanel heatMapPanel;
    //Settings
    private Color[] gradientColors;
    private float[] gradientPositions;  //All between 0 and 1
    private boolean dontPaintUnreachable = true;

    public HeatMap() {
        //Default settings
        gradientColors = new Color[] {new Color(227, 74, 51), new Color(253, 187, 132), new Color(254, 232, 200)};
        gradientPositions = new float[] {0f, 0.5f, 1f};
    }

    @Override
    public void select() {
    }

    @Override
    public void unselect() {
        listeners = null;
        heatMapPanel = null;
    }

    @Override
    public ToolEventListener[] getListeners() {
        listeners = new ToolEventListener[1];
        listeners[0] = new NodeClickEventListener() {
            @Override
            public void clickNodes(Node[] nodes) {<FILL_FUNCTION_BODY>}
        };
        return listeners;
    }

    @Override
    public ToolUI getUI() {
        return new ToolUI() {
            @Override
            public JPanel getPropertiesBar(Tool tool) {
                heatMapPanel = new HeatMapPanel(gradientColors, gradientPositions, dontPaintUnreachable);
                return heatMapPanel;
            }

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

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

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

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

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

                try {
                    Node n = nodes[0];
                    Color[] colors;
                    float[] positions;
                    if (heatMapPanel.isUsePalette()) {
                        colors = heatMapPanel.getSelectedPalette().getColors();
                        positions = heatMapPanel.getSelectedPalette().getPositions();
                        dontPaintUnreachable = true;
                    } else {
                        gradientColors = colors = heatMapPanel.getGradientColors();
                        gradientPositions = positions = heatMapPanel.getGradientPositions();
                        dontPaintUnreachable = heatMapPanel.isDontPaintUnreachable();
                    }
                    GraphController gc = Lookup.getDefault().lookup(GraphController.class);

                    AbstractShortestPathAlgorithm algorithm;
                    if (gc.getGraphModel().isDirected()) {
                        DirectedGraph graph = gc.getGraphModel().getDirectedGraphVisible();
                        algorithm = new BellmanFordShortestPathAlgorithm(graph, n);
                        algorithm.compute();
                    } else {
                        Graph graph = gc.getGraphModel().getGraphVisible();
                        algorithm = new DijkstraShortestPathAlgorithm(graph, n);
                        algorithm.compute();
                    }

                    //Color
                    LinearGradient linearGradient = new LinearGradient(colors, positions);

                    //Algorithm


                    double maxDistance = algorithm.getMaxDistance();
                    if (!dontPaintUnreachable) {
                        maxDistance++;   //+1 to have the maxdistance nodes a ratio<1
                    }
                    if (maxDistance > 0) {
                        for (Entry<Node, Double> entry : algorithm.getDistances().entrySet()) {
                            Node node = entry.getKey();
                            if (!Double.isInfinite(entry.getValue())) {
                                float ratio = (float) (entry.getValue() / maxDistance);
                                Color c = linearGradient.getValue(ratio);
                                node.setColor(c);
                            } else if (!dontPaintUnreachable) {
                                Color c = colors[colors.length - 1];
                                node.setColor(c);
                            }
                        }
                    }
                    Color c = colors[0];
                    n.setColor(c);
                    heatMapPanel.setStatus(NbBundle.getMessage(HeatMap.class, "HeatMap.status.maxdistance") +
                        new DecimalFormat("#.##").format(algorithm.getMaxDistance()));
                } catch (Exception e) {
                    Logger.getLogger("").log(Level.SEVERE, "", e);
                }
            
<no_super_class>