Object getObject(double x, double y, Tool tool) {
        Object o = null;
        if (tool.type == ToolType.init && Vertex.randomInit.isOnPoint(x, y)) {
            return Vertex.randomInit;
        }
        if (tool.compatible(ToolTarget.message) && (o = getMessage(x, y)) != null) {
            return o;
        }
        if (tool.compatible(ToolTarget.vertex) && (o = getVertex(x, y)) != null) {
            return o;
        }
        if (tool.compatible(ToolTarget.edge) && (o = getEdge(x, y)) != null) {
            return o;
        }
        return null;
    }